cancel
Showing results for 
Search instead for 
Did you mean: 

howto separate process definition from visual metadata

robokaso
Champ in-the-making
Champ in-the-making
Hi,

I'm just starting to work with Activiti and one of the first problems I face is that I don't see a good way how to have a clean activiti process definition xml and use the modeler at the same time.

E.g. when I look at the VacationRequest sample the process definition is quite different in activiti-modeler-examples and in the grails plugin example. Namely the modeler version contains additional bmpndi diagram section (not too bad as it is clearly separated from the process definition) and signavio metadata (mixed in the process element as extensions - wish they were part of the diagram section instead). The grails version takes advantage of the activiti namespace and contains the process definition only so it's more concise and better suited for hand-editing.

Is there a way to have the best of both worlds keeping the process definition close to hand-written style while using the modeler at the same time? Are there any best practices in this regard?

Thanks
Robert

The two process definitions reference above:

VacationRequest from Grails plugin:
<definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.org/bpmn"
   id="definitions" targetNamespace="http://activiti.org/bpmn20">
   <process id="vacationRequest" name="Vacation Request">
      <startEvent id="start" />
      <sequenceFlow id="flow0" targetRef="initiateVacationRequest"
         sourceRef="start" />
      <userTask id="initiateVacationRequest" activiti:formKey="/vacationRequest/create"
         name="Initiate Vacation Request">
         <documentation>Vacation request by ${username}</documentation>
         <potentialOwner>
            <resourceAssignmentExpression>
               <formalExpression>user</formalExpression>
            </resourceAssignmentExpression>
         </potentialOwner>
      </userTask>
      <sequenceFlow id="flow1" targetRef="handleVacationRequest"
         sourceRef="initiateVacationRequest" />
      <userTask id="handleVacationRequest" activiti:formKey="/vacationRequest/approval"
         name="Handle Vacation Request">
         <documentation>Vacation request by ${username}</documentation>
         <potentialOwner>
            <resourceAssignmentExpression>
               <formalExpression>management</formalExpression>
            </resourceAssignmentExpression>
         </potentialOwner>
      </userTask>
      <sequenceFlow id="flow2" targetRef="requestApproved"
         sourceRef="handleVacationRequest" />
      <exclusiveGateway id="requestApproved" name="Request Approved?" />
      <sequenceFlow id="flow3" targetRef="sendConfirmationE-mail"
         sourceRef="requestApproved">
         <conditionExpression xsi:type="tFormalExpression">${vacationApproved}</conditionExpression>
      </sequenceFlow>
      <serviceTask id="sendConfirmationE-mail" name="Send Confirmation E-mail"
         activiti:type="mail">
         <extensionElements>
            <activiti:field expression="${from}" name="from" />
            <activiti:field expression="${emailTo}" name="to" />
            <activiti:field stringValue="Your Vacation Request has been approved." name="subject" />
            <activiti:field name="text">
               <activiti:expression>${approvalRemark}</activiti:expression>
            </activiti:field>
         </extensionElements>
      </serviceTask>
      <sequenceFlow id="flow4" targetRef="end0"
         sourceRef="sendConfirmationE-mail" />
      <endEvent id="end0" />
      <sequenceFlow id="flow5" targetRef="adjustVacationRequest"
         sourceRef="requestApproved">
         <conditionExpression xsi:type="tFormalExpression">${!vacationApproved}</conditionExpression>
      </sequenceFlow>
      <userTask id="adjustVacationRequest" activiti:formKey="/vacationRequest/edit"
         name="Adjust Vacation Request">
         <documentation>Your manager has not approved your vacation request.
         </documentation>
         <humanPerformer>
            <resourceAssignmentExpression>
               <formalExpression>${username}</formalExpression>
            </resourceAssignmentExpression>
         </humanPerformer>
      </userTask>
      <sequenceFlow id="flow6" targetRef="resendRequest"
         sourceRef="adjustVacationRequest" />
      <exclusiveGateway id="resendRequest" name="Resend Request?" />
      <sequenceFlow id="flow7" targetRef="handleVacationRequest"
         sourceRef="resendRequest">
         <conditionExpression xsi:type="tFormalExpression">${resendRequest}</conditionExpression>
      </sequenceFlow>
      <sequenceFlow id="flow8" sourceRef="resendRequest"
         targetRef="end1">
         <conditionExpression xsi:type="tFormalExpression">${!resendRequest}</conditionExpression>
      </sequenceFlow>
      <endEvent id="end1" />
   </process>
</definitions>

VacationRequest from activiti-modeler-examples:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"  xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:signavio="http://www.signavio.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exporter="Signavio Process Editor, http://www.signavio.com" exporterVersion="" expressionLanguage="http://www.w3.org/1999/XPath" id="sid-28da1acc-280f-4b03-aa50-7165b8bf3e85" targetNamespace="http://www.signavio.com/bpmn20" typeLanguage="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL http://www.omg.org/spec/BPMN/2.0/20100501/BPMN20.xsd">
   <process id="sid-8cab1011-1b36-4154-986b-48627cfe3e05" isExecutable="false">
      <startEvent id="sid-E2CC4D54-9C99-46CB-A145-3E44807A50F8" name="" activiti:formKey="request.form">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <outgoing>sid-9F799F35-6DCE-47C8-B1C5-793D3936F5F2</outgoing>
      </startEvent>
      <userTask completionQuantity="1" id="sid-E9027EA2-10EE-4B5E-98DD-3BC86CFA3486"
         implementation="unspecified" isForCompensation="false"
         name="Handle vacation request" startQuantity="1"
         activiti:formKey="approve.form">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-9F799F35-6DCE-47C8-B1C5-793D3936F5F2</incoming>
         <incoming>sid-F50530D8-28A7-4F4E-A950-42E5BD5A6AEC</incoming>
         <outgoing>sid-A7BB7780-9518-4515-B496-1B0B5A5EBAA1</outgoing>
         <potentialOwner id="sid-3980ffe0-9459-44f5-bb94-3c3551e198c1" resourceRef="">
            <resourceAssignmentExpression id="sid-a6a2b407-5f9d-423d-b199-3c53bf0fb7a8">
               <formalExpression id="sid-f25b90f6-bd1a-4047-82be-2414d189b092">management</formalExpression>
            </resourceAssignmentExpression>
         </potentialOwner>
      </userTask>
      <exclusiveGateway gatewayDirection="Diverging" id="sid-32173968-C77C-4BD7-ADB0-4EB7DBFE3DEB" name="Resend request?">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-92E6DBF4-6E3B-4DCA-ADDF-DD1C1D591400</incoming>
         <outgoing>sid-F50530D8-28A7-4F4E-A950-42E5BD5A6AEC</outgoing>
         <outgoing>sid-3FCE8675-C827-4E30-9066-4BB007804C87</outgoing>
      </exclusiveGateway>
      <userTask completionQuantity="1" id="sid-42F64CC2-974B-48EC-B770-4F189D31B9D1"
                implementation="unspecified" isForCompensation="false"
                name="Adjust vacation request" startQuantity="1"
                activiti:formKey="adjustRequest.form">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-F32BE919-CAC7-4555-AD77-389B6FE265AE</incoming>
         <outgoing>sid-92E6DBF4-6E3B-4DCA-ADDF-DD1C1D591400</outgoing>
         <humanPerformer id="sid-6d3cd863-39c8-4010-bf8b-21486d0f7e5f" resourceRef="">
            <resourceAssignmentExpression id="sid-78c387d2-e819-4924-89b9-f8eb1dd371db">
               <formalExpression id="sid-65471700-ccdf-463a-af95-4d6fc5b2bd29">${employeeName}</formalExpression>
            </resourceAssignmentExpression>
         </humanPerformer>
      </userTask>
      <exclusiveGateway gatewayDirection="Diverging" id="sid-92436D48-1474-4223-8BE7-D5E341076373" name="Request approved?">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-A7BB7780-9518-4515-B496-1B0B5A5EBAA1</incoming>
         <outgoing>sid-02320A54-EB16-43F7-AB1D-D0ACA32345F7</outgoing>
         <outgoing>sid-F32BE919-CAC7-4555-AD77-389B6FE265AE</outgoing>
      </exclusiveGateway>
      <task completionQuantity="1" id="sid-1B2EA8CC-6CFB-417D-9E64-0A753E7E3CF5" isForCompensation="false" name="Send confirmation email" startQuantity="1">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffcc"/>
         </extensionElements>
         <incoming>sid-02320A54-EB16-43F7-AB1D-D0ACA32345F7</incoming>
         <outgoing>sid-F9079A6D-ED44-4D87-906A-7E7A3F9E94E9</outgoing>
      </task>
      <endEvent id="sid-E62A67D2-32F2-4E3D-9397-0386C43D91D7" name="">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-F9079A6D-ED44-4D87-906A-7E7A3F9E94E9</incoming>
      </endEvent>
      <endEvent id="sid-72B34C3D-69BF-41C7-8B83-6559EAEA969E" name="">
         <extensionElements>
            <signavio:signavioMetaData metaKey="bgcolor" metaValue="#ffffff"/>
         </extensionElements>
         <incoming>sid-3FCE8675-C827-4E30-9066-4BB007804C87</incoming>
      </endEvent>
      <sequenceFlow id="sid-9F799F35-6DCE-47C8-B1C5-793D3936F5F2" name="" sourceRef="sid-E2CC4D54-9C99-46CB-A145-3E44807A50F8" targetRef="sid-E9027EA2-10EE-4B5E-98DD-3BC86CFA3486"/>
      <sequenceFlow id="sid-A7BB7780-9518-4515-B496-1B0B5A5EBAA1" name="" sourceRef="sid-E9027EA2-10EE-4B5E-98DD-3BC86CFA3486" targetRef="sid-92436D48-1474-4223-8BE7-D5E341076373"/>
      <sequenceFlow id="sid-F9079A6D-ED44-4D87-906A-7E7A3F9E94E9" name="" sourceRef="sid-1B2EA8CC-6CFB-417D-9E64-0A753E7E3CF5" targetRef="sid-E62A67D2-32F2-4E3D-9397-0386C43D91D7"/>
      <sequenceFlow id="sid-02320A54-EB16-43F7-AB1D-D0ACA32345F7" name="${vacationApproved}" sourceRef="sid-92436D48-1474-4223-8BE7-D5E341076373" targetRef="sid-1B2EA8CC-6CFB-417D-9E64-0A753E7E3CF5"/>
      <sequenceFlow id="sid-F32BE919-CAC7-4555-AD77-389B6FE265AE" name="${!vacationApproved}" sourceRef="sid-92436D48-1474-4223-8BE7-D5E341076373" targetRef="sid-42F64CC2-974B-48EC-B770-4F189D31B9D1"/>
      <sequenceFlow id="sid-92E6DBF4-6E3B-4DCA-ADDF-DD1C1D591400" name="" sourceRef="sid-42F64CC2-974B-48EC-B770-4F189D31B9D1" targetRef="sid-32173968-C77C-4BD7-ADB0-4EB7DBFE3DEB"/>
      <sequenceFlow id="sid-F50530D8-28A7-4F4E-A950-42E5BD5A6AEC" name="${resendRequest}" sourceRef="sid-32173968-C77C-4BD7-ADB0-4EB7DBFE3DEB" targetRef="sid-E9027EA2-10EE-4B5E-98DD-3BC86CFA3486"/>
      <sequenceFlow id="sid-3FCE8675-C827-4E30-9066-4BB007804C87" name="${!resendRequest}" sourceRef="sid-32173968-C77C-4BD7-ADB0-4EB7DBFE3DEB" targetRef="sid-72B34C3D-69BF-41C7-8B83-6559EAEA969E"/>
   </process>
   <bpmndi:BPMNDiagram id="sid-4dabe680-fe92-40c3-aedf-5a01e75f6351">
      <bpmndi:BPMNPlane bpmnElement="sid-8cab1011-1b36-4154-986b-48627cfe3e05" id="sid-cbc429b7-0062-410d-8876-c17fea3a7bba">
         <bpmndi:BPMNShape bpmnElement="sid-E2CC4D54-9C99-46CB-A145-3E44807A50F8" id="sid-E2CC4D54-9C99-46CB-A145-3E44807A50F8_gui">
            <omgdc:Bounds height="30.0" width="30.0" x="75.0" y="85.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-E9027EA2-10EE-4B5E-98DD-3BC86CFA3486" id="sid-E9027EA2-10EE-4B5E-98DD-3BC86CFA3486_gui">
            <omgdc:Bounds height="80.0" width="111.0" x="150.0" y="60.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-32173968-C77C-4BD7-ADB0-4EB7DBFE3DEB" id="sid-32173968-C77C-4BD7-ADB0-4EB7DBFE3DEB_gui" isMarkerVisible="true">
            <omgdc:Bounds height="40.0" width="40.0" x="559.0" y="233.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-42F64CC2-974B-48EC-B770-4F189D31B9D1" id="sid-42F64CC2-974B-48EC-B770-4F189D31B9D1_gui">
            <omgdc:Bounds height="84.0" width="124.0" x="390.0" y="211.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-92436D48-1474-4223-8BE7-D5E341076373" id="sid-92436D48-1474-4223-8BE7-D5E341076373_gui" isMarkerVisible="true">
            <omgdc:Bounds height="40.0" width="40.0" x="318.0" y="80.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-1B2EA8CC-6CFB-417D-9E64-0A753E7E3CF5" id="sid-1B2EA8CC-6CFB-417D-9E64-0A753E7E3CF5_gui">
            <omgdc:Bounds height="80.0" width="100.0" x="538.0" y="60.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-E62A67D2-32F2-4E3D-9397-0386C43D91D7" id="sid-E62A67D2-32F2-4E3D-9397-0386C43D91D7_gui">
            <omgdc:Bounds height="28.0" width="28.0" x="754.0" y="86.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNShape bpmnElement="sid-72B34C3D-69BF-41C7-8B83-6559EAEA969E" id="sid-72B34C3D-69BF-41C7-8B83-6559EAEA969E_gui">
            <omgdc:Bounds height="28.0" width="28.0" x="754.0" y="239.0"/>
         </bpmndi:BPMNShape>
         <bpmndi:BPMNEdge bpmnElement="sid-92E6DBF4-6E3B-4DCA-ADDF-DD1C1D591400" id="sid-92E6DBF4-6E3B-4DCA-ADDF-DD1C1D591400_gui">
            <omgdi:waypoint x="514.0" y="253.0"/>
            <omgdi:waypoint x="559.0" y="253.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-F50530D8-28A7-4F4E-A950-42E5BD5A6AEC" id="sid-F50530D8-28A7-4F4E-A950-42E5BD5A6AEC_gui">
            <omgdi:waypoint x="579.0" y="273.0"/>
            <omgdi:waypoint x="579.5" y="404.0"/>
            <omgdi:waypoint x="205.5" y="404.0"/>
            <omgdi:waypoint x="205.0" y="140.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-F9079A6D-ED44-4D87-906A-7E7A3F9E94E9" id="sid-F9079A6D-ED44-4D87-906A-7E7A3F9E94E9_gui">
            <omgdi:waypoint x="638.0" y="100.0"/>
            <omgdi:waypoint x="754.0" y="100.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-F32BE919-CAC7-4555-AD77-389B6FE265AE" id="sid-F32BE919-CAC7-4555-AD77-389B6FE265AE_gui">
            <omgdi:waypoint x="338.0" y="120.0"/>
            <omgdi:waypoint x="338.5" y="253.0"/>
            <omgdi:waypoint x="390.0" y="253.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-A7BB7780-9518-4515-B496-1B0B5A5EBAA1" id="sid-A7BB7780-9518-4515-B496-1B0B5A5EBAA1_gui">
            <omgdi:waypoint x="261.0" y="100.0"/>
            <omgdi:waypoint x="318.0" y="100.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-9F799F35-6DCE-47C8-B1C5-793D3936F5F2" id="sid-9F799F35-6DCE-47C8-B1C5-793D3936F5F2_gui">
            <omgdi:waypoint x="105.0" y="100.0"/>
            <omgdi:waypoint x="150.0" y="100.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-02320A54-EB16-43F7-AB1D-D0ACA32345F7" id="sid-02320A54-EB16-43F7-AB1D-D0ACA32345F7_gui">
            <omgdi:waypoint x="358.0" y="100.0"/>
            <omgdi:waypoint x="538.0" y="100.0"/>
         </bpmndi:BPMNEdge>
         <bpmndi:BPMNEdge bpmnElement="sid-3FCE8675-C827-4E30-9066-4BB007804C87" id="sid-3FCE8675-C827-4E30-9066-4BB007804C87_gui">
            <omgdi:waypoint x="599.0" y="253.0"/>
            <omgdi:waypoint x="754.0" y="253.0"/>
         </bpmndi:BPMNEdge>
      </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
</definitions>
2 REPLIES 2

jbarrez
Star Contributor
Star Contributor
I'm afraid not. The Modeler has its own way of laying out the elements (note: the Eclipse plugin doesn't do this), however the Cycle app has some ways of facilitating this  (so in time this will be more powerful then now)

robokaso
Champ in-the-making
Champ in-the-making
Thanks for the reply.

The eclipse plugin seems to work much better indeed. Making changes by hand in the xml doesn't work either (the xml is generated from the diagram and overwritten when diagram is saved) but the UI is rich enough to specify the common stuff I needed so far and the generated process definition is nicely readable (takes advantage of activiti namespace and doesn't clutter the process definition with visual metadata).