Erik,
Thanks for your comment. In your suggestion, you have compared the memory
field with MEM.CONST1 and are setting the price to MEM.value.
But, the requirement is to restrict the field memory with the value of
CONST1 (like 512, 1024, 2048) in the decision table and based on that set
the price which is not really an attribute of the CONST MEM.CONST1 (so
MEM.getValue() doesn't fetch the price), but is a set of pre defined values
mapped to the actual memory values.
If someone in this group has used ENUMs in Decision tables, I would be very
interested in those examples. Can you share the same? Please.
Thanks in advance,
-Visu
<erik(a)clairiot.co
m>
Sent by: To
rules-users-bounc Rules Users List
es(a)lists.jboss.or <rules-users(a)lists.jboss.org>
g cc
Subject
08/07/2009 22:55 Re: [rules-users] Using field
values of an ENUM in the decision
table
Please respond to
Rules Users List
<rules-users@list
s.jboss.org>
Are you sure you have to have a Memory object inserted as a fact ?
Don't this rule works (not tested and I'm so not a drools expert)
rule "memory"
when
$c : Computer(memory == MEM1 || memory == MEM2 || memory == MEM3)
then
modify($c) { setPrice(MEM1.getValue() };
end
On Wed, 8 Jul 2009 09:50:16 -0700 (PDT), Visu Nageswaran
<visu.nageswaran(a)in.ibm.com> wrote:
I was able to achieve this using a join-column in the decision table
equivalent to the below rule:
WHEN $m: Memory(value == "512") $c: Computer(memory == $m)
THEN modify($c){ setPrice(100) };
However, a Memory instance needs to be inserted into the session. For
every
discrete valued field, it would then be required for them to be
inserted
into the session to be considered in rule propogation. If there is a
better
way / simpler way, I am very interested. Thanks in advance..
Visu Nageswaran wrote:
>
> Hello, I am posting a simpler version of the actual requirement:
> Class Computer has a field 'memory' of the enum type 'Memory' which
is
> defined over integer values
> - - - - - - - - - -
> public enum Memory{
> MEM1(512), MEM2(1024), MEM3(2048);
> public int value;
> Memory(int i){this.value = i;}
> public int getValue(){return value;}
> }
> - - - - - - - - - -
> There is a requirement to model a decision table between memory and
price
>
> I am looking for the field constraint on the memory field to match to
the
> values:
>
> memory.???--> Price
> 512 --> 100
> 1024 --> 200
> 2048 --> 300
>
> I tried memory.name, memory.name(), memory.value, memory.getValue();
Does
> this have to be done using template expressions say something
like
memory
> == Memory.reverseLookupEnum($param)
>
> Any help, pointers in this regard would be appreciated. thanks.
> -Visu
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users