Search in sources :

Example 1 with UpdateModelKeyCmd

use of com.plumdo.flow.cmd.UpdateModelKeyCmd in project plumdo-work by wengwh.

the class ModelEditorResource method saveModelEditor.

@PostMapping(value = "/models/{modelId}/editor", name = "模型设计器保存模型")
@ResponseStatus(value = HttpStatus.OK)
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void saveModelEditor(@PathVariable String modelId, @RequestBody ModelEditorJsonRequest values) {
    Model model = getModel(modelId, values.isNewVersion());
    if (!model.getKey().equals(values.getKey())) {
        checkModelKeyExists(values.getKey());
        managementService.executeCommand(new UpdateModelKeyCmd(modelId, values.getKey()));
    }
    try {
        ObjectNode modelJson = (ObjectNode) objectMapper.readTree(model.getMetaInfo());
        modelJson.put("name", values.getName());
        modelJson.put("description", values.getDescription());
        model.setMetaInfo(modelJson.toString());
        model.setName(values.getName());
        model.setKey(values.getKey());
        repositoryService.saveModel(model);
        managementService.executeCommand(new SaveModelEditorCmd(model.getId(), values.getJsonXml()));
    } catch (Exception e) {
        logger.error("保存模型设计信息异常", e);
        exceptionFactory.throwDefinedException(ErrorConstant.MODEL_GET_EDITOR_ERROR, e.getMessage());
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Model(org.flowable.engine.repository.Model) UpdateModelKeyCmd(com.plumdo.flow.cmd.UpdateModelKeyCmd) SaveModelEditorCmd(com.plumdo.flow.cmd.SaveModelEditorCmd) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with UpdateModelKeyCmd

use of com.plumdo.flow.cmd.UpdateModelKeyCmd in project plumdo-work by wengwh.

the class ModelResource method updateModel.

@PutMapping(value = "/models/{modelId}", name = "模型修改")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public ModelResponse updateModel(@PathVariable String modelId, @RequestBody ModelRequest modelRequest) {
    Model model = getModelFromRequest(modelId);
    model.setCategory(modelRequest.getCategory());
    if (!modelRequest.getKey().equals(model.getKey())) {
        checkModelKeyExists(modelRequest.getKey());
        managementService.executeCommand(new UpdateModelKeyCmd(modelId, modelRequest.getKey()));
    }
    model.setKey(modelRequest.getKey());
    model.setName(modelRequest.getName());
    model.setMetaInfo(modelRequest.getMetaInfo());
    model.setTenantId(modelRequest.getTenantId());
    repositoryService.saveModel(model);
    return restResponseFactory.createModelResponse(model);
}
Also used : Model(org.flowable.engine.repository.Model) UpdateModelKeyCmd(com.plumdo.flow.cmd.UpdateModelKeyCmd) PutMapping(org.springframework.web.bind.annotation.PutMapping) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

UpdateModelKeyCmd (com.plumdo.flow.cmd.UpdateModelKeyCmd)2 Model (org.flowable.engine.repository.Model)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 SaveModelEditorCmd (com.plumdo.flow.cmd.SaveModelEditorCmd)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 PutMapping (org.springframework.web.bind.annotation.PutMapping)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1