16
16
17
17
import org .apache .commons .lang3 .StringUtils ;
18
18
import org .flowable .cmmn .converter .CmmnXmlConstants ;
19
+ import org .flowable .cmmn .converter .CmmnXmlConverterOptions ;
19
20
import org .flowable .cmmn .converter .util .CmmnXmlUtil ;
20
21
import org .flowable .cmmn .model .CmmnModel ;
21
22
import org .flowable .cmmn .model .PlanItemDefinition ;
@@ -35,20 +36,20 @@ public abstract class AbstractPlanItemDefinitionExport<T extends PlanItemDefinit
35
36
* @param xtw the XML to write the definition to
36
37
* @throws Exception in case of write exception
37
38
*/
38
- public void writePlanItemDefinition (CmmnModel model , T planItemDefinition , XMLStreamWriter xtw ) throws Exception {
39
+ public void writePlanItemDefinition (CmmnModel model , T planItemDefinition , XMLStreamWriter xtw , CmmnXmlConverterOptions options ) throws Exception {
39
40
40
41
writePlanItemDefinitionStartElement (planItemDefinition , xtw );
41
- writePlanItemDefinitionCommonAttributes (planItemDefinition , xtw );
42
+ writePlanItemDefinitionCommonAttributes (planItemDefinition , xtw , options );
42
43
writePlanItemDefinitionSpecificAttributes (planItemDefinition , xtw );
43
44
44
- boolean didWriteExtensionElement = writePlanItemDefinitionCommonElements (model , planItemDefinition , xtw );
45
+ boolean didWriteExtensionElement = writePlanItemDefinitionCommonElements (model , planItemDefinition , xtw , options );
45
46
didWriteExtensionElement = writePlanItemDefinitionExtensionElements (model , planItemDefinition , didWriteExtensionElement , xtw );
46
47
if (didWriteExtensionElement ) {
47
48
xtw .writeEndElement ();
48
49
}
49
50
50
51
writePlanItemDefinitionDefaultItemControl (model , planItemDefinition , xtw );
51
- writePlanItemDefinitionBody (model , planItemDefinition , xtw );
52
+ writePlanItemDefinitionBody (model , planItemDefinition , xtw , options );
52
53
writePlanItemDefinitionEndElement (xtw );
53
54
}
54
55
@@ -64,10 +65,11 @@ protected void writePlanItemDefinitionStartElement(T planItemDefinition, XMLStre
64
65
*/
65
66
protected abstract String getPlanItemDefinitionXmlElementValue (T planItemDefinition );
66
67
67
- protected void writePlanItemDefinitionCommonAttributes (T planItemDefinition , XMLStreamWriter xtw ) throws Exception {
68
+ protected void writePlanItemDefinitionCommonAttributes (T planItemDefinition , XMLStreamWriter xtw , CmmnXmlConverterOptions options ) throws Exception {
68
69
xtw .writeAttribute (ATTRIBUTE_ID , planItemDefinition .getId ());
69
70
70
- if (StringUtils .isNotEmpty (planItemDefinition .getName ()) && !CmmnXmlUtil .containsNewLine (planItemDefinition .getName ())) {
71
+ if (StringUtils .isNotEmpty (planItemDefinition .getName ()) &&
72
+ !(options .isSaveElementNameWithNewLineInExtensionElement () && CmmnXmlUtil .containsNewLine (planItemDefinition .getName ()))) {
71
73
xtw .writeAttribute (ATTRIBUTE_NAME , planItemDefinition .getName ());
72
74
}
73
75
}
@@ -92,14 +94,17 @@ protected void writePlanItemDefinitionSpecificAttributes(T planItemDefinition, X
92
94
* @param xtw the XML to write the definition to
93
95
* @throws Exception in case of write exception
94
96
*/
95
- protected boolean writePlanItemDefinitionCommonElements (CmmnModel model , T planItemDefinition , XMLStreamWriter xtw ) throws Exception {
97
+ protected boolean writePlanItemDefinitionCommonElements (CmmnModel model , T planItemDefinition , XMLStreamWriter xtw , CmmnXmlConverterOptions options ) throws Exception {
96
98
if (StringUtils .isNotEmpty (planItemDefinition .getDocumentation ())) {
97
99
xtw .writeStartElement (ELEMENT_DOCUMENTATION );
98
100
xtw .writeCharacters (planItemDefinition .getDocumentation ());
99
101
xtw .writeEndElement ();
100
102
}
101
103
102
- boolean didWriteExtensionStartElement = CmmnXmlUtil .writeElementNameExtensionElement (planItemDefinition , false , xtw );
104
+ boolean didWriteExtensionStartElement = false ;
105
+ if (options .isSaveElementNameWithNewLineInExtensionElement ()) {
106
+ didWriteExtensionStartElement = CmmnXmlUtil .writeElementNameExtensionElement (planItemDefinition , didWriteExtensionStartElement , xtw );
107
+ }
103
108
104
109
return CmmnXmlUtil .writeExtensionElements (planItemDefinition , didWriteExtensionStartElement , model .getNamespaces (), xtw );
105
110
}
@@ -122,7 +127,7 @@ protected void writePlanItemDefinitionDefaultItemControl(CmmnModel model, T plan
122
127
* @param xtw the XML to write the definition to
123
128
* @throws Exception in case of write exception
124
129
*/
125
- protected void writePlanItemDefinitionBody (CmmnModel model , T planItemDefinition , XMLStreamWriter xtw ) throws Exception {
130
+ protected void writePlanItemDefinitionBody (CmmnModel model , T planItemDefinition , XMLStreamWriter xtw , CmmnXmlConverterOptions options ) throws Exception {
126
131
127
132
}
128
133
0 commit comments