hello,
i m traying to merge my custom Json editor with stencilset_bpmn.json and stencilset_cmmn.json. on the result i cant show my custom.json on page.(pic1)
1- Added new json folder …flowable-engine\modules\flowable-ui-modeler\flowable-ui-modeler-logic\src\main\resources\custom_stencilset_webapp.json
2- chance, flowable-engine\modules\flowable-ui-modeler\flowable-ui-modeler-rest\src\main\java\org\flowable\ui\modeler\rest\app\StencilSetResource.java
public class StencilSetResource {
private static final Logger LOGGER = LoggerFactory.getLogger(StencilSetResource.class);
protected ObjectMapper objectMapper;
@RequestMapping(value = "/rest/stencil-sets/editor", method = RequestMethod.GET, produces = "application/json")
public JsonNode getStencilSetForEditor() {
try {
JsonNode stencilNode = objectMapper
.readTree(this.getClass().getClassLoader().getResourceAsStream("stencilset_bpmn.json"));
_JsonNode robusta = objectMapper.readTree(this.getClass().getClassLoader().getResourceAsStream("stencilset_cmmn.json"));_
return merge(stencilNode, robusta);
} catch (Exception e) {
LOGGER.error("Error reading bpmn stencil set json", e);
throw new InternalServerErrorException("Error reading bpmn stencil set json");
}
}
@RequestMapping(value = "/rest/stencil-sets/cmmneditor", method = RequestMethod.GET, produces = "application/json")
public JsonNode getCmmnStencilSetForEditor() {
try {
JsonNode stencilNode = objectMapper
.readTree(this.getClass().getClassLoader().getResourceAsStream("stencilset_cmmn.json"));
JsonNode robusta = objectMapper
.readTree(this.getClass().getClassLoader().getResourceAsStream("custom_stencilset_webapp.json"));
return merge(stencilNode, robusta);
} catch (Exception e) {
LOGGER.error("Error reading bpmn stencil set json", e);
throw new InternalServerErrorException("Error reading bpmn stencil set json");
}
}
public static JsonNode merge(JsonNode mainNode, JsonNode updateNode) {
Iterator<String> fieldNames = updateNode.fieldNames();
while (fieldNames.hasNext()) {
String updatedFieldName = fieldNames.next();
JsonNode valueToBeUpdated = mainNode.get(updatedFieldName);
JsonNode updatedValue = updateNode.get(updatedFieldName);
// If the node is an @ArrayNode
if (valueToBeUpdated != null && valueToBeUpdated.isArray() &&
updatedValue.isArray()) {
// running a loop for all elements of the updated ArrayNode
for (int i = 0; i < updatedValue.size(); i++) {
JsonNode updatedChildNode = updatedValue.get(i);
// Create a new Node in the node that should be updated, if there was no corresponding node in it
// Use-case - where the updateNode will have a new element in its Array
if (valueToBeUpdated.size() <= i) {
((ArrayNode) valueToBeUpdated).add(updatedChildNode);
}
// getting reference for the node to be updated
JsonNode childNodeToBeUpdated = valueToBeUpdated.get(i);
merge(childNodeToBeUpdated, updatedChildNode);
}
// if the Node is an @ObjectNode
} else if (valueToBeUpdated != null && valueToBeUpdated.isObject()) {
merge(valueToBeUpdated, updatedValue);
} else {
if (mainNode instanceof ObjectNode) {
((ObjectNode) mainNode).replace(updatedFieldName, updatedValue);
}
}
}
return mainNode;
}
after I’ve tried merge stencilset_bpmn.json and stencilset_cmmn.json. all merge object come to application but not working(pic 2)
Q1. how can i merge my custom.json and bmpn or cmmn.json? Where should I change?
Q2. which class i have to chance for work all new object?
Thank you