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

first update

parent dea6b80b
......@@ -85,40 +85,163 @@ public class Example {
String fileOntology = "/home/franco/Repositories/STEaMINg-SR_SitDet/ContextOntology-COInd4.owl";
/*
final String queryBody = "REGISTER QUERY reasoning AS "
+ "PREFIX :<http://onto#> "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
//+ "CONSTRUCT { ?o1 :isInSituation [a :situationCODE1234] } "
//+ "CONSTRUCT { [] a :situationCODE1234 ; :hasObservation ?o1 ; :hasObservation ?o2 . } "
+ "SELECT ?o1 ?o2 ?average "
+ "FROM STREAM <sensorTM2> [RANGE 5s TUMBLING] " //STEP 5s
+ "FROM STREAM <sensorTM1> [RANGE 5s TUMBLING] "
+ "FROM <http://streamreasoning.org/roomConnection> "
+ "WHERE { "
+ " :sensorTM1 :madeObservation ?o1 ." // ?s instead of :sensorTM1 for both cases
+ " ?o1 :hasSimpleResult ?p1 ."
+ " ?o1 :hasTime ?r1 . "
+ " ?s2 :madeObservation ?o2 ."
+ "{ SELECT ?s2 ( avg(?p2) AS ?average ) "
+ " WHERE { "
+ " ?s2 :madeObservation ?o2 ." //
+ " ?o2 :hasSimpleResult ?p2 ."
+ " ?o2 :hasTime ?r2 ."
+ " } "
+ " GROUP BY ?s2"
+ " HAVING ( avg(?p2) > 2 ) "
+ "} "
+ "FILTER ( ?p1 > 2 && ?s2 != :sensorTM1 ) . "
+ " } ";
*/
String queryS1 = "REGISTER QUERY S1-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_S_G_current> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_S_C_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_S_T_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_S_OilTemp> [RANGE 20s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_G_current . "
+ " :S_G_current sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_C_temp . "
+ " :S_C_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_T_temp . "
+ " :S_T_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " ?m sosa:hosts sosa:S_OilTemp . "
+ " :S_OilTemp sosa:madeObservation ?o4 . "
+ " ?o4 sosa:hasSimpleResult ?v4 . "
+ " FILTER ( "
+ " ?v1 > 800.0 && "
+ " ?v2 > 40.0 && "
+ " ?v3 > 45.0 && "
+ " ?v4 > 40.0 ) . "
+ "} ";
String queryS2 = "REGISTER QUERY S2-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_S_G_current> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_S_C_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_S_T_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_S_OilTemp> [RANGE 20s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_G_current . "
+ " :S_G_current sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_C_temp . "
+ " :S_C_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_T_temp . "
+ " :S_T_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " ?m sosa:hosts sosa:S_OilTemp . "
+ " :S_OilTemp sosa:madeObservation ?o4 . "
+ " ?o4 sosa:hasSimpleResult ?v4 . "
+ " FILTER ( "
+ " ?v1 > 800.0 && "
+ " ?v2 > 40.0 && "
+ " ?v3 > 45.0 && "
+ " ?v4 > 60.0 ) . "
+ "} ";
String queryS3 = "REGISTER QUERY S3-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_S_P_temp> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_GB_temp> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_G_speed> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_E_Temp> [RANGE 25s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_P_temp . "
+ " :S_P_temp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_GB_temp . "
+ " :S_GB_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_G_speed . "
+ " :S_G_speed sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " ?m sosa:hosts sosa:S_E_Temp . "
+ " :S_E_Temp sosa:madeObservation ?o4 . "
+ " ?o4 sosa:hasSimpleResult ?v4 . "
+ " FILTER ( "
+ " ?v1 < 35.0 && "
+ " ?v2 > 40.0 && "
+ " ?v3 < 500.0 && "
+ " ?v4 < 25.0 ) . "
+ "} ";
String queryS4 = "REGISTER QUERY S4-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_S_P_temp> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_GB_temp> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_G_speed> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_E_Temp> [RANGE 25s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_P_temp . "
+ " :S_P_temp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_GB_temp . "
+ " :S_GB_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_G_speed . "
+ " :S_G_speed sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " ?m sosa:hosts sosa:S_E_Temp . "
+ " :S_E_Temp sosa:madeObservation ?o4 . "
+ " ?o4 sosa:hasSimpleResult ?v4 . "
+ " FILTER ( "
+ " ?v1 < 35.0 && "
+ " ?v2 > 60.0 && "
+ " ?v3 < 500.0 && "
+ " ?v4 < 25.0 ) . "
+ "} ";
String queryS5 = "REGISTER QUERY S5-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_S_P_temp> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_GB_temp> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_G_speed> [RANGE 25s STEPS 5s] "
+ "FROM STREAM <Stream_S_E_Temp> [RANGE 25s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_P_temp . "
+ " :S_P_temp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_GB_temp . "
+ " :S_GB_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_G_speed . "
+ " :S_G_speed sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " ?m sosa:hosts sosa:S_E_Temp . "
+ " :S_E_Temp sosa:madeObservation ?o4 . "
+ " ?o4 sosa:hasSimpleResult ?v4 . "
+ " FILTER ( "
+ " ?v1 > 40.0 && "
+ " ?v2 > 60.0 && "
+ " ?v3 < 500.0 && "
+ " ?v4 < 25.0 ) . "
+ "} ";
String queryS6 = "REGISTER QUERY S6-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_C_Wtemp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_G_temp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_G_temp> [RANGE 15s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
......@@ -137,61 +260,139 @@ public class Example {
+ " ?v3 > 45.0 ) . "
+ "} ";
String queryS7 = "REGISTER QUERY S7-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_C_Wtemp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_G_temp> [RANGE 15s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_C_Wtemp . "
+ " :S_C_Wtemp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_TG_temp . "
+ " :S_TG_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_G_temp . "
+ " :S_G_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " FILTER ( "
+ " ?v1 > 80.0 && "
+ " ?v2 < 35.0 && "
+ " ?v3 > 45.0 ) . "
+ "} ";
String queryS8 = "REGISTER QUERY S8-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_P_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_Conv_temp> [RANGE 15s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_P_temp . "
+ " :S_P_Wtemp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_TG_temp . "
+ " :S_TG_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_Conv_temp . "
+ " :S_Conv_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " FILTER ( "
+ " ?v1 < 35.0 && "
+ " ?v2 < 35.0 && "
+ " ?v3 > 60.0 ) . "
+ "} ";
String queryS9 = "REGISTER QUERY S9-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_P_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_Conv_temp> [RANGE 15s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_P_temp . "
+ " :S_P_Wtemp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_TG_temp . "
+ " :S_TG_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_Conv_temp . "
+ " :S_Conv_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " FILTER ( "
+ " ?v1 < 35.0 && "
+ " ?v2 < 35.0 && "
+ " ?v3 > 80.0 ) . "
+ "} ";
String queryS10 = "REGISTER QUERY S10-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_C_Wtemp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_Conv_temp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_G_temp> [RANGE 15s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_C_Wtemp . "
+ " :S_P_Wtemp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_TG_temp . "
+ " :S_TG_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_Conv_temp . "
+ " :S_Conv_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " ?m sosa:hosts sosa:S_G_temp . "
+ " :S_G_temp sosa:madeObservation ?o4 . "
+ " ?o4 sosa:hasSimpleResult ?v4 . "
+ " FILTER ( "
+ " ?v1 > 80.0 && "
+ " ?v2 < 35.0 && "
+ " ?v3 > 60.0 && "
+ " ?v4 < 45.0 ) . "
+ "} ";
//String queryS6 = "REGISTER QUERY reasoning AS "
// + "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
// + "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
// + "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
// //+ "CONSTRUCT { [] a :situationCODE1234 ; :hasObservation ?o1 ; :hasObservation ?o2 . } "
// + "SELECT ?o1 ?o2 ?o3 ?m ?pl "
// + "FROM STREAM <Stream_C_Wtemp> [RANGE 10s TUMBLING] "
// + "FROM STREAM <Stream_TG_temp> [RANGE 10s TUMBLING] "
// + "FROM STREAM <Stream_G_temp> [RANGE 10s TUMBLING] "
// + "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4> "
// + "WHERE { "
// + "{ ?m :isPartOf ?pl ."
// + " ?m sosa:hosts sosa:S_C_Wtemp ."
// + " :S_C_Wtemp :madeObservation ?o1 ."
// + " ?o1 :hasSimpleResult ?p1 ."
// + " ?m sosa:hosts sosa:S_TG_temp ."
// + " :S_TG_temp :madeObservation ?o2 ."
// + " ?o2 :hasSimpleResult ?p2 ."
// + " ?m sosa:hosts sosa:S_G_temp ."
// + " :S_G_temp :madeObservation ?o3 ."
// + " ?o3 :hasSimpleResult ?p3 ."
// + "FILTER ("
// //+ "f:timestamp(:sensorTM1,:madeObservation,?o1) < f:timestamp(?s1,:madeObservation,?o2)"
// //+ " && "
// + "?p1 > 1.0 && ?p2 > 1.0 && ?p3 > 1.0 ). }"
// + "} ";
String queryS7 = "REGISTER QUERY reasoning AS "
+ "PREFIX : <http://onto#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
//+ "CONSTRUCT { [] a :situationCODE1234 ; :hasObservation ?o1 ; :hasObservation ?o2 . } "
+ "SELECT ?o1 ?o2 ?o3 ?m ?pl "
+ "FROM STREAM <Stream_C_Wtemp> [RANGE 10s TUMBLING] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 10s TUMBLING] "
+ "FROM STREAM <Stream_G_temp> [RANGE 10s TUMBLING] "
+ "FROM <http://streamreasoning.org/roomConne> "
+ "WHERE { "
+ "{ ?m :isPartOf ?pl ."
+ " ?m sosa:hosts sosa:S_C_Wtemp ."
+ " :S_C_Wtemp :madeObservation ?o1 ."
+ " ?o1 :hasSimpleResult ?p1 ."
+ " ?m sosa:hosts sosa:S_TG_temp ."
+ " :S_TG_temp :madeObservation ?o2 ."
+ " ?o2 :hasSimpleResult ?p2 ."
+ " ?m sosa:hosts sosa:S_G_temp ."
+ " :S_G_temp :madeObservation ?o3 ."
+ " ?o3 :hasSimpleResult ?p3 ."
+ "FILTER ("
//+ "f:timestamp(:sensorTM1,:madeObservation,?o1) < f:timestamp(?s1,:madeObservation,?o2)"
//+ " && "
+ "?p1 > 1.0 && ?p2 > 1.0 && ?p3 > 1.0 ). }"
+ "} ";
String queryS11 = "REGISTER QUERY S11-detection AS "
+ "PREFIX : <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "PREFIX sosa: <http://www.w3.org/ns/sosa/> "
+ "SELECT ?m ?pl "
+ "FROM STREAM <Stream_C_Wtemp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_TG_temp> [RANGE 20s STEPS 5s] "
+ "FROM STREAM <Stream_Conv_temp> [RANGE 15s STEPS 5s] "
+ "FROM STREAM <Stream_G_temp> [RANGE 15s STEPS 5s] "
+ "FROM <http://semanticweb.org/STEaMINg/ContextOntology-COInd4#> "
+ "WHERE { "
+ " ?m :isPartOf ?pl . "
+ " ?m sosa:hosts sosa:S_C_Wtemp . "
+ " :S_P_Wtemp sosa:madeObservation ?o1 . "
+ " ?o1 sosa:hasSimpleResult ?v1 . "
+ " ?m sosa:hosts sosa:S_TG_temp . "
+ " :S_TG_temp sosa:madeObservation ?o2 "
+ " ?o2 sosa:hasSimpleResult ?v2 . "
+ " ?m sosa:hosts sosa:S_Conv_temp . "
+ " :S_Conv_temp sosa:madeObservation ?o3 . "
+ " ?o3 sosa:hasSimpleResult ?v3 . "
+ " FILTER ( "
+ " ?v1 > 80.0 && "
+ " ?v2 < 35.0 && "
+ " ?v3 < 45.0 ) . "
+ "} ";
//+ "CONSTRUCT { [] a :situationCODE1234 ; :hasObservation ?o1 ; :hasObservation ?o2 . } "
//+ "f:timestamp(:sensorTM1,:madeObservation,?o1) < f:timestamp(?s1,:madeObservation,?o2)"
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
......
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