diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/constants/BpmnXMLConstants.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/constants/BpmnXMLConstants.java index b203bf39926..29a94645583 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/constants/BpmnXMLConstants.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/constants/BpmnXMLConstants.java @@ -288,6 +288,7 @@ public interface BpmnXMLConstants { public static final String ELEMENT_GATEWAY_INCLUSIVE = "inclusiveGateway"; public static final String ELEMENT_GATEWAY_PARALLEL = "parallelGateway"; public static final String ELEMENT_GATEWAY_COMPLEX = "complexGateway"; + public static final String ATTRIBUTE_GATEWAY_EXCLUSIVE_ISMARKERVISIBLE = "isMarkerVisible"; public static final String ELEMENT_EVENT_START = "startEvent"; public static final String ELEMENT_EVENT_END = "endEvent"; diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/ExclusiveGatewayXMLConverter.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/ExclusiveGatewayXMLConverter.java index 5b05b35263c..f3805a88448 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/ExclusiveGatewayXMLConverter.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/ExclusiveGatewayXMLConverter.java @@ -12,6 +12,9 @@ */ package org.flowable.bpmn.converter; +import java.util.Arrays; +import java.util.List; + import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; @@ -19,12 +22,18 @@ import org.flowable.bpmn.model.BaseElement; import org.flowable.bpmn.model.BpmnModel; import org.flowable.bpmn.model.ExclusiveGateway; +import org.flowable.bpmn.model.ExtensionAttribute; /** * @author Tijs Rademakers + * @author Dominik Simmen */ public class ExclusiveGatewayXMLConverter extends BaseBpmnXMLConverter { + /** default attributes taken from bpmn spec and from extension namespace */ + protected static final List defaultExclusiveGatewayAttributes = Arrays.asList( + new ExtensionAttribute(ATTRIBUTE_GATEWAY_EXCLUSIVE_ISMARKERVISIBLE)); + @Override public Class getBpmnElementType() { return ExclusiveGateway.class; @@ -41,7 +50,12 @@ protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) ExclusiveGateway gateway = new ExclusiveGateway(); BpmnXMLUtil.addXMLLocation(gateway, xtr); - BpmnXMLUtil.addCustomAttributes(xtr, gateway, defaultElementAttributes, defaultActivityAttributes); + String isMarkerVisibleAttribute = BpmnXMLUtil.getAttributeValue(ATTRIBUTE_GATEWAY_EXCLUSIVE_ISMARKERVISIBLE, xtr); + if (ATTRIBUTE_VALUE_FALSE.equalsIgnoreCase(isMarkerVisibleAttribute)) { + gateway.setMarkerVisible(false); + } + + BpmnXMLUtil.addCustomAttributes(xtr, gateway, defaultElementAttributes, defaultActivityAttributes, defaultExclusiveGatewayAttributes); parseChildElements(getXMLElementName(), gateway, model, xtr); return gateway; @@ -49,6 +63,11 @@ protected BaseElement convertXMLToElement(XMLStreamReader xtr, BpmnModel model) @Override protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception { + ExclusiveGateway gateway = (ExclusiveGateway) element; + if (!gateway.isMarkerVisible()) { + // default value is true + writeQualifiedAttribute(ATTRIBUTE_GATEWAY_EXCLUSIVE_ISMARKERVISIBLE, "false", xtw); + } } @Override diff --git a/modules/flowable-bpmn-converter/src/test/java/org/flowable/editor/language/xml/ExclusiveGatewayConverterTest.java b/modules/flowable-bpmn-converter/src/test/java/org/flowable/editor/language/xml/ExclusiveGatewayConverterTest.java new file mode 100644 index 00000000000..786a88e5bb6 --- /dev/null +++ b/modules/flowable-bpmn-converter/src/test/java/org/flowable/editor/language/xml/ExclusiveGatewayConverterTest.java @@ -0,0 +1,35 @@ +/* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.flowable.editor.language.xml; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.flowable.bpmn.model.BpmnModel; +import org.flowable.bpmn.model.ExclusiveGateway; +import org.flowable.bpmn.model.FlowElement; +import org.flowable.editor.language.xml.util.BpmnXmlConverterTest; + +/** + * @author Dominik Simmen + */ +class ExclusiveGatewayConverterTest { + + @BpmnXmlConverterTest("exclusivegatewaymodel.bpmn") + void validateModel(BpmnModel model) { + FlowElement flowElement = model.getMainProcess().getFlowElement("exclusiveGateway"); + assertThat(flowElement).isInstanceOf(ExclusiveGateway.class); + + ExclusiveGateway gateway = (ExclusiveGateway) flowElement; + assertThat(gateway.isMarkerVisible()).isFalse(); + } +} \ No newline at end of file diff --git a/modules/flowable-bpmn-converter/src/test/resources/exclusivegatewaymodel.bpmn b/modules/flowable-bpmn-converter/src/test/resources/exclusivegatewaymodel.bpmn new file mode 100644 index 00000000000..e0e09c3204a --- /dev/null +++ b/modules/flowable-bpmn-converter/src/test/resources/exclusivegatewaymodel.bpmn @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/ExclusiveGateway.java b/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/ExclusiveGateway.java index eb5083ac569..712c953f4bb 100644 --- a/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/ExclusiveGateway.java +++ b/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/ExclusiveGateway.java @@ -14,9 +14,20 @@ /** * @author Tijs Rademakers + * @author Dominik Simmen */ public class ExclusiveGateway extends Gateway { + protected boolean markerVisible = true; + + public boolean isMarkerVisible() { + return markerVisible; + } + + public void setMarkerVisible(boolean markerVisible) { + this.markerVisible = markerVisible; + } + @Override public ExclusiveGateway clone() { ExclusiveGateway clone = new ExclusiveGateway(); @@ -26,5 +37,6 @@ public ExclusiveGateway clone() { public void setValues(ExclusiveGateway otherElement) { super.setValues(otherElement); + setMarkerVisible(otherElement.isMarkerVisible()); } }