Skip to content

Commit

Permalink
added isExecutable property (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoika committed Jan 10, 2025
1 parent cfdd3c0 commit 8bbdbbc
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,37 @@ public boolean handlesBPMNElement(final BPMNElement bpmnElement) {
public void buildPropertiesForm(final BPMNElement bpmnElement, final DataBuilder dataBuilder,
final SchemaBuilder schemaBuilder, final UISchemaBuilder uiSchemaBuilder) {

String sIsExecuteable = "Yes";
Participant participant = (Participant) bpmnElement;
BPMNProcess process;
try {
process = modelState.getBpmnModel().openProcess(participant.getProcessRef());
if (!process.isExecutable()) {
sIsExecuteable = "No";
}
} catch (BPMNModelException e) {
// no op
}

dataBuilder //
.addData("name", bpmnElement.getName()) //
.addData("isExecutable", sIsExecuteable) //
.addData("documentation", bpmnElement.getDocumentation());

String[] executeOptions = { "Yes", "No" };
schemaBuilder. //
addProperty("name", "string", null). //
// addProperty("execution", "string", null). //
addProperty("isExecutable", "string", null, executeOptions). //
addProperty("documentation", "string", "Participant description.");

Map<String, String> radioOption = new HashMap<>();
radioOption.put("format", "radio");

uiSchemaBuilder. //
addCategory("General"). //
addLayout(Layout.HORIZONTAL). //
addElements("name"). //
addElement("isExecutable", "Executeable", radioOption). //
addLayout(Layout.VERTICAL). //
addElement("documentation", "Documentation", this.getFileEditorOption());

Expand All @@ -127,35 +145,45 @@ public boolean updatePropertiesData(final JsonObject json, final String category
bpmnElement.setName(json.getString("name", ""));
process.setName(json.getString("name", ""));
((BPMNGNode) gNodeElement).setName(json.getString("name", ""));

String jExecuteable = json.getString("isExecutable", "Yes");
if ("No".equals(jExecuteable)) {
process.setExecutable(false);
} else {
process.setExecutable(true);
}

bpmnElement.setDocumentation(json.getString("documentation", ""));

// LaneSet...
List<String> laneDataIDs = new ArrayList<>(); // collect remaining lanes
logger.debug("...update feature = " + "lanes");
JsonArray laneSetValues = json.getJsonArray("lanes");
for (JsonValue laneValue : laneSetValues) {
// update lane properties
JsonObject laneData = (JsonObject) laneValue;
if (laneData.get("id") != null) {
String id = laneData.getJsonString("id").getString();
// String id = jsonID.toString();
laneDataIDs.add(id);
Lane bpmnLane = process.findLaneById(id);
if (bpmnLane != null) {
bpmnLane.setName(laneData.getString("name"));
bpmnLane.setDocumentation(laneData.getString("documentation"));
// update gnode...
Optional<GModelElement> _gLane = modelState.getIndex().get(bpmnLane.getId());
if (_gLane.isPresent()) {
LaneGNode gLane = (LaneGNode) _gLane.get();
gLane.setName(laneData.getString("name"));
if (laneSetValues != null) {
for (JsonValue laneValue : laneSetValues) {
// update lane properties
JsonObject laneData = (JsonObject) laneValue;
if (laneData.get("id") != null) {
String id = laneData.getJsonString("id").getString();
// String id = jsonID.toString();
laneDataIDs.add(id);
Lane bpmnLane = process.findLaneById(id);
if (bpmnLane != null) {
bpmnLane.setName(laneData.getString("name"));
bpmnLane.setDocumentation(laneData.getString("documentation"));
// update gnode...
Optional<GModelElement> _gLane = modelState.getIndex().get(bpmnLane.getId());
if (_gLane.isPresent()) {
LaneGNode gLane = (LaneGNode) _gLane.get();
gLane.setName(laneData.getString("name"));
}
}
} else {
// this is a new lane - construct the lane in the BPMN model first..
Lane bpmnLane = process.addLane("Lane " + (process.getLanes().size() + 1));
laneDataIDs.add(bpmnLane.getId());
updateClient = true;
}
} else {
// this is a new lane - construct the lane in the BPMN model first..
Lane bpmnLane = process.addLane("Lane " + (process.getLanes().size() + 1));
laneDataIDs.add(bpmnLane.getId());
updateClient = true;
}
}
// now we need to delete all lanes no longer part of the laneSetValues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ public void closeArray() {

}

// public void closeArray() {
// if (arrayObjectBuilder != null) {
// arrayBuilder.add(arrayObjectBuilder.build());
// arrayObjectBuilder = null;
// rootBuilder.add(arrayName, arrayBuilder.build());
// arrayBuilder = null;
// }
// }

/**
* Returns a String with the JSON UISchema
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class BPMNProcess extends BPMNElement {
private static Logger logger = Logger.getLogger(BPMNProcess.class.getName());

protected String processType = BPMNTypes.PROCESS_TYPE_NONE;
protected boolean isExecutable = true;
protected Set<Activity> activities = null;
protected Set<DataObject> dataObjects = null;
protected Set<DataStoreReference> dataStoreReferences = null;
Expand Down Expand Up @@ -80,6 +81,15 @@ public BPMNProcess(BPMNModel model, Element element, String processType) {
element.setAttribute("processType", processType);
}
setProcessType(processType);

// set executeable flag onloy for private process
if (BPMNTypes.PROCESS_TYPE_PRIVATE.equals(processType)) {
if ("false".equals(this.elementNode.getAttribute("isExecutable"))) {
setExecutable(false);
} else {
setExecutable(true);
}
}
}

public String getProcessType() {
Expand All @@ -90,6 +100,15 @@ public void setProcessType(String processType) {
this.processType = processType;
}

public boolean isExecutable() {
return isExecutable;
}

public void setExecutable(boolean isExecutable) {
this.isExecutable = isExecutable;
this.elementNode.setAttribute("isExecutable", "" + isExecutable);
}

/**
* This method parses the content of the process element and adds all tasks,
* gateways and events. This is a lazy loading mechanism called by the BPMNModel
Expand Down

0 comments on commit 8bbdbbc

Please sign in to comment.