Search in sources :

Example 1 with Variable

use of org.kie.api.runtime.rule.Variable in project drools by kiegroup.

the class MvelConstraint method isAllowedCachedRight.

public boolean isAllowedCachedRight(Tuple tuple, ContextEntry context) {
    if (isUnification) {
        DroolsQuery query = (DroolsQuery) tuple.get(0).getObject();
        Variable v = query.getVariables()[((UnificationContextEntry) context).getReader().getIndex()];
        if (v != null) {
            return true;
        }
        context = ((UnificationContextEntry) context).getContextEntry();
    }
    MvelContextEntry mvelContextEntry = (MvelContextEntry) context;
    return evaluate(mvelContextEntry.rightHandle, mvelContextEntry.workingMemory, tuple);
}
Also used : Variable(org.kie.api.runtime.rule.Variable) DroolsQuery(org.drools.core.base.DroolsQuery)

Example 2 with Variable

use of org.kie.api.runtime.rule.Variable in project drools by kiegroup.

the class QueryCommand method execute.

public QueryResults execute(Context context) {
    KieSession ksession = ((RegistryContext) context).lookup(KieSession.class);
    if (this.arguments == null || this.arguments.isEmpty()) {
        this.arguments = Collections.emptyList();
    }
    for (int j = 0; j < arguments.size(); j++) {
        if (arguments.get(j) instanceof Variable) {
            arguments.set(j, Variable.v);
        }
    }
    QueryResults results = ksession.getQueryResults(name, this.arguments.toArray());
    if (this.outIdentifier != null) {
        ((RegistryContext) context).lookup(ExecutionResultImpl.class).setResult(this.outIdentifier, new FlatQueryResults((QueryResultsImpl) results));
    }
    return results;
}
Also used : QueryResultsImpl(org.drools.core.QueryResultsImpl) Variable(org.kie.api.runtime.rule.Variable) ExecutionResultImpl(org.drools.core.runtime.impl.ExecutionResultImpl) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) FlatQueryResults(org.drools.core.runtime.rule.impl.FlatQueryResults) FlatQueryResults(org.drools.core.runtime.rule.impl.FlatQueryResults) QueryResults(org.kie.api.runtime.rule.QueryResults)

Aggregations

Variable (org.kie.api.runtime.rule.Variable)2 QueryResultsImpl (org.drools.core.QueryResultsImpl)1 DroolsQuery (org.drools.core.base.DroolsQuery)1 RegistryContext (org.drools.core.command.impl.RegistryContext)1 ExecutionResultImpl (org.drools.core.runtime.impl.ExecutionResultImpl)1 FlatQueryResults (org.drools.core.runtime.rule.impl.FlatQueryResults)1 KieSession (org.kie.api.runtime.KieSession)1 QueryResults (org.kie.api.runtime.rule.QueryResults)1