[rules-users] Calling POJO class get Method in BRL
Michael Anstis
michael.anstis at gmail.com
Mon Jan 16 06:50:49 EST 2012
Where do you insert a PersonDetails fact?
Why do you set the age on Person when you state it'll be in PersonDetails?
You'll also need to have a relationship between Person and PersonDetails
and include this in your rule.
For example (in DRL terms, but possible to create in Guvnor):-
$p : Person()
PersonDetails ( this == $p, age > 0 )
On 16 January 2012 11:40, srinivasasanda <srinivasasanda at gmail.com> wrote:
> Thank you Manstis for quick response.I've a small doubt in this Manstis.
>
> Actually My Main class PERSON source code is
> RuleAgent agent = RuleAgent.newRuleAgent("/Guvnor.properties");
> RuleBase rb = agent.getRuleBase();
> FactType appType = rb.getFactType("details.Personn");
> Object application = appType.newInstance();
> appType.set(application, "age", 40);
> rb.newStatelessSession().execute(new Object[]
> {application});
> WorkingMemory wm=rb.newStatefulSession();
> wm.fireAllRules();
>
> And my POJO class PersonDetails code is
> package com.sample;
>
> public class PersonDetails {
> public int age=40;
> public String name="drools";
> public int getAge() {
> return age;
> }
> public void setAge(int age) {
> this.age = age;
> }
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> }
>
> Now my BRL in guvnor is(As per your instructions)
> rule "brl1"
> dialect "mvel"
> 3. | when
> 4. | PersonDetails( a : age > 0 )
> 5. | Personn( age == a )
> 6. | then
> 7. | System.out.println("Welcome Drools");
> 8. | end
>
>
> Even it is equal to 40,Im unable to see WELCOME drools message in guvnor
> 5.3.I uploaded PersonDetails POJO class in that package,it is uploaded and
> I'm able to see that model in that package,But one error I'm always seeing
> one message when I'm saving changes in uploaded model.."Unable to save,it
> was recently updated by guest".Does this error affects my source code of
> BRL..I didnt get what is the wrong in my BRL.
>
> Could you please suggest me what the wrong thing i coded here..Please
>
> Thanks
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Calling-POJO-class-get-Method-in-BRL-tp3662420p3662934.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/20120116/7db7c6b4/attachment.html
More information about the rules-users
mailing list