Package org.drools.core

Examples of org.drools.core.FactHandle


        assertEquals( 0,
                      results.size() );

        final Cheese stilton1 = new Cheese( "stilton",
                                            100 );
        final FactHandle handle1 = workingMemory.insert( stilton1 );

        results = workingMemory.getQueryResults( "query-1" );

        assertEquals( 1,
                      results.size() );

        final Cheese cheddar = new Cheese( "cheddar",
                                           55 );
        workingMemory.insert( cheddar );

        results = workingMemory.getQueryResults( "query-1" );

        assertEquals( 1,
                      results.size() );

        final Cheese stilton2 = new Cheese( "stilton",
                                            5 );

        final FactHandle handle2 = workingMemory.insert( stilton2 );

        results = workingMemory.getQueryResults( "query-1" );

        assertEquals( 2,
                      results.size() );
View Full Code Here


                                                          new ClassObjectType(List.class),
                                                          buildContext);
        listOtn.attach(buildContext);

        // Will automatically create an ArrayList ObjectTypeNode
        FactHandle handle = workingMemory.insert(new ArrayList());

        // Check we have three ObjectTypeNodes, List, ArrayList and InitialFactImpl
        assertEquals(3,
                     rete.getObjectTypeNodes().size());
View Full Code Here

   
    public void propertyChange(final PropertyChangeEvent event) {
        final Object object = event.getSource();

        try {
            FactHandle handle = getFactHandle( object );
            if ( handle == null ) {
                throw new FactException( "Update error: handle not found for object: " + object + ". Is it in the working memory?" );
            }
            update( handle,
                    object );
View Full Code Here

    public <T extends org.kie.api.runtime.rule.FactHandle> Collection<T> getFactHandles() {
        List list = new ArrayList();

        for ( Iterator it = iterateFactHandles(); it.hasNext(); ) {
            FactHandle fh = ( FactHandle) it.next();
            list.addfh );
        }

        return list;
    }
View Full Code Here

    public Map getActivationParameters(Activation activation) {
        Map result = new HashMap();
        Declaration[] declarations = ((RuleTerminalNode) ((LeftTuple) activation.getTuple()).getLeftTupleSink()).getDeclarations();

        for (int i = 0; i < declarations.length; i++) {
            FactHandle handle = activation.getTuple().get(declarations[i]);
            if (handle instanceof InternalFactHandle) {
                result.put(declarations[i].getIdentifier(),
                           declarations[i].getValue(this,
                                                    ((InternalFactHandle) handle).getObject()));
            }
View Full Code Here

            }
            for ( String[] str : args ) {
                Serializable expr = MVEL.compileExpression( Arrays.asList( str ).toString(), new ParserContext(conf) );
                List< ? > objects = (List< ? >) MVEL.executeExpression( expr );
                for ( Object object : objects ) {
                    FactHandle handle = wm.insert( object );
                    handles.add( handle );
                }
            }
        } else {
            throw new IllegalArgumentException( "Cannot arguments " + Arrays.asList( args ) );
View Full Code Here

        final TruthMaintenanceSystem tms = ((NamedEntryPoint)workingMemory.getWorkingMemoryEntryPoint( EntryPointId.DEFAULT.getEntryPointId() ) ).getTruthMaintenanceSystem();
        final String string = "test";

        workingMemory.insert( string );

        FactHandle fd = workingMemory.insertLogical( string );

        assertEquals( 1,
                      tms.getEqualityKeyMap().size() );

        EqualityKey key = tms.get( string );
View Full Code Here

        final StatefulSession session = ruleBase.newStatefulSession();

        CheeseEqual cheese = new CheeseEqual( "stilton",
                                              10 );
        session.insert( cheese );
        FactHandle fh1 = session.getFactHandle( new Cheese( "stilton",
                                                            10 ) );
        assertNull( fh1 );
        FactHandle fh2 = session.getFactHandle( cheese );
        assertNotNull( fh2 );
    }
View Full Code Here

        A a1 = new A( "x1",
                      null );
        A a2 = new A( "x2",
                      null );

        FactHandle fa1 = (FactHandle) ksession.insert( a1 );
        FactHandle fa2 = (FactHandle) ksession.insert( a2 );

        // make sure the 'exists' is obeyed when fact is cycled causing add/remove node memory
        ksession.update( fa1,
                         a1 );
        ksession.update( fa2,
View Full Code Here

        A a1 = new A( "x1",
                      null );
        A a2 = new A( "x2",
                      null );

        FactHandle fa1 = (FactHandle) ksession.insert( a1 );
        FactHandle fa2 = (FactHandle) ksession.insert( a2 );

        // make sure the 'exists' is obeyed when fact is cycled causing add/remove node memory
        ksession.update( fa1,
                         a1 );
        ksession.update( fa2,
View Full Code Here

TOP

Related Classes of org.drools.core.FactHandle

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.