Re: [rules-users] Using field values of an ENUM in the decision table

2009-07-11 Thread Visu Nageswaran
better still using in-line eval: when $c: Computer(memory!=null memory.value == 128) then doSomething(); The owners / contributers to the drools-expert code base can comment: Is the check for null necessary when using nested accessors??? Is this something that the engine can take care during

Re: [rules-users] Using field values of an ENUM in the decision table

2009-07-10 Thread Visu Nageswaran
Is the following rule in-valid? when $c: Computer() eval($c.getMemory().getValue() == 512) then System.out.println( THIS IS IT XXX ); ___ Can someone help me understand if eval is used incorrectly to invoke the nested accessor method getValue()? Null pointer

Re: [rules-users] Using field values of an ENUM in the decision table

2009-07-10 Thread Visu Nageswaran
Modifying the eval expression to include a check for NULL got it working: when $c: Computer() eval( $c.getMemory()!=null $c.getMemory().getValue().equals(512) ) then System.out.println( THIS IS IT XXX ); end Visu Nageswaran wrote: Hello, I am posting a simpler version of

[rules-users] Using field values of an ENUM in the decision table

2009-07-08 Thread Visu Nageswaran
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;}

Re: [rules-users] Using field values of an ENUM in the decision table

2009-07-08 Thread Visu Nageswaran
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

Re: [rules-users] Using field values of an ENUM in the decision table

2009-07-08 Thread erik
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

Re: [rules-users] Using field values of an ENUM in the decision table

2009-07-08 Thread Viswanathan Nageswaran
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