use of org.mvel2.tests.core.res.KnowledgeHelper in project drools by kiegroup.
the class MVELSalienceExpression method getValue.
public int getValue(final KnowledgeHelper khelper, final Rule rule, final WorkingMemory workingMemory) {
VariableResolverFactory factory = unit.getFactory(khelper, khelper != null ? ((AgendaItem) khelper.getMatch()).getTerminalNode().getSalienceDeclarations() : null, rule, null, khelper != null ? (LeftTuple) khelper.getMatch().getTuple() : null, 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());
}
Object value = MVEL.executeExpression(this.expr, factory);
if (value instanceof String) {
value = TimeUtils.parseTimeString((String) value);
}
return ((Number) value).intValue();
}
Aggregations