From eec451fe8e588b27a230b111a5b1b3fd04d6075b Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Wed, 5 Oct 2016 20:10:22 +0200 Subject: [PATCH] [TASK] Add Code to enable reasoning. --- .../jpt/csparqlproject/SimulationContext.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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()); + } + } }