Commit eb32460c authored by Giustozzi Franco's avatar Giustozzi Franco
Browse files

date problem fix

parent df8d2c94
...@@ -101,7 +101,7 @@ public class App { ...@@ -101,7 +101,7 @@ public class App {
//+ "PREFIX : <http://semanticweb.org/mathieu/ontologies/2020/11/sicopad#> " //+ "PREFIX : <http://semanticweb.org/mathieu/ontologies/2020/11/sicopad#> "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> " + "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> " + "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " //+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
+ "SELECT ?s (AVG(?v1) as ?avgTemp) " + "SELECT ?s (AVG(?v1) as ?avgTemp) "
+ "FROM STREAM <Stream_S_temp> [RANGE 10s TUMBLING] " + "FROM STREAM <Stream_S_temp> [RANGE 10s TUMBLING] "
+ "FROM <http://streamreasoning.org/sicopad> " + "FROM <http://streamreasoning.org/sicopad> "
...@@ -146,7 +146,7 @@ public class App { ...@@ -146,7 +146,7 @@ public class App {
//Start streaming data //Start streaming data
Stream_temp_Thread.start(); Stream_temp_Thread.start();
}catch (Exception e) { } catch (Exception e) {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
} }
......
...@@ -2,6 +2,8 @@ package csparql.ind.streamer; ...@@ -2,6 +2,8 @@ package csparql.ind.streamer;
import java.io.FileReader; import java.io.FileReader;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -53,7 +55,6 @@ public class SensorsStreamer extends RdfStream implements Runnable { ...@@ -53,7 +55,6 @@ public class SensorsStreamer extends RdfStream implements Runnable {
} }
public void run() { public void run() {
try { try {
SimpleDateFormat date_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); SimpleDateFormat date_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
CSVReader reader = new CSVReader(new FileReader("example.csv")); CSVReader reader = new CSVReader(new FileReader("example.csv"));
...@@ -62,8 +63,10 @@ public class SensorsStreamer extends RdfStream implements Runnable { ...@@ -62,8 +63,10 @@ public class SensorsStreamer extends RdfStream implements Runnable {
int observationIndex = 0; int observationIndex = 0;
int timeIndex = 0; int timeIndex = 0;
List<Date> data_x = new ArrayList<>(); List<Date> data_x = new ArrayList<>();
List<String> data_xStr = new ArrayList<>();
List<Double> data_y = new ArrayList<>(); List<Double> data_y = new ArrayList<>();
int i = 1; int i = 1;
for (String[] row : allRows) { for (String[] row : allRows) {
if (i > start) { if (i > start) {
if (!row[3].isEmpty()) { if (!row[3].isEmpty()) {
...@@ -73,6 +76,7 @@ public class SensorsStreamer extends RdfStream implements Runnable { ...@@ -73,6 +76,7 @@ public class SensorsStreamer extends RdfStream implements Runnable {
} }
String date_str = row[1].replace("/", "-") + " " + row[2]; String date_str = row[1].replace("/", "-") + " " + row[2];
Date date = date_formatter.parse(date_str); Date date = date_formatter.parse(date_str);
data_xStr.add(date_str);
data_x.add(date); data_x.add(date);
data_y.add(value); data_y.add(value);
//System.out.println("Reading Values from file"); //System.out.println("Reading Values from file");
...@@ -101,7 +105,9 @@ public class SensorsStreamer extends RdfStream implements Runnable { ...@@ -101,7 +105,9 @@ public class SensorsStreamer extends RdfStream implements Runnable {
try{ try{
value = data_y.get(observationIndex); //axis_y_values.get(observationIndex); value = data_y.get(observationIndex); //axis_y_values.get(observationIndex);
Date date = data_x.get(timeIndex); //axis_x_values.get(timeIndex); Date date = data_x.get(timeIndex); //axis_x_values.get(timeIndex);
LocalDateTime datetime = LocalDateTime.parse(data_xStr.get(timeIndex), DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss"));
String d = datetime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.S"));
axis_y_values.add(value); axis_y_values.add(value);
axis_x_values.add(date); axis_x_values.add(date);
chart.updateXYSeries(prop, axis_x_values, axis_y_values, null); chart.updateXYSeries(prop, axis_x_values, axis_y_values, null);
...@@ -119,7 +125,8 @@ public class SensorsStreamer extends RdfStream implements Runnable { ...@@ -119,7 +125,8 @@ public class SensorsStreamer extends RdfStream implements Runnable {
q = new RdfQuadruple(baseUri + "S_" + prop + "-Obs-" + observationIndex, baseUri + "hasTime", baseUri + "t-obs-S_" + prop + "-"+ timeIndex, System.currentTimeMillis()); q = new RdfQuadruple(baseUri + "S_" + prop + "-Obs-" + observationIndex, baseUri + "hasTime", baseUri + "t-obs-S_" + prop + "-"+ timeIndex, System.currentTimeMillis());
//System.out.println(q); //System.out.println(q);
this.put(q); this.put(q);
q = new RdfQuadruple(baseUri + "t-obs-S_" + prop + "-"+ timeIndex, baseUri + "inXSDDateTime", date + "^^http://www.w3.org/2001/XMLSchema#dateTime", System.currentTimeMillis()); //q = new RdfQuadruple(baseUri + "t-obs-S_" + prop + "-"+ timeIndex, baseUri + "inXSDDateTime", date + "^^http://www.w3.org/2001/XMLSchema#dateTime", System.currentTimeMillis());
q = new RdfQuadruple(baseUri + "t-obs-S_" + prop + "-"+ timeIndex, baseUri + "inXSDDateTime", d + "^^http://www.w3.org/2001/XMLSchema#dateTime", System.currentTimeMillis());
System.out.println(q); System.out.println(q);
this.put(q); this.put(q);
......
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