ExecutionResultImpl disconnectedResults = new ExecutionResultImpl(); HashMap<String, Object> disconnectedHandles = new HashMap<String, Object>(); for (String key : kresults.getIdentifiers()) { FactHandle handle = (FactHandle) kresults.getFactHandle(key); if (handle != null) { DefaultFactHandle disconnectedHandle = ((DefaultFactHandle) handle).clone();
throw new RuntimeException("Response was not correctly received"); String value = (String) ((ExecutionResults) object).getValue(commandId); String type = String.valueOf(value.charAt(0)); String instanceId = value.substring(2);
MarshallingContext context) { ExecutionResults result = (ExecutionResults) object; for ( String identifier : result.getIdentifiers() ) { writer.startNode( "result" ); writer.addAttribute( "identifier", identifier ); Object value = result.getValue( identifier ); if ( value instanceof org.drools.runtime.rule.QueryResults ) { String name = mapper().serializedClass(FlatQueryResults.class); Object handle = result.getFactHandle( identifier ); if ( handle instanceof FactHandle ) { writer.startNode( "fact-handle" );
@Test public void executeBatchTest() { StatefulKnowledgeSession ksession = createSession(); List<GenericCommand<?>> cmds = new ArrayList<GenericCommand<?>>(); cmds.add((GenericCommand<?>)CommandFactory.newSetGlobal("myGlobalObj", new MyObject("myglobalObj"))); cmds.add((GenericCommand<?>)CommandFactory.newInsert(new MyObject("obj1"), "myObject1")); cmds.add((GenericCommand<?>)CommandFactory.newFireAllRules()); BatchExecutionCommandImpl batch = new BatchExecutionCommandImpl(cmds, "out"); ExecutionResults results = ksession.execute(batch); System.out.println("Results = "+results); Assert.assertNotNull(results); Assert.assertEquals(1, results.getIdentifiers().size()); Assert.assertEquals("myObject1", results.getIdentifiers().iterator().next()); }
ExecutionResults result = (ExecutionResults) object; writer.startNode( "results" ); if ( !result.getIdentifiers().isEmpty() ) { for ( String identifier : result.getIdentifiers() ) { writer.startNode( "result" ); Object value = result.getValue( identifier ); if ( value instanceof org.drools.runtime.rule.QueryResults ) { String name = mapper().serializedClass(FlatQueryResults.class); Object handle = result.getFactHandle( identifier ); if ( handle instanceof FactHandle ) { writer.startNode( "fact-handle" );
public ProcessInstance startProcess(String processId) { String commandId = "ksession.execute" + messageSession.getNextId(); String kresultsId = "kresults_" + messageSession.getSessionId(); Message msg = new Message( messageSession.getSessionId(), messageSession.counter.incrementAndGet(), false, new KnowledgeContextResolveFromContextCommand( new StartProcessRemoteCommand( processId ), null, null, instanceId, kresultsId ) ); try { Object object = client.write( msg ).getPayload(); if ( object == null ) { throw new RuntimeException( "Response was not correctly received" ); } return (ProcessInstance) ((ExecutionResults) object).getValue( processId ); } catch ( Exception e ) { throw new RuntimeException( "Unable to execute message", e ); } }
public ExecutionResults execute(Command command) { String commandId = "ksession.execute" + messageSession.getNextId(); String kresultsId = "kresults_" + messageSession.getSessionId(); Message msg = new Message( messageSession.getSessionId(), messageSession.counter.incrementAndGet(), false, new KnowledgeContextResolveFromContextCommand( new ExecuteCommand( commandId, command ), null, null, instanceId, kresultsId ) ); try { Object object = client.write( msg ).getPayload();if ( object == null ) { throw new RuntimeException( "Response was not correctly received" ); } return (ExecutionResults) ((ExecutionResults) object).getValue( commandId ); } catch ( Exception e ) { throw new RuntimeException( "Unable to execute message", e ); } }
public int fireAllRules() { String commandId = "ksession.fireAllRules" + messageSession.getNextId(); String kresultsId = "kresults_" + messageSession.getSessionId(); Message msg = new Message( messageSession.getSessionId(), messageSession.counter.incrementAndGet(), false, new KnowledgeContextResolveFromContextCommand( new FireAllRulesCommand( commandId ), null, null, instanceId, kresultsId ) ); try { Object object = client.write( msg ).getPayload(); if ( object == null ) { throw new RuntimeException( "Response was not correctly received" ); } return (Integer) ((ExecutionResults) object).getValue( commandId ); } catch ( Exception e ) { throw new RuntimeException( "Unable to execute message", e ); } }
public KnowledgeBuilderErrors getErrors() { String commandId = "kbuilder.getErrors_" + messageSession.getNextId(); String kresultsId = "kresults_" + messageSession.getSessionId(); Message msg = new Message( messageSession.getSessionId(), messageSession.counter.incrementAndGet(), false, new KnowledgeContextResolveFromContextCommand( new KnowledgeBuilderGetErrorsCommand( commandId ), instanceId, null, null, kresultsId ) ); try { Object object = client.write( msg ).getPayload(); if ( object == null ) { throw new RuntimeException( "Response was not correctly received" ); } return (KnowledgeBuilderErrors) ((ExecutionResults) object).getValue( commandId ); } catch ( Exception e ) { throw new RuntimeException( "Unable to execute message", e ); } }
public boolean hasErrors() { String commandId = "kbuilder.hasErrors_" + messageSession.getNextId(); String kresultsId = "kresults_" + messageSession.getSessionId(); Message msg = new Message( messageSession.getSessionId(), messageSession.getNextId(), false, new KnowledgeContextResolveFromContextCommand( new KnowledgeBuilderHasErrorsCommand( commandId ), instanceId, null, null, kresultsId ) ); try { Object object = client.write( msg ).getPayload(); if ( object == null ) { throw new RuntimeException( "Response was not correctly received" ); } return (Boolean) ((ExecutionResults) object).getValue( commandId ); } catch ( Exception e ) { throw new RuntimeException( "Unable to execute message", e ); } }
public WorkItemManager getWorkItemManager() { String kresultsId = "kresults_" + messageSession.getSessionId(); Message msg = new Message( messageSession.getSessionId(), messageSession.counter.incrementAndGet(), true, new KnowledgeContextResolveFromContextCommand( new GetWorkItemManagerCommand(), null, null, instanceId, kresultsId ) ); try { Object payload = client.write( msg ).getPayload(); WorkItemManager workItemManager = (WorkItemManager) ((ExecutionResults) payload).getValue( "workItemManager" ); ((WorkItemManagerRemoteClient)workItemManager).setClient(client); ((WorkItemManagerRemoteClient)workItemManager).setMessageSession(messageSession); ((WorkItemManagerRemoteClient)workItemManager).setInstanceId(instanceId); return workItemManager; } catch ( Exception e ) { throw new RuntimeException( "Unable to execute message", e ); } }