Re: [rules-users] variables confusion Java/MVEL

2011-11-09 Thread Els Destickere

Thanks for the insight,
br,
Els

--- On Wed, 11/9/11, Wolfgang Laun  wrote:

From: Wolfgang Laun 
Subject: Re: [rules-users] variables confusion Java/MVEL
To: "Rules Users List" 
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  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 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 bruikEx

=openRes.getMasterExemplaar().getBruikbareExemplaren();

       eval(Reservatie.getVandaagOpenstaandeReservaties().size() > 0 &&

openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0)

    then

        //List 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@lists.jboss.org

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




-Inline Attachment Follows-

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] variables confusion Java/MVEL

2011-11-09 Thread Wolfgang Laun
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  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 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 bruikEx
> =openRes.getMasterExemplaar().getBruikbareExemplaren();
>   eval(Reservatie.getVandaagOpenstaandeReservaties().size() > 0 &&
> openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0)
>then
>//List 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@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] variables confusion Java/MVEL

2011-11-09 Thread elsdestickere
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 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 bruikEx
=openRes.getMasterExemplaar().getBruikbareExemplaren();
   eval(Reservatie.getVandaagOpenstaandeReservaties().size() > 0 &&
openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0) 
then
//List 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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users