[TASK] Add a TBox for testing purposes, figured it out.
This commit is contained in:
parent
6d2c90ef96
commit
ce802396ff
|
@ -0,0 +1,67 @@
|
|||
<rdf:RDF
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#Car">
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#Driver">
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#Event">
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#CarEvent">
|
||||
<rdfs:subClassOf rdf:resource="http://jpt.lu/carSimulationOntology#Event"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#CarAirbagEvent">
|
||||
<rdfs:subClassOf rdf:resource="http://jpt.lu/carSimulationOntology#CarEvent"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#CarStatusEvent">
|
||||
<rdfs:subClassOf rdf:resource="http://jpt.lu/carSimulationOntology#CarEvent"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#CarUserEvent">
|
||||
<rdfs:subClassOf rdf:resource="http://jpt.lu/carSimulationOntology#CarEvent"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#CarTakenEvent">
|
||||
<rdfs:subClassOf rdf:resource="http://jpt.lu/carSimulationOntology#CarUserEvent"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#CarReturnedEvent">
|
||||
<rdfs:subClassOf rdf:resource="http://jpt.lu/carSimulationOntology#CarUserEvent"/>
|
||||
</rdf:Description>
|
||||
|
||||
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#drives">
|
||||
<rdfs:domain rdf:resource="http://jpt.lu/carSimulationOntology#Driver"/>
|
||||
<rdfs:range rdf:resource="http://jpt.lu/carSimulationOntology#Car"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#isDrivenBy">
|
||||
<rdfs:domain rdf:resource="http://jpt.lu/carSimulationOntology#Car"/>
|
||||
<rdfs:range rdf:resource="http://jpt.lu/carSimulationOntology#Driver"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#relatedCar">
|
||||
<rdfs:domain rdf:resource="http://jpt.lu/carSimulationOntology#CarEvent"/>
|
||||
<rdfs:range rdf:resource="http://jpt.lu/carSimulationOntology#Car"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#relatedUser">
|
||||
<rdfs:domain rdf:resource="http://jpt.lu/carSimulationOntology#Event"/>
|
||||
<rdfs:range rdf:resource="http://jpt.lu/carSimulationOntology#Driver"/>
|
||||
</rdf:Description>
|
||||
|
||||
<rdf:Description rdf:about="http://jpt.lu/carSimulationOntology#relatedEvent">
|
||||
<rdfs:domain rdf:resource="http://jpt.lu/carSimulationOntology#Car"/>
|
||||
<rdfs:domain rdf:resource="http://jpt.lu/carSimulationOntology#Driver"/>
|
||||
<rdfs:range rdf:resource="http://jpt.lu/carSimulationOntology#Event"/>
|
||||
</rdf:Description>
|
||||
|
||||
|
||||
</rdf:RDF>
|
|
@ -7,6 +7,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.larkc.csparql.common.utils.CsparqlUtils;
|
||||
import eu.larkc.csparql.common.utils.ReasonerChainingType;
|
||||
import eu.larkc.csparql.core.engine.ConsoleFormatter;
|
||||
import eu.larkc.csparql.core.engine.CsparqlEngine;
|
||||
import eu.larkc.csparql.core.engine.CsparqlEngineImpl;
|
||||
|
@ -47,10 +48,7 @@ public class Main {
|
|||
+ "{ GRAPH <http://streamreasoning.org/roomConnection> { :room :isConnectedTo :room2 } }";
|
||||
engine.execUpdateQueryOverDatasource(updateQuery);
|
||||
*/
|
||||
|
||||
// Enable reasoning with rdfs rules from file and a tbox rdf file.
|
||||
//engine.updateReasoner(c.getSparqlQueryId(), CsparqlUtils.fileToString("examples_files/rdfs.rules"), ReasonerChainingType.FORWARD, CsparqlUtils.serializeRDFFile("examples_files/tbox.rdf"));
|
||||
|
||||
|
||||
|
||||
// Debugging: Needed to verify which engine is being used
|
||||
//logger.debug("CWD: " + System.getProperty("user.dir"));
|
||||
|
@ -76,6 +74,21 @@ public class Main {
|
|||
logger.error(e.toString());
|
||||
logger.error(e.getStackTrace().toString());
|
||||
}
|
||||
|
||||
// Enable reasoning with rdfs rules from file and a tbox rdf file.
|
||||
/*try {
|
||||
engine.updateReasoner(
|
||||
resultProxy.getSparqlQueryId(),
|
||||
CsparqlUtils.fileToString("data/rdfs.rules"),
|
||||
ReasonerChainingType.FORWARD,
|
||||
CsparqlUtils.serializeRDFFile("data/carSimulationTBox.rdf")
|
||||
);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e.toString());
|
||||
logger.error(e.getStackTrace().toString());
|
||||
}*/
|
||||
|
||||
// Add ConsoleFormatter as observer so it gets notified of every query result
|
||||
resultProxy.addObserver(new ConsoleFormatter());
|
||||
|
||||
|
@ -107,6 +120,7 @@ public class Main {
|
|||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?s a <http://jpt.lu/carSimulationOntology#CarStatusEvent> . "
|
||||
+ " ?s ?p ?o . "
|
||||
+ "}";
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ public class Car {
|
|||
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
||||
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
|
||||
String eventIri = baseIri + "/event#" + time;
|
||||
this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarAirbagEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarAirbagEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ public class Car {
|
|||
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
||||
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
|
||||
String eventIri = baseIri + "/event#" + time;
|
||||
this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarStatusEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarStatusEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.getIri(), time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"motorOn", ""+this.motorOn+"^^http://www.w3.org/2001/XMLSchema#boolean", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"motorRPM", ""+this.motorRpm+"^^http://www.w3.org/2001/XMLSchema#integer", time));
|
||||
|
|
|
@ -151,7 +151,7 @@ public class Driver {
|
|||
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
||||
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
|
||||
String eventIri = baseIri + "/event#" + time;
|
||||
this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarTakenEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarTakenEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedUser", this.getIri(), time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.car.getIri(), System.currentTimeMillis()));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"usagePeriod", ""+useCycles+"^^http://www.w3.org/2001/XMLSchema#integer", System.currentTimeMillis()));
|
||||
|
@ -162,7 +162,7 @@ public class Driver {
|
|||
String baseIri = RentACarSimulation.BASE_OBJECT_IRI;
|
||||
String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI;
|
||||
String eventIri = baseIri + "/event#" + time;
|
||||
this.quads.add(new RdfQuadruple(eventIri, "rdf:type", baseOnt+"CarReturnedEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", baseOnt+"CarReturnedEvent", time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedUser", this.getIri(), time));
|
||||
this.quads.add(new RdfQuadruple(eventIri, baseOnt+"relatedCar", this.car.getIri(), time));
|
||||
this.carPool.returnCar(this.car);
|
||||
|
|
|
@ -99,8 +99,9 @@ public class RentACarSimulation implements Runnable {
|
|||
this.runSimulation = false;
|
||||
}
|
||||
|
||||
public static String getEvents() {
|
||||
public static String getEventsQuery() {
|
||||
return "REGISTER QUERY getEvents AS "
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
|
||||
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
|
||||
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
|
||||
+ "PREFIX car: <"+RentACarSimulation.BASE_ONTOLOGY_IRI+"> "
|
||||
|
@ -108,6 +109,7 @@ public class RentACarSimulation implements Runnable {
|
|||
+ "FROM STREAM <"+RentACarSimulation.CAR_STREAM_IRI+"> [RANGE 5s STEP 1s] "
|
||||
+ "FROM STREAM <"+RentACarSimulation.DRIVER_STREAM_IRI+"> [RANGE 15s STEP 1s] "
|
||||
+ "WHERE { "
|
||||
+ " ?e rdf:type car:Event . "
|
||||
+ " ?e car:subject ?car . "
|
||||
+ " ?e car:locked ?locked . "
|
||||
+ " ?e car:motorOn ?on . "
|
||||
|
|
Loading…
Reference in New Issue