Hi,
could I ask for some advice, please, how to use a parametrized method
call to get some data using 'from' element in LHS.
To be more precise, I would like to do something like this:
rule "My Rule"
when
$fact : Fact( ) from
factSource.getSomeFacts("a","b","c")
then
// do something
end
where factSource is for example some global and
getSomeFacts(String,String,String) is a parametrized method that returns
some array of Fact objects.
Unfortunately, when I try to launch the following rule I have an error:
Exception in thread "main" org.mvel.PropertyAccessException: unable to
resolve property: factSource.getSomeFacts("a","b","c")
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:295)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
at
org.mvel.ast.VariableDeepPropertyNode.getReducedValueAccelerated(VariableDeepPropertyNode.java:26)
at
org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:70)
at
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24)
at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:252)
at
org.drools.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:55)
at org.drools.reteoo.FromNode.assertTuple(FromNode.java:68)
at
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:181)
at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1312)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:915)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)
at com.sample.DroolsTest6.main(DroolsTest6.java:29)
Caused by: java.lang.NullPointerException
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:530)
at
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:261)
... 21 more
Documentation says:
"The from Conditional Element allows users to specify a source for
patterns to reason over. This allows the engine to reason over data not
in the Working Memory. This could be a sub-field on a bound variable or
the results of a method call."
so I assume that it is possible to do what I want. If not, could I ask
for an advice of some workaround, please?
Best regards,
--
Przemysław Różycki
IT Architect
AMG.net, A Bull Group Company
ul. Łąkowa 29
90-554 Łódź
www.amg.net.pl