Presumably ConcreteType1 extends BaseType. In this case the rule will evaluate true as
ConcreateType1 IS A BaseType and therefore the same object matches both the o1 condition
and the o2 conditions. This is why the tuple contains only 1 entry as there was only one
unique object matched (o1 == o2).
Thomas
From: rules-users-bounces(a)lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On
Behalf Of Rajnikant Gupta
Sent: 09 April 2010 10:01
To: Rules Users List
Subject: Re: [rules-users] Tuples in Agenda Item.
DroolsWorkingMemory is our custom class which contains asserted facts and other custom
objects based on our project requirement. It should not be confused with
"WorkingMemory" of Drools.
For issue 1, I assume that if I overwrite one field in ConcreteType1 to a different value
than that in BaseType, they are treated as diferrent objects. Consider the xml snapshot of
the two objects for eg:
BaseType object:
<com.parentchild.BaseType>
<Boolean>false</Boolean>
<Date>2010-04-09T00:00:00</Date>
<String>a</String>
<Double>0.0</Double>
</com.parentchild.BaseType>
ConcreteType1 object:
<com.parentchild.ConcreteType1>
<Boolean>false</Boolean>
<Date>2010-04-09T00:00:00</Date>
<String>b</String>
<Double>0.0</Double>
<ConcreteType1Boolean>false</ConcreteType1Boolean>
</com.parentchild.ConcreteType1>
so I assume I have two objects BaseType(with value of String as "a") and
ConcreteType1 object (with value of String as "b"). The rule should evaluate to
false on the above assumption.
For issue 2, Sorry If i have misled, my only question was why does the Tuple inside Agenda
Item show only ConcreteType1 and not the BaseType, If both of them are inserted in
WorkingMemory. Doesn't the tuple contain all the objects inserted in WM.
Regards,
Rajnikant Gupta
2010/4/9 Wolfgang Laun
<wolfgang.laun@gmail.com<mailto:wolfgang.laun@gmail.com>>
Regarding Issue 1:
Even if you do have different objects of ConcreteType1, the rule is fired for each of
them, since each of these is equal to itself in terms of the BaseType.
I also fail to understand Issue 2. But perhaps your misconception about base type and
subtype matching is also responsible for that.
Rule "s" looks strange for more than one reason. What is the
DroolsWorkingMemory() pattern supposed to achieve? Is it a general trigger so that the
rule only fires if one such object is present?
Leaving base and extended types aside, testing for the equality of two objects of the same
type must be done much more carefully. Assuming three objects of TypeX, x1, x2, x3 with
x1.equals(x2) and NOT x1.equals(x3) and a rule like this:
rule "xxx"
when
o1 : TypeX()
o2 : TypeX()
eval( o1.equals( o2 ) )
then
...
This rule will fire 5 times, with the following activations:
<x1,x1>, <x2,x2>, <x3,x3>, <x1,x2>, <x2,x1>.
Using, e.g.,
o2:TypeX( this != o1 )
reduces this to two firings.
-W
2010/4/9 Rajnikant Gupta
<capricorn.raj@gmail.com<mailto:capricorn.raj@gmail.com>>
Hi,
Sorry for not being very clear. Here's the rule which I run:
package rr
import com.thirdpillar.common.util.DroolsWorkingMemoryimport com.parentchild.BaseType
import com.parentchild.ConcreteType1
rule "s"
no-loop true
salience 999999
when
DroolsWorkingMemory:DroolsWorkingMemory()
BaseType:BaseType()
ConcreteType1:ConcreteType1()
eval (
(
((BaseType.equals(ConcreteType1)))
)
)
then
BaseType.setString("Blah Blah!");
end
where ConcreteType1 extends BaseType.
Issues:
1. Even for different values for fields in ConcreteType1 and BaseType, the rule gets
fired.
2. I also do audit for the rules for which i need tuples so that I can extract the objects
out of it and evaluate the expression against Mvel. But the tuple shows me only the
ConcreteType1 instance not the BaseType. Thus getting wrong audit.
Regards,
Rajnikant Gupta
Sr. Software Engineer
GlobalLogic,Noida
09899530562
http://rkthinks.wordpress.com/
2010/4/9 Greg Barton <greg_barton@yahoo.com<mailto:greg_barton@yahoo.com>>
We need some rule code to get a better idea of what's going on. Can you post some?
--- On Thu, 4/8/10, Rajnikant Gupta
<capricorn.raj@gmail.com<mailto:capricorn.raj@gmail.com>> wrote:
From: Rajnikant Gupta
<capricorn.raj@gmail.com<mailto:capricorn.raj@gmail.com>>
Subject: [rules-users] Tuples in Agenda Item.
To: rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
Date: Thursday, April 8, 2010, 1:36 PM
Hi,
I have a doubt regarding tuples. I created a rule using complex types objects. I am
comparing two complex type objecs which have parent-child relationship eg.
"ParentType.equals(ChildType)". I expect this to follow java rule which allows
such comparision. Now when I run the rules with different values for fields in ParentType
and ChildType (which means the rule should fail) to my surprise it evals to TRUE. Also
upon inspection, the tuple shows me only the ChildType instance not the ParentType.
I would appreciate any help on this.
Regards,
Rajnikant
-----Inline Attachment Follows-----
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<http://mc/compose?to=rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
________________________________
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes. To protect the environment please
do not print this e-mail unless necessary.
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United
Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603
8808 40-00
**************************************************************************************
________________________________
This message is confidential and intended only for the addressee. If you have received
this message in error, please immediately notify the postmaster(a)nds.com and delete it from
your system as well as any copies. The content of e-mails as well as traffic data may be
monitored by NDS for employment and security purposes.
To protect the environment please do not print this e-mail unless necessary.
An NDS Group Limited company.
www.nds.com