Пример #1
0
  /**
   * マップを登録する。
   *
   * @param mapInfo 登録するマップ情報
   * @return 登録結果電文
   */
  public ResponseDto insert(final MapInfo mapInfo) {
    ResponseDto responseDto = new ResponseDto();
    if (getByName(mapInfo.name).size() > 0) {
      String errorMessage = MessageUtil.getMessage("WEWD0160", new Object[] {});
      responseDto.setMessage(errorMessage);
      responseDto.setResult(ResponseConstants.RESULT_FAIL);
      return responseDto;
    }

    // 最終更新日時を設定
    mapInfo.lastUpdate = new Timestamp(Calendar.getInstance().getTimeInMillis());
    int count = 0;
    try {
      count = mapInfoDao_.insert(mapInfo);
      if (count > 0) {
        responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
      } else {
        String errorMessage = MessageUtil.getMessage("WEWD0161", new Object[] {});
        responseDto.setResult(ResponseConstants.RESULT_FAIL);
        responseDto.setMessage(errorMessage);
      }

      return responseDto;
    } catch (DuplicateKeyException dkEx) {
      LOGGER.log(LogMessageCodes.SQL_EXCEPTION, dkEx, dkEx.getMessage());
      String errorMessage = MessageUtil.getMessage("WEWD0160", new Object[] {});
      responseDto.setMessage(errorMessage);
      responseDto.setResult(ResponseConstants.RESULT_FAIL);
      return responseDto;
    }
  }
Пример #2
0
  /**
   * マップを削除する。
   *
   * @param mapId マップID
   * @return 削除結果
   */
  public ResponseDto removeMapById(final long mapId) {
    int count = 0;
    ResponseDto responseDto = new ResponseDto();
    try {
      count = mapInfoDao_.deleteById(mapId);
      if (count == 0) {
        String errorMessage = MessageUtil.getMessage("WEWD0166", new Object[] {});
        responseDto.setMessage(errorMessage);
        responseDto.setResult(ResponseConstants.RESULT_FAIL);
        return responseDto;
      }

      responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
      return responseDto;
    } catch (PersistenceException pEx) {
      Throwable cause = pEx.getCause();
      if (cause instanceof SQLException) {
        SQLException sqlEx = (SQLException) cause;
        LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage());
      } else {
        LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage());
      }

      String errorMessage = MessageUtil.getMessage("WEWD0167", new Object[] {});
      responseDto.setMessage(errorMessage);
      responseDto.setResult(ResponseConstants.RESULT_FAIL);
      return responseDto;
    }
  }
Пример #3
0
  /**
   * マップを更新する。
   *
   * @param mapInfo マップ情報
   * @return 更新結果電文
   */
  public ResponseDto update(final MapInfo mapInfo) {
    // 最終更新日時を設定
    mapInfo.lastUpdate = new Timestamp(Calendar.getInstance().getTimeInMillis());
    int count = 0;
    ResponseDto responseDto = new ResponseDto();
    try {
      count = mapInfoDao_.update(mapInfo);
      if (count > 0) {
        responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
      } else {
        String errorMessage = MessageUtil.getMessage("WEWD0162", new Object[] {});
        responseDto.setResult(ResponseConstants.RESULT_FAIL);
        responseDto.setMessage(errorMessage);
      }

      return responseDto;
    } catch (PersistenceException pEx) {
      Throwable cause = pEx.getCause();
      if (cause instanceof SQLException) {
        SQLException sqlEx = (SQLException) cause;
        LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage());
      } else {
        LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage());
      }

      String errorMessage = MessageUtil.getMessage("WEWD0163", new Object[] {});
      responseDto.setMessage(errorMessage);
      responseDto.setResult(ResponseConstants.RESULT_FAIL);
      return responseDto;
    }
  }
Пример #4
0
  /**
   * マップを取得する。
   *
   * @param mapId Target mapId
   * @return 取得結果
   */
  public ResponseDto getById(final long mapId) {
    ResponseDto responseDto = new ResponseDto();
    try {
      MapInfo mapInfo = mapInfoDao_.selectById(mapId);
      if (mapInfo == null) {
        String errorMessage = MessageUtil.getMessage("WEWD0164", new Object[] {});
        responseDto.setMessage(errorMessage);
        responseDto.setResult(ResponseConstants.RESULT_FAIL);
        return responseDto;
      }

      Map<String, String> convertData = this.convertDataMap(mapInfo);
      responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
      responseDto.setData(convertData);

      return responseDto;
    } catch (PersistenceException pEx) {
      Throwable cause = pEx.getCause();
      if (cause instanceof SQLException) {
        SQLException sqlEx = (SQLException) cause;
        LOGGER.log(LogMessageCodes.SQL_EXCEPTION, sqlEx, sqlEx.getMessage());
      } else {
        LOGGER.log(LogMessageCodes.SQL_EXCEPTION, pEx, pEx.getMessage());
      }

      String errorMessage = MessageUtil.getMessage("WEWD0165", new Object[] {});
      responseDto.setMessage(errorMessage);
      responseDto.setResult(ResponseConstants.RESULT_FAIL);
      return responseDto;
    }
  }
  /**
   * 閾値判定の定義を新規に追加する。
   *
   * @param mulResGraphDefinition 閾値判定の定義のJSONデータ
   * @return 追加した閾値判定の定義
   */
  @RequestMapping(value = "/add", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto add(
      @RequestParam(value = "mulResGraphDefinition") final String mulResGraphDefinition) {
    ResponseDto responseDto = new ResponseDto();
    MultipleResourceGraphDefinitionDto multipleResourceGraphDefinitionDto =
        JSON.decode(mulResGraphDefinition, MultipleResourceGraphDefinitionDto.class);

    String multipleResourceGraphName =
        multipleResourceGraphDefinitionDto.getMultipleResourceGraphName();
    boolean hasSameMulResGraphName =
        this.multipleResourceGraphService_.hasSamemultipleResourceGraphName(
            multipleResourceGraphName);
    if (hasSameMulResGraphName) {
      String errorMessage = MessageUtil.getMessage("WEWD0131", multipleResourceGraphName);
      responseDto.setResult(ResponseConstants.RESULT_FAIL);
      responseDto.setMessage(errorMessage);
      return responseDto;
    }

    MultipleResourceGraphInfo multipleResourceGraphInfo =
        this.multipleResourceGraphService_.convertMultipleResourceGraphInfo(
            multipleResourceGraphDefinitionDto);

    // DBに追加する
    MultipleResourceGraphDefinitionDto addedDefinitionDto =
        this.multipleResourceGraphService_.insertMultipleResourceGraphInfo(
            multipleResourceGraphInfo);

    responseDto.setData(addedDefinitionDto);
    responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
    return responseDto;
  }