Quantcast

[rules-users] how to use only updated value in drools

classic Classic list List threaded Threaded
22 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

[rules-users] how to use only updated value in drools

learner
I am having a drl file with 2 rules

The 1st rule updates a attribute, say updates attribute b to 10 based on
some condition.

The 2nd rule has a check for values with b not equal to 10. It logs error
for those values not equals to 10.

The b value gets updated to 10 in rule 1. However in the second rule it does
not use updated value and logs error.

Is there a way to use the updated b value in the 2nd rule. I tried using
modify but still the error gets logged.

--
View this message in context: http://drools.46999.n3.nabble.com/how-to-use-only-updated-value-in-drools-tp4017626.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

Vincent Legendre
what is the initial value of b ?
what are the salience of your rules ?
and why not posting your rules directly ?

----- Original Message -----
From: "learner" <[hidden email]>
To: [hidden email]
Sent: Mardi 29 Mai 2012 12:29:28
Subject: [rules-users] how to use only updated value in drools

I am having a drl file with 2 rules

The 1st rule updates a attribute, say updates attribute b to 10 based on
some condition.

The 2nd rule has a check for values with b not equal to 10. It logs error
for those values not equals to 10.

The b value gets updated to 10 in rule 1. However in the second rule it does
not use updated value and logs error.

Is there a way to use the updated b value in the 2nd rule. I tried using
modify but still the error gets logged.

--
View this message in context: http://drools.46999.n3.nabble.com/how-to-use-only-updated-value-in-drools-tp4017626.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

bharadwaj2012
can u please share ur drl file?

On Tue, May 29, 2012 at 4:05 PM, Vincent LEGENDRE <[hidden email]> wrote:
what is the initial value of b ?
what are the salience of your rules ?
and why not posting your rules directly ?

----- Original Message -----
From: "learner" <[hidden email]>
To: [hidden email]
Sent: Mardi 29 Mai 2012 12:29:28
Subject: [rules-users] how to use only updated value in drools

I am having a drl file with 2 rules

The 1st rule updates a attribute, say updates attribute b to 10 based on
some condition.

The 2nd rule has a check for values with b not equal to 10. It logs error
for those values not equals to 10.

The b value gets updated to 10 in rule 1. However in the second rule it does
not use updated value and logs error.

Is there a way to use the updated b value in the 2nd rule. I tried using
modify but still the error gets logged.

--
View this message in context: http://drools.46999.n3.nabble.com/how-to-use-only-updated-value-in-drools-tp4017626.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
This post was updated on .
In reply to this post by Vincent Legendre
Thanks for the reply.

Please find a basic structure of my drl file

rule "set b value"
      salience 10
    no-loop
    when
        e : Person(b == " ");
    then
    e.setB("10");
end
 
rule "b other than 10"
      salience 1
     no-loop
     when
      e : Person(b != 10)
     then
       System.out.println("error"+e.getB());
end    

The problem is the sysout gets printed but it should not
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

bharadwaj2012
learner wrote
Thanks for the reply.

Please find a basic structure of my drl file

rule "set b value"
      salience 10
    no-loop
    when
        e : Person(b == " ");
    then
//use this to get value in an another rule    
e.setB("10");
insert(e);
end
 
rule "b other than 10"
      salience 1
     no-loop
     when
      e : Person(b != 10)
     then
       System.out.println("error"+e.getB());
end
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
I tried using insert but still the issue persists
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

bharadwaj2012
use update(e);

On Tue, May 29, 2012 at 4:42 PM, learner <[hidden email]> wrote:
I tried using insert but still the issue persists

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-how-to-use-only-updated-value-in-drools-tp4017628p4017635.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

sumatheja
In reply to this post by learner
Whats the datatype of variable b?

On Tue, May 29, 2012 at 12:12 PM, learner <[hidden email]> wrote:
I tried using insert but still the issue persists

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-how-to-use-only-updated-value-in-drools-tp4017628p4017635.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
cheers
Sumatheja Dasararaju



_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
In reply to this post by bharadwaj2012
When I use update the message appears twice.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
In reply to this post by sumatheja
Datatype of b is String
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

bharadwaj2012
In reply to this post by learner
second rule condition is wrong

b is a string it seems to be.
then it should be
 e : Person(b != "10")
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

sumatheja
String b should be compare using "10" .... try with this

On Tue, May 29, 2012 at 12:19 PM, bharadwaj2012 <[hidden email]> wrote:
second rule condition is wrong

b is a string it seems to be.
then it should be
 e : Person(b != "10")

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-how-to-use-only-updated-value-in-drools-tp4017628p4017640.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
cheers
Sumatheja Dasararaju



_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
In reply to this post by bharadwaj2012
Modifying the condition does not fix the issue

It seems even though the value of b was modified to 10 in the first rule. It considers b as only blank (initial value) in the When clause of second rule.However in sysout the value of b appears properly as 10
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

sumatheja
Are you sure the first rule is fired? I tried out a similar program locally and it works fine. If the first rule is fired and you are updating the fact in the consequence of first rule, then certainly the second rule wont be fired.

On Tue, May 29, 2012 at 12:23 PM, learner <[hidden email]> wrote:
Modifying the condition does not fix the issue

It seems even though the value of b was modified to 10 in the first rule. It
considers b as only blank (initial value) in the When clause of second
rule.However in sysout the value of b appears properly as 10

--
View this message in context: http://drools.46999.n3.nabble.com/rules-users-how-to-use-only-updated-value-in-drools-tp4017628p4017641.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users



--
cheers
Sumatheja Dasararaju



_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

laune
In reply to this post by learner
Please post the *current* state of your rules. Too much line noise,
not sure what you have now :-{
-W

On 29/05/2012, learner <[hidden email]> wrote:

> Modifying the condition does not fix the issue
>
> It seems even though the value of b was modified to 10 in the first rule.
> It
> considers b as only blank (initial value) in the When clause of second
> rule.However in sysout the value of b appears properly as 10
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/rules-users-how-to-use-only-updated-value-in-drools-tp4017628p4017641.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
Please find a basic structure of my drl file

rule "set b value"
      salience 10
    no-loop
    when
        e : Person(b == " ");
    then
    e.setB("10");
end
 
rule "b other than 10"
      salience 1
     no-loop
     when
      e : Person(b != "10")
     then
       System.out.println("error"+e.getB());
end    

The problem is the sysout gets printed in rule 2 , but it should not as the value of b is modified to 10 in 1st rule
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

bharadwaj2012
you just use "update" in first rule it's works perfeclty

you'll get only one sysout printed.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

laune
In reply to this post by learner
On 29/05/2012, learner <[hidden email]> wrote:
> Please find a basic structure of my drl file
>
> rule "set b value"
>       salience 10
>     no-loop
>     when
>         e : Person(b == " ");
>     then
>     ############## e.setB("10");

       modify( e ){ setB( "10" ) }

Otherwise the Engine doesn't know about the change.

Read the Expert manual - this is fundamental.

-W

> end
>
> rule "b other than 10"
>       salience 1
>      no-loop
>      when
>       e : Person(b != "10")
>      then
>        System.out.println("error"+e.getB());
> end
>
_______________________________________________
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

learner
In reply to this post by bharadwaj2012
But since the b value is updated to 10 , is there a way to use this updated value in second rule and not print any sysout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: [rules-users] how to use only updated value in drools

bharadwaj2012
use update(e) in first rule man then u can get the updated value in second rule for sure.
12
Loading...