AnsweredAssumed Answered

Wrong ID generation for start and end events in subprocess

Question asked by vgavrilov on Feb 2, 2011
Latest reply on Feb 3, 2011 by trademak
In case of subprocess, start and end events have wrong IDs which prevents the result BPMN file to be deployed by Activiti:
Issue seems to be here: org.activiti.designer.export.bpmn20.export.BPMN20ExportMarshaller

private void createXML(EObject object, XMLStreamWriter xtw, String subProcessId) throws Exception {
    if (object instanceof StartEvent) {
      StartEvent startEvent = (StartEvent) object;
      // start StartEvent element
      xtw.writeAttribute("id", startEvent.getId()); //start event has plain id
      xtw.writeAttribute("name", startEvent.getName());

      // end StartEvent element

    } else if (object instanceof EndEvent) {
      EndEvent endEvent = (EndEvent) object;
      // start EndEvent element
      xtw.writeAttribute("id", endEvent.getId()); //end event has plain id
      xtw.writeAttribute("name", endEvent.getName());

      // end EndEvent element

    } else if (object instanceof SequenceFlow) {
      SequenceFlow sequenceFlow = (SequenceFlow) object;
      // start SequenceFlow element
      xtw.writeAttribute("id", subProcessId + sequenceFlow.getId());
      if (sequenceFlow.getName() == null) {
        xtw.writeAttribute("name", "");
      } else {
        xtw.writeAttribute("name", sequenceFlow.getName());
      xtw.writeAttribute("sourceRef", subProcessId + sequenceFlow.getSourceRef().getId()); //start event source ref will have composite id
      xtw.writeAttribute("targetRef", subProcessId + sequenceFlow.getTargetRef().getId()); //start event source ref will have composite id

So if we have sequence flow outgoing from i.e. start event, it will result in different id mentioned in start event and sourceRef.


<process id="helloworld" name="helloworld">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <userTask id="usertask1" name="User Task" activiti:candidateUsers="particopant" activiti:formKey="/form/task.form"></userTask>
    <subProcess id="subprocess1" name="Sub Process">
      <startEvent id="startevent3" name="Start"></startEvent>
      <endEvent id="endevent2" name="End"></endEvent>
      <userTask id="subprocess1_usertask2" name="User Task" activiti:candidateUsers="participant" activiti:formKey="/form/task.form"></userTask>
      <sequenceFlow id="subprocess1_flow4" name="" sourceRef="subprocess1_startevent3" targetRef="subprocess1_usertask2"></sequenceFlow>
      <sequenceFlow id="subprocess1_flow5" name="" sourceRef="subprocess1_usertask2" targetRef="subprocess1_endevent2"></sequenceFlow>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="usertask1" targetRef="subprocess1"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="subprocess1" targetRef="endevent1"></sequenceFlow>

Could you please confirm this bug and fix it if it was identified correctly? I could actually fix it locally myself if only I know how to build the plugin from sources :) Are there any step by step instructions regarding build procedure?