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);
}
}
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();
}
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);
}
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;
}
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]);
}
}
}
}
}
}
Aggregations