2008/12/15 Olivier THIERRY
<olivier.thierry@gmail.com>
Hi,
I use drools 4.0.7 and I encounter a problem calling a function from a
rule written for mvel dialect.
The function I need to call has this signature :
function VOCounter createCounter(org.drools.spi.KnowledgeHelper
drools, String code, Number number)
When I call this function, I want to assign result to a variable, for
example to insert it to working memory later, or just to use it in
another function call.
So I wrote something like that (I am writing a DSL so part of the code is DSL ):
rule "CALCUL_RELICAT_CP"
salience 8
no-loop
when
not There is a counter called "RELICAT_CP"
There is a date called "startDate"
There is a date called "endDate"
There is a counter called "SOLDE_CP_CUM" with
- start date is last year
then
> VOCounter $relicat = createCounter(drools,"RELICAT_CP",$SOLDE_CP_CUM.value);
> insert($relicat);
Copy counter $SOLDE_CP_CUM to SOLDE_RELICAT_CP
end
But I have the following stack trace :
org.drools.spi.ConsequenceException:
org.mvel.UnresolveablePropertyException: unable to resolve token:
createCounter(drools,"RELICAT_CP",$SOLDE_CP_CUM.value)
at org.drools.base.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:13)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:558)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:518)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:475)
at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:439)
at fr.horoquartz.t4.test.drools.TestRuleBase.executeRuleWithDsl(TestRuleBase.java:120)
at fr.horoquartz.t4.test.drools.Test1.testDsl(Test1.java:39)
Caused by: org.mvel.UnresolveablePropertyException: unable to resolve
token: createCounter(drools,"RELICAT_CP",$SOLDE_CP_CUM.value)
at org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:129)
at org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24)
at org.mvel.ExecutableAccessor.getValue(ExecutableAccessor.java:45)
at org.mvel.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:43)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:235)
at org.drools.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:48)
at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:554)
... 34 more
What is strange is that it works if I don't assign function call
result to a variable. For example the following works :
insert (createCounter(drools,"RELICAT_CP",$SOLDE_CP_CUM.value));
It also works if I assign $SOLDE_CP_CUM.value to a temporary variable
and use it for function call :
Number $val = $SOLDE_CP_CUM.value;
VOCounter $relicat = createCounter(drools,"RELICAT_CP",$val);
insert($relicat);
I had not this problem using java dialect. I understand nothing in
what happens ... Anyone has an idea what the problem is ?
Thanks in advance,
Olivier
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users