Java Code Examples for org.drools.core.impl.InternalKnowledgeBase#invalidateSegmentPrototype()

The following examples show how to use org.drools.core.impl.InternalKnowledgeBase#invalidateSegmentPrototype() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddRemoveRule.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
private static void collectPathEndNodes(InternalKnowledgeBase kBase,
                                        LeftTupleNode lt,
                                        PathEndNodes endNodes,
                                        TerminalNode tn,
                                        Rule processedRule,
                                        boolean hasProtos,
                                        boolean hasWms,
                                        boolean isBelowNewSplit) {
    // Traverses the sinks in reverse order in order to collect PathEndNodes so that
    // the outermost (sub)network are evaluated before the innermost one
    for (LeftTupleSinkNode sink = lt.getSinkPropagator().getLastLeftTupleSink(); sink != null; sink = sink.getPreviousLeftTupleSinkNode()) {
        if (sink == tn) {
            continue;
        }
        if (hasProtos) {
            if (isBelowNewSplit) {
                if ( isRootNode( sink, null )) {
                    kBase.invalidateSegmentPrototype( sink );
                }
            } else {
                isBelowNewSplit = isSplit(sink);
                if (isBelowNewSplit) {
                    invalidateRootNode( kBase, sink );
                }
            }
        }
        if (NodeTypeEnums.isLeftTupleSource(sink)) {
            if (hasWms && SegmentUtilities.isTipNode(sink, null)) {
                if (!SegmentUtilities.isTipNode(sink, tn)) {
                    endNodes.subjectSplits.add(sink);
                }
            }

            collectPathEndNodes(kBase, sink, endNodes, tn, processedRule, hasProtos, hasWms, isBelowNewSplit);
        } else if (NodeTypeEnums.isTerminalNode(sink)) {
            endNodes.otherEndNodes.add((PathEndNode) sink);
        } else if (NodeTypeEnums.RightInputAdaterNode == sink.getType()) {
            if (sink.isAssociatedWith( processedRule )) {
                endNodes.subjectEndNodes.add( (PathEndNode) sink );
            }
            if (sink.getAssociationsSize() > 1 || !sink.isAssociatedWith(processedRule)) {
                endNodes.otherEndNodes.add( (PathEndNode) sink );
            }
        } else {
            throw new RuntimeException("Error: Unknown Node. Defensive programming test..");
        }
    }
}
 
Example 2
Source File: AddRemoveRule.java    From kogito-runtimes with Apache License 2.0 4 votes vote down vote up
private static void invalidateRootNode( InternalKnowledgeBase kBase, LeftTupleNode lt ) {
    while (!isRootNode( lt, null )) {
        lt = lt.getLeftTupleSource();
    }
    kBase.invalidateSegmentPrototype( lt );
}