0 Replies Latest reply on Jun 5, 2012 1:24 PM by marcosdutto

    Converge tasks dynamically

    marcosdutto

      I have this diagram:

      modelo.png

      At the beginning of the process i don't kno hoy many tasks of Solicitud i will have in runtime so i make this construction to create more than one "solicitud". The flow "otra solicitud?" is a conditional and it is apply N times.

      I want to converge two instance of the task "Solicitud" into one instance of the task "Orden". While in the diagram ther is only one flow from Solicitud to Orden in runtime there are more than one and i want to join that instances of the flow into one Orden flow.

       

       

      How can i do it? Ther is any construction that help me?

       

      Thanks

       

      Here is the .bpmn code

       

       

      <?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">
      
        <process processType="Private" isExecutable="true" id="comprasGecos" name="Sample Process" tns:packageName="defaultPackage" >
      
          <extensionElements>
           <tns:import name="com.sample.TerminoHandler" />
          </extensionElements>
          <!-- nodes -->
          <startEvent id="_1" name="StartProcess" />
          <exclusiveGateway id="_2" name="Converge1" gatewayDirection="Converging" />
          <userTask id="_3" name="Solicitud" >
            <ioSpecification>
              <dataInput id="_3_TaskNameInput" name="TaskName" />
              <inputSet>
                <dataInputRefs>_3_TaskNameInput</dataInputRefs>
              </inputSet>
              <outputSet>
              </outputSet>
            </ioSpecification>
            <dataInputAssociation>
              <targetRef>_3_TaskNameInput</targetRef>
              <assignment>
                <from xsi:type="tFormalExpression">Solicitud</from>
                <to xsi:type="tFormalExpression">_3_TaskNameInput</to>
              </assignment>
            </dataInputAssociation>
            <potentialOwner>
              <resourceAssignmentExpression>
                <formalExpression>mary</formalExpression>
              </resourceAssignmentExpression>
            </potentialOwner>
          </userTask>
          <inclusiveGateway id="_4" name="Gateway" gatewayDirection="Diverging" />
          <exclusiveGateway id="_5" name="Converge2" gatewayDirection="Converging" />
          <userTask id="_6" name="Orden" >
            <ioSpecification>
              <dataInput id="_6_TaskNameInput" name="TaskName" />
              <inputSet>
                <dataInputRefs>_6_TaskNameInput</dataInputRefs>
              </inputSet>
              <outputSet>
              </outputSet>
            </ioSpecification>
            <dataInputAssociation>
              <targetRef>_6_TaskNameInput</targetRef>
              <assignment>
                <from xsi:type="tFormalExpression">Orden</from>
                <to xsi:type="tFormalExpression">_6_TaskNameInput</to>
              </assignment>
            </dataInputAssociation>
            <potentialOwner>
              <resourceAssignmentExpression>
                <formalExpression>mary</formalExpression>
              </resourceAssignmentExpression>
            </potentialOwner>
          </userTask>
          <inclusiveGateway id="_7" name="Gateway" gatewayDirection="Diverging" />
          <exclusiveGateway id="_8" name="Converge3" gatewayDirection="Converging" />
          <userTask id="_9" name="Recepcion" >
            <ioSpecification>
              <dataInput id="_9_TaskNameInput" name="TaskName" />
              <inputSet>
                <dataInputRefs>_9_TaskNameInput</dataInputRefs>
              </inputSet>
              <outputSet>
              </outputSet>
            </ioSpecification>
            <dataInputAssociation>
              <targetRef>_9_TaskNameInput</targetRef>
              <assignment>
                <from xsi:type="tFormalExpression">Recepcion</from>
                <to xsi:type="tFormalExpression">_9_TaskNameInput</to>
              </assignment>
            </dataInputAssociation>
            <potentialOwner>
              <resourceAssignmentExpression>
                <formalExpression>mary</formalExpression>
              </resourceAssignmentExpression>
            </potentialOwner>
          </userTask>
          <inclusiveGateway id="_10" name="Gateway" gatewayDirection="Diverging" />
          <exclusiveGateway id="_11" name="Converge4" gatewayDirection="Converging" />
          <userTask id="_12" name="Factura" >
            <ioSpecification>
              <dataInput id="_12_TaskNameInput" name="TaskName" />
              <inputSet>
                <dataInputRefs>_12_TaskNameInput</dataInputRefs>
              </inputSet>
              <outputSet>
              </outputSet>
            </ioSpecification>
            <dataInputAssociation>
              <targetRef>_12_TaskNameInput</targetRef>
              <assignment>
                <from xsi:type="tFormalExpression">Factura</from>
                <to xsi:type="tFormalExpression">_12_TaskNameInput</to>
              </assignment>
            </dataInputAssociation>
            <potentialOwner>
              <resourceAssignmentExpression>
                <formalExpression>mary</formalExpression>
              </resourceAssignmentExpression>
            </potentialOwner>
          </userTask>
          <endEvent id="_13" name="End" >
              <terminateEventDefinition/>
          </endEvent>
          <exclusiveGateway id="_14" name="Gateway" gatewayDirection="Diverging" />
      
          <!-- connections -->
          <sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" />
          <sequenceFlow id="_4-_2" sourceRef="_4" targetRef="_2" name="otra solicitud?" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.java.com/java" >System.out.println("Necesito otra solicitud???");
      TerminoHandler th = new TerminoHandler();
      return !th.fin(1);</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_2-_3" sourceRef="_2" targetRef="_3" />
          <sequenceFlow id="_3-_4" sourceRef="_3" targetRef="_4" />
          <sequenceFlow id="_4-_5" sourceRef="_4" targetRef="_5" name="sigo" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.jboss.org/drools/rule" >eval(true)</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_7-_5" sourceRef="_7" targetRef="_5" name="otra orden?" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.java.com/java" >System.out.println("Necesito otra orden?");
      TerminoHandler th = new TerminoHandler();
      return !th.fin(2);</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_5-_6" sourceRef="_5" targetRef="_6" />
          <sequenceFlow id="_6-_7" sourceRef="_6" targetRef="_7" />
          <sequenceFlow id="_7-_8" sourceRef="_7" targetRef="_8" name="sigo" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.jboss.org/drools/rule" >eval(true)</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_10-_8" sourceRef="_10" targetRef="_8" name="otra recepcion?" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.java.com/java" >System.out.println("Necesito otra recepcion???");
      TerminoHandler th = new TerminoHandler();
      return !th.fin(3);</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_8-_9" sourceRef="_8" targetRef="_9" />
          <sequenceFlow id="_9-_10" sourceRef="_9" targetRef="_10" />
          <sequenceFlow id="_10-_11" sourceRef="_10" targetRef="_11" name="sigo" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.jboss.org/drools/rule" >eval(true)</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_14-_11" sourceRef="_14" targetRef="_11" name="otra factura?" tns:priority="1" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.java.com/java" >System.out.println("Necesito otra factura???");
      TerminoHandler th = new TerminoHandler();
      return !th.fin(4);</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_11-_12" sourceRef="_11" targetRef="_12" />
          <sequenceFlow id="_14-_13" sourceRef="_14" targetRef="_13" name="termino" tns:priority="2" >
            <conditionExpression xsi:type="tFormalExpression" language="http://www.java.com/java" >return true;</conditionExpression>
          </sequenceFlow>
          <sequenceFlow id="_12-_14" sourceRef="_12" targetRef="_14" />
      
        </process>
      
        <bpmndi:BPMNDiagram>
          <bpmndi:BPMNPlane bpmnElement="comprasGecos" >
            <bpmndi:BPMNShape bpmnElement="_1" >
              <dc:Bounds x="47" y="48" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_2" >
              <dc:Bounds x="139" y="48" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_3" >
              <dc:Bounds x="231" y="48" width="100" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_4" >
              <dc:Bounds x="373" y="51" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_5" >
              <dc:Bounds x="468" y="49" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_6" >
              <dc:Bounds x="571" y="46" width="100" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_7" >
              <dc:Bounds x="732" y="48" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_8" >
              <dc:Bounds x="733" y="195" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_9" >
              <dc:Bounds x="575" y="194" width="100" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_10" >
              <dc:Bounds x="471" y="195" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_11" >
              <dc:Bounds x="374" y="194" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_12" >
              <dc:Bounds x="235" y="197" width="100" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_13" >
              <dc:Bounds x="49" y="196" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNShape bpmnElement="_14" >
              <dc:Bounds x="136" y="195" width="48" height="48" />
            </bpmndi:BPMNShape>
            <bpmndi:BPMNEdge bpmnElement="_1-_2" >
              <di:waypoint x="71" y="72" />
              <di:waypoint x="163" y="72" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_4-_2" >
              <di:waypoint x="397" y="75" />
              <di:waypoint x="281" y="131" />
              <di:waypoint x="163" y="72" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_2-_3" >
              <di:waypoint x="163" y="72" />
              <di:waypoint x="281" y="72" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_3-_4" >
              <di:waypoint x="281" y="72" />
              <di:waypoint x="397" y="75" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_4-_5" >
              <di:waypoint x="397" y="75" />
              <di:waypoint x="492" y="73" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_7-_5" >
              <di:waypoint x="756" y="72" />
              <di:waypoint x="626" y="122" />
              <di:waypoint x="492" y="73" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_5-_6" >
              <di:waypoint x="492" y="73" />
              <di:waypoint x="621" y="70" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_6-_7" >
              <di:waypoint x="621" y="70" />
              <di:waypoint x="756" y="72" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_7-_8" >
              <di:waypoint x="756" y="72" />
              <di:waypoint x="757" y="219" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_10-_8" >
              <di:waypoint x="495" y="219" />
              <di:waypoint x="637" y="291" />
              <di:waypoint x="757" y="219" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_8-_9" >
              <di:waypoint x="757" y="219" />
              <di:waypoint x="625" y="218" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_9-_10" >
              <di:waypoint x="625" y="218" />
              <di:waypoint x="495" y="219" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_10-_11" >
              <di:waypoint x="495" y="219" />
              <di:waypoint x="398" y="218" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_14-_11" >
              <di:waypoint x="160" y="219" />
              <di:waypoint x="285" y="282" />
              <di:waypoint x="398" y="218" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_11-_12" >
              <di:waypoint x="398" y="218" />
              <di:waypoint x="285" y="221" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_14-_13" >
              <di:waypoint x="160" y="219" />
              <di:waypoint x="73" y="220" />
            </bpmndi:BPMNEdge>
            <bpmndi:BPMNEdge bpmnElement="_12-_14" >
              <di:waypoint x="285" y="221" />
              <di:waypoint x="160" y="219" />
            </bpmndi:BPMNEdge>
          </bpmndi:BPMNPlane>
        </bpmndi:BPMNDiagram>
      
      </definitions>
      

       

       

      And my TerminoHandler

       

       

      package com.sample;
      
      public class TerminoHandler {
          boolean termino = false;
          static int[] cantidades = {2,3,1,1};
          
          public TerminoHandler(){
          }
          
          public boolean getTermino(){
              return true;
          }
          
          public boolean fin(int index){
              if (cantidades[index -1] == 0){
                  return true;
              }else{
                  cantidades[index -1] --;
                  return false;
              }
          }
      }