use of org.drools.core.reteoo.BetaNode 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]);
}
}
}
}
}
}
use of org.drools.core.reteoo.BetaNode in project drools by kiegroup.
the class LeftMemory method getLeftTuples.
public List<LeftTuple> getLeftTuples(Object... objects) {
BetaNode node = scenario.getBetaNode();
BetaMemory bm = scenario.getBm();
TupleMemory ltm = bm.getLeftTupleMemory();
InternalWorkingMemory wm = scenario.getWorkingMemory();
if (objects == null) {
objects = new Object[0];
}
List<LeftTuple> list = new ArrayList<LeftTuple>();
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
LeftTuple expectedLeftTuple = node.createLeftTuple(fh, node, true);
expectedLeftTuple.setPropagationContext(new PhreakPropagationContext());
list.add(expectedLeftTuple);
}
scenario.setTestLeftMemory(true);
return list;
}
use of org.drools.core.reteoo.BetaNode in project drools by kiegroup.
the class RightMemory method getRightTuples.
public List<RightTuple> getRightTuples(Object... objects) {
BetaNode node = scenario.getBetaNode();
BetaMemory bm = scenario.getBm();
TupleMemory rtm = bm.getRightTupleMemory();
InternalWorkingMemory wm = scenario.getWorkingMemory();
if (objects == null) {
objects = new Object[0];
}
List<RightTuple> rightTuples = new ArrayList<RightTuple>();
for (Object object : objects) {
InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
// node.createLeftTuple( fh, node, true );
RightTuple expectedRightTuple = new RightTupleImpl(fh, node);
expectedRightTuple.setPropagationContext(new PhreakPropagationContext());
rightTuples.add(expectedRightTuple);
}
scenario.setTestRightMemory(true);
return rightTuples;
}
Aggregations