[rules-users] Checking fact "id"

Anstis, Michael (M.) manstis1 at ford.com
Mon Jan 7 04:09:53 EST 2008


Forgetting the use of Drools how do you determine (programmatically) which
is the main contract and which are related?
 
Once you can answer this your Drools solution should become self evident.

An attribute 
 

when
    $mc: Contract(type == "main" ) 
then
    #rule fired over "the" main contract
end
 
when
   $rc: Contract(type == "related" )
then
   #rule fired over "a" related contract
end
 
A relationship
 

when
    $mc: Contract( ) 
then
    #rule fired over "the" main contract
end
 
when

    $mc: Contract( ) 
    $rc: Contract( ) from $mc.contracts
then
   #rule fired over "a" related contract
end


  _____  

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Massi Gmail
Sent: 05 January 2008 11:33
To: Rules Users List
Subject: Re: [rules-users] Checking fact "id"


ok
 
But i think I do not need to differentiate them.
 
I try to explain it better.
 
I have got a set of "Contract" class Facts. All of them inserted into the
working memory.
 
But Just one of them is the "main contract", all the others all "related
contracts".
 
So , when i write a rule I need to distinguish between a "main contract"
(which is unique along the session) 
and a "related contract".
 
I should write rules like the followings:
 

when
    $mc: Contract() from maincontract
then
    #rule fired over "the" main contract
end
 
when
   $rc: Contract() from relatedcontract
then
   #rule fired over "a" related contract
end

I think the only solution to do that is to make "maincontract" and
"relatedcontracr" globals.
But, if I make them globals, then the rule engine will not be notified about
their changes and
I do want it to be notified about it. 
 
Should I make them "globals" and "facts" as well?
Can globals be inserted into the WM as well? Is it too horrible? :D
 
Thank u anyway.
 
Massi
 

----- Original Message ----- 
From: Edson Tirelli <mailto:tirelli at post.com>  
To: Rules Users List <mailto:rules-users at lists.jboss.org>  
Sent: Saturday, January 05, 2008 12:00 PM
Subject: Re: [rules-users] Checking fact "id"


   What attribute differentiates A1 from A2? 
   Such scenarios usually are solved by an additional constraint...

   []s
   Edson


2008/1/4, Massi Gmail < mmquelo at gmail.com <mailto:mmquelo at gmail.com> >: 

 
Hi guys,
 
Now I am strugglin' with "fact id checking"  or whatever we can call it....
:D
 
Let's take into account the followong scenario:
 
I have class A (it's just a name) javabeans to be inserted into the WM.
 
I define two objects of class A: A1 and A2.
 
Somewhere I do "insert(A1)" and "insert(A2)" ( let's say I do it in the same
package of R1 and R2..see below...) 
 
Then I define two different rules R1 and R2 that reason over class "A" facts
(let's say R1 and R2 are in the same package) .
 
The point is....  I want R1 to fire only on A1 and R2 only on A2.
 
Is that possible in drools? Is there a sort of "fact id" I can reason over?
 
I do not think globals will be of any help, cause in the guide i have read
that globals should never be used within LHS.
We should never reason over globals. 
 
Let me know.
 
Massi
 
 

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users






-- 
  Edson Tirelli
  JBoss Drools Core Development
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646 
  JBoss, a division of Red Hat @ www.jboss.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/20080107/5456b682/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4159 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20080107/5456b682/attachment.bin 


More information about the rules-users mailing list