Package org.drools.common

Examples of org.drools.common.InternalFactHandle


        TruthMaintenanceSystem tms = ((NamedEntryPoint) wmep).getTruthMaintenanceSystem();
       
        ProtobufMessages.TruthMaintenanceSystem _tms = _ep.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 );
           
            if ( key.getStatus() == EqualityKey.JUSTIFIED ) {
                // not yet added to the object stores
                ((NamedEntryPoint) handle.getEntryPoint() ).getObjectStore().addHandle( handle,
                                                                                        handle.getObject() );
                // add handle to object type node
                assertHandleIntoOTN( context,
                                     context.wm,
                                     handle );               
            }
           
            for( Integer factHandleId : _key.getOtherHandleList() ) {
                handle = (InternalFactHandle) context.handles.get( factHandleId.intValue() );
                key.addFactHandle( handle );
                handle.setEqualityKey( key );
            }
            tms.put( key );
           
            readBeliefSet(context, tms, key, _key.getBeliefSet() );
        }
View Full Code Here


    private static void readBeliefSet(MarshallerReaderContext context,
                                      TruthMaintenanceSystem tms,
                                      EqualityKey key,
                                      ProtobufMessages.BeliefSet _beliefSet) throws IOException,
                                                                            ClassNotFoundException {
        InternalFactHandle handle = (InternalFactHandle) context.handles.get( _beliefSet.getHandleId() );
        for ( ProtobufMessages.LogicalDependency _logicalDependency : _beliefSet.getLogicalDependencyList() ) {
            ProtobufMessages.Activation _activation = _logicalDependency.getActivation();
            Activation activation = (Activation) context.filter.getTuplesCache().get(
                                                                                      PersisterHelper.createActivationKey( _activation.getPackageName(),
                                                                                                                           _activation.getRuleName(),
                                                                                                                           _activation.getTuple() ) ).getObject();

            Object object = null;
            ObjectMarshallingStrategy strategy = null;
            if ( _logicalDependency.hasObjectStrategyIndex() ) {
                strategy = context.usedStrategies.get( _logicalDependency.getObjectStrategyIndex() );
                object = strategy.unmarshal( context.strategyContexts.get( strategy ),
                                             context,
                                             _logicalDependency.getObject().toByteArray(),
                                             (context.ruleBase == null) ? null : context.ruleBase.getRootClassLoader() );
            }

            Object value = null;
            if ( _logicalDependency.hasValueStrategyIndex() ) {
                strategy = context.usedStrategies.get( _logicalDependency.getValueStrategyIndex() );
                value = strategy.unmarshal( context.strategyContexts.get( strategy ),
                                            context,
                                            _logicalDependency.getValue().toByteArray(),
                                            (context.ruleBase == null) ? null : context.ruleBase.getRootClassLoader() );
            }

            ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( ((NamedEntryPoint) handle.getEntryPoint()).getEntryPoint(),
                                                                                                         handle.getObject() );
            tms.readLogicalDependency( handle,
                                       object,
                                       value,
                                       activation,
                                       activation.getPropagationContext(),
View Full Code Here

                    // used for rules, salience and timers so they work with 'or' CEs
                    prevDecl =  this.previousDeclarations;
                }

                for (Declaration decl : prevDecl) {
                    InternalFactHandle handle = getFactHandle(decl, handles);

                    Object o = decl.getValue(workingMemory, handle.getObject());
                    if (knowledgeHelper != null && decl.isPatternDeclaration()) {
                        identityMap.put(o, handle);
                    }
                    factory.getIndexedVariableResolver(i++).setValue(o);
                }
            }
        }

        if ( this.localDeclarations != null && this.localDeclarations.length > 0 ) {
            for ( Declaration decl : this.localDeclarations ) {
                Object value;
                if( readLocalsFromTuple && tuples != null ) {
                    InternalFactHandle handle = getFactHandle( decl,
                                                               handles );

                    value = decl.getValue( workingMemory,
                                           handle.getObject() );
                } else {
                    value = decl.getValue( workingMemory,
                                          rightObject );
                }
                factory.getIndexedVariableResolver( i++ ).setValue( value );
View Full Code Here

        this.disconnected = disconnected;
    }

    public FactHandle execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
        InternalFactHandle factHandle = (InternalFactHandle) ksession.getFactHandle( object );
        if ( factHandle != null ){
            InternalFactHandle handle = factHandle.clone();
            if ( disconnected ) {
                handle.disconnect();
            }
            return handle;
        }
        return null;
    }
View Full Code Here

            DroolsQuery queryObject = new DroolsQuery( queryName,
                                                       arguments,
                                                       getQueryListenerInstance(),
                                                       false );

            InternalFactHandle handle = this.handleFactory.newFactHandle( queryObject,
                                                                          null,
                                                                          this,
                                                                          this );

            final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
View Full Code Here

            DroolsQuery queryObject = new DroolsQuery( query,
                                                       arguments,
                                                       new OpenQueryViewChangedEventListenerAdapter( listener ),
                                                       true );
            InternalFactHandle handle = this.handleFactory.newFactHandle( queryObject,
                                                                          null,
                                                                          this,
                                                                          this );

            final PropagationContext propagationContext = new PropagationContextImpl( getNextPropagationIdCounter(),
View Full Code Here

        Collection<FactHandle> disconnectedFactHandles = new ArrayList<FactHandle>();
        if ( filter != null ) {
            Collection<InternalFactHandle> factHandles = ep.getFactHandles( this.filter );
            if(factHandles != null && disconnected){
                for(InternalFactHandle factHandle: factHandles){
                    InternalFactHandle handle = factHandle.clone();
                    handle.disconnect();
                    disconnectedFactHandles.add(handle);
                }
                return disconnectedFactHandles;
            }
            else {
                return ksession.getFactHandles( this.filter );
            }
        } else {
            Collection<InternalFactHandle> factHandles = ep.getFactHandles( );
            if(factHandles != null && disconnected){
                for(InternalFactHandle factHandle: factHandles){
                    InternalFactHandle handle = factHandle.clone();
                    handle.disconnect();
                    disconnectedFactHandles.add(handle);
                }
                return disconnectedFactHandles;
            }
            else {
View Full Code Here

    }

    public FactHandle execute(Context context) {
        StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
        WorkingMemoryEntryPoint ep = ksession.getWorkingMemoryEntryPoint(entryPoint);
        InternalFactHandle factHandle = (InternalFactHandle) ep.getFactHandle( object );
        if ( factHandle != null ){
            InternalFactHandle handle = factHandle.clone();
            if ( disconnected ) {
                handle.disconnect();
            }
            return handle;
        }
        return null;
    }
View Full Code Here

        }
        Declaration declr = this.rule.getDeclaration( identifier );
        if ( declr == null ) {
            throw new RuntimeException("The identifier '" + identifier + "' does not exist as a bound varirable for this query" );
        }
        InternalFactHandle factHandle = getFactHandle( declr );
        return declr.getValue( null, factHandle.getObject() );
    }
View Full Code Here

        }
        Declaration declr = this.rule.getDeclaration( identifier );
        if ( declr == null ) {
            throw new RuntimeException("The identifier '" + identifier + "' does not exist as a bound varirable for this query" );
        }
        InternalFactHandle factHandle = getFactHandle( declr );
        return factHandle;
    }
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.