Exemplo n.º 1
0
  /**
   * Get the ModelParameter Struct for a given parameter name based on a given data model.
   *
   * @param model
   * @param paramName
   * @return
   */
  public static ModelParameter getModelParameter(Model model, String paramName) {
    /** Get the parameter's parent object in the data model */
    ModelObject modelObject = getObjectByParamName(model, paramName);
    if (modelObject == null) {
      log.error("Unable to find parent object for parameter " + paramName);
      return null;
    }

    /** Short Parameter name within the object */
    String paramShortName = paramName.substring(paramName.lastIndexOf(".") + 1, paramName.length());
    /*
    log.debug("paramName " + paramName +
            ": modelObjectName " + modelObject.getName() + ", parameterShortName " + paramShortName);
    */

    /** lookup the parameter within the parent object */
    for (ModelParameter modelParameter : modelObject.getParameterArray()) {
      if (paramShortName.equals(modelParameter.getName())) {
        return modelParameter;
      }
    }
    log.error(
        "Unable to find parameter "
            + paramShortName
            + " within object "
            + modelObject.getName()
            + "!");
    return null;
  }
Exemplo n.º 2
0
  /**
   * Find Model Object by Name
   *
   * @param objName
   * @return
   */
  public static ModelObject getObjectByObjName(Model model, String objName) {
    for (ModelObject object : model.getObjectArray()) {
      if (object.getName().equals(objName)) {
        return object;
      }
    }

    return null;
  }