[rules-users] Check a set of objects for a value?

Wolfgang Laun wolfgang.laun at gmail.com
Wed Feb 13 10:20:34 EST 2013


See inline.

On 13/02/2013, Patrick <patrick.kelley at anixter.com> wrote:
> Hello,
>
> This is my current drool rule:
>
> rule "RULE1"
> 	when
> 		context : StaticTaskContext(
> 			taskToPerform.name == "TRANSFER",
> 			deallocatedOrder == true,
> 			currentTask != null
> 		)
> 	then
> 		context.setRuleResult("STAYPUT");
> end
>
> What I need to do is check to see if the predecessor task is of a certain
> value.
>
> ie:
> currentTask.getPredecessorTaskChains().iterate().next().getPredecessorTask.getTaskType()
> ==  "VALUE"
>

I'm not aware of an *iterate()* method, I guess you mean iterator()?

Almost certainly, this condition does not describe what you want - it
just compares the first set element's predecessorTask.taskType.

But, again, I guess what you need:

rule "test type"
when
    StaticTaskContext( $ct: currentTask != null )
    TaskChain( predecessorTask.getTaskType() ==  "VALUE" )
       from $ct.getPredecessorTaskChains()
then
...
end

This may fire repeatedly if there is more than one match - don't know
whether this is posible.

-W

> The predecessorTaskChain is declared as:
> private Set<TaskChain> predecessorTaskChains;
>
> How can I go through all the task chains on the current task?
>
> Thanks
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Check-a-set-of-objects-for-a-value-tp4022277.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list