[TASK] More comments.
This commit is contained in:
parent
557de999de
commit
a8d3b0932f
|
@ -5,7 +5,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import lu.jpt.csparqltest.gui.SimulationControlWindow;
|
||||
import lu.jpt.csparqltest.rentacar.RentACarSimulation;
|
||||
|
||||
/**
|
||||
* This is the main entry point of the whole project. A logger is being set up
|
||||
|
@ -32,239 +31,4 @@ public class Main {
|
|||
// That's it, the program is now basically running on its own.
|
||||
}
|
||||
|
||||
private static String getSPO() {
|
||||
return "REGISTER QUERY getSPO AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?s ?p ?o "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?s ?p ?o . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/*
|
||||
* WHERE {
|
||||
OPTIONAL {
|
||||
?eventA rdf:type <http://example.org/type/A> .
|
||||
}
|
||||
OPTIONAL {
|
||||
?eventB rdf:type <http://example.org/type/B> .
|
||||
}
|
||||
FILTER((BOUND(?eventA) || BOUND(?eventB))
|
||||
&& NOT (BOUND(?eventA) && BOUND(?eventB)))
|
||||
}
|
||||
* */
|
||||
private static String getAXORB() {
|
||||
return "REGISTER QUERY matchAXORB AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?atype ?btype "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?a a ?atype . "
|
||||
+ " } "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " ?b a ?btype . "
|
||||
+ " } "
|
||||
+ " FILTER( (BOUND(?a) || BOUND(?b)) && !(BOUND(?a) && BOUND(?b)) ) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getNOTA() {
|
||||
return "REGISTER QUERY matchNOTA AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?anyEventType "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?anyEvent a ?anyEventType . "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?eventA a <http://example.org/type/A> . "
|
||||
+ " } "
|
||||
+ " FILTER(!BOUND(?eventA)) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getTestPatternQuery() {
|
||||
return "REGISTER QUERY matchANotBC AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?a ?b ?c "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?c a <http://example.org/type/C> . "
|
||||
+ " BIND(f:timestamp(?a,rdf:type,<http://example.org/type/A>) AS ?tsa) "
|
||||
+ " BIND(f:timestamp(?c,rdf:type,<http://example.org/type/C>) AS ?tsc) "
|
||||
+ " FILTER(?tsa < ?tsc) "
|
||||
+ " FILTER NOT EXISTS { "
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " BIND(f:timestamp(?b,rdf:type,<http://example.org/type/B>) AS ?tsb) "
|
||||
+ " FILTER(?tsa < ?tsb && ?tsb < ?tsc)"
|
||||
+ " } "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getPatternANOTBCQuery() {
|
||||
return "REGISTER QUERY matchANotBC AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?bbound ?abeforeb ?bbeforec ?tsa ?tsb ?tsc "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?c a <http://example.org/type/C> . "
|
||||
+ " BIND(f:timestamp(?a,rdf:type,<http://example.org/type/A>) AS ?tsa) "
|
||||
+ " BIND(f:timestamp(?c,rdf:type,<http://example.org/type/C>) AS ?tsc) "
|
||||
+ " FILTER(?tsa < ?tsc) "
|
||||
+ " OPTIONAL {"
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " BIND(f:timestamp(?b,rdf:type,<http://example.org/type/B>) AS ?tsb) "
|
||||
+ " FILTER(?tsb < ?tsa || ?tsc < ?tsb)"
|
||||
+ " } "
|
||||
+ " BIND(BOUND(?b) AS ?bbound) "
|
||||
+ " BIND(?tsa < ?tsb AS ?abeforeb) "
|
||||
+ " BIND(?tsb < ?tsc AS ?bbeforec) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
|
||||
private static String getTestPatternABCQuery() {
|
||||
return "REGISTER QUERY matchABC AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?tsa ?tsb ?tsc "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?a a ?atype . "
|
||||
+ " OPTIONAL {"
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " ?b a ?btype . "
|
||||
+ " } "
|
||||
+ " ?c a <http://example.org/type/C> . "
|
||||
+ " ?c a ?ctype . "
|
||||
+ " BIND(f:timestamp(?a,rdf:type,?atype) AS ?tsa) "
|
||||
+ " BIND(f:timestamp(?b,rdf:type,?btype) AS ?tsb) "
|
||||
+ " BIND(f:timestamp(?c,rdf:type,?ctype) AS ?tsc) "
|
||||
+ " FILTER(f:timestamp(?a,rdf:type,?atype) < f:timestamp(?b,rdf:type,?btype)) "
|
||||
+ " FILTER(f:timestamp(?b,rdf:type,?btype) < f:timestamp(?c,rdf:type,?ctype)) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getSPOFromRentACar() {
|
||||
return "REGISTER QUERY BasicCarInfo AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?s ?p ?o "
|
||||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?s a <"+RentACarSimulation.BASE_ONTOLOGY_IRI+"CarStatusEvent> . "
|
||||
+ " ?s ?p ?o . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getAllCarAttributesQuery() {
|
||||
return "REGISTER QUERY BasicCarInfo AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX car: <http://example.org/car#> "
|
||||
+ "SELECT ?car ?locked ?on ?speed ?rpm ?handbrake ?tirePressure "
|
||||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e car:subject ?car . "
|
||||
+ " ?e car:locked ?locked . "
|
||||
+ " ?e car:motorOn ?on . "
|
||||
+ " ?e car:speed ?speed . "
|
||||
+ " ?e car:motorRPM ?rpm . "
|
||||
+ " ?e car:handbrakeEngaged ?handbrake . "
|
||||
+ " ?e car:tirePressure ?pressure . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getBasicCarInfoQuery() {
|
||||
return "REGISTER QUERY BasicCarInfo AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car ?speed ?temp (f:timestamp(?e,cars:carID,?car) AS ?ts) "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e cars:carID ?car . "
|
||||
+ " ?e cars:currentSpeed ?speed . "
|
||||
+ " ?e cars:currentTemperature ?temp . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getIncreasingTemperatureQuery() {
|
||||
return "REGISTER QUERY IncreasingTemperature AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car (?temp2-?temp1 AS ?delta) "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e1 cars:carID ?car . "
|
||||
+ " ?e1 cars:currentSpeed ?speed1 . "
|
||||
+ " ?e1 cars:currentTemperature ?temp1 . "
|
||||
+ " ?e2 cars:carID ?car . "
|
||||
+ " ?e2 cars:currentSpeed ?speed2 . "
|
||||
+ " ?e2 cars:currentTemperature ?temp2 . "
|
||||
+ " FILTER(f:timestamp(?e1,cars:carID,?car) < f:timestamp(?e2,cars:carID,?car)) "
|
||||
+ " FILTER(?temp1 < ?temp2) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getAcceleratingCarsQuery() {
|
||||
return "REGISTER QUERY AcceleratingCars AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car (?speed2-?speed1 AS ?delta) "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e1 cars:carID ?car . "
|
||||
+ " ?e1 cars:currentSpeed ?speed1 . "
|
||||
+ " ?e1 cars:currentTemperature ?temp1 . "
|
||||
+ " ?e2 cars:carID ?car . "
|
||||
+ " ?e2 cars:currentSpeed ?speed2 . "
|
||||
+ " ?e2 cars:currentTemperature ?temp2 . "
|
||||
+ " FILTER(f:timestamp(?e1,cars:carID,?car) < f:timestamp(?e2,cars:carID,?car)) "
|
||||
+ " FILTER(?speed1 < ?speed2) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getBreakingDownCarsQuery() {
|
||||
return "REGISTER QUERY BreakingDownCars AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car (?speed2 - ?speed1 AS ?deltaspeed) (?temp2 - ?temp1 AS ?deltatemp) ?speed2 ?temp2 "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e1 cars:carID ?car ; "
|
||||
+ " cars:currentSpeed ?speed1 ; "
|
||||
+ " cars:currentTemperature ?temp1 . "
|
||||
+ " ?e2 cars:carID ?car ; "
|
||||
+ " cars:currentSpeed ?speed2 ; "
|
||||
+ " cars:currentTemperature ?temp2 . "
|
||||
+ " FILTER(f:timestamp(?e1,cars:carID,?car) < f:timestamp(?e2,cars:carID,?car)) "
|
||||
+ " FILTER(f:timestamp(?e2,cars:carID,?car) - f:timestamp(?e1,cars:carID,?car) < 1800) "
|
||||
+ " FILTER(?speed1 > ?speed2) "
|
||||
+ " FILTER(?temp2 > ?temp1) "
|
||||
+ " FILTER(?temp2 > 90) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,248 @@
|
|||
package lu.jpt.csparqltest.misc;
|
||||
|
||||
import lu.jpt.csparqltest.rentacar.RentACarSimulation;
|
||||
|
||||
/**
|
||||
* This class contains a bunch of unused C-SPARQL queries.
|
||||
* It may be used for inspiration, but tread with care, as they
|
||||
* probably won't work without adapting them a lot/little bit.
|
||||
*/
|
||||
public class UnusedQueryCollection {
|
||||
|
||||
/**
|
||||
* Fetch subject, predicate and object of everything (in given stream and window)
|
||||
*/
|
||||
private static String getSPO() {
|
||||
return "REGISTER QUERY getSPO AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?s ?p ?o "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?s ?p ?o . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Match A XOR B within window
|
||||
*/
|
||||
private static String getAXORB() {
|
||||
return "REGISTER QUERY matchAXORB AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?atype ?btype "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?a a ?atype . "
|
||||
+ " } "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " ?b a ?btype . "
|
||||
+ " } "
|
||||
+ " FILTER( (BOUND(?a) || BOUND(?b)) && !(BOUND(?a) && BOUND(?b)) ) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* NOT A
|
||||
*/
|
||||
private static String getNOTA() {
|
||||
return "REGISTER QUERY matchNOTA AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?anyEventType "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?anyEvent a ?anyEventType . "
|
||||
+ " OPTIONAL { "
|
||||
+ " ?eventA a <http://example.org/type/A> . "
|
||||
+ " } "
|
||||
+ " FILTER(!BOUND(?eventA)) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* A -> NOT B -> C
|
||||
*/
|
||||
private static String getTestPatternQuery() {
|
||||
return "REGISTER QUERY matchANotBC AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?a ?b ?c "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?c a <http://example.org/type/C> . "
|
||||
+ " BIND(f:timestamp(?a,rdf:type,<http://example.org/type/A>) AS ?tsa) "
|
||||
+ " BIND(f:timestamp(?c,rdf:type,<http://example.org/type/C>) AS ?tsc) "
|
||||
+ " FILTER(?tsa < ?tsc) "
|
||||
+ " FILTER NOT EXISTS { "
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " BIND(f:timestamp(?b,rdf:type,<http://example.org/type/B>) AS ?tsb) "
|
||||
+ " FILTER(?tsa < ?tsb && ?tsb < ?tsc)"
|
||||
+ " } "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* A -> NOT B -> C
|
||||
*/
|
||||
private static String getPatternANOTBCQuery() {
|
||||
return "REGISTER QUERY matchANotBC AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?bbound ?abeforeb ?bbeforec ?tsa ?tsb ?tsc "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?c a <http://example.org/type/C> . "
|
||||
+ " BIND(f:timestamp(?a,rdf:type,<http://example.org/type/A>) AS ?tsa) "
|
||||
+ " BIND(f:timestamp(?c,rdf:type,<http://example.org/type/C>) AS ?tsc) "
|
||||
+ " FILTER(?tsa < ?tsc) "
|
||||
+ " OPTIONAL {"
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " BIND(f:timestamp(?b,rdf:type,<http://example.org/type/B>) AS ?tsb) "
|
||||
+ " FILTER(?tsb < ?tsa || ?tsc < ?tsb)"
|
||||
+ " } "
|
||||
+ " BIND(BOUND(?b) AS ?bbound) "
|
||||
+ " BIND(?tsa < ?tsb AS ?abeforeb) "
|
||||
+ " BIND(?tsb < ?tsc AS ?bbeforec) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getTestPatternABCQuery() {
|
||||
return "REGISTER QUERY matchABC AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?tsa ?tsb ?tsc "
|
||||
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?a a <http://example.org/type/A> . "
|
||||
+ " ?a a ?atype . "
|
||||
+ " OPTIONAL {"
|
||||
+ " ?b a <http://example.org/type/B> . "
|
||||
+ " ?b a ?btype . "
|
||||
+ " } "
|
||||
+ " ?c a <http://example.org/type/C> . "
|
||||
+ " ?c a ?ctype . "
|
||||
+ " BIND(f:timestamp(?a,rdf:type,?atype) AS ?tsa) "
|
||||
+ " BIND(f:timestamp(?b,rdf:type,?btype) AS ?tsb) "
|
||||
+ " BIND(f:timestamp(?c,rdf:type,?ctype) AS ?tsc) "
|
||||
+ " FILTER(f:timestamp(?a,rdf:type,?atype) < f:timestamp(?b,rdf:type,?btype)) "
|
||||
+ " FILTER(f:timestamp(?b,rdf:type,?btype) < f:timestamp(?c,rdf:type,?ctype)) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getSPOFromRentACar() {
|
||||
return "REGISTER QUERY BasicCarInfo AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "SELECT ?s ?p ?o "
|
||||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?s a <"+RentACarSimulation.BASE_ONTOLOGY_IRI+"CarStatusEvent> . "
|
||||
+ " ?s ?p ?o . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getAllCarAttributesQuery() {
|
||||
return "REGISTER QUERY BasicCarInfo AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX car: <http://example.org/car#> "
|
||||
+ "SELECT ?car ?locked ?on ?speed ?rpm ?handbrake ?tirePressure "
|
||||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e car:subject ?car . "
|
||||
+ " ?e car:locked ?locked . "
|
||||
+ " ?e car:motorOn ?on . "
|
||||
+ " ?e car:speed ?speed . "
|
||||
+ " ?e car:motorRPM ?rpm . "
|
||||
+ " ?e car:handbrakeEngaged ?handbrake . "
|
||||
+ " ?e car:tirePressure ?pressure . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getBasicCarInfoQuery() {
|
||||
return "REGISTER QUERY BasicCarInfo AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car ?speed ?temp (f:timestamp(?e,cars:carID,?car) AS ?ts) "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e cars:carID ?car . "
|
||||
+ " ?e cars:currentSpeed ?speed . "
|
||||
+ " ?e cars:currentTemperature ?temp . "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getIncreasingTemperatureQuery() {
|
||||
return "REGISTER QUERY IncreasingTemperature AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car (?temp2-?temp1 AS ?delta) "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e1 cars:carID ?car . "
|
||||
+ " ?e1 cars:currentSpeed ?speed1 . "
|
||||
+ " ?e1 cars:currentTemperature ?temp1 . "
|
||||
+ " ?e2 cars:carID ?car . "
|
||||
+ " ?e2 cars:currentSpeed ?speed2 . "
|
||||
+ " ?e2 cars:currentTemperature ?temp2 . "
|
||||
+ " FILTER(f:timestamp(?e1,cars:carID,?car) < f:timestamp(?e2,cars:carID,?car)) "
|
||||
+ " FILTER(?temp1 < ?temp2) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getAcceleratingCarsQuery() {
|
||||
return "REGISTER QUERY AcceleratingCars AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car (?speed2-?speed1 AS ?delta) "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e1 cars:carID ?car . "
|
||||
+ " ?e1 cars:currentSpeed ?speed1 . "
|
||||
+ " ?e1 cars:currentTemperature ?temp1 . "
|
||||
+ " ?e2 cars:carID ?car . "
|
||||
+ " ?e2 cars:currentSpeed ?speed2 . "
|
||||
+ " ?e2 cars:currentTemperature ?temp2 . "
|
||||
+ " FILTER(f:timestamp(?e1,cars:carID,?car) < f:timestamp(?e2,cars:carID,?car)) "
|
||||
+ " FILTER(?speed1 < ?speed2) "
|
||||
+ "}";
|
||||
}
|
||||
|
||||
private static String getBreakingDownCarsQuery() {
|
||||
return "REGISTER QUERY BreakingDownCars AS "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX cars: <http://myexample.org/cars#> "
|
||||
+ "SELECT ?car (?speed2 - ?speed1 AS ?deltaspeed) (?temp2 - ?temp1 AS ?deltatemp) ?speed2 ?temp2 "
|
||||
+ "FROM STREAM <http://myexample.org/cars> [RANGE 5s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e1 cars:carID ?car ; "
|
||||
+ " cars:currentSpeed ?speed1 ; "
|
||||
+ " cars:currentTemperature ?temp1 . "
|
||||
+ " ?e2 cars:carID ?car ; "
|
||||
+ " cars:currentSpeed ?speed2 ; "
|
||||
+ " cars:currentTemperature ?temp2 . "
|
||||
+ " FILTER(f:timestamp(?e1,cars:carID,?car) < f:timestamp(?e2,cars:carID,?car)) "
|
||||
+ " FILTER(f:timestamp(?e2,cars:carID,?car) - f:timestamp(?e1,cars:carID,?car) < 1800) "
|
||||
+ " FILTER(?speed1 > ?speed2) "
|
||||
+ " FILTER(?temp2 > ?temp1) "
|
||||
+ " FILTER(?temp2 > 90) "
|
||||
+ "}";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue