Search in sources :

Example 16 with PropagationContextFactory

use of org.drools.core.common.PropagationContextFactory in project drools by kiegroup.

the class RuleUnitExecutorImpl method initInitialFact.

private void initInitialFact(RuleBase kBase) {
    WorkingMemoryEntryPoint defaultEntryPoint = entryPointsManager.getDefaultEntryPoint();
    InternalFactHandle handle = getFactHandleFactory().newInitialFactHandle(defaultEntryPoint);
    ObjectTypeNode otn = defaultEntryPoint.getEntryPointNode().getObjectTypeNodes().get(InitialFact_ObjectType);
    if (otn != null) {
        PropagationContextFactory ctxFact = RuntimeComponentFactory.get().getPropagationContextFactory();
        PropagationContext pctx = ctxFact.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, handle, defaultEntryPoint.getEntryPoint(), null);
        otn.assertInitialFact(handle, pctx, this);
    }
}
Also used : PropagationContextFactory(org.drools.core.common.PropagationContextFactory) PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) PropagationContext(org.drools.core.spi.PropagationContext) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) InternalFactHandle(org.drools.core.common.InternalFactHandle) WorkingMemoryEntryPoint(org.drools.core.WorkingMemoryEntryPoint)

Example 17 with PropagationContextFactory

use of org.drools.core.common.PropagationContextFactory in project drools by kiegroup.

the class ProtobufInputMarshaller method assertHandleIntoOTN.

private static void assertHandleIntoOTN(ProtobufMarshallerReaderContext context, InternalWorkingMemory wm, InternalFactHandle handle, List<PropagationContext> pctxs) {
    Object object = handle.getObject();
    WorkingMemoryEntryPoint ep = handle.getEntryPoint(wm);
    ObjectTypeConf typeConf = ep.getObjectTypeConfigurationRegistry().getOrCreateObjectTypeConf(ep.getEntryPoint(), object);
    PropagationContextFactory pctxFactory = RuntimeComponentFactory.get().getPropagationContextFactory();
    PropagationContext propagationContext = pctxFactory.createPropagationContext(wm.getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, handle, ep.getEntryPoint(), context);
    // keeping this list for a later cleanup is necessary because of the lazy propagations that might occur
    pctxs.add(propagationContext);
    ep.getEntryPointNode().assertObject(handle, propagationContext, typeConf, wm);
    wm.flushPropagations();
}
Also used : PropagationContextFactory(org.drools.core.common.PropagationContextFactory) ObjectTypeConf(org.drools.core.reteoo.ObjectTypeConf) PropagationContext(org.drools.core.spi.PropagationContext) WorkingMemoryEntryPoint(org.drools.core.WorkingMemoryEntryPoint)

Example 18 with PropagationContextFactory

use of org.drools.core.common.PropagationContextFactory in project drools by kiegroup.

the class WorkingMemoryReteAssertAction method execute.

public void execute(ReteEvaluator reteEvaluator) {
    PropagationContextFactory pctxFactory = RuntimeComponentFactory.get().getPropagationContextFactory();
    final PropagationContext context = pctxFactory.createPropagationContext(reteEvaluator.getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, this.ruleOrigin, this.tuple != null ? this.tuple.getTupleSink() : null, this.factHandle);
    reteEvaluator.getKnowledgeBase().getRete().assertObject(this.factHandle, context, reteEvaluator);
}
Also used : PropagationContextFactory(org.drools.core.common.PropagationContextFactory) PropagationContext(org.drools.core.spi.PropagationContext)

Example 19 with PropagationContextFactory

use of org.drools.core.common.PropagationContextFactory in project drools by kiegroup.

the class StatefulKnowledgeSessionImpl method initInitialFact.

public InternalFactHandle initInitialFact(InternalKnowledgeBase kBase, InternalWorkingMemoryEntryPoint entryPoint, EntryPointId epId, MarshallerReaderContext context) {
    InitialFact initialFact = InitialFactImpl.getInstance();
    InternalFactHandle handle = new DefaultFactHandle(0, initialFact, 0, entryPoint);
    ClassObjectTypeConf otc = (ClassObjectTypeConf) entryPoint.getObjectTypeConfigurationRegistry().getObjectTypeConf(epId, initialFact);
    ObjectTypeNode otn = otc.getConcreteObjectTypeNode();
    if (otn != null) {
        PropagationContextFactory ctxFact = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
        PropagationContext pctx = ctxFact.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, handle, epId, context);
        otn.assertInitialFact(handle, pctx, this);
    }
    return handle;
}
Also used : PropagationContextFactory(org.drools.core.common.PropagationContextFactory) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) ClassObjectTypeConf(org.drools.core.reteoo.ClassObjectTypeConf) PropagationContext(org.drools.core.spi.PropagationContext) InitialFact(org.drools.core.InitialFact) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) InternalFactHandle(org.drools.core.common.InternalFactHandle)

Example 20 with PropagationContextFactory

use of org.drools.core.common.PropagationContextFactory in project drools by kiegroup.

the class AddRemoveRule method insertFacts.

private static void insertFacts(PathEndNodes endNodes, InternalWorkingMemory[] wms) {
    Set<LeftTupleNode> visited = new HashSet<LeftTupleNode>();
    for (PathEndNode endNode : endNodes.subjectEndNodes) {
        LeftTupleNode[] nodes = endNode.getPathNodes();
        for (int i = 0; i < nodes.length; i++) {
            LeftTupleNode node = nodes[i];
            if (NodeTypeEnums.isBetaNode(node) && node.getAssociationsSize() == 1) {
                if (!visited.add(node)) {
                    // this is to avoid rentering a path, and processing nodes twice. This can happen for nested subnetworks.
                    continue;
                }
                BetaNode bn = (BetaNode) node;
                if (!bn.isRightInputIsRiaNode()) {
                    for (int j = 0; j < wms.length; j++) {
                        PropagationContextFactory pctxFactory = wms[j].getKnowledgeBase().getConfiguration().getComponentFactory().getPropagationContextFactory();
                        final PropagationContext pctx = pctxFactory.createPropagationContext(wms[j].getNextPropagationIdCounter(), PropagationContext.Type.RULE_ADDITION, null, null, null);
                        bn.getRightInput().updateSink(bn, pctx, wms[j]);
                    }
                }
            }
        }
    }
}
Also used : PropagationContextFactory(org.drools.core.common.PropagationContextFactory) BetaNode(org.drools.core.reteoo.BetaNode) PropagationContext(org.drools.core.spi.PropagationContext) LeftTupleNode(org.drools.core.reteoo.LeftTupleNode) PathEndNode(org.drools.core.reteoo.PathEndNode) HashSet(java.util.HashSet)

Aggregations

PropagationContextFactory (org.drools.core.common.PropagationContextFactory)27 PropagationContext (org.drools.core.spi.PropagationContext)17 BuildContext (org.drools.core.reteoo.builder.BuildContext)16 RuleImpl (org.drools.core.definitions.rule.impl.RuleImpl)14 ClassObjectType (org.drools.core.base.ClassObjectType)8 Test (org.junit.Test)8 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)7 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)6 InternalFactHandle (org.drools.core.common.InternalFactHandle)5 WorkingMemoryEntryPoint (org.drools.core.WorkingMemoryEntryPoint)4 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)4 StatefulKnowledgeSessionImpl (org.drools.core.impl.StatefulKnowledgeSessionImpl)4 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)3 PhreakPropagationContextFactory (org.drools.core.common.PhreakPropagationContextFactory)3 AlphaNode (org.drools.core.reteoo.AlphaNode)3 LeftInputAdapterNode (org.drools.core.reteoo.LeftInputAdapterNode)3 MockObjectSink (org.drools.core.reteoo.MockObjectSink)3 MvelConstraintTestUtil (org.drools.core.rule.MvelConstraintTestUtil)3 MvelConstraint (org.drools.core.rule.constraint.MvelConstraint)3 AlphaNodeFieldConstraint (org.drools.core.spi.AlphaNodeFieldConstraint)3