Search in sources :

Example 11 with FlowableException

use of org.flowable.engine.common.api.FlowableException 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;
}
Also used : FlowableException(org.flowable.engine.common.api.FlowableException) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Model(org.flowable.engine.repository.Model) BpmnModel(org.flowable.bpmn.model.BpmnModel) FlowableException(org.flowable.engine.common.api.FlowableException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FlowableException (org.flowable.engine.common.api.FlowableException)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 BpmnModel (org.flowable.bpmn.model.BpmnModel)7 Model (org.flowable.engine.repository.Model)7 ProcessDefinition (org.flowable.engine.repository.ProcessDefinition)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 InputStream (java.io.InputStream)5 BpmnXMLConverter (org.flowable.bpmn.converter.BpmnXMLConverter)5 BpmnJsonConverter (org.flowable.editor.language.json.converter.BpmnJsonConverter)5 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)5 FlowableObjectNotFoundException (org.flowable.engine.common.api.FlowableObjectNotFoundException)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 FlowableIllegalArgumentException (org.flowable.engine.common.api.FlowableIllegalArgumentException)3 Deployment (org.flowable.engine.repository.Deployment)3 DeploymentBuilder (org.flowable.engine.repository.DeploymentBuilder)3 HttpHeaders (org.springframework.http.HttpHeaders)3 ResponseEntity (org.springframework.http.ResponseEntity)3 Transactional (org.springframework.transaction.annotation.Transactional)3 InputStreamReader (java.io.InputStreamReader)2