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 f31955803b9..5e16277089a 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 @@ -387,6 +387,7 @@ public interface BpmnXMLConstants { public static final String ATTRIBUTE_DI_SOURCE_DOCKER_Y = "sourceDockerY"; public static final String ATTRIBUTE_DI_TARGET_DOCKER_X = "targetDockerX"; public static final String ATTRIBUTE_DI_TARGET_DOCKER_Y = "targetDockerY"; + public static final String ATTRIBUTE_DI_ROTATION = "rotation"; public static final String ELEMENT_DATA_OBJECT = "dataObject"; public static final String ATTRIBUTE_DATA_ID = "id"; diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java index 947d60f6a5e..87c1b3af5ab 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/export/BPMNDIExport.java @@ -190,6 +190,12 @@ protected static void createBpmnShape(BpmnModel model, String elementId, XMLStre xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(graphicInfo.getY())); xtw.writeEndElement(); + GraphicInfo labelGraphicInfo = model.getLabelGraphicInfo(elementId); + + if (labelGraphicInfo != null && flowElement != null && StringUtils.isNotEmpty(flowElement.getName())) { + addLabelElement(labelGraphicInfo, xtw); + } + xtw.writeEndElement(); } @@ -231,16 +237,23 @@ protected static void createBpmnEdge(BpmnModel model, String elementId, XMLStrea } if (labelGraphicInfo != null && hasName) { - xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_LABEL, BPMNDI_NAMESPACE); - xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE); - xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(labelGraphicInfo.getHeight())); - xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(labelGraphicInfo.getWidth())); - xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(labelGraphicInfo.getX())); - xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(labelGraphicInfo.getY())); - xtw.writeEndElement(); - xtw.writeEndElement(); + addLabelElement(labelGraphicInfo, xtw); } xtw.writeEndElement(); } + + protected static void addLabelElement(GraphicInfo labelGraphicInfo, XMLStreamWriter xtw) throws Exception { + xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_LABEL, BPMNDI_NAMESPACE); + if (labelGraphicInfo.getRotation() > 0) { + xtw.writeAttribute(FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_DI_ROTATION, String.valueOf(labelGraphicInfo.getRotation())); + } + xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE); + xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(labelGraphicInfo.getHeight())); + xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(labelGraphicInfo.getWidth())); + xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(labelGraphicInfo.getX())); + xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(labelGraphicInfo.getY())); + xtw.writeEndElement(); + xtw.writeEndElement(); + } } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnEdgeParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnEdgeParser.java index 3b62d874942..574f1f6cbc2 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnEdgeParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnEdgeParser.java @@ -60,21 +60,7 @@ public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { while (xtr.hasNext()) { xtr.next(); if (xtr.isStartElement() && ELEMENT_DI_LABEL.equalsIgnoreCase(xtr.getLocalName())) { - while (xtr.hasNext()) { - xtr.next(); - if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) { - GraphicInfo graphicInfo = new GraphicInfo(); - BpmnXMLUtil.addXMLLocation(graphicInfo, xtr); - graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)).intValue()); - graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)).intValue()); - graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH)).intValue()); - graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT)).intValue()); - model.addLabelGraphicInfo(id, graphicInfo); - break; - } else if (xtr.isEndElement() && ELEMENT_DI_LABEL.equalsIgnoreCase(xtr.getLocalName())) { - break; - } - } + BpmnXMLUtil.parseLabelElement(xtr, model, id); } else if (xtr.isStartElement() && ELEMENT_DI_WAYPOINT.equalsIgnoreCase(xtr.getLocalName())) { GraphicInfo graphicInfo = new GraphicInfo(); diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnShapeParser.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnShapeParser.java index 3722004e6b8..9051c2931e3 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnShapeParser.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/parser/BpmnShapeParser.java @@ -41,14 +41,16 @@ public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception { BpmnXMLUtil.addXMLLocation(graphicInfo, xtr); while (xtr.hasNext()) { xtr.next(); - if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) { + if (xtr.isStartElement() && ELEMENT_DI_LABEL.equalsIgnoreCase(xtr.getLocalName())) { + BpmnXMLUtil.parseLabelElement(xtr, model, id); + + } else if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) { graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X))); graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y))); graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH))); graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT))); model.addGraphicInfo(id, graphicInfo); - break; } else if (xtr.isEndElement() && ELEMENT_DI_SHAPE.equalsIgnoreCase(xtr.getLocalName())) { break; } diff --git a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/util/BpmnXMLUtil.java b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/util/BpmnXMLUtil.java index 81b4ba19be6..8aba4885172 100644 --- a/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/util/BpmnXMLUtil.java +++ b/modules/flowable-bpmn-converter/src/main/java/org/flowable/bpmn/converter/util/BpmnXMLUtil.java @@ -589,4 +589,29 @@ public static boolean isBlacklisted(ExtensionAttribute attribute, List + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/GraphicInfo.java b/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/GraphicInfo.java index 07c8a818d41..89fc56b3fba 100644 --- a/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/GraphicInfo.java +++ b/modules/flowable-bpmn-model/src/main/java/org/flowable/bpmn/model/GraphicInfo.java @@ -25,6 +25,7 @@ public class GraphicInfo { protected Boolean expanded; protected int xmlRowNumber; protected int xmlColumnNumber; + protected double rotation; public GraphicInfo() {} @@ -104,6 +105,14 @@ public void setXmlColumnNumber(int xmlColumnNumber) { this.xmlColumnNumber = xmlColumnNumber; } + public double getRotation() { + return rotation; + } + + public void setRotation(double rotation) { + this.rotation = rotation; + } + public boolean equals(GraphicInfo ginfo) { if (this.getX() != ginfo.getX()) { return false; @@ -117,6 +126,9 @@ public boolean equals(GraphicInfo ginfo) { if (this.getWidth() != ginfo.getWidth()) { return false; } + if (this.getRotation() != ginfo.getRotation()) { + return false; + } // check for zero value in case we are comparing model value to BPMN DI value // model values do not have xml location information diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiBoundsXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiBoundsXmlConverter.java index c22af32391f..ba2a16d466f 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiBoundsXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiBoundsXmlConverter.java @@ -34,14 +34,26 @@ public boolean hasChildElements() { @Override protected BaseElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { - GraphicInfo graphicInfo = new GraphicInfo(); + // If this Bounds element is in a Label element, there will be a currentLabelGraphicInfo available + GraphicInfo graphicInfo = null; + if (conversionHelper.getCurrentLabelGraphicInfo() != null) { + graphicInfo = conversionHelper.getCurrentLabelGraphicInfo(); + + if (conversionHelper.getCurrentDiEdge() != null) { + conversionHelper.getCurrentDiEdge().setLabelGraphicInfo(graphicInfo); + } else if (conversionHelper.getCurrentDiShape() != null) { + conversionHelper.getCurrentDiShape().setLabelGraphicInfo(graphicInfo); + } + } else { + graphicInfo = new GraphicInfo(); + conversionHelper.getCurrentDiShape().setGraphicInfo(graphicInfo); + } + graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_X))); graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_Y))); graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_WIDTH))); graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_HEIGHT))); - conversionHelper.getCurrentDiShape().setGraphicInfo(graphicInfo); - return graphicInfo; } diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiEdgeXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiEdgeXmlConverter.java index ce26c710028..4866199632d 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiEdgeXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiEdgeXmlConverter.java @@ -43,5 +43,10 @@ protected BaseElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return diEdge; } + + @Override + protected void elementEnd(XMLStreamReader xtr, ConversionHelper conversionHelper) { + conversionHelper.setCurrentDiEdge(null); + } } \ No newline at end of file diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiLabelXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiLabelXmlConverter.java new file mode 100644 index 00000000000..0a1cf9efef3 --- /dev/null +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiLabelXmlConverter.java @@ -0,0 +1,50 @@ +/* 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.cmmn.converter; + +import javax.xml.stream.XMLStreamReader; + +import org.flowable.cmmn.model.BaseElement; +import org.flowable.cmmn.model.GraphicInfo; + +public class CmmnDiLabelXmlConverter extends BaseCmmnXmlConverter { + + @Override + public String getXMLElementName() { + return CmmnXmlConstants.ELEMENT_DI_LABEL; + } + + @Override + public boolean hasChildElements() { + return false; + } + + @Override + protected BaseElement convert(XMLStreamReader xtr, ConversionHelper conversionHelper) { + GraphicInfo labelGraphicInfo = new GraphicInfo(); + + if (xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_ROTATION) != null + && !xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_ROTATION).isEmpty()) { + labelGraphicInfo.setRotation(Double.valueOf(xtr.getAttributeValue(null, CmmnXmlConstants.ATTRIBUTE_DI_ROTATION)).intValue()); + } + + conversionHelper.setCurrentLabelGraphicInfo(labelGraphicInfo); + + return labelGraphicInfo; + } + + @Override + protected void elementEnd(XMLStreamReader xtr, ConversionHelper conversionHelper) { + conversionHelper.setCurrentLabelGraphicInfo(null); + } +} \ No newline at end of file diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiShapeXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiShapeXmlConverter.java index caed1e119d7..278067f798a 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiShapeXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnDiShapeXmlConverter.java @@ -42,5 +42,10 @@ protected BaseElement convert(XMLStreamReader xtr, ConversionHelper conversionHe return diShape; } + + @Override + protected void elementEnd(XMLStreamReader xtr, ConversionHelper conversionHelper) { + conversionHelper.setCurrentDiShape(null); + } } \ No newline at end of file diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConstants.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConstants.java index d464da8bbd5..47179fce435 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConstants.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConstants.java @@ -243,5 +243,6 @@ public interface CmmnXmlConstants { String ATTRIBUTE_DI_HEIGHT = "height"; String ATTRIBUTE_DI_X = "x"; String ATTRIBUTE_DI_Y = "y"; + String ATTRIBUTE_DI_ROTATION = "rotation"; } diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java index 50d8ba8b186..14cfdb24725 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/CmmnXmlConverter.java @@ -128,6 +128,7 @@ public class CmmnXmlConverter implements CmmnXmlConstants { addElementConverter(new CmmnDiShapeXmlConverter()); addElementConverter(new CmmnDiEdgeXmlConverter()); addElementConverter(new CmmnDiBoundsXmlConverter()); + addElementConverter(new CmmnDiLabelXmlConverter()); addElementConverter(new CmmnDiWaypointXmlConverter()); addElementConverter(new CmmnDiExtensionXmlConverter()); addElementConverter(new StandardEventXmlConverter()); @@ -393,6 +394,9 @@ protected void processCmmnElements(ConversionHelper conversionHelper) { // set DI elements for (CmmnDiShape diShape : conversionHelper.getDiShapes()) { cmmnModel.addGraphicInfo(diShape.getCmmnElementRef(), diShape.getGraphicInfo()); + if (diShape.getLabelGraphicInfo() != null) { + cmmnModel.addLabelGraphicInfo(diShape.getCmmnElementRef(), diShape.getLabelGraphicInfo()); + } } processDiEdges(cmmnModel, conversionHelper.getDiEdges()); @@ -438,6 +442,9 @@ protected void processDiEdges(CmmnModel cmmnModel, List diEdges) { cmmnModel.addEdgeInfo(diEdge.getId(), diEdge); cmmnModel.addFlowGraphicInfoList(diEdge.getId(), diEdge.getWaypoints()); + if (diEdge.getLabelGraphicInfo() != null) { + cmmnModel.addLabelGraphicInfo(diEdge.getId(), diEdge.getLabelGraphicInfo()); + } } } diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ConversionHelper.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ConversionHelper.java index 612c1309f93..9c8dde6f358 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ConversionHelper.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/ConversionHelper.java @@ -31,6 +31,7 @@ import org.flowable.cmmn.model.CmmnElement; import org.flowable.cmmn.model.CmmnModel; import org.flowable.cmmn.model.Criterion; +import org.flowable.cmmn.model.GraphicInfo; import org.flowable.cmmn.model.HasEntryCriteria; import org.flowable.cmmn.model.HasExitCriteria; import org.flowable.cmmn.model.PlanFragment; @@ -57,6 +58,7 @@ public class ConversionHelper { protected PlanItem currentPlanItem; protected CmmnDiShape currentDiShape; protected CmmnDiEdge currentDiEdge; + protected GraphicInfo currentLabelGraphicInfo; protected Map> caseElements = new HashMap<>(); protected List stages = new ArrayList<>(); @@ -355,4 +357,12 @@ public List getDiEdges() { return diEdges; } + public GraphicInfo getCurrentLabelGraphicInfo() { + return currentLabelGraphicInfo; + } + + public void setCurrentLabelGraphicInfo(GraphicInfo labelGraphicInfo) { + this.currentLabelGraphicInfo = labelGraphicInfo; + } + } diff --git a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/CmmnDIExport.java b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/CmmnDIExport.java index faa9ecd40d4..78acedf7d11 100644 --- a/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/CmmnDIExport.java +++ b/modules/flowable-cmmn-converter/src/main/java/org/flowable/cmmn/converter/export/CmmnDIExport.java @@ -18,6 +18,7 @@ import javax.xml.stream.XMLStreamWriter; +import org.apache.commons.lang3.StringUtils; import org.flowable.cmmn.converter.CmmnXmlConstants; import org.flowable.cmmn.model.Association; import org.flowable.cmmn.model.CmmnDiEdge; @@ -121,6 +122,10 @@ protected static void createCmmnShape(CmmnModel model, String elementId, XMLStre // The xsd requires a CMMNLabel to be there, even though the spec text says it's optional xtw.writeStartElement(CMMNDI_PREFIX, ELEMENT_DI_LABEL, CMMNDI_NAMESPACE); + GraphicInfo labelGraphicInfo = model.getLabelGraphicInfo(elementId); + if (labelGraphicInfo != null) { + addLabelElementContent(labelGraphicInfo, xtw); + } xtw.writeEndElement(); xtw.writeEndElement(); @@ -166,8 +171,24 @@ protected static void createCmmnEdge(CmmnModel model, String associationId, Stri // The xsd requires a CMMNLabel to be there, even though the spec text says it's optional xtw.writeStartElement(CMMNDI_PREFIX, ELEMENT_DI_LABEL, CMMNDI_NAMESPACE); + GraphicInfo labelGraphicInfo = model.getLabelGraphicInfo(edgeId); + if (labelGraphicInfo != null) { + addLabelElementContent(labelGraphicInfo, xtw); + } xtw.writeEndElement(); xtw.writeEndElement(); } + + protected static void addLabelElementContent(GraphicInfo labelGraphicInfo, XMLStreamWriter xtw) throws Exception { + if (labelGraphicInfo.getRotation() > 0) { + xtw.writeAttribute(FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_DI_ROTATION, String.valueOf(labelGraphicInfo.getRotation())); + } + xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE); + xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, String.valueOf(labelGraphicInfo.getHeight())); + xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, String.valueOf(labelGraphicInfo.getWidth())); + xtw.writeAttribute(ATTRIBUTE_DI_X, String.valueOf(labelGraphicInfo.getX())); + xtw.writeAttribute(ATTRIBUTE_DI_Y, String.valueOf(labelGraphicInfo.getY())); + xtw.writeEndElement(); + } } diff --git a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/LabelCmmnXmlConverterTest.java b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/LabelCmmnXmlConverterTest.java new file mode 100644 index 00000000000..7047b1be3d0 --- /dev/null +++ b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/LabelCmmnXmlConverterTest.java @@ -0,0 +1,46 @@ +/* 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.test.cmmn.converter; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.flowable.cmmn.model.CmmnModel; +import org.flowable.cmmn.model.GraphicInfo; +import org.flowable.test.cmmn.converter.util.CmmnXmlConverterTest; + +public class LabelCmmnXmlConverterTest { + + @CmmnXmlConverterTest("org/flowable/test/cmmn/converter/labelCase.cmmn") + public void validateModel(CmmnModel cmmnModel) { + assertThat(cmmnModel.getLabelLocationMap().size()).isEqualTo(2); + + // Test start event label + GraphicInfo labelGraphicInfo = cmmnModel.getLabelGraphicInfo("planItemcmmnEventListener_16"); + assertThat(labelGraphicInfo).isNotNull(); + assertThat(labelGraphicInfo.getX()).isEqualTo(350.0); + assertThat(labelGraphicInfo.getY()).isEqualTo(250.0); + assertThat(labelGraphicInfo.getWidth()).isEqualTo(85.0); + assertThat(labelGraphicInfo.getHeight()).isEqualTo(18.0); + assertThat(labelGraphicInfo.getRotation()).isEqualTo(30.0); + + // Test association label + GraphicInfo labelGraphicInfo2 = cmmnModel.getLabelGraphicInfo("CMMNEdge_cmmnConnector_19"); + assertThat(labelGraphicInfo2).isNotNull(); + assertThat(labelGraphicInfo2.getX()).isEqualTo(500.0); + assertThat(labelGraphicInfo2.getY()).isEqualTo(250.0); + assertThat(labelGraphicInfo2.getWidth()).isEqualTo(85.0); + assertThat(labelGraphicInfo2.getHeight()).isEqualTo(18.0); + assertThat(labelGraphicInfo2.getRotation()).isEqualTo(45.0); + } + +} diff --git a/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/labelCase.cmmn b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/labelCase.cmmn new file mode 100644 index 00000000000..9ed06d6ed69 --- /dev/null +++ b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/labelCase.cmmn @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + occur + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiEdge.java b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiEdge.java index 5f74f8e24f2..ca99559d248 100644 --- a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiEdge.java +++ b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiEdge.java @@ -25,6 +25,7 @@ public class CmmnDiEdge extends BaseElement { protected GraphicInfo sourceDockerInfo; protected GraphicInfo targetDockerInfo; protected List waypoints = new ArrayList<>(); + protected GraphicInfo labelGraphicInfo; public String getCmmnElementRef() { return cmmnElementRef; @@ -69,4 +70,12 @@ public List getWaypoints() { public void setWaypoints(List waypoints) { this.waypoints = waypoints; } + + public GraphicInfo getLabelGraphicInfo() { + return labelGraphicInfo; + } + + public void setLabelGraphicInfo(GraphicInfo labelGraphicInfo) { + this.labelGraphicInfo = labelGraphicInfo; + } } diff --git a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiShape.java b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiShape.java index 97cc8c69f12..294b4a46bd9 100644 --- a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiShape.java +++ b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/CmmnDiShape.java @@ -19,6 +19,7 @@ public class CmmnDiShape extends BaseElement { protected String cmmnElementRef; protected GraphicInfo graphicInfo; + protected GraphicInfo labelGraphicInfo; public String getCmmnElementRef() { return cmmnElementRef; @@ -35,4 +36,12 @@ public GraphicInfo getGraphicInfo() { public void setGraphicInfo(GraphicInfo graphicInfo) { this.graphicInfo = graphicInfo; } + + public GraphicInfo getLabelGraphicInfo() { + return labelGraphicInfo; + } + + public void setLabelGraphicInfo(GraphicInfo labelGraphicInfo) { + this.labelGraphicInfo = labelGraphicInfo; + } } diff --git a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/GraphicInfo.java b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/GraphicInfo.java index 4bd1dacd23b..36e3e69fb4a 100644 --- a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/GraphicInfo.java +++ b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/GraphicInfo.java @@ -25,6 +25,7 @@ public class GraphicInfo extends BaseElement { protected Boolean expanded; protected int xmlRowNumber; protected int xmlColumnNumber; + protected double rotation; public double getX() { return x; @@ -94,6 +95,14 @@ public void setXmlColumnNumber(int xmlColumnNumber) { this.xmlColumnNumber = xmlColumnNumber; } + public double getRotation() { + return rotation; + } + + public void setRotation(double rotation) { + this.rotation = rotation; + } + public boolean equals(GraphicInfo ginfo) { if (this.getX() != ginfo.getX()) { return false; @@ -107,6 +116,9 @@ public boolean equals(GraphicInfo ginfo) { if (this.getWidth() != ginfo.getWidth()) { return false; } + if (this.getRotation() != ginfo.getRotation()) { + return false; + } // check for zero value in case we are comparing model value to BPMN DI value // model values do not have xml location information