use of org.drools.core.runtime.impl.ExecutionResultImpl in project drools by kiegroup.
the class AdvanceSessionTimeCommand method execute.
@Override
public Long execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
SessionPseudoClock sessionClock = ksession.<SessionPseudoClock>getSessionClock();
sessionClock.advanceTime(amount, unit);
long result = sessionClock.getCurrentTime();
ExecutionResultImpl results = ((RegistryContext) context).lookup(ExecutionResultImpl.class);
if (results != null) {
results.getResults().put(this.outIdentifier, result);
}
return result;
}
use of org.drools.core.runtime.impl.ExecutionResultImpl in project drools by kiegroup.
the class GetSessionTimeCommand method execute.
@Override
public Long execute(Context context) {
KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
SessionClock sessionClock = ksession.<SessionClock>getSessionClock();
long result = sessionClock.getCurrentTime();
ExecutionResultImpl results = ((RegistryContext) context).lookup(ExecutionResultImpl.class);
if (results != null) {
results.getResults().put(this.outIdentifier, result);
}
return result;
}
use of org.drools.core.runtime.impl.ExecutionResultImpl in project drools by kiegroup.
the class XStreamXMLTest method testExecutionResults.
@Test
public void testExecutionResults() {
final Message msg = new Message("Hello World!");
final FactHandle msgHandle = new DefaultFactHandle(1, null, 10, 10, 20, msg);
final Message msg2 = new Message("Hello World again!");
final FactHandle msgHandle2 = new DefaultFactHandle(2, null, 10, 10, 20, msg2);
HashMap<String, Object> factHandles = new LinkedHashMap<String, Object>();
factHandles.put("first", msgHandle);
factHandles.put("second", msgHandle2);
ExecutionResultImpl executionResult = new ExecutionResultImpl();
executionResult.setFactHandles(factHandles);
HashMap<String, Object> results = new LinkedHashMap<String, Object>();
results.put("message1", msg);
results.put("message2", msg2);
executionResult.setResults(results);
String xmlString = xstream.toXML(executionResult);
Assert.assertEquals("<execution-results>\n" + " <result identifier=\"message1\">\n" + " <org.drools.xml.support.XStreamXMLTest_-Message>\n" + " <msg>Hello World!</msg>\n" + " </org.drools.xml.support.XStreamXMLTest_-Message>\n" + " </result>\n" + " <result identifier=\"message2\">\n" + " <org.drools.xml.support.XStreamXMLTest_-Message>\n" + " <msg>Hello World again!</msg>\n" + " </org.drools.xml.support.XStreamXMLTest_-Message>\n" + " </result>\n" + " <fact-handle identifier=\"first\" external-form=\"0:1:10:10:20:null:NON_TRAIT:org.drools.xml.support.XStreamXMLTest$Message\"/>\n" + " <fact-handle identifier=\"second\" external-form=\"0:2:10:10:20:null:NON_TRAIT:org.drools.xml.support.XStreamXMLTest$Message\"/>\n" + "</execution-results>", xmlString);
ExecutionResultImpl executionResult2 = (ExecutionResultImpl) xstream.fromXML(xmlString);
Assert.assertEquals(executionResult.getFactHandles().size(), executionResult2.getFactHandles().size());
Assert.assertEquals(executionResult.getResults().size(), executionResult2.getResults().size());
}
Aggregations