[rules-users] Fetching values of an object's attribute setbydifferent rules
Anstis, Michael (M.)
manstis1 at ford.com
Mon Aug 11 10:06:06 EDT 2008
Hi Paul,
What about subclassing List and adding a "type" attribute?
class MyArrayList extends ArrayList {
private String type;
public String getType() {
return type;
}
}
Rule "smurf"
when
$l : MyArrayList( type == 'shirt' )
...
then
...
end
Still not understanding your requirement but happy to keep punting ideas
until you get the "spark".
Cheers,
Mike
-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of psentosa
Sent: 11 August 2008 14:48
To: rules-users at lists.jboss.org
Subject: RE: [rules-users] Fetching values of an object's attribute
setbydifferent rules
Hi Mike,
thanks for the reply.
Actually for each object I check, depending on how many rules are
activated,
I'd need so many value holder too.
So, each value holder actually contains information about each activated
rule (e.g. regarding the temperature and detergent.
But thank you for the keyword LIST. I think, instead of using 2 level
(i.e.
Value Holder and the Match-objects, I could use
session.insert(List<ValueHolder>), and for every activated rule, in THEN
part I'll create a new ValueHolder, set its values, and add it to the
list.
But another question to this:
How can I insert 2 different kind of lists, and refer to them?
I saw that List<MyClass>() can't be used, and only List() is possible
when
$wash : List()
$shirt : List()
then
$wash.add(new Wash..())
$shirt.add(new Shirt())
Can RE find the correct list to add the objet? Or how should I do this?
Again, thanks in advance :)
Paul
Hi psentosa,
I don't fully understand what you require, but won't using a List of
WashRuleMatches provide what you need?
rule A
when
$s : Shirt (dirtinessLevel == high)
$holder : WashRuleValueHolder()
Then
System.out.println ("this cloth should be washed in 60 degree
water with 1 spoon of detergent")
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(60);
m.setDetergent(1);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);
rule B
when
$s : Shirt(material == satin)
$holder : WashRuleValueHolder()
then
System.out.println ("this cloth should be washed in 30 degree
water with 0,5 spoon of detergent")
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(30);
m.setDetergent(0.5);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);
Do you need only one WashRuleValueHolder for each shirt?
[WashRuleValueHolder setup by rules]
rule A1.0
when
$s : Shirt (dirtinessLevel == high)
not WashRuleValueHolder(shirt == $s)
Then
WashRuleValueHolder wrvh = new WashRuleValueHolder($s);
insertLogical(wrvh);
rule A1.1
when
$s : Shirt (dirtinessLevel == high)
$holder : WashRuleValueHolder(shirt == $s)
Then
System.out.println ("this cloth should be washed in 60 degree
water with 1 spoon of detergent")
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(60);
m.setDetergent(1);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);
Etc...
With kind regards,
Mike
--
View this message in context:
http://www.nabble.com/Fetching-values-of-an-object%27s-attribute-set-by-
different-rules-tp18922201p18926194.html
Sent from the drools - user mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
More information about the rules-users
mailing list