This content has been marked as final.
Show 2 replies
-
1. Re: Round trip process to task variable mapping
msandoz May 31, 2007 10:30 AM (in response to msandoz)heres an example of one of the things im trying to do - is there a better way to get the variables into the process context from the xml? also it doesnt seem to be pulling them in the EL further down in the script.
the action is pretty basic - just jython-executes the code.<?xml version="1.0" encoding="UTF-8"?> <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="simple"> <swimlane name="automated"></swimlane> <event type="process-start"> <script>token.getProcessInstance().getContextInstance().createVariable("reusableCode", "print 'foo';");</script> </event> <start-state name="start"> <transition name="" to="jython"></transition> </start-state> <node name="jython"> <action class="com.nexusbpm.services.jython.JythonService"> <jythonCode>#{contextInstance.variable[reusableCode]}</jythonCode> </action> <transition name="j2" to="jython2"> </transition> </node> <node name="jython2"> <action class="com.nexusbpm.services.jython.JythonService"> <jythonCode>#{contextInstance.variable[reusableCode]}</jythonCode> </action> <transition name="toEnd" to="end"></transition> </node> <end-state name="end"></end-state> </process-definition>
-
2. Re: Round trip process to task variable mapping
msandoz Jun 1, 2007 10:56 AM (in response to msandoz)looking at old posts this topic has been addressed under dataflow and "Add support for specifying process context variable values in the process definition xml"
this is what ive come up with for my situation and id like to know if the solution is reasonable or if there are capabilities of jbpm that im not using through ignorance.
anyway heres what ive done so far:
an xsd for validating data maps<?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.nexusbpm.org/JbpmDataFlowSchema" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:df="http://www.nexusbpm.org/JbpmDataFlowSchema"> <xsd:complexType name="mappingsType"> <xsd:sequence minOccurs="0" maxOccurs="unbounded"> <xsd:element name="mapping" type="df:mappingType"></xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="mappingType"> <xsd:sequence minOccurs="0" maxOccurs="1"> <xsd:any namespace="##any" minOccurs="0" maxOccurs="unbounded" processContents="lax"/> </xsd:sequence> <xsd:attribute name="name" type="xsd:string" use="required"></xsd:attribute> <xsd:attribute name="source" type="xsd:string" use="optional"></xsd:attribute> <xsd:attribute name="destination" type="xsd:string" use="optional"> </xsd:attribute> </xsd:complexType> <xsd:element name="mappings" type="df:mappingsType"> <xsd:unique name="oneMapPerName"> <xsd:selector xpath="df:mapping"/> <xsd:field xpath="@name"/> </xsd:unique> </xsd:element> </xsd:schema>
an example of a data map that would be embedded in a node variable:<df:mappings xmlns:df="http://www.nexusbpm.org/JbpmDataFlowSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nexusbpm.org/JbpmDataFlowSchema JbpmDataFlowSchema.xsd " > <df:mapping name="localvar1" source="processvarname" /> <df:mapping name="localvar2">embedded data</df:mapping> <df:mapping name="outvar1" destination="destvar"/> </df:mappings>
for the jpdl i would use something like in the JIRA ticket:<process-state name="p"> <event type="node-enter"> <script> <variable name="myvariable" access="write" /> <expression>myvariable = "myvalue"</expression> </script> </event>
or another alternative that seems to work for a process variable:<script> executionContext.setVariable("jythonCode", "print 'foo';"); </script> </event>
an in-place example of mapping would be:<node name="jython2"> <action class="com.nexusbpm.services.jython.JythonService"> <mappings> <mapping name="jythonCode">print 'foo';</mapping> <mapping name="output" destination="output"/> <mapping name="error" destination="error"/> </mappings> </action> <transition name="toEnd" to="end"></transition> </node>
and then a base class for all my node types that will take the initialized mappings and turn them into local variables for use by the subclasses.