Skip to content

Commit

Permalink
Fix issue with event registry start event set as initial flow element
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Sep 1, 2023
1 parent b373b33 commit e3e38f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ protected void executeParse(BpmnParse bpmnParse, StartEvent element) {
element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessVariableListenerlStartEventActivityBehavior(element, variableListenerEventDefinition));
}

} else {
} else if (hasEventTypeElement(element)) {
List<ExtensionElement> eventTypeElements = element.getExtensionElements().get(BpmnXMLConstants.ELEMENT_EVENT_TYPE);
if (eventTypeElements != null && !eventTypeElements.isEmpty()) {
String eventType = eventTypeElements.get(0).getElementText();
if (StringUtils.isNotEmpty(eventType)) {
element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessEventRegistryStartEventActivityBehavior(element, eventType));
}
String eventType = eventTypeElements.get(0).getElementText();
if (StringUtils.isNotEmpty(eventType)) {
element.setBehavior(bpmnParse.getActivityBehaviorFactory().createEventSubProcessEventRegistryStartEventActivityBehavior(element, eventType));
}
}

Expand All @@ -99,7 +97,7 @@ protected void executeParse(BpmnParse bpmnParse, StartEvent element) {
}
}

if (element.getSubProcess() == null && (CollectionUtil.isEmpty(element.getEventDefinitions()) ||
if (element.getSubProcess() == null && (hasNoEventDefinitionOrTypeElement(element) ||
bpmnParse.getCurrentProcess().getInitialFlowElement() == null)) {

bpmnParse.getCurrentProcess().setInitialFlowElement(element);
Expand All @@ -118,5 +116,18 @@ protected MessageEventDefinition fillMessageRef(BpmnParse bpmnParse, EventDefini

return messageDefinition;
}

protected boolean hasNoEventDefinitionOrTypeElement(StartEvent element) {
return CollectionUtil.isEmpty(element.getEventDefinitions()) && !hasEventTypeElement(element);
}

protected boolean hasEventTypeElement(StartEvent element) {
boolean foundEventTypeElement = false;
List<ExtensionElement> eventTypeElements = element.getExtensionElements().get(BpmnXMLConstants.ELEMENT_EVENT_TYPE);
if (eventTypeElements != null && !eventTypeElements.isEmpty()) {
foundEventTypeElement = true;
}

return foundEventTypeElement;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.Comparator;
import java.util.List;

import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants;
import org.flowable.engine.ManagementService;
import org.flowable.engine.ProcessEngine;
Expand Down Expand Up @@ -665,6 +667,15 @@ public void testMultiInstanceSendSystemEvent() {
}
}

@Test
@Deployment(resources = "org/flowable/eventregistry/integrationtest/testMultipleStartEvents.bpmn20.xml")
public void testMultipleStartEventsForInitialStartEvent() {
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("multipleStartEvents").singleResult();
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
Process process = bpmnModel.getMainProcess();
assertThat(process.getInitialFlowElement().getId()).isEqualTo("start3");
}

protected EventRepositoryService getEventRepositoryService() {
return getEventRegistryEngineConfiguration().getEventRepositoryService();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
<sequenceFlow sourceRef="receive1" targetRef="theEnd"/>

<sequenceFlow sourceRef="receive2" targetRef="theEnd"/>

<startEvent id="start3" flowable:formKey="testKey" />

<sequenceFlow sourceRef="start3" targetRef="receive3"/>

<receiveTask id="receive3" />

<sequenceFlow sourceRef="receive3" targetRef="theEnd"/>

<endEvent id="theEnd"/>

Expand Down

0 comments on commit e3e38f6

Please sign in to comment.