[rules-users] Fetching values of an object's attribute set bydifferent rules

psentosa psentosa at yahoo.com
Mon Aug 11 09:48:01 EDT 2008


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.




More information about the rules-users mailing list