Search in sources :

Example 1 with PhreakPropagationContext

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

the class RightBuilder method update.

public RightBuilder update(Object... objects) {
    for (Object object : objects) {
        InternalFactHandle fh = (InternalFactHandle) wm.insert(object);
        RightTuple rightTuple = fh.getFirstRightTuple();
        rightTuple.setPropagationContext(new PhreakPropagationContext());
        rightTuples.addUpdate(rightTuple);
    }
    return this;
}
Also used : PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) InternalFactHandle(org.drools.core.common.InternalFactHandle) RightTuple(org.drools.core.reteoo.RightTuple)

Example 2 with PhreakPropagationContext

use of org.drools.core.common.PhreakPropagationContext 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;
}
Also used : InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) BetaNode(org.drools.core.reteoo.BetaNode) ArrayList(java.util.ArrayList) BetaMemory(org.drools.core.reteoo.BetaMemory) RightTupleImpl(org.drools.core.reteoo.RightTupleImpl) InternalFactHandle(org.drools.core.common.InternalFactHandle) RightTuple(org.drools.core.reteoo.RightTuple) TupleMemory(org.drools.core.reteoo.TupleMemory)

Example 3 with PhreakPropagationContext

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

the class RuleUnitExecutorImpl method getQueryResults.

@Override
public QueryResults getQueryResults(String queryName, Object... arguments) {
    activationsManager.flushPropagations();
    DroolsQuery queryObject = new DroolsQuery(queryName, arguments, new NonCloningQueryViewListener(), false);
    InternalFactHandle handle = this.handleFactory.newFactHandle(queryObject, null, this, getDefaultEntryPoint());
    final PropagationContext pCtx = new PhreakPropagationContext(getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, handle, getDefaultEntryPointId());
    PropagationEntry.ExecuteQuery executeQuery = new PropagationEntry.ExecuteQuery(queryName, queryObject, handle, pCtx, false);
    addPropagation(executeQuery);
    TerminalNode[] terminalNodes = executeQuery.getResult();
    List<Map<String, Declaration>> decls = new ArrayList<>();
    if (terminalNodes != null) {
        for (TerminalNode node : terminalNodes) {
            decls.add(node.getSubRule().getOuterDeclarations());
        }
    }
    this.handleFactory.destroyFactHandle(handle);
    return new QueryResultsImpl((List<QueryRowWithSubruleIndex>) queryObject.getQueryResultCollector().getResults(), decls.toArray(new Map[decls.size()]), this, (queryObject.getQuery() != null) ? queryObject.getQuery().getParameters() : new Declaration[0]);
}
Also used : QueryRowWithSubruleIndex(org.drools.core.base.QueryRowWithSubruleIndex) PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) QueryResultsImpl(org.drools.core.QueryResultsImpl) PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) PropagationContext(org.drools.core.spi.PropagationContext) ArrayList(java.util.ArrayList) PropagationEntry(org.drools.core.phreak.PropagationEntry) Declaration(org.drools.core.rule.Declaration) InternalFactHandle(org.drools.core.common.InternalFactHandle) TerminalNode(org.drools.core.reteoo.TerminalNode) Map(java.util.Map) NonCloningQueryViewListener(org.drools.core.base.NonCloningQueryViewListener) DroolsQuery(org.drools.core.base.DroolsQuery)

Example 4 with PhreakPropagationContext

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

the class LeftBuilder method delete.

public LeftBuilder delete(Object... objects) {
    for (Object object : objects) {
        InternalFactHandle fh = (InternalFactHandle) wm.getFactHandle(object);
        LeftTuple leftTuple = fh.getFirstLeftTuple();
        leftTuple.setPropagationContext(new PhreakPropagationContext());
        leftTuples.addDelete(leftTuple);
    }
    return this;
}
Also used : PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) InternalFactHandle(org.drools.core.common.InternalFactHandle) LeftTuple(org.drools.core.reteoo.LeftTuple)

Example 5 with PhreakPropagationContext

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

the class LeftBuilder method update.

public LeftBuilder update(Object... objects) {
    for (Object object : objects) {
        InternalFactHandle fh = (InternalFactHandle) wm.getFactHandle(object);
        LeftTuple leftTuple = fh.getFirstLeftTuple();
        leftTuple.setPropagationContext(new PhreakPropagationContext());
        leftTuples.addUpdate(leftTuple);
    }
    return this;
}
Also used : PhreakPropagationContext(org.drools.core.common.PhreakPropagationContext) InternalFactHandle(org.drools.core.common.InternalFactHandle) LeftTuple(org.drools.core.reteoo.LeftTuple)

Aggregations

InternalFactHandle (org.drools.core.common.InternalFactHandle)17 PhreakPropagationContext (org.drools.core.common.PhreakPropagationContext)17 LeftTuple (org.drools.core.reteoo.LeftTuple)8 RightTuple (org.drools.core.reteoo.RightTuple)8 ArrayList (java.util.ArrayList)5 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)4 BetaMemory (org.drools.core.reteoo.BetaMemory)4 BetaNode (org.drools.core.reteoo.BetaNode)4 RightTupleImpl (org.drools.core.reteoo.RightTupleImpl)4 TupleMemory (org.drools.core.reteoo.TupleMemory)4 Map (java.util.Map)1 QueryResultsImpl (org.drools.core.QueryResultsImpl)1 DroolsQuery (org.drools.core.base.DroolsQuery)1 NonCloningQueryViewListener (org.drools.core.base.NonCloningQueryViewListener)1 QueryRowWithSubruleIndex (org.drools.core.base.QueryRowWithSubruleIndex)1 PropagationEntry (org.drools.core.phreak.PropagationEntry)1 TerminalNode (org.drools.core.reteoo.TerminalNode)1 Declaration (org.drools.core.rule.Declaration)1 PropagationContext (org.drools.core.spi.PropagationContext)1