[rules-users] Checking fact "id"

mmquelo massi mmquelo at gmail.com
Wed Jan 9 10:02:52 EST 2008


Thank You guys.

I worked it out. I have the contracts (main and related) encapsulated within
a parent object.
So, once I did the assertion I checked the "pattern matched" fact agains the
parent object.

Thank You again.

This ML is always usefull as usual!

I really hope to be usefull as well to the few I can answer back.

Bye

Massi



On Jan 7, 2008 9:27 PM, Mark Proctor <mproctor at codehaus.org> wrote:

> rules are just querries over data, like a database view.
> Ask yourself this. If you asserted those two objects, A1 and A2, into a
> database and you had two views V1 and V2. How would you make V1 select A1
> and V2 select A2?
>
> When you have the  answer for  that, it'll apply to Drools too.
>
> Mark
> Massi Gmail wrote:
>
>   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 <tirelli at post.com>
> *To:* Rules Users List <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>:
> >
> >
> > 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
>
> ------------------------------
>
> _______________________________________________
> rules-users mailing listrules-users at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> 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/20080109/fd6b3a6b/attachment.html 


More information about the rules-users mailing list