Example #1
0
  /**
   * In ODA layer, it references the index positions of input parameters and output parameters in a
   * single sequential list. However, in ODI layer, we need to clearly distinguish them since only
   * retrieving output parameter is supported and it should be based on its own output parameter
   * index. Therefore, this method will do such a conversion from the output parameter index to the
   * parameter index.
   *
   * @param index based on output parameter order
   * @return index based on the whole parameters order
   * @throws DataException
   */
  private int getCorrectParamIndex(int index) throws DataException {
    if (index <= 0)
      throw new DataException(
          ResourceConstants.INVALID_OUTPUT_PARAMETER_INDEX, Integer.valueOf(index));

    int newIndex = 0; // 1-based
    int curOutputIndex = 0; // 1-based

    Collection collection = getParameterMetaData();
    if (collection != null) {
      Iterator it = collection.iterator();
      while (it.hasNext()) {
        newIndex++;

        IParameterMetaData metaData = (IParameterMetaData) it.next();
        if (metaData.isOutputMode().booleanValue() == true) {
          curOutputIndex++;

          if (curOutputIndex == index) break;
        }
      }
    }

    if (curOutputIndex < index)
      throw new DataException(
          ResourceConstants.OUTPUT_PARAMETER_OUT_OF_BOUND, Integer.valueOf(index));

    return newIndex;
  }
Example #2
0
  /**
   * Validate the name of output parameter
   *
   * @param name
   * @throws DataException
   */
  private void checkOutputParamNameValid(String name) throws DataException {
    assert name != null;

    boolean isValid = false;

    Collection collection = getParameterMetaData();
    if (collection != null) {
      Iterator it = collection.iterator();
      while (it.hasNext()) {
        IParameterMetaData metaData = (IParameterMetaData) it.next();

        String paramName = metaData.getName();
        if (paramName.equals(name)) {
          isValid = metaData.isOutputMode().booleanValue();
          break;
        }
      }
    }

    if (isValid == false)
      throw new DataException(ResourceConstants.INVALID_OUTPUT_PARAMETER_NAME, name);
  }