[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:
ListExemplaar 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();
 ListExemplaar bruikEx
=openRes.getMasterExemplaar().getBruikbareExemplaren();
   eval(Reservatie.getVandaagOpenstaandeReservaties().size()  0 
openRes.getMasterExemplaar().getBruikbareExemplaren().size() != 0) 
then
//ListExemplaar 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] global as link to DB: different results

2011-10-31 Thread elsdestickere
Hi,

I read docs about global and Hibernate to access your DB from the rules.
I tried something simular for in memory DAO's.
But some rules fire (WM in RHS) as the DAO has 3 items, but others (dao
in LHS) don't, how is that possible?

global RepositoryFactory repFact;
rule dao 
when
   k : Customer(  ) from repFact.getCustomerRepository().findAll();
then
System.out.println( Drools +drools.getRule().getName()+: 
+k.getName());
end
rule WM
when
   k : Customer(  ) ;
then
System.out.println( Drools +drools.getRule().getName()+: 
+k.getName()+ + size: +repFact.getCustomerRepository().findAll().size());
end
...
RepositoryFactory repFact = Registry.getRepositoryFactory();
ksession.setGlobal(repFact, repFact);
...
CustomerRepository customerRepo = Registry.getRepositoryFactory()
.getCustomerRepository();
customerRepo.add(tom);
customerRepo.add(elise);
customerRepo.add(bert);
ksession.insert(bert);
ksession.fireAllRules();

...
Output:
Drools WM: Bert + size: 3

br,
Els


--
View this message in context: 
http://drools.46999.n3.nabble.com/global-as-link-to-DB-different-results-tp3467897p3467897.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] rule fires several times

2011-10-30 Thread elsdestickere
Hi,

The Expert documentation says  a rule may fire once or several times, but
I don't understand why a rule sould fire several times if the objects state
does not change?

I have an example of a Customer object inserted in the Working Memory, with
2 rules that should fire, but the last rule fires twice.
Can someone explain?

rule isAdult
when
k : Customer( age(date)=18, adult==false );
then
modify( k ) { setAdult(true)  };
System.out.println( Drools +drools.getRule().getName()+: +
k.getAdult() );
end
rule WM 
when
   k : Customer(  ) ;
then
System.out.println( Drools +drools.getRule().getName()+: 
+k.getName());
end

...
Customer bert = new Customer ();
bert.setName(Bert);
bert.setDate(30);
ksession.insert(bert);
ksession.fireAllRules();
...
Output:
Drools WM: Bert 
Drools isAdult: true
Drools WM: Bert 

Br,
Els Destickere

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466250.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


Re: [rules-users] rule fires several times

2011-10-30 Thread elsdestickere
I see, the MODIFY in the LHS triggers the rule WM again. 
thanks !
Els

--
View this message in context: 
http://drools.46999.n3.nabble.com/rule-fires-several-times-tp3466250p3466287.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