You cannot create variables on the Left Hand Side; there you can only bind (!)<br>variable names (!) to matched facts or their attributes.<br>-W <br><br><div class="gmail_quote">On 9 November 2011 15:14, elsdestickere <span dir="ltr"><<a href="mailto:elsdestickere@yahoo.com">elsdestickere@yahoo.com</a>></span> wrote:<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'm confused about when en where to use Java or MVEL in a rule.<br>
In the example below I want to replace "<br>
openRes.getMasterExemplaar().getBruikbareExemplaren()" with a variable.<br>
RHD: works with JAva expression:<br>
List<Exemplaar> bruikEx =<br>
openRes.getMasterExemplaar().getBruikbareExemplaren();<br>
but I prefer to create the variable in the LHS, but Java doesn't work here.<br>
Should this be a MVEL expression or should JAVA allways be possible?<br>
<br>
rule "GarandeerReservaties"<br>
when<br>
garRes : GarandeerReservatieTaak();<br>
openRes : Reservatie() from<br>
repFact.getReservatieRepository().findVandaagOpenstaandeReservaties();<br>
List<Exemplaar> bruikEx<br>
=openRes.getMasterExemplaar().getBruikbareExemplaren();<br>
eval(Reservatie.getVandaagOpenstaandeReservaties().size() > 0 &&<br>
openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0)<br>
then<br>
//List<Exemplaar> bruikEx =<br>
openRes.getMasterExemplaar().getBruikbareExemplaren();<br>
bruikEx.get(0).setStatus(ExemplaarStatus.MOMENTEEL_GERESERVEERD);<br>
openRes.setStatus(ReservatieStatus.GEGARANDEERD);<br>
System.out.println( "Drools "+drools.getRule().getName()+": ocr:<br>
"+openRes.getAantalVandaagOpenstaandeConcurReservaties() + " bruikex: "<br>
+bruikEx.size() );<br>
end<br>
(written in Dutch, but I think it will be ok to understand)<br>
br,<br>
Els<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/variables-confusion-Java-MVEL-tp3493632p3493632.html" target="_blank">http://drools.46999.n3.nabble.com/variables-confusion-Java-MVEL-tp3493632p3493632.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<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>
</font></blockquote></div><br>