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

Ramon Buckland ramon at thebuckland.com
Wed May 22 07:18:40 EDT 2013


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



On 22 May 2013, at 10:33, Michael Anstis <michael.anstis at 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 at 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 at thebuckland.com
> 
> 
> 
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

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


More information about the rules-users mailing list