JBoss Community

Re: JBPM 5: Workflow not leaving embedded sub process

created by Robert de Lorimier in jBPM - View the full discussion

I looked at all of the gateways, and other than the first divergent gateway, all the others were set to XOR. Here is the bpmn:

 

<?xml version="1.0" encoding="UTF-8"?>

<definitions id="Definition"

             targetNamespace="http://www.jboss.org/drools"

             typeLanguage="http://www.java.com/javaTypes"

             expressionLanguage="http://www.mvel.org/2.0"

             xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"

             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

             xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd"

             xmlns:g="http://www.jboss.org/drools/flow/gpd"

             xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"

             xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"

             xmlns:di="http://www.omg.org/spec/DD/20100524/DI"

             xmlns:tns="http://www.jboss.org/drools">

 

  <itemDefinition id="_2-ruleStateItem" structureRef="String" />

 

  <process processType="Private" isExecutable="true" id="workflow" name="Rule Workflow Process" tns:packageName="defaultPackage" >

 

    <laneSet>

      <lane name="ruleState" >

      </lane>

      <lane name="ruleId" >

      </lane>

    </laneSet>

    <!-- nodes -->

    <startEvent id="_1" name="Start Process" />

    <subProcess id="_2" name="Approval Process"  >

    <!-- variables -->

    <property id="ruleState" itemSubjectRef="_2-ruleStateItem"/>

    <!-- nodes -->

    <startEvent id="_2-1" name="Start" />

    <exclusiveGateway id="_2-2" name="Gateway" gatewayDirection="Converging" />

    <userTask id="_2-3" name="Submit for Approval" >

      <ioSpecification>

        <dataInput id="_2-3_CommentInput" name="Comment" />

        <dataInput id="_2-3_SkippableInput" name="Skippable" />

        <dataInput id="_2-3_TaskNameInput" name="TaskName" />

        <inputSet>

          <dataInputRefs>_2-3_CommentInput</dataInputRefs>

          <dataInputRefs>_2-3_SkippableInput</dataInputRefs>

          <dataInputRefs>_2-3_TaskNameInput</dataInputRefs>

        </inputSet>

        <outputSet>

        </outputSet>

      </ioSpecification>

      <dataInputAssociation>

        <targetRef>_2-3_CommentInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Task to submit the draft rule</from>

          <to xsi:type="tFormalExpression">_2-3_CommentInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_2-3_SkippableInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">true</from>

          <to xsi:type="tFormalExpression">_2-3_SkippableInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_2-3_TaskNameInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Submit for Approval</from>

          <to xsi:type="tFormalExpression">_2-3_TaskNameInput</to>

        </assignment>

      </dataInputAssociation>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>submitter</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

    </userTask>

    <parallelGateway id="_2-4" name="Gateway" gatewayDirection="Diverging" />

    <userTask id="_2-5" name="Approve Rule" >

      <extensionElements>

        <tns:onExit-script scriptFormat="http://www.java.com/java">

          <script>org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

 

process.setVariable("ruleState", "LIVE");</script>

        </tns:onExit-script>

      </extensionElements>

      <ioSpecification>

        <dataInput id="_2-5_CommentInput" name="Comment" />

        <dataInput id="_2-5_SkippableInput" name="Skippable" />

        <dataInput id="_2-5_TaskNameInput" name="TaskName" />

        <inputSet>

          <dataInputRefs>_2-5_CommentInput</dataInputRefs>

          <dataInputRefs>_2-5_SkippableInput</dataInputRefs>

          <dataInputRefs>_2-5_TaskNameInput</dataInputRefs>

        </inputSet>

        <outputSet>

        </outputSet>

      </ioSpecification>

      <dataInputAssociation>

        <targetRef>_2-5_CommentInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Approve the rule</from>

          <to xsi:type="tFormalExpression">_2-5_CommentInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_2-5_SkippableInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">true</from>

          <to xsi:type="tFormalExpression">_2-5_SkippableInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_2-5_TaskNameInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Approve Rule</from>

          <to xsi:type="tFormalExpression">_2-5_TaskNameInput</to>

        </assignment>

      </dataInputAssociation>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>approver</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>appUser</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

    </userTask>

    <userTask id="_2-6" name="Reject Rule" >

      <extensionElements>

        <tns:onExit-script>

          <script>org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

 

process.setVariable("ruleState", "DRAFT");</script>

        </tns:onExit-script>

      </extensionElements>

      <ioSpecification>

        <dataInput id="_2-6_CommentInput" name="Comment" />

        <dataInput id="_2-6_SkippableInput" name="Skippable" />

        <dataInput id="_2-6_TaskNameInput" name="TaskName" />

        <inputSet>

          <dataInputRefs>_2-6_CommentInput</dataInputRefs>

          <dataInputRefs>_2-6_SkippableInput</dataInputRefs>

          <dataInputRefs>_2-6_TaskNameInput</dataInputRefs>

        </inputSet>

        <outputSet>

        </outputSet>

      </ioSpecification>

      <dataInputAssociation>

        <targetRef>_2-6_CommentInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Reject the rule</from>

          <to xsi:type="tFormalExpression">_2-6_CommentInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_2-6_SkippableInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">true</from>

          <to xsi:type="tFormalExpression">_2-6_SkippableInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_2-6_TaskNameInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Reject Rule</from>

          <to xsi:type="tFormalExpression">_2-6_TaskNameInput</to>

        </assignment>

      </dataInputAssociation>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>approver</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>appUser</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

    </userTask>

    <exclusiveGateway id="_2-7" name="Gateway" gatewayDirection="Converging" />

    <exclusiveGateway id="_2-8" name="approveDecision" gatewayDirection="Diverging" />

    <endEvent id="_2-9" name="FinishSubProcess" />

    <!-- connections -->

    <sequenceFlow id="_2-1-_2-2" sourceRef="_2-1" targetRef="_2-2" />

    <sequenceFlow id="_2-8-_2-2" sourceRef="_2-8" targetRef="_2-2" name="Rejected" tns:priority="1" >

      <conditionExpression xsi:type="tFormalExpression" >org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

 

if (((String)process.getVariable("ruleState")).equals("DRAFT"))

{

    System.out.println("Rule rejected and staying DRAFT. Back to the beginning");

    return true;

}

else

{

    return false;

}</conditionExpression>

    </sequenceFlow>

    <sequenceFlow id="_2-2-_2-3" sourceRef="_2-2" targetRef="_2-3" />

    <sequenceFlow id="_2-3-_2-4" sourceRef="_2-3" targetRef="_2-4" />

    <sequenceFlow id="_2-4-_2-5" sourceRef="_2-4" targetRef="_2-5" />

    <sequenceFlow id="_2-4-_2-6" sourceRef="_2-4" targetRef="_2-6" />

    <sequenceFlow id="_2-6-_2-7" sourceRef="_2-6" targetRef="_2-7" />

    <sequenceFlow id="_2-5-_2-7" sourceRef="_2-5" targetRef="_2-7" />

    <sequenceFlow id="_2-7-_2-8" sourceRef="_2-7" targetRef="_2-8" />

    <sequenceFlow id="_2-8-_2-9" sourceRef="_2-8" targetRef="_2-9" name="Go live" tns:priority="1" >

      <conditionExpression xsi:type="tFormalExpression" >org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

 

if (((String)process.getVariable("ruleState")).equals("LIVE"))

{

    System.out.println("Rule approved and going LIVE");

    return true;

}

else

{

    return false;

}</conditionExpression>

    </sequenceFlow>

    </subProcess>

    <userTask id="_3" name="Modify Rule" >

      <extensionElements>

        <tns:onExit-script scriptFormat="http://www.java.com/java">

          <script>org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

 

process.setVariable("ruleState", "DRAFT");</script>

        </tns:onExit-script>

      </extensionElements>

      <ioSpecification>

        <dataInput id="_3_CommentInput" name="Comment" />

        <dataInput id="_3_SkippableInput" name="Skippable" />

        <dataInput id="_3_TaskNameInput" name="TaskName" />

        <inputSet>

          <dataInputRefs>_3_CommentInput</dataInputRefs>

          <dataInputRefs>_3_SkippableInput</dataInputRefs>

          <dataInputRefs>_3_TaskNameInput</dataInputRefs>

        </inputSet>

        <outputSet>

        </outputSet>

      </ioSpecification>

      <dataInputAssociation>

        <targetRef>_3_CommentInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Modify the rule</from>

          <to xsi:type="tFormalExpression">_3_CommentInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_3_SkippableInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">true</from>

          <to xsi:type="tFormalExpression">_3_SkippableInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_3_TaskNameInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Modify Rule</from>

          <to xsi:type="tFormalExpression">_3_TaskNameInput</to>

        </assignment>

      </dataInputAssociation>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>submitter</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>editor</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

    </userTask>

    <endEvent id="_4" name="End" >

        <terminateEventDefinition/>

    </endEvent>

    <exclusiveGateway id="_5" name="Gateway" gatewayDirection="Converging" />

    <parallelGateway id="_6" name="Gateway" gatewayDirection="Diverging" />

    <exclusiveGateway id="_7" name="Gateway" gatewayDirection="Converging" />

    <exclusiveGateway id="_8" name="Gateway" gatewayDirection="Diverging" />

    <userTask id="_9" name="Start Workflow" >

      <extensionElements>

        <tns:onExit-script scriptFormat="http://www.java.com/java">

          <script>System.out.println("Start Workflow triggered");</script>

        </tns:onExit-script>

      </extensionElements>

      <ioSpecification>

        <dataInput id="_9_CommentInput" name="Comment" />

        <dataInput id="_9_SkippableInput" name="Skippable" />

        <dataInput id="_9_TaskNameInput" name="TaskName" />

        <dataInput id="_9_GroupIdInput" name="GroupId" />

        <inputSet>

          <dataInputRefs>_9_CommentInput</dataInputRefs>

          <dataInputRefs>_9_SkippableInput</dataInputRefs>

          <dataInputRefs>_9_TaskNameInput</dataInputRefs>

          <dataInputRefs>_9_GroupIdInput</dataInputRefs>

        </inputSet>

        <outputSet>

        </outputSet>

      </ioSpecification>

      <dataInputAssociation>

        <targetRef>_9_CommentInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Starts the workflow</from>

          <to xsi:type="tFormalExpression">_9_CommentInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_9_SkippableInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">false</from>

          <to xsi:type="tFormalExpression">_9_SkippableInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_9_TaskNameInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression">Start Workflow</from>

          <to xsi:type="tFormalExpression">_9_TaskNameInput</to>

        </assignment>

      </dataInputAssociation>

      <dataInputAssociation>

        <targetRef>_9_GroupIdInput</targetRef>

        <assignment>

          <from xsi:type="tFormalExpression"></from>

          <to xsi:type="tFormalExpression">_9_GroupIdInput</to>

        </assignment>

      </dataInputAssociation>

      <potentialOwner>

        <resourceAssignmentExpression>

          <formalExpression>appUser</formalExpression>

        </resourceAssignmentExpression>

      </potentialOwner>

    </userTask>

 

    <!-- connections -->

    <sequenceFlow id="_6-_2" sourceRef="_6" targetRef="_2" />

    <sequenceFlow id="_6-_3" sourceRef="_6" targetRef="_3" />

    <sequenceFlow id="_8-_4" sourceRef="_8" targetRef="_4" name="Finish workflow" >

      <conditionExpression xsi:type="tFormalExpression" >org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

System.out.println("Rule state is now " + ((String)process.getVariable("ruleState")));

 

if (((String)process.getVariable("ruleState")).equals("LIVE"))

{

    System.out.println("Finish workflow");

    return true;

}

else

{

    return false;

}</conditionExpression>

    </sequenceFlow>

    <sequenceFlow id="_3-_5" sourceRef="_3" targetRef="_5" />

    <sequenceFlow id="_2-_5" sourceRef="_2" targetRef="_5" />

    <sequenceFlow id="_7-_6" sourceRef="_7" targetRef="_6" />

    <sequenceFlow id="_8-_7" sourceRef="_8" targetRef="_7" name="Return to start" >

      <conditionExpression xsi:type="tFormalExpression" >org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

System.out.println("Rule state is now " + ((String)process.getVariable("ruleState")));

 

if (((String)process.getVariable("ruleState")).equals("DRAFT"))

{

    System.out.println("Go back to start");

    return true;

}

else

{

    return false;

}</conditionExpression>

    </sequenceFlow>

    <sequenceFlow id="_9-_7" sourceRef="_9" targetRef="_7" />

    <sequenceFlow id="_5-_8" sourceRef="_5" targetRef="_8" />

    <sequenceFlow id="_1-_9" sourceRef="_1" targetRef="_9" />

 

  </process>

 

  <bpmndi:BPMNDiagram>

    <bpmndi:BPMNPlane bpmnElement="workflow" >

      <bpmndi:BPMNShape bpmnElement="_1" >

        <dc:Bounds x="236" y="12" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2" >

        <dc:Bounds x="360" y="191" width="607" height="502" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-1" >

        <dc:Bounds x="456" y="220" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-2" >

        <dc:Bounds x="458" y="315" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-3" >

        <dc:Bounds x="406" y="400" width="153" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-4" >

        <dc:Bounds x="458" y="488" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-5" >

        <dc:Bounds x="435" y="609" width="100" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-6" >

        <dc:Bounds x="573" y="490" width="100" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-7" >

        <dc:Bounds x="737" y="611" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-8" >

        <dc:Bounds x="732" y="319" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_2-9" >

        <dc:Bounds x="895" y="318" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_3" >

        <dc:Bounds x="90" y="326" width="100" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_4" >

        <dc:Bounds x="40" y="726" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_5" >

        <dc:Bounds x="118" y="640" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_6" >

        <dc:Bounds x="236" y="181" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_7" >

        <dc:Bounds x="41" y="187" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_8" >

        <dc:Bounds x="40" y="640" width="48" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNShape bpmnElement="_9" >

        <dc:Bounds x="210" y="102" width="100" height="48" />

      </bpmndi:BPMNShape>

      <bpmndi:BPMNEdge bpmnElement="_2-1-_2-2" >

        <di:waypoint x="120" y="53" />

        <di:waypoint x="122" y="148" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-8-_2-2" >

        <di:waypoint x="396" y="152" />

        <di:waypoint x="122" y="148" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-2-_2-3" >

        <di:waypoint x="122" y="148" />

        <di:waypoint x="122" y="233" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-3-_2-4" >

        <di:waypoint x="122" y="233" />

        <di:waypoint x="122" y="321" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-4-_2-5" >

        <di:waypoint x="122" y="321" />

        <di:waypoint x="125" y="442" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-4-_2-6" >

        <di:waypoint x="122" y="321" />

        <di:waypoint x="263" y="323" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-6-_2-7" >

        <di:waypoint x="263" y="323" />

        <di:waypoint x="401" y="444" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-5-_2-7" >

        <di:waypoint x="125" y="442" />

        <di:waypoint x="401" y="444" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-7-_2-8" >

        <di:waypoint x="401" y="444" />

        <di:waypoint x="396" y="152" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-8-_2-9" >

        <di:waypoint x="396" y="152" />

        <di:waypoint x="559" y="151" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_6-_2" >

        <di:waypoint x="260" y="205" />

        <di:waypoint x="663" y="442" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_6-_3" >

        <di:waypoint x="260" y="205" />

        <di:waypoint x="140" y="350" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_8-_4" >

        <di:waypoint x="64" y="664" />

        <di:waypoint x="64" y="750" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_3-_5" >

        <di:waypoint x="140" y="350" />

        <di:waypoint x="142" y="664" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_2-_5" >

        <di:waypoint x="663" y="442" />

        <di:waypoint x="142" y="664" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_7-_6" >

        <di:waypoint x="65" y="211" />

        <di:waypoint x="260" y="205" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_8-_7" >

        <di:waypoint x="64" y="664" />

        <di:waypoint x="65" y="211" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_9-_7" >

        <di:waypoint x="260" y="126" />

        <di:waypoint x="65" y="211" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_5-_8" >

        <di:waypoint x="142" y="664" />

        <di:waypoint x="64" y="664" />

      </bpmndi:BPMNEdge>

      <bpmndi:BPMNEdge bpmnElement="_1-_9" >

        <di:waypoint x="260" y="36" />

        <di:waypoint x="260" y="126" />

      </bpmndi:BPMNEdge>

    </bpmndi:BPMNPlane>

  </bpmndi:BPMNDiagram>

 

</definitions>

Reply to this message by going to Community

Start a new discussion in jBPM at Community