[rules-users] variables confusion Java/MVEL

elsdestickere elsdestickere at yahoo.com
Wed Nov 9 09:14:14 EST 2011


Hi,

I'm confused about when en where to use Java or MVEL in a rule.
In the example below I want to replace  "
openRes.getMasterExemplaar().getBruikbareExemplaren()" with a variable. 
RHD: works with JAva expression:
 	List<Exemplaar> bruikEx =
openRes.getMasterExemplaar().getBruikbareExemplaren();
but I prefer to create the variable in the LHS, but Java doesn't work here.
Should this be a MVEL expression or should JAVA allways be possible?

rule "GarandeerReservaties"
    when
	garRes : GarandeerReservatieTaak();
	openRes : Reservatie() from
repFact.getReservatieRepository().findVandaagOpenstaandeReservaties();
     List<Exemplaar> bruikEx
=openRes.getMasterExemplaar().getBruikbareExemplaren();
       eval(Reservatie.getVandaagOpenstaandeReservaties().size() > 0 &&
openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0) 
    then
    	//List<Exemplaar> bruikEx =
openRes.getMasterExemplaar().getBruikbareExemplaren();
	bruikEx.get(0).setStatus(ExemplaarStatus.MOMENTEEL_GERESERVEERD);
	openRes.setStatus(ReservatieStatus.GEGARANDEERD);
        System.out.println( "Drools "+drools.getRule().getName()+": ocr:
"+openRes.getAantalVandaagOpenstaandeConcurReservaties() + " bruikex: "
+bruikEx.size() );
end 
(written in Dutch, but I think it will be ok to understand)
br,
Els

--
View this message in context: http://drools.46999.n3.nabble.com/variables-confusion-Java-MVEL-tp3493632p3493632.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list