/** {@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);
  }
  /** {@inheritDoc} */
  @Override
  public ReportDesignModel saveOrUpdateModel(ReportDesignModel model)
      throws ReportModelOperationException {
    if (model == null) {
      logger.warn("current model is null");
      throw new ReportModelOperationException("model can not be null");
    }
    if (StringUtils.isEmpty(model.getName())) {
      logger.debug("model's name can not be empty");
      throw new ReportModelOperationException("model's name can not be empty");
    }
    if (StringUtils.isEmpty(model.getId())) {
      model.setId(UuidGeneratorUtils.generate());
    }
    try {
      ReportDesignModel oldReport = getModelByIdOrName(model.getId(), false);
      if (oldReport != null) {
        try {
          this.deleteModel(oldReport, true);
        } catch (Exception e) {
          try {
            fileService.rm(generateOriDevReportLocation(model));
          } catch (Exception e1) {
            logger.error(e.getMessage(), e);
          }
        }
      }
      boolean rs =
          fileService.write(generateDevReportLocation(model), SerializationUtils.serialize(model));
      if (rs) {
        return model;
      }
    } catch (FileServiceException e) {
      logger.error(e.getMessage(), e);
    }

    return null;
  }