[TASK] Downgrade to engine 0.9.6
This commit is contained in:
@@ -11,9 +11,11 @@ import eu.larkc.csparql.cep.api.RdfStream;
|
||||
import eu.larkc.csparql.core.engine.CsparqlEngine;
|
||||
import eu.larkc.csparql.core.engine.CsparqlEngineImpl;
|
||||
import eu.larkc.csparql.core.engine.CsparqlQueryResultProxy;
|
||||
import eu.larkc.csparql.core.engine.RDFStreamFormatter;
|
||||
import lu.jpt.csparqlproject.gui.FancyTextObserverWindow;
|
||||
import lu.jpt.csparqlproject.rentacar.RentACarSimulation;
|
||||
import lu.jpt.csparqlproject.util.CsparqlQueryHelper;
|
||||
import lu.jpt.csparqlproject.util.CsparqlQueryHelper.CsparqlQueryInfo;
|
||||
|
||||
/**
|
||||
* This class encapsulates the use of the C-SPARQL Engine. Here, the RentACarSimulation,
|
||||
@@ -153,23 +155,38 @@ public class SimulationContext {
|
||||
RdfStream driverStream = simulation.getDriverStream();
|
||||
this.engine.registerStream(driverStream);
|
||||
this.registeredStreams.add(driverStream);
|
||||
// Register all the queries and add result observers!
|
||||
Collection<String> queriesToRegister = new ArrayList<String>();
|
||||
queriesToRegister.add(RentACarSimulation.getEventsQuery());
|
||||
queriesToRegister.add(RentACarSimulation.getAverageDataByCar());
|
||||
// Collect the queries to use!
|
||||
//queriesToRegister.add(RentACarSimulation.getEventsQuery());
|
||||
queriesToRegister.add(RentACarSimulation.getAverageDataByCarAsStream());
|
||||
queriesToRegister.add(RentACarSimulation.selectFromRegisteredStream());
|
||||
// Now register each query appropriately!
|
||||
for(String query : queriesToRegister) {
|
||||
String queryName = CsparqlQueryHelper.getQueryName(query);
|
||||
CsparqlQueryInfo queryInfo = CsparqlQueryHelper.getQueryInfo(query);
|
||||
CsparqlQueryResultProxy resultProxy = null;
|
||||
try {
|
||||
resultProxy = this.engine.registerQuery(query, true);
|
||||
resultProxy = this.engine.registerQuery(query, false);
|
||||
// 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.
|
||||
String streamUri = "http://example.org/stream/"+queryInfo.name;
|
||||
RDFStreamFormatter rdfStreamFormatter = new RDFStreamFormatter(streamUri);
|
||||
engine.registerStream(rdfStreamFormatter);
|
||||
resultProxy.addObserver(rdfStreamFormatter);
|
||||
Observer resultObserver = this.createResultObserverWindow(queryInfo.name);
|
||||
resultProxy.addObserver(resultObserver);
|
||||
} else {
|
||||
// If it is a regular query, just attach a fitting observer
|
||||
Observer resultObserver = this.createResultObserverWindow(queryInfo.name);
|
||||
resultProxy.addObserver(resultObserver);
|
||||
}
|
||||
this.queryResultProxies.add(resultProxy);
|
||||
SimulationContext.logger.info("Successfully registered query " + queryInfo.name + ": " + query);
|
||||
} catch (Exception e) {
|
||||
SimulationContext.logger.error(e.toString());
|
||||
SimulationContext.logger.error("Could not register query "+queryName);
|
||||
SimulationContext.logger.error("Could not register query "+queryInfo.name);
|
||||
SimulationContext.logger.error(query);
|
||||
}
|
||||
this.queryResultProxies.add(resultProxy);
|
||||
Observer resultObserver = this.createResultObserverWindow(queryName);
|
||||
resultProxy.addObserver(resultObserver);
|
||||
}
|
||||
// Setup complete, ready to run.
|
||||
SimulationContext.logger.info("Simulation set up and ready to go!");
|
||||
|
||||
Reference in New Issue
Block a user