Commit 14036bab authored by neop's avatar neop
Browse files

use parseAnyDateTime in graphdb import

to support more timestamp formats
parent a4e38a00
neo4j_uri=bolt://sensordata.open-forecast.eu:7687
neo4j_uri=bolt://localhost:7687
database_name=neo4j
already_uploaded_days_file = all_days.txt
failed_to_upload_sensors_file = test_sensor.txt
pid_reg_server_cert = pid_reg_server_cert.pem
pid_reg_keystore = pid_reg_keystore.p12
neo4j_server_certificate_file = sensordata_cert.pem
sensor_type_info = config/sensor_type_info.json
influxdb_uri = http://localhost:8086
\ No newline at end of file
......@@ -9,6 +9,7 @@ import okhttp3.*;
import com.google.gson.*;
import java.time.*;
import java.util.*;
import java.util.stream.Collectors;
import java.util.function.*;
......@@ -185,7 +186,6 @@ class Sensor {
BiFunction<String, String, String> string_if_exists = (dependency, merge_string) -> (properties.get(dependency) != null ? merge_string : "");
return new Query(
"with date($date) as date_ " +
string_if_exists.apply("country",
"merge (country:Country {code: $country_code})" +
"on create set country.name = $country\n"
......@@ -219,8 +219,8 @@ class Sensor {
string_if_exists.apply("city", "merge (measurement)-[:IN]->(city)") +
"set" +
" measurement.first_msg = case when date_ > measurement.first_msg then measurement.first_msg else date_ end," +
" measurement.last_msg = case when date_ < measurement.last_msg then measurement.last_msg else date_ end " +
" measurement.first_msg = case when $date > measurement.first_msg then measurement.first_msg else $date end," +
" measurement.last_msg = case when $date < measurement.last_msg then measurement.last_msg else $date end " +
"with s, type\n" +
"match (s)--(all_measurements:MeasurementLocation)" +
......@@ -240,7 +240,10 @@ class Sensor {
result.properties.put("sensor_id", data_as_strings.get("sensor_id"));
result.properties.put("location", data_as_strings.get("location"));
result.properties.put("sensor_type", data_as_strings.get("sensor_type"));
result.properties.put("date", data_as_strings.get("timestamp").substring(0, 10));
result.properties.put("date", LocalDate.ofInstant(
Util.parseAnyDateTime(data_as_strings.get("timestamp")),
ZoneOffset.UTC
));
try {
add_geographic_data(data_as_strings, result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment