diff --git a/data/carSimulationOntology.owl b/data/carSimulationOntology.owl index 593d997..cd0b66b 100644 --- a/data/carSimulationOntology.owl +++ b/data/carSimulationOntology.owl @@ -1,18 +1,42 @@ - - + Beispielhafte Ontologie für die Autosimulation + + + + + + + + + + + + + + + + + + - - - - + + + + - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -54,60 +108,129 @@ - + - - - + + + - + - - - - - - - - - - - - - - - - - - - - + + - + - - - + + + + - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -142,25 +319,25 @@ - + - - - B + + + B - + - - - - B - 4500 - 3.5 - 800 - 2.9 + + + + 800 + 2.9 + B + 4500 + 3.5 diff --git a/src/main/java/lu/jpt/csparqltest/rentacar/Car.java b/src/main/java/lu/jpt/csparqltest/rentacar/Car.java index 78e1a67..e31f5ae 100644 --- a/src/main/java/lu/jpt/csparqltest/rentacar/Car.java +++ b/src/main/java/lu/jpt/csparqltest/rentacar/Car.java @@ -45,7 +45,7 @@ public class Car { public Car(int id) { this.id = id; - this.IRI = RentACarSimulation.CAR_IRI; + this.IRI = RentACarSimulation.BASE_OBJECT_IRI + "/car"; this.quads = new ArrayList(); this.CAR_TYPE = RandomHelper.nextInt(2); this.initializeCarType(this.CAR_TYPE); @@ -197,23 +197,26 @@ public class Car { private void fireAirbagEvent() { long time = System.currentTimeMillis(); - String baseIri = RentACarSimulation.BASE_IRI; + String baseIri = RentACarSimulation.BASE_OBJECT_IRI; + String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI; String eventIri = baseIri + "/event#" + time; - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#subject", this.getIri(), time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#airbagTriggered", ""+true+"^^http://www.w3.org/2001/XMLSchema#boolean", time)); + this.quads.add(new RdfQuadruple(eventIri, "a", baseOnt+"/CarAirbagEvent", time)); + this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#relatedCar", this.getIri(), time)); } private void generateContinousReportQuads() { long time = System.currentTimeMillis(); - String baseIri = RentACarSimulation.BASE_IRI; + String baseIri = RentACarSimulation.BASE_OBJECT_IRI; + String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI; String eventIri = baseIri + "/event#" + time; - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#subject", this.getIri(), time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#motorOn", ""+this.motorOn+"^^http://www.w3.org/2001/XMLSchema#boolean", time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#motorRPM", ""+this.motorRpm+"^^http://www.w3.org/2001/XMLSchema#integer", time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#speed", ""+this.speed+"^^http://www.w3.org/2001/XMLSchema#integer", time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#handbrakeEngaged", ""+this.handbrakeEngaged+"^^http://www.w3.org/2001/XMLSchema#boolean", time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#tirePressure", ""+this.tirePressure+"^^http://www.w3.org/2001/XMLSchema#double", time)); - this.quads.add(new RdfQuadruple(eventIri, "http://myexample.org/car#locked", ""+this.isLocked+"^^http://www.w3.org/2001/XMLSchema#boolean", time)); + this.quads.add(new RdfQuadruple(eventIri, "a", 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)); + this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#speed", ""+this.speed+"^^http://www.w3.org/2001/XMLSchema#integer", time)); + this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#handbrakeEngaged", ""+this.handbrakeEngaged+"^^http://www.w3.org/2001/XMLSchema#boolean", time)); + this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#tirePressure", ""+this.tirePressure+"^^http://www.w3.org/2001/XMLSchema#double", time)); + this.quads.add(new RdfQuadruple(eventIri, baseOnt+"#locked", ""+this.isLocked+"^^http://www.w3.org/2001/XMLSchema#boolean", time)); } public CarState getState() { @@ -237,7 +240,7 @@ public class Car { } public String getIri() { - return RentACarSimulation.CAR_IRI + "#" + this.id; + return this.IRI + "#" + this.id; } public List getQuadruples() { diff --git a/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java b/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java index 254b086..071d61e 100644 --- a/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java +++ b/src/main/java/lu/jpt/csparqltest/rentacar/Driver.java @@ -27,9 +27,12 @@ public class Driver { private List quads; + private final String IRI; + public Driver(int id, CarPool carPool) { this.id = id; + this.IRI = RentACarSimulation.BASE_OBJECT_IRI + "/driver"; this.carPool = carPool; this.car = null; this.quads = new ArrayList(); @@ -42,7 +45,7 @@ public class Driver { } public String getIri() { - return RentACarSimulation.DRIVER_IRI + "#" + this.id; + return this.IRI + "#" + this.id; } /** @@ -145,19 +148,23 @@ public class Driver { this.car = this.carPool.takeRandomCar(); this.carUseCycles = useCycles; long time = System.currentTimeMillis(); - String baseIri = RentACarSimulation.BASE_IRI; + String baseIri = RentACarSimulation.BASE_OBJECT_IRI; + String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI; String eventIri = baseIri + "/event#" + time; - this.quads.add(new RdfQuadruple(eventIri, baseIri+"#user", this.getIri(), time)); - this.quads.add(new RdfQuadruple(eventIri, baseIri+"#took", this.car.getIri(), System.currentTimeMillis())); - this.quads.add(new RdfQuadruple(eventIri, baseIri+"#usagePeriod", ""+useCycles+"^^http://www.w3.org/2001/XMLSchema#integer", System.currentTimeMillis())); + this.quads.add(new RdfQuadruple(eventIri, "a", 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())); } private void returnCar() { long time = System.currentTimeMillis(); - String baseIri = RentACarSimulation.BASE_IRI; + String baseIri = RentACarSimulation.BASE_OBJECT_IRI; + String baseOnt = RentACarSimulation.BASE_ONTOLOGY_IRI; String eventIri = baseIri + "/event#" + time; - this.quads.add(new RdfQuadruple(eventIri, baseIri+"#user", this.getIri(), time)); - this.quads.add(new RdfQuadruple(eventIri, baseIri+"#returned", this.car.getIri(), time)); + this.quads.add(new RdfQuadruple(eventIri, "a", 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); this.car = null; } diff --git a/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java b/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java index 74f3477..6c68f3f 100644 --- a/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java +++ b/src/main/java/lu/jpt/csparqltest/rentacar/RentACarSimulation.java @@ -8,9 +8,11 @@ import eu.larkc.csparql.cep.api.RdfStream; public class RentACarSimulation implements Runnable { - public static final String BASE_IRI = "http://myexample.org"; - public static final String CAR_IRI = BASE_IRI + "/car"; - public static final String DRIVER_IRI = BASE_IRI + "/driver"; + public static final String BASE_ONTOLOGY_IRI = "http://simontology.org"; + public static final String BASE_STREAM_IRI = "http://simstream.org"; + public static final String BASE_OBJECT_IRI = "http://simobject.org"; + public static final String CAR_STREAM_IRI = BASE_STREAM_IRI + "/carStream"; + public static final String DRIVER_STREAM_IRI = BASE_STREAM_IRI + "/driverStream"; private CarPool carPool; private List drivers; @@ -33,8 +35,8 @@ public class RentACarSimulation implements Runnable { this.drivers.add(driver); } // Create streams - this.carStream = new RdfStream(CAR_IRI); - this.driverStream = new RdfStream(DRIVER_IRI); + this.carStream = new RdfStream(CAR_STREAM_IRI); + this.driverStream = new RdfStream(DRIVER_STREAM_IRI); // Green light for simulation this.runSimulation = true; }