Package org.drools.runtime

Examples of org.drools.runtime.ExecutionResults


        cmds.add( setGlobal1 );
        cmds.add( setGlobal2 );
        cmds.add( setGlobal3 );
        cmds.addinsert );
       
        ExecutionResults result = ( ExecutionResults ) ksession.execute( CommandFactory.newBatchExecution( cmds ) );
       
        assertEquals( 30,
                      stilton.getPrice() );
       
        assertNull( result.getValue( "list1" ) );
       
        list2 = ( List ) result.getValue( "list2" );
        assertEquals( 1, list2.size() );
        assertSame( stilton, list2.get( 0 ) );
       
         
       
        list3 = ( List ) result.getValue( "outList3" );
        assertEquals( 1, list3.size() );
        assertSame( stilton, list3.get( 0 ) );
    }
View Full Code Here


        cmds.add( CommandFactory.newInsert( cheddar2 ) );
        cmds.add( CommandFactory.newInsert( cheddar3 ) );
       
        cmds.addCommandFactory.newQuery( "cheeses", "cheeses" ) );
       
        ExecutionResults batchResult = (ExecutionResults) ksession.execute( CommandFactory.newBatchExecution( cmds ) );
       
        org.drools.runtime.rule.QueryResults results = ( org.drools.runtime.rule.QueryResults) batchResult.getValue( "cheeses" );
        assertEquals( 3, results.size() );
        assertEquals( 2, results.getIdentifiers().length );
        Set newSet = new HashSet();
        for ( org.drools.runtime.rule.QueryResultsRow result : results ) {
            list = new ArrayList();
View Full Code Here

           
            if ( exec == null ) {
                throw new RuntimeException( "No defined ksession for uri" + de.getEndpointUri() );
            }           

            ExecutionResults results = exec.execute( (BatchExecutionCommandImpl) cmd );;

//            if ( de.dataFormat != null ) {
//                ByteArrayOutputStream baos = new ByteArrayOutputStream();
//                de.dataFormat.marshal( exchange,
//                                       results,
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

            ((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;
      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);
              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.drools.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

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

        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());


    }
View Full Code Here

TOP

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