-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Save element name in extension element if it has any new lines (#3946)
- Loading branch information
1 parent
be6593b
commit 68468df
Showing
18 changed files
with
958 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...ble-bpmn-converter/src/main/java/org/flowable/bpmn/converter/child/ElementNameParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* 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.bpmn.converter.child; | ||
|
||
import javax.xml.stream.XMLStreamReader; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.flowable.bpmn.model.BaseElement; | ||
import org.flowable.bpmn.model.BpmnModel; | ||
import org.flowable.bpmn.model.FlowElement; | ||
|
||
public class ElementNameParser extends BaseChildElementParser { | ||
|
||
@Override | ||
public String getElementName() { | ||
return ATTRIBUTE_ELEMENT_NAME; | ||
} | ||
|
||
@Override | ||
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception { | ||
String elementName = xtr.getElementText(); | ||
if (StringUtils.isNotEmpty(elementName)) { | ||
if (parentElement instanceof FlowElement) { | ||
((FlowElement) parentElement).setName(elementName.trim()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...le-bpmn-converter/src/test/java/org/flowable/editor/language/xml/NameWithNewLineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* 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 static org.flowable.bpmn.constants.BpmnXMLConstants.ATTRIBUTE_ELEMENT_NAME; | ||
|
||
import org.flowable.bpmn.model.BpmnModel; | ||
import org.flowable.bpmn.model.ExtensionElement; | ||
import org.flowable.bpmn.model.FlowElement; | ||
import org.flowable.bpmn.model.SubProcess; | ||
import org.flowable.editor.language.xml.util.BpmnXmlConverterTest; | ||
|
||
class NameWithNewLineTest { | ||
|
||
@BpmnXmlConverterTest("nameWithNewLineTestProcess.bpmn") | ||
void validateModel(BpmnModel model) { | ||
FlowElement flowElement = model.getMainProcess().getFlowElement("startnoneevent1"); | ||
assertThat(flowElement.getName()).isEqualTo("start\nevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = model.getMainProcess().getFlowElement("bpmnCatchEvent_12"); | ||
assertThat(flowElement.getName()).isEqualTo("intermediate\nevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = model.getMainProcess().getFlowElement("bpmnGateway_14"); | ||
assertThat(flowElement.getName()).isEqualTo("gate\nway"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = model.getMainProcess().getFlowElement("bpmnEndEvent_3"); | ||
assertThat(flowElement.getName()).isEqualTo("end\nevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
SubProcess subProcess = (SubProcess) model.getMainProcess().getFlowElement("bpmnStructure_1"); | ||
assertThat(subProcess.getName()).isEqualTo("sub\nprocess"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = subProcess.getFlowElement("bpmnTask_5"); | ||
assertThat(flowElement.getName()).isEqualTo("user\ntask"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = subProcess.getFlowElement("bpmnBoundaryEvent_10"); | ||
assertThat(flowElement.getName()).isEqualTo("boundary\nevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
} | ||
|
||
@BpmnXmlConverterTest("nameWithoutNewLineTestProcess.bpmn") | ||
void validateModelWithoutNewLines(BpmnModel model) { | ||
FlowElement flowElement = model.getMainProcess().getFlowElement("startnoneevent1"); | ||
assertThat(flowElement.getName()).isEqualTo("startevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = model.getMainProcess().getFlowElement("bpmnCatchEvent_12"); | ||
assertThat(flowElement.getName()).isEqualTo("intermediateevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = model.getMainProcess().getFlowElement("bpmnGateway_14"); | ||
assertThat(flowElement.getName()).isEqualTo("gateway"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = model.getMainProcess().getFlowElement("bpmnEndEvent_3"); | ||
assertThat(flowElement.getName()).isEqualTo("endevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
SubProcess subProcess = (SubProcess) model.getMainProcess().getFlowElement("bpmnStructure_1"); | ||
assertThat(subProcess.getName()).isEqualTo("subprocess"); | ||
assertThat(subProcess.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = subProcess.getFlowElement("bpmnTask_5"); | ||
assertThat(flowElement.getName()).isEqualTo("usertask"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
|
||
flowElement = subProcess.getFlowElement("bpmnBoundaryEvent_10"); | ||
assertThat(flowElement.getName()).isEqualTo("boundaryevent"); | ||
assertThat(flowElement.getExtensionElements().get(ATTRIBUTE_ELEMENT_NAME)).isNull(); | ||
} | ||
} |
Oops, something went wrong.