use of org.flowable.engine.repository.Model in project plumdo-work by wengwh.
the class ModelEditorResource method getEditorJson.
@RequestMapping(value = "/models/{modelId}/editor", method = RequestMethod.GET, produces = "application/json", name = "设计器获取模型信息")
public ObjectNode getEditorJson(@PathVariable String modelId) {
ObjectNode modelNode = null;
Model model = getModelFromRequest(modelId);
if (model != null) {
try {
if (StringUtils.isNotEmpty(model.getMetaInfo())) {
modelNode = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
} else {
modelNode = objectMapper.createObjectNode();
modelNode.put(MODEL_NAME, model.getName());
}
modelNode.put("key", model.getKey());
modelNode.put("category", model.getCategory());
modelNode.put("tenantId", model.getTenantId());
modelNode.put(MODEL_ID, model.getId());
ObjectNode editorJsonNode = (ObjectNode) objectMapper.readTree(new String(repositoryService.getModelEditorSource(model.getId()), "utf-8"));
editorJsonNode.put("modelType", "model");
modelNode.set("model", editorJsonNode);
} catch (Exception e) {
LOGGER.error("Error creating model JSON", e);
throw new FlowableException("Error creating model JSON", e);
}
}
return modelNode;
}
Aggregations