Package org.drools.common

Examples of org.drools.common.InternalFactHandle


        final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
        final WorkingMemory wm = ruleBase.newStatefulSession();

        final Cheese cheddar = new Cheese( "cheddar",
                                           10 );
        final InternalFactHandle f0 = (InternalFactHandle) wm.insert( cheddar );
        final ReteTuple tuple = new ReteTuple( f0 );
       
        Object evalContext = eval.createContext();

        assertTrue( eval.isAllowed( tuple,
View Full Code Here


        final Cheese stilton = new Cheese( "stilton",
                                           10 );

        final Cheese cheddar = new Cheese( "cheddar",
                                           10 );
        final InternalFactHandle f0 = (InternalFactHandle) wm.insert( cheddar );
        ReteTuple tuple = new ReteTuple( f0 );

        final InternalFactHandle f1 = (InternalFactHandle) wm.insert( stilton );
        tuple = new ReteTuple( tuple,
                               f1 );

        final Cheese brie = new Cheese( "brie",
                                        20 );
View Full Code Here

            implements
            TimersInputMarshaller {
        public void read(MarshallerReaderContext inCtx) throws IOException,
                                                       ClassNotFoundException {

            InternalFactHandle factHandle = inCtx.handles.get( inCtx.readInt() );
           
            String entryPointId = inCtx.readUTF();           
            EntryPointNode epn = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRete().getEntryPointNode( new EntryPoint( entryPointId ) );
           
            String className = inCtx.readUTF();
View Full Code Here

        }
       
        public void deserialize(MarshallerReaderContext inCtx,
                                Timer _timer) throws ClassNotFoundException {
            ExpireTimer _expire = _timer.getExpire();
            InternalFactHandle factHandle = inCtx.handles.get( _expire.getHandleId() );
            EntryPointNode epn = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRete().getEntryPointNode( new EntryPoint( _expire.getEntryPointId() ) );
            Class<?> cls = ((ReteooRuleBase)inCtx.wm.getRuleBase()).getRootClassLoader().loadClass( _expire.getClassName() );
            ObjectTypeNode otn = epn.getObjectTypeNodes().get( new ClassObjectType( cls ) );
           
            TimerService clock = inCtx.wm.getTimerService();
View Full Code Here

        final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
       
        Iterator it = memory.memory.iterator();

        InternalFactHandle ctxHandle = (InternalFactHandle) context.getFactHandle();

        if ( !context.isPropagating( this ) ||
             (context.isPropagating( this ) && context.shouldPropagateAll()) ) {

            for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                // Assert everything
                sink.assertObject( (InternalFactHandle) entry.getValue(),
                        context,
                        workingMemory );
            }
           
        } else {
           
            for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                InternalFactHandle handle = (InternalFactHandle) entry.getValue();
                // Exclude the current fact propagation
                if (handle.getId() != ctxHandle.getId()) {
                    sink.assertObject( handle,
                            context,
                            workingMemory );
                }
            }
View Full Code Here

            for ( InternalWorkingMemory workingMemory : workingMemories ) {
                CleanupAdapter adapter = context.getCleanupAdapter();
                final ObjectTypeNodeMemory memory = (ObjectTypeNodeMemory) workingMemory.getNodeMemory( this );
                Iterator it = memory.memory.iterator();
                for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
                    InternalFactHandle handle = (InternalFactHandle) entry.getValue();
                    for ( LeftTuple leftTuple = handle.getFirstLeftTuple(); leftTuple != null; leftTuple = leftTuple.getLeftParentNext() ) {
                        adapter.cleanUp( leftTuple,
                                         workingMemory );
                    }
                }
            }
View Full Code Here

                                                                    SessionConfiguration config,
                                                                    ProtobufMessages.KnowledgeSession _session) throws IOException {
        FactHandleFactory handleFactory = context.ruleBase.newFactHandleFactory( _session.getRuleData().getLastId(),
                                                                                 _session.getRuleData().getLastRecency() );

        InternalFactHandle initialFactHandle = new DefaultFactHandle( _session.getRuleData().getInitialFact().getId(),
                                                                      InitialFactImpl.getInstance(),
                                                                      _session.getRuleData().getInitialFact().getRecency(),
                                                                      null );
        context.handles.put( initialFactHandle.getId(),
                             initialFactHandle );

        DefaultAgenda agenda = new DefaultAgenda( context.ruleBase,
                                                  false );
        readAgenda( context,
                    _session.getRuleData(),
                    agenda );

        ReteooStatefulSession session = new ReteooStatefulSession( id,
                                                                   context.ruleBase,
                                                                   executor,
                                                                   handleFactory,
                                                                   initialFactHandle,
                                                                   0,
                                                                   config,
                                                                   agenda,
                                                                   environment );
        new StatefulKnowledgeSessionImpl( session );

        initialFactHandle.setEntryPoint( session.getEntryPoints().get( EntryPoint.DEFAULT.getEntryPointId() ) );
        return session;
    }
View Full Code Here

        InternalWorkingMemory wm = context.wm;

        WorkingMemoryEntryPoint entryPoint = context.wm.getEntryPoints().get( _ep.getEntryPointId() );
        // load the handles
        for ( ProtobufMessages.FactHandle _handle : _ep.getHandleList() ) {
            InternalFactHandle handle = readFactHandle( context,
                                                        entryPoint,
                                                        _handle );

            context.handles.put( handle.getId(),
                                 handle );

            if ( handle.getObject() != null ) {
                objectStore.addHandle( handle,
                                       handle.getObject() );
            }

            // add handle to object type node
            assertHandleIntoOTN( context,
                                 wm,
View Full Code Here

                                         context,
                                         _handle.getObject().toByteArray(),
                                         (context.ruleBase == null)?null:context.ruleBase.getRootClassLoader() );
        }

        InternalFactHandle handle = null;
        switch ( _handle.getType() ) {
            case FACT : {
                handle = new DefaultFactHandle( _handle.getId(),
                                                object,
                                                _handle.getRecency(),
View Full Code Here

        TruthMaintenanceSystem tms = context.wm.getTruthMaintenanceSystem();
        ProtobufMessages.TruthMaintenanceSystem _tms = _session.getTms();
       
        for( ProtobufMessages.EqualityKey _key : _tms.getKeyList() ) {
            InternalFactHandle handle = (InternalFactHandle) context.handles.get( _key.getHandleId() );

            // ObjectTypeConf state is not marshalled, so it needs to be re-determined
            ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( ((NamedEntryPoint)handle.getEntryPoint()).getEntryPoint(),
                                                                                                         handle.getObject() );
            if (!typeConf.isTMSEnabled()) {
                typeConf.enableTMS();
            }

            EqualityKey key = new EqualityKey( handle,
                                               _key.getStatus() );
            handle.setEqualityKey( key );
            for( Integer factHandleId : _key.getOtherHandleList() ) {
                handle = (InternalFactHandle) context.handles.get( factHandleId.intValue() );
                key.addFactHandle( handle );
                handle.setEqualityKey( key );
            }
            tms.put( key );
        }
       
        for( ProtobufMessages.Justification _justification : _tms.getJustificationList() ) {
            InternalFactHandle handle = (InternalFactHandle) context.handles.get( _justification.getHandleId() );
           
            for( ProtobufMessages.Activation _activation : _justification.getActivationList() ) {
                Activation activation = (Activation) context.filter.getTuplesCache().get(
                              PersisterHelper.createActivationKey( _activation.getPackageName(),
                                                                   _activation.getRuleName(),
View Full Code Here

TOP

Related Classes of org.drools.common.InternalFactHandle

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.