cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong ID generation for start and end events in subprocess

vgavrilov
Champ in-the-making
Champ in-the-making
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.writeStartElement("startEvent");
      xtw.writeAttribute("id", startEvent.getId()); //start event has plain id
      xtw.writeAttribute("name", startEvent.getName());

      // end StartEvent element
      xtw.writeEndElement();

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

      // end EndEvent element
      xtw.writeEndElement();

    } else if (object instanceof SequenceFlow) {
      SequenceFlow sequenceFlow = (SequenceFlow) object;
      // start SequenceFlow element
      xtw.writeStartElement("sequenceFlow");
      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.

Example:

<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>
    </subProcess>
    <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>
  </process>

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 Smiley Happy Are there any step by step instructions regarding build procedure?
3 REPLIES 3

trademak
Star Contributor
Star Contributor
Hi,

Thanks for reporting this issue. Yes it's a bug.
If you could create a JIRA that would be great and of course it'll be fixed in the next release.
About the build procedure, I listed the steps in this forum post:

http://forums.activiti.org/en/viewtopic.php?f=8&t=936

I still have to create a wiki page for this, but now the 5.2 release is out I'll have the time to do this.

Best regards,

h_ter_schuur
Champ in-the-making
Champ in-the-making
I've already reported this issue in JIRA (http://jira.codehaus.org/browse/ACT-599).
I've also attached a patch file to this issue.

Best regards,
Hinse

trademak
Star Contributor
Star Contributor
Hi Hinse,

Thanks, I'll make sure this patch is committed to the trunk.

Best regards,