Package org.kie.runtime

Examples of org.kie.runtime.ExecutionResults


            }
            if ( autoFireAllRules ) {
                ksession.fireAllRules( );
            }
            if ( command instanceof BatchExecutionCommandImpl) {
                ExecutionResults result = ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
                return (T) result;
            } else {
                return (T) o;
            }
        } finally {
View Full Code Here


    }

    public ExecutionResults execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
       
        ExecutionResults kresults = null;
        if( ksession instanceof StatefulKnowledgeSessionImpl ) {
            kresults = ((StatefulKnowledgeSessionImpl)ksession).execute(context, this.command );
        }
        else {
            // Graceful failure
            kresults = ksession.execute(this.command);
        }
       
        if ( this.outIdentifier != null ) {
            ((ExecutionResultImpl)((KnowledgeCommandContext) context ).getExecutionResults()).getResults().put( this.outIdentifier, kresults );
        }
        if (disconnected) {
            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();
                    disconnectedHandle.disconnect();
                    disconnectedHandles.put(key, disconnectedHandle);
                }
View Full Code Here

                                                                                                                
        BatchExecutionCommand batchCmd = CommandFactory.newBatchExecution(cmds, "kresults");
        ExecuteCommand execCmd = new ExecuteCommand(batchCmd,true);
        KnowledgeContextResolveFromContextCommand resolveFromContextCommand = new KnowledgeContextResolveFromContextCommand(execCmd,  
                                                                                        null,null,"ksession","localResults");
        ExecutionResults results = (ExecutionResults)commandService.execute(resolveFromContextCommand);
       
        assertNotNull(results);
       
        assertNotNull(results.getFactHandle("handle"));
       
        assertTrue(((DefaultFactHandle)results.getFactHandle("handle")).isDisconnected());
       
       
       
        cmds = new ArrayList();
        cmds.add(new InsertObjectCommand(new String("Hi!"), "handle"));
        batchCmd = CommandFactory.newBatchExecution(cmds, "kresults");
        execCmd = new ExecuteCommand(batchCmd);
        resolveFromContextCommand = new KnowledgeContextResolveFromContextCommand(execCmd,  
                                                                                        null,null,"ksession","localResults");
        results = (ExecutionResults)commandService.execute(resolveFromContextCommand);
       
        assertNotNull(results);
       
        assertNotNull(results.getFactHandle("handle"));
       
        assertFalse(((DefaultFactHandle)results.getFactHandle("handle")).isDisconnected());
       
    }
View Full Code Here

        ExecuteCommand execCmd = new ExecuteCommand(batchCmd,true);
       
       
        KnowledgeContextResolveFromContextCommand resolveFromContextCommand = new KnowledgeContextResolveFromContextCommand(execCmd,
                null, null, "ksession", "localResults");
        ExecutionResults results = (ExecutionResults) commandService.execute(resolveFromContextCommand);

        // I'm not expecting any results here
        assertNotNull(results);

        GetVariableCommand getVariableCmd = new GetVariableCommand("query123", "__TEMP__");
View Full Code Here

        QueryCommand queryCommand = new QueryCommand("out", "myQuery", new Object[]{});
        SetVariableCommandFromCommand setVariableCmd = new SetVariableCommandFromCommand("__TEMP__", "query123", queryCommand);
       
        KnowledgeContextResolveFromContextCommand resolveFromContextCommand = new KnowledgeContextResolveFromContextCommand(setVariableCmd,
                null, null, "ksession", "localResults");
        ExecutionResults results = (ExecutionResults) commandService.execute(resolveFromContextCommand);

        // I'm not expecting any results here
        assertNull(results);

        GetVariableCommand getVariableCmd = new GetVariableCommand("query123", "__TEMP__");
View Full Code Here

            ((GenericCommand) command).execute( new FixedKnowledgeCommandContext( context,
                                                                                  null,
                                                                                  this.kbase,
                                                                                  this,
                                                                                  results ) );
            ExecutionResults result = session.getExecutionResult();
            return (T) result;
        } finally {
            session.endBatchExecution();
        }
    }
View Full Code Here

        }

        public void marshal(Object object,
                            HierarchicalStreamWriter writer,
                            MarshallingContext context) {
            ExecutionResults result = (ExecutionResults) object;
            writer.startNode( "results" );
            if ( !result.getIdentifiers().isEmpty() ) {
                for ( String identifier : result.getIdentifiers() ) {
                    writer.startNode( "result" );

                    writer.startNode( "identifier" );
                    writer.setValue( identifier );
                    writer.endNode();

                    writer.startNode( "value" );
                    Object value = result.getValue( identifier );
                    if ( value instanceof org.kie.runtime.rule.QueryResults ) {
                        String name = mapper().serializedClass(FlatQueryResults.class);
                        ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, FlatQueryResults.class);
                        context.convertAnother(value);
                        writer.endNode();
                    } else {
                        writeItem( value,
                                   context,
                                   writer );
                    }
                    writer.endNode();

                    writer.endNode();
                }
            }

            for ( String identifier : ((ExecutionResultImpl) result).getFactHandles().keySet() ) {
                Object handle = result.getFactHandle( identifier );
                if ( handle instanceof FactHandle ) {
                    writer.startNode( "fact-handle" );

                    writer.startNode( "identifier" );
                    writer.setValue( identifier );
View Full Code Here

            }
            if ( autoFireAllRules ) {
                ksession.fireAllRules( );
            }
            if ( command instanceof BatchExecutionCommandImpl) {
                ExecutionResults result = ((StatefulKnowledgeSessionImpl) ksession).session.getExecutionResult();
                return (T) result;
            } else {
                return (T) o;
            }
        } finally {
View Full Code Here

  }

  public void marshal(Object object,
                      HierarchicalStreamWriter writer,
                      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.kie.runtime.rule.QueryResults ) {
              String name = mapper().serializedClass(FlatQueryResults.class);
              ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, FlatQueryResults.class);
              context.convertAnother(value);
              writer.endNode();
          } else {
              writeItem( value,
                         context,
                         writer );
          }
          writer.endNode();
      }

      for ( String identifier : ((ExecutionResultImpl) result).getFactHandles().keySet() ) {
          Object handle = result.getFactHandle( identifier );
          if ( handle instanceof FactHandle ) {
              writer.startNode( "fact-handle" );
              writer.addAttribute( "identifier",
                                   identifier );
              writer.addAttribute( "external-form",
View Full Code Here

            ((GenericCommand) command).execute( new FixedKnowledgeCommandContext( context,
                                                                                  null,
                                                                                  this.kbase,
                                                                                  this,
                                                                                  results ) );
            ExecutionResults result = session.getExecutionResult();
            return (T) result;
        } finally {
            session.endBatchExecution();
        }
    }
View Full Code Here

TOP

Related Classes of org.kie.runtime.ExecutionResults

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.