Skip to content

Commit

Permalink
improved message and signal validation and validation mapping (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jan 21, 2025
1 parent d3644a9 commit 89b2dff
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,13 @@ public boolean updatePropertiesData(final JsonObject json, final String category
Element eventDefinitionElement = iter.next();
JsonObject jsonData = dataList.getJsonObject(i);
if (jsonData != null) {
eventDefinitionElement.setAttribute("messageRef", jsonData.getString("messageRef", ""));
String oldRef = eventDefinitionElement.getAttribute("messageRef");
String newRef = jsonData.getString("messageRef", "");
eventDefinitionElement.setAttribute("messageRef", newRef);
if (!newRef.equals(oldRef)) {
// reset validation and update the client view
updateClient = true;
}
}
i++;
// update completed
Expand All @@ -194,7 +200,7 @@ public boolean updatePropertiesData(final JsonObject json, final String category
}

if (updateClient) {
// modelState.reset();
bpmnElement.resetValidation();
modelState.refreshGModelState();

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,20 @@ public boolean updatePropertiesData(final JsonObject json, final String category
Element eventDefinitionElement = iter.next();
JsonObject jsonData = dataList.getJsonObject(i);
if (jsonData != null) {
eventDefinitionElement.setAttribute("signalRef", jsonData.getString("signal", ""));
String oldRef = eventDefinitionElement.getAttribute("signalRef");
String newRef = jsonData.getString("signal", "");
eventDefinitionElement.setAttribute("signalRef", newRef);
if (!newRef.equals(oldRef)) {
// reset validation and update the client view
updateClient = true;
}
}
i++;
// update completed
}
}
if (updateClient) {
// modelState.reset();
bpmnElement.resetValidation();
modelState.refreshGModelState();
}
return updateClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.openbpmn.bpmn.exceptions.BPMNModelException;
import org.openbpmn.bpmn.validation.BPMNValidationHandler;
import org.openbpmn.bpmn.validation.BPMNValidationMarker;
import org.openbpmn.bpmn.validation.BPMNValidationMarker.ErrorType;
import org.openbpmn.extensions.BPMNElementExtension;
import org.openbpmn.glsp.model.BPMNGModelState;

Expand Down Expand Up @@ -173,9 +174,19 @@ public List<Marker> doBatchValidation(final GModelElement element) {
List<Marker> result = new ArrayList<>();
for (BPMNValidationMarker bpmnMarker : bpmnExtensionMarkers) {
if (bpmnMarker.getElementId().equals(element.getId())) {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.ERROR));
if (bpmnMarker.getErrorType() == ErrorType.ERROR) {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.ERROR));
} else if (bpmnMarker.getErrorType() == ErrorType.WARNING) {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.WARNING));
} else {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.INFO));
}
}
}

Expand All @@ -192,9 +203,20 @@ public List<Marker> doLiveValidation(GModelElement element) {
List<Marker> result = new ArrayList<>();
for (BPMNValidationMarker bpmnMarker : bpmnMarkers) {
if (bpmnMarker.getElementId().equals(element.getId())) {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.ERROR));
if (bpmnMarker.getErrorType() == ErrorType.ERROR) {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.ERROR));
} else if (bpmnMarker.getErrorType() == ErrorType.WARNING) {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.WARNING));
} else {
result.add(new Marker(bpmnMarker.getLabel(), bpmnMarker.getDescription(),
bpmnMarker.getElementId(),
MarkerKind.INFO));
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ public List<BPMNValidationMarker> validate() {
if (!hasMessage) {
this.addValidationMarker(
new BPMNValidationMarker("Event",
"A Event must have a corresponding Message!", this.getId(),
BPMNValidationMarker.ErrorType.ERROR));
"A Message Event Definition should be assigned to a corresponding Message Object!",
this.getId(),
BPMNValidationMarker.ErrorType.WARNING));
}
});

Expand All @@ -247,8 +248,9 @@ public List<BPMNValidationMarker> validate() {
if (!hasMessage) {
this.addValidationMarker(
new BPMNValidationMarker("Event",
"A Event must have a corresponding Signal!", this.getId(),
BPMNValidationMarker.ErrorType.ERROR));
"A Signal Event Definition should be assigned to a corresponding Signal!",
this.getId(),
BPMNValidationMarker.ErrorType.WARNING));
}
});

Expand Down

0 comments on commit 89b2dff

Please sign in to comment.