'from' returns one element from the collection you target, not all of them. If
you wish to continue that approach you should use collect of accumulate.
Is the dao object in working memory? If so, just match it and test for the
list size there:
when
Dao(list.size > 0)
then
System.out.println("DAO call is successful!");
end
Of course, your current implementation of Dao.getList(), since it returns
Collections.EMPTY_LIST, will not match this rule anyway.
--- On Fri, 11/28/08, techy <[EMAIL PROTECTED]> wrote:
> From: techy <[EMAIL PROTECTED]>
> Subject: Re: [rules-users] DAO call in LHS
> To: [email protected]
> Date: Friday, November 28, 2008, 4:52 PM
> I tried following simple rule with dao call and still no
> luck. getting
> "org.mvel.PropertyAccessException: unable to resolve
> property:
> dao.getList()". could not figure out what is wrong.
> some help please.
>
> rule "Test DAo call"
> when
> count : List(size > 0) from dao.getList()
> then
> System.out.println("DAO call is successful!");
> end
>
> dao.getList() definition:
>
>
> public List<Integer> getList(){
> return Collections.EMPTY_LIST;
> }
>
> Exception stackTRace:
>
> org.mvel.PropertyAccessException: unable to resolve
> property: dao.getList()
> 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
> org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:160)
> at DAOCallTest.main()
> 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)
> ... 22 more
>
>
> Michal Bali-2 wrote:
> >
> > this blog post may be of use
> >
> http://blog.athico.com/2007/06/chained-from-accumulate-collect.html
> >
> >
> > On Wed, Nov 26, 2008 at 9:08 PM, techy
> <[EMAIL PROTECTED]> wrote:
> >
> >>
> >> though I referred other thread about this topic,
> I'm not successful to
> >> make
> >> a
> >> dao call.
> >> I beg your pardon to ask again.
> >>
> >> 1. I want to pass the fact object to the dao
> function which returns
> >> boolean.
> >> I tried following rule and getting "
> >> Unexpected token '$fact'" as eclipse
> compilation error. Please guide with
> >> right syntax.
> >> global RuleDAO dao;
> >>
> >> rule "test DAO call"
> >> $fact : Fact(some condition)
> >> fact : Fact(dao.isValid($fact))
> >> then
> >> #do something
> >> end
> >>
> >> 2. Will be there any performance issue for above
> kind of rule?
> >>
> >> Thanks
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/DAO-call-in-LHS-tp20709043p20709043.html
> >> Sent from the drools - user mailing list archive
> at Nabble.com.
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> [email protected]
> >>
> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> >
> > _______________________________________________
> > rules-users mailing list
> > [email protected]
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/DAO-call-in-LHS-tp20709043p20741585.html
> Sent from the drools - user mailing list archive at
> Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users