[TASK] Add Code to enable reasoning.
This commit is contained in:
parent
e093469fa9
commit
eec451fe8e
|
@ -9,6 +9,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import eu.larkc.csparql.cep.api.RdfStream;
|
import eu.larkc.csparql.cep.api.RdfStream;
|
||||||
import eu.larkc.csparql.common.utils.CsparqlUtils;
|
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.CsparqlEngine;
|
||||||
import eu.larkc.csparql.core.engine.CsparqlEngineImpl;
|
import eu.larkc.csparql.core.engine.CsparqlEngineImpl;
|
||||||
import eu.larkc.csparql.core.engine.CsparqlQueryResultProxy;
|
import eu.larkc.csparql.core.engine.CsparqlQueryResultProxy;
|
||||||
|
@ -165,7 +166,8 @@ public class SimulationContext {
|
||||||
CsparqlQueryInfo queryInfo = CsparqlQueryHelper.getQueryInfo(query);
|
CsparqlQueryInfo queryInfo = CsparqlQueryHelper.getQueryInfo(query);
|
||||||
CsparqlQueryResultProxy resultProxy = null;
|
CsparqlQueryResultProxy resultProxy = null;
|
||||||
try {
|
try {
|
||||||
resultProxy = this.engine.registerQuery(query, false);
|
resultProxy = this.engine.registerQuery(query, true);
|
||||||
|
this.enableReasoningForResultProxy(resultProxy);
|
||||||
// Take care of streams and queries differently.
|
// Take care of streams and queries differently.
|
||||||
if(queryInfo.isStream) {
|
if(queryInfo.isStream) {
|
||||||
// If the query is a stream, we need additional components to feed it back into the engine.
|
// 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;
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue