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