RE: [rules-users] Drools, Grails, and default packages for domain objects

2009-01-21 Thread Costello, Robert
I have to say, the Guvnor is awfully cool.  I was able to import my
pojos and get a rule up and running in a couple hours.   Would have been
even faster if I had my coffee this morning.  

 

Next step is to export the rules and deploy them to the Execution
Server.  I like the fact that it can take JSON.  

 

Is there much documentation out there yet on the Execution server?

 

Thanks,

 

Robert Costello

Lead Systems Engineer

IMA Performance

E3- 279A

847.286.0910

 

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Costello,
Robert
Sent: Wednesday, January 21, 2009 8:23 AM
To: Rules Users List
Subject: RE: [rules-users] Drools, Grails,and default packages for
domain objects

 

That's good advice.  I tried putting everything in a default package,
including the rules, but still no luck.  

 

For the time being, I'm going to put aside working with rule tables in
spreadsheets and see how they work in Guvnor.  There must be some
subtleties with the spreadsheets that I am not getting yet.  

 

Robert Costello

Lead Systems Engineer

IMA Performance

E3- 279A

847.286.0910

 

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of CK
Sent: Tuesday, January 20, 2009 12:11 PM
To: Rules Users List
Subject: Re: [rules-users] Drools, Grails,and default packages for
domain objects

 

If I understand you correctly, this is a Java runtime restriction.  

 

Java classes in the default package can reference any class in a named
package.  Other the other hand, classes in a named package cannot
reference any class in a default package.  Classes in a default package
can reference other classes in a default package.

 

Thus, the easiest way normally to deal with this problem is to either
(1) put everything in a named package, including any grails
classes/domain objects/etc or (2) put everything in a default package.
I'd suggest that you go with option 1 because it'll give you fewer
problems.

 

But I'm not sure if that's the question you're asking or if this helps
you.  Hopefully, it does. :)

 

 

On Jan 20, 2009, at 6:00 AM, Costello, Robert wrote:

 

I'm using the latest as of this date, which is 5.0.0M4

 

Thanks!

 

Robert Costello

Lead Systems Engineer

IMA Performance

E3- 279A

847.286.0910

 

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Monday, January 19, 2009 3:59 PM
To: Rules Users List
Subject: Re: [rules-users] Drools, Grails,and default packages for
domain objects

 


   Robert,

   What version of Drools are you using?
   I remember seeing something about this in the past... I will search
JIRAs to see if we have any ticket open for 5.0.

   []s
   Edson

2009/1/19 Costello, Robert 

Has anyone else run into issues trying to reference objects in a default
package?  I'm trying to use Drools with Grails and my rule which
compiled nicely in a package setting has issues when faced with a
default package. 

 

The error is "foo" cannot be resolved to a type

 

I've tried putting the rule both in the default package and putting it
in a named package, and neither seem to work.   If I put my objects back
into packages, everything is fine.

 

Any  advice?

 

Thanks,

 

Robert Costello

 

 


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




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.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


Re: [rules-users] Reasoning over hierarchies.

2009-01-21 Thread Mark Proctor
you can do something like this to drive backward chaining queries. 
Notice it inserts a new fact to drive the query down the graph, but 
deletes that driver once all it's  children have been evaluated. It uses 
the -5 salience to ensure it's done after all the children have been 
evaluated. So just insert an initial FindAncestor fact call 
fireAllRules() and it'll println if it's an ancesor, you could ofcourse 
have it insert a result object, or set a value on the originally 
inserted FindAncestor.


rule "query parent"
 when
   FindAncestor( $name == name, $ancestor : ancestor )
   $child : Person(  name == $name, $parent : parent )
   $parent : Person( this == $parent, this != ancestor)
 then
   insert( new FindAncestor( $parent, $ancestor ) )
end

rule "retract query parent driver"
 salience - 5
 when
   $f : FindAncestor( $name == name, $ancestor : ancestor )
   $child : Person(  name == $name, $parent : parent )
   $parent : Person( this == $parent, this != ancestor)
 then
   retract( $f )
end

rule "ancestor found"
 when
   FindAncestor( $name == name, $ancestor : ancestor )
   $child : Person(  name == $name, $parent : parent )
   $parent : Person( this == $parent, this == ancestor)
 then
println( "is ancestor" )
end

rule "retract query ancestor found driver"
 salience - 5
 when
   $f : FindAncestor( $name == name, $ancestor : ancestor )
   $child : Person(  name == $name, $parent : parent )
   $parent : Person( this == $parent, this == ancestor)
 then
   retract( $f )
end

Mark
Faron Dutton wrote:

Thanks. I'll look into this.

On Wed, Jan 21, 2009 at 9:46 AM, Anstis, Michael (M.)  wrote:
  

I wonder whether a custom accumulate function could be used to move your
logic out of the object model?

Not that accumulate was (probably) meant for this sort of function but the
"init" method could create the empty set and "accumulate" perform your
iteration below?

Just the musing of an idle mind.


From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Sinclair
Sent: 21 January 2009 14:28
To: Rules Users List
Subject: Re: [rules-users] Reasoning over hierarchies.

You could have something along the lines

class Person {
 Person parent;

 Collection getAncestors() {
   Collection ancestors = new HashSet();

Person currentAncestor = parent;

while(currentAncestor != null) {
   ancestors.add(currentAncestor);
   currentAncestor = currentAncestor.getParent();
}
 }
}

query isAncestor(String a, String b)
   p: Person(name = a)
   c: Person(name = b, ancestors contains p)
end

that should do it

dave

On Wed, Jan 21, 2009 at 8:54 AM, Faron Dutton  wrote:


I know this has probably been asked before but I cannot find any mention
of
it. How does one reason over a transitive (recursive) relation in Drools?

---

The classic example from Prolog:

-- The relation parent(P,C) says that P is a parent of C.
parent(P,C).

-- The predicate ancestor(A,B) implies that A is an ancestor
-- of B if A is a parent of B or A is a parent of C and C
-- is an ancestor of B.
ancestor(A,B) :- parent(A,B).
ancestor(A,B) :- parent(A,C), ancestor(C,B).

-- The query ancestor(bob,frank) asks if bob is an ancestor
-- of frank.
?- ancestor(bob,frank).

---

In Drools, I can find the parent using

query isParent(String a, String b)
   p: Person(name = a)
   c: Person(name = b, parent = p)
end

likewise, I can find the grandparent using

query isGrandparent(String a, String b)
   g: Person(name = a)
   p: Person(parent = g)
   c: Person(name = b, parent = p)
end

I am unable to formulate the query isAncestor.

___
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 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] Guvnor deployment exception

2009-01-21 Thread Raphael Duarte Paiva
Hi!

I'm using JBoss 4.2.3.GA  via JBoss Tools and when I try
to deploy drools-guvnor.war I get the attached stack trace.

This one draws my attention as it's the stack's base:

Caused by: java.io.FileNotFoundException: repository.xml (Permission denied)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.(FileOutputStream.java:179)
at java.io.FileOutputStream.(FileOutputStream.java:131)
at
org.apache.jackrabbit.core.TransientRepository$2.getRepository(TransientRepository.java:218)

Where does it try to create the repository.xml file? Is there any way to
modify the path of this file so It would be in a folder with r/w permission
to the user?

Please forgive any grammatical/English errors!
Thanks in advance!


-- 
Abraços
Raphael Duarte Paiva
Graduando em Ciência da Computação
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Reasoning over hierarchies.

2009-01-21 Thread Faron Dutton
Thanks. I'll look into this.

On Wed, Jan 21, 2009 at 9:46 AM, Anstis, Michael (M.)  wrote:
> I wonder whether a custom accumulate function could be used to move your
> logic out of the object model?
>
> Not that accumulate was (probably) meant for this sort of function but the
> "init" method could create the empty set and "accumulate" perform your
> iteration below?
>
> Just the musing of an idle mind.
>
> 
> From: rules-users-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Sinclair
> Sent: 21 January 2009 14:28
> To: Rules Users List
> Subject: Re: [rules-users] Reasoning over hierarchies.
>
> You could have something along the lines
>
> class Person {
>  Person parent;
>
>  Collection getAncestors() {
>Collection ancestors = new HashSet();
>
> Person currentAncestor = parent;
>
> while(currentAncestor != null) {
>ancestors.add(currentAncestor);
>currentAncestor = currentAncestor.getParent();
> }
>  }
> }
>
> query isAncestor(String a, String b)
>p: Person(name = a)
>c: Person(name = b, ancestors contains p)
> end
>
> that should do it
>
> dave
>
> On Wed, Jan 21, 2009 at 8:54 AM, Faron Dutton  wrote:
>>
>> I know this has probably been asked before but I cannot find any mention
>> of
>> it. How does one reason over a transitive (recursive) relation in Drools?
>>
>> ---
>>
>> The classic example from Prolog:
>>
>> -- The relation parent(P,C) says that P is a parent of C.
>> parent(P,C).
>>
>> -- The predicate ancestor(A,B) implies that A is an ancestor
>> -- of B if A is a parent of B or A is a parent of C and C
>> -- is an ancestor of B.
>> ancestor(A,B) :- parent(A,B).
>> ancestor(A,B) :- parent(A,C), ancestor(C,B).
>>
>> -- The query ancestor(bob,frank) asks if bob is an ancestor
>> -- of frank.
>> ?- ancestor(bob,frank).
>>
>> ---
>>
>> In Drools, I can find the parent using
>>
>> query isParent(String a, String b)
>>p: Person(name = a)
>>c: Person(name = b, parent = p)
>> end
>>
>> likewise, I can find the grandparent using
>>
>> query isGrandparent(String a, String b)
>>g: Person(name = a)
>>p: Person(parent = g)
>>c: Person(name = b, parent = p)
>> end
>>
>> I am unable to formulate the query isAncestor.
>>
>> ___
>> 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 mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Reasoning over hierarchies.

2009-01-21 Thread Faron Dutton
This was just an example. I am looking for a more generic way since I
do not know, in advance, what rules are needed. Most of the domain
objects I deal with cannot be changed as they come from third-parties.

On Wed, Jan 21, 2009 at 9:27 AM, David Sinclair
 wrote:
> You could have something along the lines
>
> class Person {
>  Person parent;
>
>  Collection getAncestors() {
>Collection ancestors = new HashSet();
>
> Person currentAncestor = parent;
>
> while(currentAncestor != null) {
>ancestors.add(currentAncestor);
>currentAncestor = currentAncestor.getParent();
> }
>  }
> }
>
> query isAncestor(String a, String b)
>p: Person(name = a)
>c: Person(name = b, ancestors contains p)
> end
>
> that should do it
>
> dave
>
> On Wed, Jan 21, 2009 at 8:54 AM, Faron Dutton  wrote:
>>
>> I know this has probably been asked before but I cannot find any mention
>> of
>> it. How does one reason over a transitive (recursive) relation in Drools?
>>
>> ---
>>
>> The classic example from Prolog:
>>
>> -- The relation parent(P,C) says that P is a parent of C.
>> parent(P,C).
>>
>> -- The predicate ancestor(A,B) implies that A is an ancestor
>> -- of B if A is a parent of B or A is a parent of C and C
>> -- is an ancestor of B.
>> ancestor(A,B) :- parent(A,B).
>> ancestor(A,B) :- parent(A,C), ancestor(C,B).
>>
>> -- The query ancestor(bob,frank) asks if bob is an ancestor
>> -- of frank.
>> ?- ancestor(bob,frank).
>>
>> ---
>>
>> In Drools, I can find the parent using
>>
>> query isParent(String a, String b)
>>p: Person(name = a)
>>c: Person(name = b, parent = p)
>> end
>>
>> likewise, I can find the grandparent using
>>
>> query isGrandparent(String a, String b)
>>g: Person(name = a)
>>p: Person(parent = g)
>>c: Person(name = b, parent = p)
>> end
>>
>> I am unable to formulate the query isAncestor.
>>
>> ___
>> 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 mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Reasoning over hierarchies.

2009-01-21 Thread Anstis, Michael (M.)
I wonder whether a custom accumulate function could be used to move your
logic out of the object model?
 
Not that accumulate was (probably) meant for this sort of function but
the "init" method could create the empty set and "accumulate" perform
your iteration below?
 
Just the musing of an idle mind.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Sinclair
Sent: 21 January 2009 14:28
To: Rules Users List
Subject: Re: [rules-users] Reasoning over hierarchies.


You could have something along the lines

class Person {
 Person parent;

 Collection getAncestors() {
   Collection ancestors = new HashSet();

Person currentAncestor = parent;

while(currentAncestor != null) {
   ancestors.add(currentAncestor);
   currentAncestor =
currentAncestor.getParent();
}
 }
}

query isAncestor(String a, String b)
   p: Person(name = a)
   c: Person(name = b, ancestors contains p)
end

that should do it

dave


On Wed, Jan 21, 2009 at 8:54 AM, Faron Dutton
 wrote:


I know this has probably been asked before but I cannot
find any mention of
it. How does one reason over a transitive (recursive)
relation in Drools?


---

The classic example from Prolog:

-- The relation parent(P,C) says that P is a parent of
C.
parent(P,C).

-- The predicate ancestor(A,B) implies that A is an
ancestor
-- of B if A is a parent of B or A is a parent of C and
C
-- is an ancestor of B.
ancestor(A,B) :- parent(A,B).
ancestor(A,B) :- parent(A,C), ancestor(C,B).

-- The query ancestor(bob,frank) asks if bob is an
ancestor
-- of frank.
?- ancestor(bob,frank).


---

In Drools, I can find the parent using

query isParent(String a, String b)
   p: Person(name = a)
   c: Person(name = b, parent = p)
end

likewise, I can find the grandparent using

query isGrandparent(String a, String b)
   g: Person(name = a)
   p: Person(parent = g)
   c: Person(name = b, parent = p)
end

I am unable to formulate the query isAncestor.

___
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] using a dsl in multiple drl files

2009-01-21 Thread Thierry B

Hello,

I try to use a dsl in several DRL rule files, but it doesn't work.

In my java class, I do that :

Reader source1 = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Test1.drl" ) );
Reader source2 = new InputStreamReader(
DroolsTest.class.getResourceAsStream( "/Test2.drl" ) );

//optionally read in the DSL (if you are using it).
Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream(
"/Exemple.dsl" ) );

builder.addPackageFromDrl( source1, dsl );
builder.addPackageFromDrl( source2, dsl );

Is it possible to use a same dsl file in several drl files or I have to have
one dsl for one drl ?

Thanks :-)



-- 
View this message in context: 
http://www.nabble.com/using-a-dsl-in-multiple-drl-files-tp21584358p21584358.html
Sent from the drools - user 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] Run a set of rules in a group B from a rule inagroup A

2009-01-21 Thread Anstis, Michael (M.)
Rules that are not in any explicit user-defined Agenda Group belong
implicitly to the MAIN Agenda Group which is the last Agenda Group to
trigger activations when all others have completed. Provided ALL of your
rules belong to an explicit Agenda Group you should be able to
setFocus(...) to Group A on the WM before fireAllRules() which would
then setFocus(...) to Group B in the RHS causing this other group to
activate. As no rules are in MAIN then they will not activate by
default. Have a read about Agenda Groups in the docs. Last time I looked
in the source I believe this is how RuleFlow is (was) implemented.

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
Sent: 21 January 2009 14:05
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Run a set of rules in a group B from a rule
inagroup A


Hello,

But I see that even if I put the focus to a group, he will inevitably
execute rules that doesn't have a group, it's normal?

Thanks :-)

-- 
View this message in context:
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
roup-A-tp21580767p21583764.html
Sent from the drools - user 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


Re: [rules-users] Reasoning over hierarchies.

2009-01-21 Thread David Sinclair
You could have something along the lines

class Person {
 Person parent;

 Collection getAncestors() {
   Collection ancestors = new HashSet();

Person currentAncestor = parent;

while(currentAncestor != null) {
   ancestors.add(currentAncestor);
   currentAncestor = currentAncestor.getParent();
}
 }
}

query isAncestor(String a, String b)
   p: Person(name = a)
   c: Person(name = b, ancestors contains p)
end

that should do it

dave

On Wed, Jan 21, 2009 at 8:54 AM, Faron Dutton  wrote:

> I know this has probably been asked before but I cannot find any mention of
> it. How does one reason over a transitive (recursive) relation in Drools?
>
> ---
>
> The classic example from Prolog:
>
> -- The relation parent(P,C) says that P is a parent of C.
> parent(P,C).
>
> -- The predicate ancestor(A,B) implies that A is an ancestor
> -- of B if A is a parent of B or A is a parent of C and C
> -- is an ancestor of B.
> ancestor(A,B) :- parent(A,B).
> ancestor(A,B) :- parent(A,C), ancestor(C,B).
>
> -- The query ancestor(bob,frank) asks if bob is an ancestor
> -- of frank.
> ?- ancestor(bob,frank).
>
> ---
>
> In Drools, I can find the parent using
>
> query isParent(String a, String b)
>p: Person(name = a)
>c: Person(name = b, parent = p)
> end
>
> likewise, I can find the grandparent using
>
> query isGrandparent(String a, String b)
>g: Person(name = a)
>p: Person(parent = g)
>c: Person(name = b, parent = p)
> end
>
> I am unable to formulate the query isAncestor.
>
> ___
> 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] Drools, Grails, and default packages for domain objects

2009-01-21 Thread Costello, Robert
That's good advice.  I tried putting everything in a default package,
including the rules, but still no luck.  

 

For the time being, I'm going to put aside working with rule tables in
spreadsheets and see how they work in Guvnor.  There must be some
subtleties with the spreadsheets that I am not getting yet.  

 

Robert Costello

Lead Systems Engineer

IMA Performance

E3- 279A

847.286.0910

 

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of CK
Sent: Tuesday, January 20, 2009 12:11 PM
To: Rules Users List
Subject: Re: [rules-users] Drools, Grails,and default packages for
domain objects

 

If I understand you correctly, this is a Java runtime restriction.  

 

Java classes in the default package can reference any class in a named
package.  Other the other hand, classes in a named package cannot
reference any class in a default package.  Classes in a default package
can reference other classes in a default package.

 

Thus, the easiest way normally to deal with this problem is to either
(1) put everything in a named package, including any grails
classes/domain objects/etc or (2) put everything in a default package.
I'd suggest that you go with option 1 because it'll give you fewer
problems.

 

But I'm not sure if that's the question you're asking or if this helps
you.  Hopefully, it does. :)

 

 

On Jan 20, 2009, at 6:00 AM, Costello, Robert wrote:





I'm using the latest as of this date, which is 5.0.0M4

 

Thanks!

 

Robert Costello

Lead Systems Engineer

IMA Performance

E3- 279A

847.286.0910

 

 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Monday, January 19, 2009 3:59 PM
To: Rules Users List
Subject: Re: [rules-users] Drools, Grails,and default packages for
domain objects

 


   Robert,

   What version of Drools are you using?
   I remember seeing something about this in the past... I will search
JIRAs to see if we have any ticket open for 5.0.

   []s
   Edson

2009/1/19 Costello, Robert 

Has anyone else run into issues trying to reference objects in a default
package?  I'm trying to use Drools with Grails and my rule which
compiled nicely in a package setting has issues when faced with a
default package. 

 

The error is "foo" cannot be resolved to a type

 

I've tried putting the rule both in the default package and putting it
in a named package, and neither seem to work.   If I put my objects back
into packages, everything is fine.

 

Any  advice?

 

Thanks,

 

Robert Costello

 

 


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




-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.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


Re: [rules-users] Run a set of rules in a group B from a rule in agroup A

2009-01-21 Thread Thierry B

Hello,

But I see that even if I put the focus to a group, he will inevitably
execute rules that doesn't have a group, it's normal?

Thanks :-)

-- 
View this message in context: 
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-group-A-tp21580767p21583764.html
Sent from the drools - user 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] Reasoning over hierarchies.

2009-01-21 Thread Faron Dutton
I know this has probably been asked before but I cannot find any mention of
it. How does one reason over a transitive (recursive) relation in Drools?

---

The classic example from Prolog:

-- The relation parent(P,C) says that P is a parent of C.
parent(P,C). 

-- The predicate ancestor(A,B) implies that A is an ancestor
-- of B if A is a parent of B or A is a parent of C and C
-- is an ancestor of B.
ancestor(A,B) :- parent(A,B).
ancestor(A,B) :- parent(A,C), ancestor(C,B).

-- The query ancestor(bob,frank) asks if bob is an ancestor
-- of frank.
?- ancestor(bob,frank).

---

In Drools, I can find the parent using

query isParent(String a, String b)
p: Person(name = a)
c: Person(name = b, parent = p)
end

likewise, I can find the grandparent using

query isGrandparent(String a, String b)
g: Person(name = a)
p: Person(parent = g)
c: Person(name = b, parent = p)
end

I am unable to formulate the query isAncestor.

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


Re: [rules-users] Run a set of rules in a group B from a rule in agroup A

2009-01-21 Thread Thierry B

Ha ok, thanks :-)


Edson Tirelli-3 wrote:
> 
> Michael is right. It is just harder to explain than to do it. Just
> take
> a look at agenda-groups or ruleflow-groups. Chose which one you prefer to
> use it, place your rules in two separate groups: A and B.
> 
> If using agenda-groups, set initial focus to A, fireAllRules and make
> sure that on the consequence of one of the rules from group A you set
> focus
> to B. So if that rule never fires, B will never have the focus and will
> never fire. Just remeber that agenda-groups work like a stack, so if you
> want ALL rules from A to execute before B, add the setFocus on the rule
> with
> the lowest salience in A.
> 
> Using ruleflow-groups is similar, but you draw your "flow"
> graphically,
> and it does not work like a stack. Sometimes easier for your use case.
> 
> []s
> Edson
> 
> 2009/1/21 Anstis, Michael (M.) 
> 
>> Hi,
>>
>> See below.
>>
>> "executing a rule" is really two parts: LHS pattern matching (which
>> can't be stopped for a given RuleBase) and execution of the RHS (which
>> can be controlled by the agenda and truth maintenance).
>>
>> I hope my time away hasn't led to me giving wrong advice.
>>
>> Mike
>>
>> -Original Message-
>> From: rules-users-boun...@lists.jboss.org
>> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
>> Sent: 21 January 2009 12:53
>> To: rules-users@lists.jboss.org
>> Subject: RE: [rules-users] Run a set of rules in a group B from a rule
>> in agroup A
>>
>>
>> Hello,
>>
>> So if I've well understand :
>>
>> - before calling fireAllRules(), Drools know for all rules (from any
>> group)
>> definied in DRL files, those which all patterns in the LHS of a rule are
>> matched, and those rules are placed on a agenda.
>>
>> At which moment exactly, Drools verified from a rule that all of its
>> pattern
>> in the LHS are matched, if it's before callling fireAllRules() ?
>>
>> >>> Yes, LHS is evaluated on workingMemory.insert(o). A call to
>> fireAllRules() executes the activations on the agenda (i.e. RHS queued
>> as a consequence of LHS being matched on workingMemory.insert(o)).
>>
>> - And fireAllRules() permit to execute all rules that are placed on
>> agenda
>>
>> >>> Yes
>>
>> - When using setFocus() from a java class or a rule, we can control the
>> order of rules to specify to execute rules from group B, and group C...
>>
>> >> I believe so.
>>
>> - So it's not possible to tell Drools that we don't want to execute a
>> group
>> of rules if a rule A is not matched : in that group of rules : those
>> which
>> all paterns match LHS will be inevitably executed.
>>
>> >>> Wrong. The rules won't be executed (read as activations - RHS -
>> won't be run) but you can't stop the LHS being evaluated.
>>
>> All these points that I said, are exact?
>>
>> Thanks :-)
>>
>>
>> Anstis, Michael (M.) wrote:
>> >
>> > Please accept that my knowledge is based on 4.x and there might be
>> other
>> > alternatives in 5.
>> >
>> > Rules are not "ran" but their patterns (LHS) evaluated as facts
>> > (objects) are inserted into Working Memory. When all patterns in the
>> LHS
>> > of a rule are matched activations are placed on the agenda for
>> execution
>> > of the consequence (RHS) when fireAllRules() is called (or other
>> > mechanisms to run what is on the agenda are invoked; such as
>> RuleFlow).
>> > So you could have rules in Group A cause Group B to receive the focus
>> > but it is the RHS's execution order you control and not the pattern
>> > matching - which will happen for Group A and Group B when facts are
>> > inserted into WM.
>> >
>> > Look at Agenda Groups and RuleFlow. This should help.
>> >
>> > With kind regards,
>> >
>> > Mike
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
>> roup-A-tp21580767p21582595.html
>> Sent from the drools - user 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
>>
> 
> 
> 
> -- 
>  Edson Tirelli
>  JBoss Drools Core Development
>  JBoss, a division of Red Hat @ www.jboss.com
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-group-A-tp21580767p21583335.html
Sent from the drools - user mailing list archive at Nabble.com.

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

RE: [rules-users] Run a set of rules in a group B from a rule in agroup A

2009-01-21 Thread Thierry B

Hello,

When you said  "Wrong. The rules won't be executed (read as activations -
RHS -
won't be run) but you can't stop the LHS being evaluated.", I don't
understand : if we use fireAllRules(), those rules will be executed
inevitably no?
I don't understand how we can decide that those rules (from a certain group)
won't be executed.

Thanks :-)



Anstis, Michael (M.) wrote:
> 
> Hi,
> 
> See below.
>  
> "executing a rule" is really two parts: LHS pattern matching (which
> can't be stopped for a given RuleBase) and execution of the RHS (which
> can be controlled by the agenda and truth maintenance).
> 
> I hope my time away hasn't led to me giving wrong advice.
> 
> Mike
> 
> -Original Message-
> From: rules-users-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
> Sent: 21 January 2009 12:53
> To: rules-users@lists.jboss.org
> Subject: RE: [rules-users] Run a set of rules in a group B from a rule
> in agroup A
> 
> 
> Hello,
> 
> So if I've well understand :
> 
> - before calling fireAllRules(), Drools know for all rules (from any
> group)
> definied in DRL files, those which all patterns in the LHS of a rule are
> matched, and those rules are placed on a agenda. 
> 
> At which moment exactly, Drools verified from a rule that all of its
> pattern
> in the LHS are matched, if it's before callling fireAllRules() ?
> 
 Yes, LHS is evaluated on workingMemory.insert(o). A call to
> fireAllRules() executes the activations on the agenda (i.e. RHS queued
> as a consequence of LHS being matched on workingMemory.insert(o)).
> 
> - And fireAllRules() permit to execute all rules that are placed on
> agenda
> 
 Yes
> 
> - When using setFocus() from a java class or a rule, we can control the
> order of rules to specify to execute rules from group B, and group C... 
> 
>>> I believe so.
> 
> - So it's not possible to tell Drools that we don't want to execute a
> group
> of rules if a rule A is not matched : in that group of rules : those
> which
> all paterns match LHS will be inevitably executed.
> 
 Wrong. The rules won't be executed (read as activations - RHS -
> won't be run) but you can't stop the LHS being evaluated.
> 
> All these points that I said, are exact?
> 
> Thanks :-)
> 
> 
> Anstis, Michael (M.) wrote:
>> 
>> Please accept that my knowledge is based on 4.x and there might be
> other
>> alternatives in 5.
>> 
>> Rules are not "ran" but their patterns (LHS) evaluated as facts
>> (objects) are inserted into Working Memory. When all patterns in the
> LHS
>> of a rule are matched activations are placed on the agenda for
> execution
>> of the consequence (RHS) when fireAllRules() is called (or other
>> mechanisms to run what is on the agenda are invoked; such as
> RuleFlow).
>> So you could have rules in Group A cause Group B to receive the focus
>> but it is the RHS's execution order you control and not the pattern
>> matching - which will happen for Group A and Group B when facts are
>> inserted into WM.
>> 
>> Look at Agenda Groups and RuleFlow. This should help.
>> 
>> With kind regards,
>> 
>> Mike
>> 
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
> roup-A-tp21580767p21582595.html
> Sent from the drools - user 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
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-group-A-tp21580767p21583108.html
Sent from the drools - user 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] how to get CashMemoDtl in my dsrl file.

2009-01-21 Thread manyasri.m


Hi,

how to get CashMemoDtl in my dsrl file.once i am calling executeFormRules
than rules should be fired.
In this case i am getting CashMemoHdr details it's working fine.
problem is how to get CashMemoDtl in my rule file.

CashMemoHdr hdr = new CashMemoHdr();
hdr.setBillNo(123l);
Set cashMemoDtls = new HashSet();
CashMemoDtl dtl = new CashMemoDtl();
dtl.setQuantity(11l);

cashMemoDtls.add(dtl);
hdr.setCashMemoDtls(cashMemoDtls);

service.executeFormRules(hdr);

give me proper suggestion.ASAP.

Thanks,
-Manya
-- 
View this message in context: 
http://www.nabble.com/how-to-get-CashMemoDtl-in-my-dsrl-file.-tp21583114p21583114.html
Sent from the drools - user 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] Run a set of rules in a group B from a rule in agroup A

2009-01-21 Thread Edson Tirelli
Michael is right. It is just harder to explain than to do it. Just take
a look at agenda-groups or ruleflow-groups. Chose which one you prefer to
use it, place your rules in two separate groups: A and B.

If using agenda-groups, set initial focus to A, fireAllRules and make
sure that on the consequence of one of the rules from group A you set focus
to B. So if that rule never fires, B will never have the focus and will
never fire. Just remeber that agenda-groups work like a stack, so if you
want ALL rules from A to execute before B, add the setFocus on the rule with
the lowest salience in A.

Using ruleflow-groups is similar, but you draw your "flow" graphically,
and it does not work like a stack. Sometimes easier for your use case.

[]s
Edson

2009/1/21 Anstis, Michael (M.) 

> Hi,
>
> See below.
>
> "executing a rule" is really two parts: LHS pattern matching (which
> can't be stopped for a given RuleBase) and execution of the RHS (which
> can be controlled by the agenda and truth maintenance).
>
> I hope my time away hasn't led to me giving wrong advice.
>
> Mike
>
> -Original Message-
> From: rules-users-boun...@lists.jboss.org
> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
> Sent: 21 January 2009 12:53
> To: rules-users@lists.jboss.org
> Subject: RE: [rules-users] Run a set of rules in a group B from a rule
> in agroup A
>
>
> Hello,
>
> So if I've well understand :
>
> - before calling fireAllRules(), Drools know for all rules (from any
> group)
> definied in DRL files, those which all patterns in the LHS of a rule are
> matched, and those rules are placed on a agenda.
>
> At which moment exactly, Drools verified from a rule that all of its
> pattern
> in the LHS are matched, if it's before callling fireAllRules() ?
>
> >>> Yes, LHS is evaluated on workingMemory.insert(o). A call to
> fireAllRules() executes the activations on the agenda (i.e. RHS queued
> as a consequence of LHS being matched on workingMemory.insert(o)).
>
> - And fireAllRules() permit to execute all rules that are placed on
> agenda
>
> >>> Yes
>
> - When using setFocus() from a java class or a rule, we can control the
> order of rules to specify to execute rules from group B, and group C...
>
> >> I believe so.
>
> - So it's not possible to tell Drools that we don't want to execute a
> group
> of rules if a rule A is not matched : in that group of rules : those
> which
> all paterns match LHS will be inevitably executed.
>
> >>> Wrong. The rules won't be executed (read as activations - RHS -
> won't be run) but you can't stop the LHS being evaluated.
>
> All these points that I said, are exact?
>
> Thanks :-)
>
>
> Anstis, Michael (M.) wrote:
> >
> > Please accept that my knowledge is based on 4.x and there might be
> other
> > alternatives in 5.
> >
> > Rules are not "ran" but their patterns (LHS) evaluated as facts
> > (objects) are inserted into Working Memory. When all patterns in the
> LHS
> > of a rule are matched activations are placed on the agenda for
> execution
> > of the consequence (RHS) when fireAllRules() is called (or other
> > mechanisms to run what is on the agenda are invoked; such as
> RuleFlow).
> > So you could have rules in Group A cause Group B to receive the focus
> > but it is the RHS's execution order you control and not the pattern
> > matching - which will happen for Group A and Group B when facts are
> > inserted into WM.
> >
> > Look at Agenda Groups and RuleFlow. This should help.
> >
> > With kind regards,
> >
> > Mike
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
> roup-A-tp21580767p21582595.html
> Sent from the drools - user 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
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] how to get CashMemoDtl in my dsrl file.

2009-01-21 Thread manyasri.m


Hi,

how to get CashMemoDtl in my dsrl file.once i am calling executeFormRules
than rules should be fired.
In this case i am getting CashMemoHdr details it's working fine.
problem is how to get CashMemoDtl in my rule file.

CashMemoHdr hdr = new CashMemoHdr();
hdr.setBillNo(123l);
Set cashMemoDtls = new HashSet();
CashMemoDtl dtl = new CashMemoDtl();
dtl.setQuantity(11l);

cashMemoDtls.add(dtl);
hdr.setCashMemoDtls(cashMemoDtls);

service.executeFormRules(hdr);

give me proper suggestion.ASAP.

Thanks,
-Manya
-- 
View this message in context: 
http://www.nabble.com/how-to-get-CashMemoDtl-in-my-dsrl-file.-tp21583068p21583068.html
Sent from the drools - user 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] Run a set of rules in a group B from a rule in agroup A

2009-01-21 Thread Anstis, Michael (M.)
Hi,

See below.
 
"executing a rule" is really two parts: LHS pattern matching (which
can't be stopped for a given RuleBase) and execution of the RHS (which
can be controlled by the agenda and truth maintenance).

I hope my time away hasn't led to me giving wrong advice.

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
Sent: 21 January 2009 12:53
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Run a set of rules in a group B from a rule
in agroup A


Hello,

So if I've well understand :

- before calling fireAllRules(), Drools know for all rules (from any
group)
definied in DRL files, those which all patterns in the LHS of a rule are
matched, and those rules are placed on a agenda. 

At which moment exactly, Drools verified from a rule that all of its
pattern
in the LHS are matched, if it's before callling fireAllRules() ?

>>> Yes, LHS is evaluated on workingMemory.insert(o). A call to
fireAllRules() executes the activations on the agenda (i.e. RHS queued
as a consequence of LHS being matched on workingMemory.insert(o)).

- And fireAllRules() permit to execute all rules that are placed on
agenda

>>> Yes

- When using setFocus() from a java class or a rule, we can control the
order of rules to specify to execute rules from group B, and group C... 

>> I believe so.

- So it's not possible to tell Drools that we don't want to execute a
group
of rules if a rule A is not matched : in that group of rules : those
which
all paterns match LHS will be inevitably executed.

>>> Wrong. The rules won't be executed (read as activations - RHS -
won't be run) but you can't stop the LHS being evaluated.

All these points that I said, are exact?

Thanks :-)


Anstis, Michael (M.) wrote:
> 
> Please accept that my knowledge is based on 4.x and there might be
other
> alternatives in 5.
> 
> Rules are not "ran" but their patterns (LHS) evaluated as facts
> (objects) are inserted into Working Memory. When all patterns in the
LHS
> of a rule are matched activations are placed on the agenda for
execution
> of the consequence (RHS) when fireAllRules() is called (or other
> mechanisms to run what is on the agenda are invoked; such as
RuleFlow).
> So you could have rules in Group A cause Group B to receive the focus
> but it is the RHS's execution order you control and not the pattern
> matching - which will happen for Group A and Group B when facts are
> inserted into WM.
> 
> Look at Agenda Groups and RuleFlow. This should help.
> 
> With kind regards,
> 
> Mike
> 
> 

-- 
View this message in context:
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
roup-A-tp21580767p21582595.html
Sent from the drools - user 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


RE: [rules-users] Run a set of rules in a group B from a rule in a group A

2009-01-21 Thread Thierry B

Hello,

So if I've well understand :

- before calling fireAllRules(), Drools know for all rules (from any group)
definied in DRL files, those which all patterns in the LHS of a rule are
matched, and those rules are placed on a agenda. 

At which moment exactly, Drools verified from a rule that all of its pattern
in the LHS are matched, if it's before callling fireAllRules() ?

- And fireAllRules() permit to execute all rules that are placed on agenda

- When using setFocus() from a java class or a rule, we can control the
order of rules to specify to execute rules from group B, and group C... 

- So it's not possible to tell Drools that we don't want to execute a group
of rules if a rule A is not matched : in that group of rules : those which
all paterns match LHS will be inevitably executed.

All these points that I said, are exact?

Thanks :-)


Anstis, Michael (M.) wrote:
> 
> Please accept that my knowledge is based on 4.x and there might be other
> alternatives in 5.
> 
> Rules are not "ran" but their patterns (LHS) evaluated as facts
> (objects) are inserted into Working Memory. When all patterns in the LHS
> of a rule are matched activations are placed on the agenda for execution
> of the consequence (RHS) when fireAllRules() is called (or other
> mechanisms to run what is on the agenda are invoked; such as RuleFlow).
> So you could have rules in Group A cause Group B to receive the focus
> but it is the RHS's execution order you control and not the pattern
> matching - which will happen for Group A and Group B when facts are
> inserted into WM.
> 
> Look at Agenda Groups and RuleFlow. This should help.
> 
> With kind regards,
> 
> Mike
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-group-A-tp21580767p21582595.html
Sent from the drools - user 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] Getting facts from external source using 'from' and parametrized method call

2009-01-21 Thread Przemysław Różycki
Sorry for responsing myself, but I'm still working on it and found that 
when factSource is a fact, not global, the rule works very well. I mean, 
this rule works fine:


rule "My Rule"
  when
$factSrc : FactSource(  )
$fact : Fact(  ) from $factSrc.getSomeFacts("a","b","c")
  then
// do something
end

so what's the difference between invocation on global object and 
invocation on fact object? Why the first one doesn't work and the second 
one works?


Best regards,
Przemek


Przemysław Różycki pisze:

Hi,

could I ask for some advice, please, how to use a parametrized method 
call to get some data using 'from' element in LHS.


To be more precise, I would like to do something like this:

rule "My Rule"
  when
$fact : Fact(  ) from factSource.getSomeFacts("a","b","c")
  then
// do something
end

where factSource is for example some global and 
getSomeFacts(String,String,String) is a parametrized method that returns 
some array of Fact objects.


Unfortunately, when I try to launch the following rule I have an error:

Exception in thread "main" org.mvel.PropertyAccessException: unable to 
resolve property: factSource.getSomeFacts("a","b","c")
at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:295) 

at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110) 

at 
org.mvel.ast.VariableDeepPropertyNode.getReducedValueAccelerated(VariableDeepPropertyNode.java:26) 

at 
org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:70) 

at 
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24) 


at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:252)
at 
org.drools.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:55) 


at org.drools.reteoo.FromNode.assertTuple(FromNode.java:68)
at 
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55) 

at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116) 

at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22) 

at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)

at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at 
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at 
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:181) 

at 
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1312) 

at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:915) 

at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883) 

at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684) 


at com.sample.DroolsTest6.main(DroolsTest6.java:29)
Caused by: java.lang.NullPointerException
at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:530) 

at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:261) 


... 21 more

Documentation says:

"The from Conditional Element allows users to specify a source for 
patterns to reason over. This allows the engine to reason over data not 
in the Working Memory. This could be a sub-field on a bound variable or 
the results of a method call."


so I assume that it is possible to do what I want. If not, could I ask 
for an advice of some workaround, please?


Best regards,


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


RE: [rules-users] Run a set of rules in a group B from a rule in a group A

2009-01-21 Thread Anstis, Michael (M.)
Please accept that my knowledge is based on 4.x and there might be other
alternatives in 5.

Rules are not "ran" but their patterns (LHS) evaluated as facts
(objects) are inserted into Working Memory. When all patterns in the LHS
of a rule are matched activations are placed on the agenda for execution
of the consequence (RHS) when fireAllRules() is called (or other
mechanisms to run what is on the agenda are invoked; such as RuleFlow).
So you could have rules in Group A cause Group B to receive the focus
but it is the RHS's execution order you control and not the pattern
matching - which will happen for Group A and Group B when facts are
inserted into WM.

Look at Agenda Groups and RuleFlow. This should help.

With kind regards,

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
Sent: 21 January 2009 10:48
To: rules-users@lists.jboss.org
Subject: [rules-users] Run a set of rules in a group B from a rule in a
group A


Hello,

Is it possible to run a rule from a group A, and if conditions of that
rule
are satisfied that in consequence to tell Drools to run rules of a group
B ?
And if it's possible, how to do that?

Thanks :-)


-- 
View this message in context:
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
roup-A-tp21580767p21580767.html
Sent from the drools - user 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] Re: Getting facts from external source using 'from' and parametrized method call

2009-01-21 Thread Przemysław Różycki

Just to precise: I use Drools 4.0.7.

Best regards,
Przemek

Przemysław Różycki pisze:

Hi,

could I ask for some advice, please, how to use a parametrized method 
call to get some data using 'from' element in LHS.


To be more precise, I would like to do something like this:

rule "My Rule"
  when
$fact : Fact(  ) from factSource.getSomeFacts("a","b","c")
  then
// do something
end

where factSource is for example some global and 
getSomeFacts(String,String,String) is a parametrized method that returns 
some array of Fact objects.


Unfortunately, when I try to launch the following rule I have an error:

Exception in thread "main" org.mvel.PropertyAccessException: unable to 
resolve property: factSource.getSomeFacts("a","b","c")
at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:295) 

at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110) 

at 
org.mvel.ast.VariableDeepPropertyNode.getReducedValueAccelerated(VariableDeepPropertyNode.java:26) 

at 
org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:70) 

at 
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24) 


at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:252)
at 
org.drools.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:55) 


at org.drools.reteoo.FromNode.assertTuple(FromNode.java:68)
at 
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55) 

at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116) 

at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22) 

at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)

at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at 
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
at 
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:181) 

at 
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1312) 

at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:915) 

at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883) 

at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684) 


at com.sample.DroolsTest6.main(DroolsTest6.java:29)
Caused by: java.lang.NullPointerException
at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:530) 

at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:261) 


... 21 more

Documentation says:

"The from Conditional Element allows users to specify a source for 
patterns to reason over. This allows the engine to reason over data not 
in the Working Memory. This could be a sub-field on a bound variable or 
the results of a method call."


so I assume that it is possible to do what I want. If not, could I ask 
for an advice of some workaround, please?


Best regards,

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


[rules-users] Getting facts from external source using 'from' and parametrized method call

2009-01-21 Thread Przemysław Różycki

Hi,

could I ask for some advice, please, how to use a parametrized method 
call to get some data using 'from' element in LHS.


To be more precise, I would like to do something like this:

rule "My Rule"
  when
$fact : Fact(  ) from factSource.getSomeFacts("a","b","c")
  then
// do something
end

where factSource is for example some global and 
getSomeFacts(String,String,String) is a parametrized method that returns 
some array of Fact objects.


Unfortunately, when I try to launch the following rule I have an error:

Exception in thread "main" org.mvel.PropertyAccessException: unable to 
resolve property: factSource.getSomeFacts("a","b","c")
	at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:295)
	at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeAccessor(ReflectiveAccessorOptimizer.java:110)
	at 
org.mvel.ast.VariableDeepPropertyNode.getReducedValueAccelerated(VariableDeepPropertyNode.java:26)
	at 
org.mvel.ast.PropertyASTNode.initializePropertyNode(PropertyASTNode.java:70)
	at 
org.mvel.ast.PropertyASTNode.getReducedValueAccelerated(PropertyASTNode.java:24)

at org.mvel.MVELRuntime.execute(MVELRuntime.java:90)
at org.mvel.CompiledExpression.getValue(CompiledExpression.java:111)
at org.mvel.MVEL.executeExpression(MVEL.java:252)
	at 
org.drools.base.dataproviders.MVELDataProvider.getResults(MVELDataProvider.java:55)

at org.drools.reteoo.FromNode.assertTuple(FromNode.java:68)
	at 
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkAdapter.java:55)
	at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:116)
	at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:22)

at 
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:162)
at org.drools.reteoo.Rete.assertObject(Rete.java:175)
at 
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
	at 
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(ReteooWorkingMemory.java:181)
	at 
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorkingMemory.java:1312)
	at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:915)
	at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:883)
	at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:684)

at com.sample.DroolsTest6.main(DroolsTest6.java:29)
Caused by: java.lang.NullPointerException
	at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:530)
	at 
org.mvel.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileGetChain(ReflectiveAccessorOptimizer.java:261)

... 21 more

Documentation says:

"The from Conditional Element allows users to specify a source for 
patterns to reason over. This allows the engine to reason over data not 
in the Working Memory. This could be a sub-field on a bound variable or 
the results of a method call."


so I assume that it is possible to do what I want. If not, could I ask 
for an advice of some workaround, please?


Best regards,
--
Przemysław Różycki
IT Architect
AMG.net, A Bull Group Company
ul. Łąkowa 29
90-554 Łódź
www.amg.net.pl
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Run a set of rules in a group B from a rule in a group A

2009-01-21 Thread Thierry B

Hello,

Is it possible to run a rule from a group A, and if conditions of that rule
are satisfied that in consequence to tell Drools to run rules of a group B ?
And if it's possible, how to do that?

Thanks :-)


-- 
View this message in context: 
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-group-A-tp21580767p21580767.html
Sent from the drools - user mailing list archive at Nabble.com.

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