Any artificial sort order is useful. Can you compare against 1? Or against the hashCode of the four, added together? It does not have to have any particular meaning.

You can also use static methods in a Condition, such as

        SortHelper.arbitrarilyOrder( obj1, obj2 ) > 0

or whatnot.

        -Bob

On Dec 8, 2005, at 4:26 PM, Thakkar, Manan wrote:

Bob

Since my object has (4 attributes) the compareTo() will not do it. Any other suggestions?

Thanks

Manan
-----Original Message-----
From: Bob McWhirter [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 08, 2005 2:50 PM
To: Thakkar, Manan
Subject: Re: Drools Usage Question

Yah, that's a common problem, since Drools works with combinations of objects, not merely permutations.

Sometimes you can solve it if you objects have a natural order to them.

If you add a condition such as

obj1.compareTo( obj2 ) < 0

That will force only { obj1, obj2 } but not allow { obj2, obj1 }

I think also perhaps using a Semaphor could help, but I'm personally fuzzy on the workings of those.

fwiw, you'll get a wider set of responses if you mail [email protected], as we have a super helpful user community.

Hope that helps!

-Bob


On Dec 8, 2005, at 2:27 PM, Thakkar, Manan wrote:

Bob

I am working on a IRAD project with Lockheed Martin and we are currently investigating the benefits of using the drools rule engine. I have created some test code using the samples from the drools website. I have come across a few questions that maybe you could help with.

We are using the rules engine without the drl file. We are creating the Rules, conditions and consequence from within the Java code. We have subclassed the Condition class and overloaded the isAllowed() functions. The rule has been created with 2 declarations which are passed to the isAllowed() when those type of objects are asserted into the rule engine. The problem seems to be that the isAllowed() is called multiple time with the different set of those objects. So when I assert obj1 and obj2, the is allowed is called 4 times with the following pairs: (obj1, obj1), (obj1, obj2), (obj2, obj1) & (obj2, obj2). We have been able to handle the 1st and 4th pair since our isAllowed is returning false, but 2nd and 3rd pair both return true and hence the rule consequence is fired twice.

We needed a way to figure out that the rule or the condition currently being checked already has an activation event scheduled when the 2nd pair returned true and hence when the 3rd pair is passed we could return false. I have tried to find the best way to determine if the current condition has a pending activation but am unable to do so.

Hope this helps clarify the problem we are having, if not, please do write back with the question.

Thanks

Manan

Manan Thakkar
Staff Software Engineer
Warfighter Information Network - Tactical (WIN-T)
    Network Management Software Lead
    NetOPS System Engineering Support
Lockheed Martin Integrated Systems & Solutions (IS&S)
700 N. Frederick Ave. - 182/2C113, Gaithersburg, MD 20879

Phone: (301) 240-6213 (office)
Email:  [EMAIL PROTECTED]

                     __________/|_
L O C K H E E D   M A R T I N / |/
Integrated Systems & Solutions /|




Reply via email to