cancel
Showing results for 
Search instead for 
Did you mean: 

global definition for serviceTask and ReceiveTask

clever
Champ in-the-making
Champ in-the-making
Hi, how can i declare a receiveTask and a serviceTask globaly? i'm having an issue when calling a task that's already defined in a different subprocess as follows:



<startEvent id="start" />
      
   <sequenceFlow id="flow1" sourceRef="start" targetRef="initiate" />
   
   <serviceTask id="initiate" name="Init" activiti:class="com.activiti.ActivitiServiceTask" />
   <sequenceFlow id="flow2" sourceRef="initiate" targetRef="decision" />
   <exclusiveGateway id="bigDecision" name="pick flow A or B"/>

…. define A   
   <sequenceFlow id="flow3" sourceRef="bigDecision" targetRef="FLOW_A" >
      <conditionExpression>${service.evaluate(execution, "isWFA")}</conditionExpression>
   </sequenceFlow>
   
   <serviceTask id="FLOW_A" name="WFA" activiti:class="com.activiti.ActivitiServiceTask" />          
   <sequenceFlow id="flowA1" sourceRef="FLOW_A" targetRef="FLOW_A_SubProcess" />
   <sequenceFlow id="flowA2" sourceRef="FLOW_A_SubProcess" targetRef="decisionEnd" />          
         
   <subProcess id="FLOW_A_SubProcess" name="Handle Sub-Process">
      <startEvent id="startA" />
         <exclusiveGateway id="decisionA" name="Make decision A"  />
         <exclusiveGateway id="decisionAEnd" name="END decision A" />
      <endEvent id="StartAEnd" />

      <sequenceFlow id="flowA3" sourceRef="FLOW_A_SubProcess" targetRef="decisionA" />
      <sequenceFlow id="flowA4" sourceRef="decisionA" targetRef="createProcess" >
         <conditionExpression>${service.evaluate(execution, "isA")}</conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="flowA5" sourceRef="createProcess" targetRef="completeProcess" />
      <sequenceFlow id="flowA6" sourceRef="completeProcess" targetRef="decisionAEnd" />

      <sequenceFlow id="flowAEnd" sourceRef="decisionAEnd" targetRef="StartAEnd" />
   </subProcess>

….. now define B
   <sequenceFlow id="flow4" sourceRef="bigDecision" targetRef="FLOW_B" >
      <conditionExpression>${service.evaluate(execution, "isWFB")}</conditionExpression>
   </sequenceFlow>
   
   <serviceTask id="FLOW_B" name="WFB" activiti:class="com.activiti.ActivitiServiceTask" />          
   <sequenceFlow id="flowB1" sourceRef="FLOW_B" targetRef="FLOW_B_SubProcess" />
   <sequenceFlow id="flowB2" sourceRef="FLOW_B_SubProcess" targetRef="decisionEnd" />          
         
   <subProcess id="FLOW_B_SubProcess" name="Handle Sub-Process B">
      <startEvent id="startB" />
         <exclusiveGateway id="decisionB" name="Make decision B"  />
         <serviceTask id="createProcess" name="Create process for B" activiti:class="com.package.activiti.ActivitiServiceTask" />
         <receiveTask id="completeProcess" name="Complete process for B" />
         <exclusiveGateway id="decisionBEnd" name="END decision B" />
      <endEvent id="StartBEnd" />

      <sequenceFlow id="flowB3" sourceRef="FLOW_B_SubProcess" targetRef="decisionB" />

      <sequenceFlow id="flowB4" sourceRef="decisionB" targetRef="createProcess" >
         <conditionExpression>${service.evaluate(execution, "isB")}</conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="flowB5" sourceRef="createProcess" targetRef="completeProcess" />
      <sequenceFlow id="flowB6" sourceRef="completeProcess" targetRef="decisionBEnd" />

      <sequenceFlow id="flowBEnd" sourceRef="decisionBEnd" targetRef="StartBEnd" />
   </subProcess>
…. continue


the same code will be called by createProcess and completeProcess, this will throw an error that flowA5 cannot find createProcess. If I define it in A then subprocess B will throw an error saying it's already defined… then how do i define it globaly?

I tried defining the subprocess in a different file but i'm unable to call a different XML. See post http://forums.activiti.org/content/callactivity-doesnt-work-when-calling-another-xml

So i'm stuck trying to make it work within the same XML.

any help will be greatly appreciated.
1 REPLY 1

trademak
Star Contributor
Star Contributor
BPMN doesn't allow you to define the same element twice and there's not global definition either. But a call activity would make sense here. The problem you are having with that is that a sub process called by a call activity doesn't share the parent process instance variables. You have to pass the variables to the sub process explicitly.

Best regards,