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
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of psentosa
Sent: 11 August 2008 10:04
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Fetching values of an object's attribute set
bydifferent rules
Hi,
I have the following problems:
I need to prove an object based on certain rules, where the parts of the
rules should be kept to be used in further process within my
application.
In order to fetch those parts, my idea was to insert an additional
object as
value holder for the rule's parts,
put values on them when the corresponding rule is fired, so that later
on I
can process those value holder after my appl gets the control back from
Ruleengine.
The example below:
Shirt shirt = new Shirt(...)
WashRuleValueHolder holder = new WashRuleValueHolder();
session.insert(shirt);
session.insert(holder);
......
session.dispose()
System.out.println(holder.getTemperature());
System.out.println(holder.getDetergent());
=======================
rule A
when
Shirt (dirtinessLevel == high)
$holder : WashRuleValueHolder()
then
System.out.println ("this cloth should be washed in 60 degree
water
with 1 spoon of detergent")
$holder.temperature = 60;
$holder.detergent = 1;
rule B
when
Shirt(material == satin)
$holder : WashRuleValueHolder()
then
System.out.println ("this cloth should be washed in 30 degree
water
with 0,5 spoon of detergent")
$holder.temperature = 30;
$holder.detergent = 0,5;
Now, in case both rules evaluate to true, I'd have problem with my
valueholder, bcs depending on which one of the rules was fired latest,
that'd be the value I got from the holder, and I need both of them.
So, my questions:
- Is using such a value holder a good solution to fetch the rules'
value? Or
is there any better solution?
- How to handle this problem of multiple value association to the
holder, so
I still can get all the values without one overwriting the other and
they
are still connected?
Any idea highly appreciated, thanks in advance!
--
View this message in context:
http://www.nabble.com/Fetching-values-of-an-object%27s-attribute-set-by-
different-rules-tp18922201p18922201.html
Sent from the drools - user mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users