[rules-users] variables confusion Java/MVEL

Els Destickere elsdestickere at yahoo.com
Wed Nov 9 15:26:08 EST 2011


Thanks for the insight,
br,
Els

--- On Wed, 11/9/11, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:

From: Wolfgang Laun <wolfgang.laun at gmail.com>
Subject: Re: [rules-users] variables confusion Java/MVEL
To: "Rules Users List" <rules-users at lists.jboss.org>
Date: Wednesday, November 9, 2011, 3:35 PM

You cannot create variables on the Left Hand Side; there you can only bind (!)
variable names (!) to matched facts or their attributes.
-W 

On 9 November 2011 15:14, elsdestickere <elsdestickere at yahoo.com> wrote:

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.

_______________________________________________

rules-users mailing list

rules-users at lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users




-----Inline Attachment Follows-----

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111109/2ebb1943/attachment.html 


More information about the rules-users mailing list