Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
Issue #336
  • Loading branch information
rsoika committed Feb 24, 2024
1 parent 8ff55b6 commit 7718341
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 7 deletions.
2 changes: 2 additions & 0 deletions open-bpmn.glsp-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore dev model files
workspace/dev/
Original file line number Diff line number Diff line change
Expand Up @@ -1873,16 +1873,25 @@ private void loadMessageFlowList() throws BPMNModelException {
* This helper method loads the Signal elements from the diagram -
* 'bpmn2:signal' .
*
* The method detects duplicates and prints a warning if found.
*
* @throws BPMNModelException
*/
private void loadSignalList() throws BPMNModelException {
signals = new LinkedHashSet<Signal>();
List<String> duplicates = new ArrayList<>();
NodeList signalNodeList = definitions.getElementsByTagName(getPrefix(BPMNNS.BPMN2) + ":" + BPMNTypes.SIGNAL);
if (signalNodeList != null && signalNodeList.getLength() > 0) {
for (int i = 0; i < signalNodeList.getLength(); i++) {
Element item = (Element) signalNodeList.item(i);
Signal signal = new Signal(this, item);
signals.add(signal);
String id = signal.getId();
if (duplicates.contains(id)) {
logger.warning("Duplicate bpmn2:signal '" + id + "'' found, signal will be ignored!");
} else {
duplicates.add(id);
signals.add(signal);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testReadSignal() {
fail();
}

logger.info("...model read sucessful ");
logger.info("...model read successful ");
}

/**
Expand Down Expand Up @@ -87,7 +87,7 @@ public void testCreateSignal() {
}

model.save(out);
logger.info("...model created sucessful: " + out);
logger.info("...model created successful: " + out);

}

Expand Down Expand Up @@ -129,13 +129,13 @@ public void testCreateSignalDefinition() {
}

model.save(out);
logger.info("...model created sucessful: " + out);
logger.info("...model created successful: " + out);

}

/**
* This test parses a bpmn file and removes singnal_1 which is referred by an
* event
* This test parses a bpmn file and warns if duplicate signal ids are found.
*
*/
@Test
public void testDeleteSignal() {
Expand Down Expand Up @@ -165,7 +165,32 @@ public void testDeleteSignal() {
}

model.save(out);
logger.info("...model update sucessful: " + out);
logger.info("...model update successful: " + out);

}

/**
* This test parses a bpmn file that causes errors by not computing the signal
* list correctly
*/
@Test
public void testSignalDuplicates() {
BPMNModel model = null;

logger.info("...read model");
try {
model = BPMNModelFactory.read("/refmodel-17.bpmn");
logger.info("...read model");
// read tasks....
BPMNProcess process = model.openProcess(null);
assertNotNull(process);
// We expect 2 signals!
assertEquals(2, model.getSignals().size());

} catch (BPMNModelException e) {
e.printStackTrace();
fail();
}

}

Expand Down
60 changes: 60 additions & 0 deletions open-bpmn.metamodel/src/test/resources/refmodel-17.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- origin at X=0.0 Y=0.0 -->
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC"
xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:ext="http://org.eclipse.bpmn2/ext"
xmlns:xs="http://www.w3.org/2001/XMLSchema" id="Definitions_1"
exporter="org.eclipse.bpmn2.modeler.core" exporterVersion="1.5.4.RC1-v20220528-0836-B1"
targetNamespace="http://org.eclipse.bpmn2/default/process">
<bpmn2:signal id="Signal_1" name="Signal 1" />
<bpmn2:signal id="Signal_1" name="Signal 1" />
<bpmn2:signal id="Signal_1" name="Another name" />
<bpmn2:signal id="Signal_2" name="Another Signal" />
<bpmn2:process id="process_1" name="Default Process" isExecutable="false">
<bpmn2:startEvent id="StartEvent_1" name="Start Event 1">
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1" name="Intermediate Catch Event 1">
<bpmn2:incoming>SequenceFlow_2</bpmn2:incoming>
<bpmn2:dataOutput id="DataOutput_1" name="Signal_1_Output" />
<bpmn2:dataOutputAssociation id="DataOutputAssociation_1">
<bpmn2:sourceRef>DataOutput_1</bpmn2:sourceRef>
</bpmn2:dataOutputAssociation>
<bpmn2:outputSet id="OutputSet_1" name="Output Set 1">
<bpmn2:dataOutputRefs>DataOutput_1</bpmn2:dataOutputRefs>
</bpmn2:outputSet>
<bpmn2:signalEventDefinition id="SignalEventDefinition_1" signalRef="Signal_1" />
</bpmn2:intermediateCatchEvent>
<bpmn2:sequenceFlow id="SequenceFlow_2" sourceRef="StartEvent_1"
targetRef="IntermediateCatchEvent_1" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1" name="Default Process Diagram">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="process_1">
<bpmndi:BPMNShape id="BPMNShape_1" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="100.0" y="100.0" />
<bpmndi:BPMNLabel id="BPMNLabel_1" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="14.0" width="69.0" x="84.0" y="136.0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_IntermediateCatchEvent_1"
bpmnElement="IntermediateCatchEvent_1">
<dc:Bounds height="36.0" width="36.0" x="206.0" y="100.0" />
<bpmndi:BPMNLabel id="BPMNLabel_5" labelStyle="BPMNLabelStyle_1">
<dc:Bounds height="28.0" width="79.0" x="185.0" y="136.0" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2"
sourceElement="BPMNShape_1" targetElement="BPMNShape_IntermediateCatchEvent_1">
<di:waypoint xsi:type="dc:Point" x="136.0" y="118.0" />
<di:waypoint xsi:type="dc:Point" x="171.0" y="118.0" />
<di:waypoint xsi:type="dc:Point" x="206.0" y="118.0" />
<bpmndi:BPMNLabel id="BPMNLabel_6" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
<bpmndi:BPMNLabelStyle id="BPMNLabelStyle_1">
<dc:Font name="arial" size="9.0" />
</bpmndi:BPMNLabelStyle>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>

0 comments on commit 7718341

Please sign in to comment.