Skip to content

Commit

Permalink
feat: omit conversion messages in bpmn xml (#1066)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlukas authored Dec 3, 2024
1 parent d722886 commit 01ae562
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public abstract class AbstractConvertCommand implements Callable<Integer> {
@Option(names = "--disable-default-job-type", description = "Disables the default job type")
boolean defaultJobTypeDisabled;

@Option(
names = "--disable-append-elements",
description = "Disables adding conversion messages to the bpmn xml")
boolean disableAppendElements;

public AbstractConvertCommand() {
BpmnConverterFactory factory = BpmnConverterFactory.getInstance();
factory.getNotificationServiceFactory().setInstance(new PrintNotificationServiceImpl());
Expand Down Expand Up @@ -157,6 +162,7 @@ protected DefaultConverterProperties converterProperties() {
properties.setPlatformVersion(platformVersion);
properties.setDefaultJobTypeEnabled(!defaultJobTypeDisabled);
properties.setAppendDocumentation(documentation);
properties.setAppendElements(!disableAppendElements);
return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ public BpmnDiagramCheckResult check(
List<BpmnElementCheckMessage> messages = getMessages(element, result);
List<String> references = getReferences(element, result);
List<String> referencedBys = getReferencedBys(element, result);
conversionElementAppender.appendMessages(element, messages);
conversionElementAppender.appendReferences(element, references);
conversionElementAppender.appendReferencedBy(element, referencedBys);
if (properties.getAppendElements()) {
conversionElementAppender.appendMessages(element, messages);
conversionElementAppender.appendReferences(element, references);
conversionElementAppender.appendReferencedBy(element, referencedBys);
}
if (properties.getAppendDocumentation()) {
conversionElementAppender.appendDocumentation(
element, collectMessages(result, messages, references));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface ConverterProperties {
Boolean getDefaultJobTypeEnabled();

Boolean getAppendDocumentation();

Boolean getAppendElements();
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private void readDefaultValues(DefaultConverterProperties base, ConverterPropert
base::setDefaultJobTypeEnabled);
readFlag(
"append-documentation", properties::getAppendDocumentation, base::setAppendDocumentation);
readFlag("append-elements", properties::getAppendElements, base::setAppendElements);
}

private void readZeebeJobType(String jobType, Supplier<String> getter, Consumer<String> setter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class DefaultConverterProperties implements ConverterProperties {
private String platformVersion;
private Boolean defaultJobTypeEnabled;
private Boolean appendDocumentation;
private Boolean appendElements;

@Override
public Boolean getAppendDocumentation() {
Expand Down Expand Up @@ -91,4 +92,13 @@ public String getScriptFormatHeader() {
public void setScriptFormatHeader(String scriptFormatHeader) {
this.scriptFormatHeader = scriptFormatHeader;
}

@Override
public Boolean getAppendElements() {
return appendElements;
}

public void setAppendElements(Boolean appendElements) {
this.appendElements = appendElements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ zeebe-platform.version=8.6
flag.default-job-type-enabled=true
## Append documentation
flag.append-documentation=false
## Append elements
flag.append-elements=true
Original file line number Diff line number Diff line change
Expand Up @@ -792,4 +792,18 @@ void testCalledElementRefDeploymentBindingConversion() {
.getAttribute(ZEEBE, "bindingType"))
.isEqualTo("deployment");
}

@Test
void testShouldNotAppendElements() {
DefaultConverterProperties properties = new DefaultConverterProperties();
properties.setAppendElements(false);
ConverterProperties converterProperties =
ConverterPropertiesFactory.getInstance().merge(properties);
BpmnModelInstance bpmnModelInstance =
loadAndConvert("history-time-to-live.bpmn", converterProperties);
DomElement historyTimeToLive =
bpmnModelInstance.getDocument().getElementById("HistoryTimeToLive");
assertThat(historyTimeToLive).isNotNull();
assertThat(historyTimeToLive.getChildElements()).isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public static BpmnModelInstance loadAndConvert(String bpmnFile, String targetVer
return modelInstance;
}

public static BpmnModelInstance loadAndConvert(String bpmnFile, ConverterProperties properties) {
BpmnModelInstance modelInstance = loadModelInstance(bpmnFile);
BpmnConverter converter = BpmnConverterFactory.getInstance().get();
converter.convert(modelInstance, properties);
return modelInstance;
}

public static BpmnDiagramCheckResult loadAndCheck(String bpmnFile) {
ConverterProperties properties = ConverterPropertiesFactory.getInstance().get();
return loadAndCheckAgainstVersion(bpmnFile, properties.getPlatformVersion());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1gbx4qr" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.29.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:process id="HistoryTimeToLive" isExecutable="true" camunda:historyTimeToLive="180" />
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="HistoryTimeToLive" />
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit 01ae562

Please sign in to comment.