From 038a6a85bcf96ee03c3dfe7f3f4b81da3893ab7f Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 8 Oct 2016 22:59:27 +0200 Subject: [PATCH] [TASK] Create static method to specifically set up reaoning on simulation related QueryContainer. --- .../rentacar/RentACarSimulation.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java b/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java index 2052a8c..7136a61 100644 --- a/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java +++ b/src/main/java/lu/jpt/csparqlproject/rentacar/RentACarSimulation.java @@ -8,6 +8,8 @@ import org.slf4j.LoggerFactory; import eu.larkc.csparql.cep.api.RdfQuadruple; import eu.larkc.csparql.cep.api.RdfStream; +import eu.larkc.csparql.common.utils.CsparqlUtils; +import eu.larkc.csparql.common.utils.ReasonerChainingType; import lu.jpt.csparqlproject.Main; import lu.jpt.csparqlproject.misc.QueryContainer; import lu.jpt.csparqlproject.util.WindowLoggingRdfStream; @@ -147,6 +149,18 @@ public class RentACarSimulation implements Runnable { } + private static void setUpReasoningOnQueryContainer(QueryContainer queryContainer) { + try { + queryContainer.enableReasoning( + CsparqlUtils.fileToString("data/rdfs.rules"), + CsparqlUtils.serializeRDFFile("data/carSimulationTBox.rdf"), + ReasonerChainingType.HYBRID + ); + } catch (Exception e) { + RentACarSimulation.logger.error(e.getMessage()); + } + } + public static QueryContainer getEventsQuery() { String query = "REGISTER QUERY getCarStatusEvents AS " + "PREFIX rdf: " @@ -238,6 +252,7 @@ public class RentACarSimulation implements Runnable { + " }" + "} "; QueryContainer queryContainer = new QueryContainer("getAverageSpeedByCar", query, true); + RentACarSimulation.setUpReasoningOnQueryContainer(queryContainer); return queryContainer; }