Package org.kie.api.runtime

Examples of org.kie.api.runtime.ExecutionResults


        }

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

                Collection<String> identifiers = result.getIdentifiers();
                // this gets sorted, otherwise unit tests will not pass
                if ( SORT_MAPS ) {
                    String[] array = identifiers.toArray( new String[identifiers.size()]);
                    Arrays.sort(array);
                    identifiers = Arrays.asList(array);
                }

                for ( String identifier : identifiers ) {
                    writer.startNode( "result" );

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

                    writer.startNode( "value" );
                    Object value = result.getValue( identifier );
                    if ( value instanceof org.kie.api.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();
                }
            }


            Collection<String> handles = ((ExecutionResultImpl) result).getFactHandles().keySet();
            // this gets sorted, otherwise unit tests will not pass
            if (SORT_MAPS) {
                String[] array = handles.toArray( new String[handles.size()]);
                Arrays.sort(array);
                handles = Arrays.asList(array);
            }

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

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


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

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

            }
            if ( autoFireAllRules ) {
                ksession.fireAllRules();
            }
            if ( command instanceof BatchExecutionCommandImpl ) {
                ExecutionResults result = ((StatefulKnowledgeSessionImpl) ksession).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.api.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

        }

        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.api.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

            ((GenericCommand) command).execute( new FixedKnowledgeCommandContext( context,
                                                                                  null,
                                                                                  this.kBase,
                                                                                  this,
                                                                                  results ) );
            ExecutionResults result = getExecutionResult();
            return (T) result;
        } finally {
            endBatchExecution();
        }
    }
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

TOP

Related Classes of org.kie.api.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.