[rules-users] Action Object and Condition Object in XLS DTABLE

Ramon Buckland ramon at thebuckland.com
Wed May 22 04:55:37 EDT 2013


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 at thebuckland.com



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130522/757812b9/attachment-0001.html 


More information about the rules-users mailing list