Search in sources :

Example 11 with Model

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;
}
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

Model (org.flowable.engine.repository.Model)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 FlowableException (org.flowable.engine.common.api.FlowableException)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 BpmnModel (org.flowable.bpmn.model.BpmnModel)6 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)6 BpmnJsonConverter (org.flowable.editor.language.json.converter.BpmnJsonConverter)5 Transactional (org.springframework.transaction.annotation.Transactional)5 BpmnXMLConverter (org.flowable.bpmn.converter.BpmnXMLConverter)4 InputStream (java.io.InputStream)3 Deployment (org.flowable.engine.repository.Deployment)3 ProcessDefinition (org.flowable.engine.repository.ProcessDefinition)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 XMLInputFactory (javax.xml.stream.XMLInputFactory)2 XMLStreamReader (javax.xml.stream.XMLStreamReader)2 FlowableObjectNotFoundException (org.flowable.engine.common.api.FlowableObjectNotFoundException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 DeployModelCmd (com.plumdo.flow.cmd.DeployModelCmd)1