/** {@inheritDoc} */ @Override public boolean updateReportModel(ReportDesignModel model, boolean modelInCache) { ReportDesignModel persModel = DeepcopyUtils.deepCopy(model); // 如果当前model在编辑状态,需要更新持久化的model的name if (isNameExist(model.getName(), model.getId())) { return false; } if (modelInCache) { persModel = getModelByIdOrName(model.getId(), false); } try { try { this.deleteModel(persModel, true); } catch (Exception e) { try { fileService.rm(generateOriDevReportLocation(persModel)); } catch (FileServiceException e1) { throw new ReportModelOperationException(e1); } } persModel.setName(model.getName()); this.saveOrUpdateModel(persModel); } catch (ReportModelOperationException e) { logger.error(e.getMessage(), e); return false; } return true; }
/** {@inheritDoc} */ @Override public ReportDesignModel copyModel(String src, String targetName) throws ReportModelOperationException { if (StringUtils.isEmpty(src)) { logger.warn("source name is empty"); throw new ReportModelOperationException("source name is empty"); } if (StringUtils.isEmpty(targetName)) { logger.warn("target name is empty"); throw new ReportModelOperationException("target name is empty"); } if (isNameExist(targetName)) { throw new ReportModelOperationException("target name already exists: " + targetName); } if (isNameExist(src)) { ReportDesignModel model = getModelByIdOrName(src, false); model.setId(UuidGeneratorUtils.generate()); model.setName(targetName); MiniCubeSchema schema = (MiniCubeSchema) model.getSchema(); if (schema != null) { schema.setId(UuidGeneratorUtils.generate()); } return saveOrUpdateModel(model); } throw new ReportModelOperationException("source not exists: " + src); }