public static void updateModel(Model copyModel, String modelName, ObjectNode metaInfo, String tenantId) { copyModel.setName(modelName); if (null != metaInfo) { copyModel.setMetaInfo(metaInfo.toString()); } copyModel.setTenantId(tenantId); }
public static Model getModelVariables(ObjectNode nodesVariables, Model model) throws Exception { if (StringUtils.isEmpty(nodesVariables) || StringUtils.isEmpty(nodesVariables.get(TAG_EX_MODEL))) { throw new Exception(""); } JsonNode modelNode = nodesVariables.get(TAG_EX_MODEL); model.setName(NodeVariableUtil.hasVariableEmpty(modelNode.get(ModelDataJsonConstants.MODEL_NAME))); model.setMetaInfo(NodeVariableUtil.hasVariableEmpty(modelNode.get(TAG_EX_METAINFO))); model.setTenantId("userId"); model.setVersion(Constants.DEFAULT_VERSION); if (!StringUtils.isEmpty(modelNode.get(ModelDataJsonConstants.MODEL_REVISION))) { model.setVersion(Integer.parseInt(modelNode.get(ModelDataJsonConstants.MODEL_REVISION).textValue())); } return model; }
@ApiOperation(value = "Create a model", tags = {"Models"}, notes = "All request values are optional. For example, you can only include the name attribute in the request body JSON-object, only setting the name of the model, leaving all other fields null.") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the model was created.") }) @RequestMapping(value = "/repository/models", method = RequestMethod.POST, produces = "application/json") public ModelResponse createModel(@RequestBody ModelRequest modelRequest, HttpServletRequest request, HttpServletResponse response) { Model model = repositoryService.newModel(); model.setCategory(modelRequest.getCategory()); model.setDeploymentId(modelRequest.getDeploymentId()); model.setKey(modelRequest.getKey()); model.setMetaInfo(modelRequest.getMetaInfo()); model.setName(modelRequest.getName()); model.setVersion(modelRequest.getVersion()); model.setTenantId(modelRequest.getTenantId()); repositoryService.saveModel(model); response.setStatus(HttpStatus.CREATED.value()); return restResponseFactory.createModelResponse(model); } }
model.setTenantId(modelRequest.getTenantId());