diff --git a/src/main/java/lu/jpt/csparqlproject/SimulationContext.java b/src/main/java/lu/jpt/csparqlproject/SimulationContext.java index 58bedd5..9b1b290 100644 --- a/src/main/java/lu/jpt/csparqlproject/SimulationContext.java +++ b/src/main/java/lu/jpt/csparqlproject/SimulationContext.java @@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory; import eu.larkc.csparql.cep.api.RdfStream; import eu.larkc.csparql.common.utils.CsparqlUtils; +import eu.larkc.csparql.common.utils.ReasonerChainingType; import eu.larkc.csparql.core.engine.CsparqlEngine; import eu.larkc.csparql.core.engine.CsparqlEngineImpl; import eu.larkc.csparql.core.engine.CsparqlQueryResultProxy; @@ -165,7 +166,8 @@ public class SimulationContext { CsparqlQueryInfo queryInfo = CsparqlQueryHelper.getQueryInfo(query); CsparqlQueryResultProxy resultProxy = null; try { - resultProxy = this.engine.registerQuery(query, false); + resultProxy = this.engine.registerQuery(query, true); + this.enableReasoningForResultProxy(resultProxy); // Take care of streams and queries differently. if(queryInfo.isStream) { // If the query is a stream, we need additional components to feed it back into the engine. @@ -211,5 +213,19 @@ public class SimulationContext { return observer; } + private void enableReasoningForResultProxy(CsparqlQueryResultProxy resultProxy) { + try { + engine.updateReasoner( + resultProxy.getSparqlQueryId(), + CsparqlUtils.fileToString("data/rdfs.rules"), + ReasonerChainingType.FORWARD, + CsparqlUtils.serializeRDFFile("data/carSimulationTBox.rdf") + ); + } catch(Exception e) { + e.printStackTrace(); + SimulationContext.logger.error(e.toString()); + SimulationContext.logger.error(e.getStackTrace().toString()); + } + } }