Here is how I have solved it..
CONDITION
$c: ConditionObject
/* $1 */
Got Object
YES
YES
YES
YES
and that produces ..
when
$c: ConditionObject(/* YES */)
for every rule where there is a "YES". I didn't want to overcomplicate the
test for Drools .. i.e. : Object() is sufficient
-== Some other things I found ==-
I found a behaviour about rule generation which was not expected.
a CONDITION can have nothing in the "Object row" (the first row down).. that is
good.
and the code in the "code" row, (next row after) will be put in the When ..
nice.
ie:
CONDITION
$c : ConditionObject( /* $1 */ )
Description
YES
YES
What is unexpected is that .. these "rules" get reordered such that, if they are
at the from (column A) and there is a CONDITION in column B that looks like
CONDITION
$e: FieldObject( ) from $c.field
aField
Description
A
B
the rule will look like
when
$e: FieldObject( aField == "A" ) from $c.field
$c: ConditionObject( /* YES */ )
This occurs (looking at the source code :
https://github.com/droolsjbpm/drools/blob/master/drools-decisiontables/sr...)
because it adds each "CONDITION" into a list on a row by row basis; It will add
the CONDITION in column B first, before the Condition in Column A because there is no data
in Column "A",first cell.
hope that helps someone somewhere
Ramon Buckland
ramon(a)thebuckland.com
On 22 May 2013, at 12:18, Ramon Buckland <ramon(a)thebuckland.com> wrote:
Hi,
Thanks for the response.
That doesn't seem to be right - this is what is produced from the Compiler.
// rule values at A9, header at A3
rule "Test rule_9"
when
$c : ConditionObject(somefield)
$a : ActionObject(this != null == "X")
EmbeddedObject(myField == AnEnum.SomeOtherValue) from $c.embedded
then
ActionObject.someMethod2(50);
$a.someMethod("someOtherValue")
$a.someMethod3(B)
end
Is there a way to have a "when" rule produced where the data table row, for
that CONDITION is empty ?
The hack version I can work out is
> CONDITION
> $a : ActionObject
> $param != null
> this
> this
Ramon Buckland
ramon(a)thebuckland.com
On 22 May 2013, at 10:33, Michael Anstis <michael.anstis(a)gmail.com> wrote:
> Add an additional CONDITION for ActionObject.
>
> You'll need to probably add a constraint for "this != null" and put an
X in the rows; e.g.
>
> CONDITION
> $a : ActionObject
> this != null
> X
> X
>
>
>
>
> On 22 May 2013 09:55, Ramon Buckland <ramon(a)thebuckland.com> wrote:
> Hi.
>
> I am working on Drools 5.5.0.Final and have a question regarding XLS and a Decision
Table structure,
>
> I have a ConditionObject and an ActionObject and wanted to know or see an example for
XLS that produces a "does exist" for the ActionObject
> in the when.
>
> I can simply write the rule in a DRL, but translating how to make the XLS compiler
create the same is proving challenging.
>
> An example:
>
> I want to produce a set of rules like below
>
> rule "Test rule_11"
> when
> $c : ConditionObject( somefield )
> EmbeddedObject(myField == AnEnum.SomeValue) from $c.embedded
> $a : ActionObject( )
> then
> $a.someMethod("value")
> $a.someMethod2(10)
> $a.someMethod3("A")
> end
>
> rule "Test rule_12"
> // some other AnEnum checks.
>
> What I can't work out is how I get the test of "existence" of the
Action Object into the "when" for the rule, so that I can "use" the
Object in the ACTION.
> In addition, is there a away that I can avoid needing a whole column just for
"existence of an object with a field.. collect as a variable $c : (ConditionObject(
somefield )" ?
>
> CONDITION CONDITION ACTION ACTION ACTION
> $c : ConditionObject EmbeddedObject() from $c.embedded
> $param myField ==
AnEnum.$param $a.someMethod("$param") $a.someMethod2($param) $a.someMethod3($param)
>
"Description" "Description" "Description" "Description" "Description"
> somefield SomeValue value 10 A
> somefield SomeOtherValue someOtherValue 50 B
>
> This is the XLS of the above.
>
>
https://www.dropbox.com/s/lw3zb5hwtjdbpcm/sample_rules.xls?v=1scns
>
> When this sheet is compiled, I get the following: How do I setup a
"condition" for ActionObject to get in the when ?
>
> package packageName;
> //generated from Decision Table
> // rule values at A8, header at A3
> rule "Test rule_8"
> when
> $c : ConditionObject(somefield)
> EmbeddedObject(myField == AnEnum.SomeValue) from $c.embedded
> then
> $a.someMethod("value")
> $a.someMethod2(10)
> $a.someMethod3(A)
> end
>
> // rule values at A9, header at A3
> rule "Test rule_9"
> when
> $c : ConditionObject(somefield)
> EmbeddedObject(myField == AnEnum.SomeOtherValue) from $c.embedded
> then
> $a.someMethod("someOtherValue")
> $a.someMethod2(50)
> $a.someMethod3(B)
> end
>
>
>
>
> Ramon Buckland
> ramon(a)thebuckland.com
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users