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());
}
}
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);
}
Aggregations