use of org.drools.core.common.AgendaItem in project drools by kiegroup.
the class MVELConsequence method evaluate.
public void evaluate(final KnowledgeHelper knowledgeHelper, final WorkingMemory workingMemory) throws Exception {
VariableResolverFactory factory = unit.getFactory(knowledgeHelper, ((AgendaItem) knowledgeHelper.getMatch()).getTerminalNode().getRequiredDeclarations(), knowledgeHelper.getRule(), knowledgeHelper.getTuple(), null, (InternalWorkingMemory) workingMemory, workingMemory.getGlobalResolver());
// do we have any functions for this namespace?
InternalKnowledgePackage pkg = workingMemory.getKnowledgeBase().getPackage("MAIN");
if (pkg != null) {
MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData(this.id);
factory.setNextFactory(data.getFunctionFactory());
}
CompiledExpression compexpr = (CompiledExpression) this.expr;
if (MVELDebugHandler.isDebugMode()) {
if (MVELDebugHandler.verbose) {
logger.info(DebugTools.decompile(compexpr));
}
MVEL.executeDebugger(compexpr, knowledgeHelper, factory);
} else {
MVEL.executeExpression(compexpr, knowledgeHelper, factory);
}
}
use of org.drools.core.common.AgendaItem in project drools by kiegroup.
the class ActivationPropertyHandler method getProperty.
public Object getProperty(String name, Object obj, VariableResolverFactory variableFactory) {
AgendaItem item = (AgendaItem) obj;
if ("rule".equals(name)) {
return item.getRule();
} else if ("active".equals(name)) {
return item.isQueued();
} else if ("objects".equals(name)) {
return item.getObjects();
} else if ("factHandles".equals(name)) {
return item.getFactHandles();
} else if ("declarationIds".equals(name)) {
return item.getDeclarationIds();
} else if ("this".equals(name)) {
return item;
}
// FIXME hack as MVEL seems to be ignoring indexed variables
VariableResolver vr = variableFactory.getNextFactory().getVariableResolver(name);
if (vr != null) {
return vr.getValue();
}
Declaration declr = item.getTerminalNode().getSubRule().getOuterDeclarations().get(name);
if (declr != null) {
return declr.getValue(null, item.getTuple().get(declr).getObject());
} else {
return item.getRule().getMetaData(name);
}
}
Aggregations