[rules-users] variables confusion Java/MVEL

Wolfgang Laun wolfgang.laun at gmail.com
Wed Nov 9 09:35:57 EST 2011


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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20111109/a94871c0/attachment.html 


More information about the rules-users mailing list