-
Feature Request
-
Resolution: Unresolved
-
Optional
-
None
-
None
-
None
-
2019 Week 26-28
-
3
-
NEW
-
NEW
The executable model doesn't support custom inline accumulate code that uses external declarations such as
String str = "import " + Person.class.getCanonicalName() + ";\n" + "rule R dialect \"mvel\" when\n" + " String( $l : length )" + " $sum : Integer() from accumulate (\n" + " Person( age > 18, $age : age ), init( int sum = 0 * $l; ), action( sum += $age; ), reverse( sum -= $age; ), result( sum )\n" + " )" + "then\n" + " insert($sum);\n" + "end";
(Notice that in the init we multiply the sum value with the length of string)
But it can support such style using the "classic" generation of accumulate classes which gets compiled among the executable model and instantiate during the execution of the DSL.
This mechanism is broken with the MVEL dialect, as we don't have such generated classes.
Probably what we should do instead is putting MVEL expressions in the DSL directly such as
accumulateScript("initCode", "accCode", "reverseCode");
and then during interpretation create a new MVEL context and execute the accumulate in memory
See
AccumulateUnsupportedTest.testMVELAccumulate
AccumulateUnsupportedTest.testMVELAccumulate2WM