コード例 #1
0
  @Override
  protected void setValue(Object element, Object value) {
    MongodbTreeViewDTO dto = (MongodbTreeViewDTO) element;

    // data 수정하자
    if (dto.getValue().equals(value.toString())) return;

    try {
      // 데이터가 올바른지 검사합니다.
      MongoDBJavaStrToJavaObj.convStrToObj(dto.getType(), value.toString());

      // fully key를 검색합니다.
      String fullyKey = findRealKey(dto, dto.getRealKey());
      if (logger.isDebugEnabled())
        logger.debug(
            "====>[update][real key]======> " + fullyKey + "\t [value]" + value.toString());

      MongoDBQuery.updateDocument(
          userDB, collectionName, dto.getDbObject(), fullyKey, value.toString());

    } catch (Exception e) {
      MessageDialog.openError(
          null,
          Messages.TreeViewerEditingSupport_2,
          Messages.TreeViewerEditingSupport_3
              + dto.getType()
              + Messages.TreeViewerEditingSupport_4);
      return;
    }

    dto.setValue(value.toString());
    viewer.refresh();
  }
コード例 #2
0
  /**
   * real key path를 얻는다
   *
   * @param dto
   * @param key
   */
  private String findRealKey(MongodbTreeViewDTO dto, String key) {
    String retVal = "";
    MongodbTreeViewDTO tmpDto = dto.getParent();
    //		logger.debug("[key]" + key + "[retVal]"+ retVal);

    if (tmpDto != null) {
      if (tmpDto.getRealKey() != null) {
        retVal += findRealKey(tmpDto, tmpDto.getRealKey() + "." + key);
      } else {
        retVal = key;
      }
    } else {
      retVal = key;
    }

    return retVal;
  }