Beispiel #1
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;
  }
  /**
   * 閾値判定のシグナルを削除する。
   *
   * @param multipleResourceGraphName 閾値判定のシグナル名
   * @return 削除した閾値判定のシグナル名
   */
  @RequestMapping(value = "/delete", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto delete(
      @RequestParam(value = "multipleResourceGraphName") final String multipleResourceGraphName) {
    this.multipleResourceGraphService_.deletemultipleResourceGraphInfo(multipleResourceGraphName);
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("multipleResourceGraphName", multipleResourceGraphName);

    ResponseDto responseDto = new ResponseDto();
    responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
    responseDto.setData(map);
    return responseDto;
  }
Beispiel #4
0
  /**
   * 背景画像のリストを取得する。
   *
   * @param directoryPath 背景画像格納フォルダ
   * @param relativePath 相対パス
   * @return 背景画像のリスト取得結果
   */
  public ResponseDto getImageList(final String directoryPath, final String relativePath) {
    Map<String, String> imageMap = new HashMap<String, String>();
    File directory = new File(directoryPath);
    if (directory.isDirectory()) {
      File[] imageFile = directory.listFiles();

      for (File image : imageFile) {
        String imageName = image.getName();
        if (imageName.endsWith(".png")) {
          String imagePath = image.getPath();
          imageMap.put(imageName, relativePath + "/" + imageName);
        }
      }
    }

    ResponseDto responseDto = new ResponseDto();
    responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
    responseDto.setData(imageMap);
    return responseDto;
  }
  /**
   * 閾値判定の定義を編集する。
   *
   * @param mulResGraphDefinition 閾値判定の定義のJSONデータ
   * @return 編集後の閾値判定の定義
   */
  @RequestMapping(value = "/edit", method = RequestMethod.POST)
  @ResponseBody
  public ResponseDto edit(
      @RequestParam(value = "mulResGraphDefinition") final String mulResGraphDefinition) {
    ResponseDto responseDto = new ResponseDto();
    MultipleResourceGraphDefinitionDto multipleResourceGraphDefinitionDto =
        JSON.decode(mulResGraphDefinition, MultipleResourceGraphDefinitionDto.class);

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

    // DBに登録されている定義を更新する
    MultipleResourceGraphDefinitionDto updatedDefinitionDto =
        this.multipleResourceGraphService_.updatemultipleResourceGraphInfo(
            multipleResourceGraphInfo);
    responseDto.setResult(ResponseConstants.RESULT_SUCCESS);
    responseDto.setData(updatedDefinitionDto);

    return responseDto;
  }