Hello there,
I wanted to refer to a variable in a split constraint in a ForEach node.
What is the correct way to nest a split node in a ForEach node and refer
to the variable of the collection?
I have tried the following:
a) Start process and insert process into session, providing the map
containing the collectionExpression. Using:
<import name="org.drools.runtime.process.WorkflowProcessInstance"/>
processIntance: WorkflowProcessInstance()
$item: MyObject: (this == (processInstance.getVariable("item")))
this doesn't seem to grab the variable like I expected it to.
How can I assign processInstance.getVariable("item") itself to a variable?
(I imagine this would work if this did)
b) Set the variable on the global process from the current context
kcontext.getProcessInstance().setVariable("item",
kcontext.getVariable("item")
I know this is not the right answer.
c) Insert the item in an action at the beginning of the loop. Retract it
at the end. I then match against the item of type MyObject at the
beginning.
// in action:
insert(item)
// in constraint
$item: MyObject()
// after action
retract(item)
This requires looping in Java to start the processes individually and
setting the variable explicitly each time.
This seems a bit of a roundabout way of doing it, what is *the* correct
method?
Thanks,
This message may contain confidential and privileged information and is intended solely
for the use of the named addressee. Access, copying or re-use of the e-mail or any
information contained therein by any other person is not authorised. If you are not the
intended recipient please notify us immediately by returning the e-mail to the originator
and then immediately delete this message. Although we attempt to sweep e-mail and
attachments for viruses, we do not guarantee that either are virus-free and accept no
liability for any damage sustained as a result of viruses.
Please refer to
http://www.bnymellon.com/disclaimer/piml.html for certain disclosures.