public IElementParameter getElementParameter(String name) {
    if (name.contains(":")) { // look for the parent first, then will //$NON-NLS-1$
      // retrieve the children
      StringTokenizer token = new StringTokenizer(name, ":"); // $NON-NLS-1$
      String parentId = token.nextToken();
      String childId = token.nextToken();
      for (int i = 0; i < elementParameters.size(); i++) {
        if (elementParameters.get(i).getName().equals(parentId)) {
          IElementParameter parent = elementParameters.get(i);
          return parent.getChildParameters().get(childId);
        }
      }
    } else {
      for (IElementParameter elementParam : elementParameters) {
        if (elementParam.getName().equals(name)) {
          return elementParam;
        }
      }
    }

    // if not found, look for the name if it's the name of a children
    // this code is added only for compatibility and will be executed only
    // one time
    // to initialize the child.
    // The parameters name are unique, so we just take the first one.
    for (IElementParameter elementParam : elementParameters) {
      for (String key : elementParam.getChildParameters().keySet()) {
        IElementParameter param = elementParam.getChildParameters().get(key);
        if (param.getName().equals(name)) {
          return param;
        }
      }
    }
    return null;
  }
 public void setUniqueName(String uniqueName) {
   for (IElementParameter param : elementParameters) {
     if (param.getName().equals("UNIQUE_NAME")) { // $NON-NLS-1$
       param.setValue(uniqueName);
     }
   }
   this.uniqueName = uniqueName;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.process.INode#renameData(java.lang.String, java.lang.String)
   */
  public void renameData(String oldName, String newName) {
    if (oldName.equals(newName)) {
      return;
    }

    for (IElementParameter param : this.getElementParameters()) {
      if (param.getName().equals("UNIQUE_NAME") || isSQLQueryParameter(param)) { // $NON-NLS-1$
        continue;
      }
      ParameterValueUtil.renameValues(param, oldName, newName);
    }
  }
 private static Map<String, String> copyLine(
     Map<String, Object> currentLine, IElementParameter param) {
   Map<String, String> newLine = new HashMap<String, String>();
   String[] items = param.getListItemsDisplayCodeName();
   for (int i = 0; i < items.length; i++) {
     Object o = currentLine.get(items[i]);
     if (o instanceof Integer) {
       IElementParameter tmpParam = (IElementParameter) param.getListItemsValue()[i];
       if ((((Integer) o) == -1) || (tmpParam.getListItemsValue().length == 0)) {
         newLine.put(items[i], ""); // $NON-NLS-1$
       } else {
         newLine.put(items[i], (String) tmpParam.getListItemsValue()[(Integer) o]);
       }
     } else {
       if (o instanceof String) {
         if (param.getName().equals("SQLPATTERN_VALUE")) { // $NON-NLS-1$
           SQLPatternItem item =
               SQLPatternUtils.getItemFromCompoundId(param.getElement(), ((String) o));
           if (item != null) {
             newLine.put(items[i], new String(item.getContent().getInnerContent()));
           } else {
             newLine.put(items[i], ""); // $NON-NLS-1$
           }
         } else if (param.getElement() != null
             && param.getElement() instanceof INode
             && ((INode) param.getElement()).getComponent().getName().equals("tWebService")) {
           String replacedValue = (String) o;
           if (items[i].equals("EXPRESSION")) {
             String inputRow = "row1";
             List connList = ((INode) param.getElement()).getIncomingConnections();
             if (connList.size() > 0) {
               inputRow = ((IConnection) connList.get(0)).getName();
               replacedValue = replacedValue.replace("input.", inputRow + ".");
             }
           }
           newLine.put(items[i], replacedValue);
         } else {
           newLine.put(items[i], (String) o);
         }
       } else {
         if (o instanceof Boolean) {
           newLine.put(items[i], ((Boolean) o).toString());
         } else {
           newLine.put(items[i], ""); // $NON-NLS-1$
         }
       }
     }
   }
   return newLine;
 }
  /*
   * (non-Javadoc)
   *
   * @see org.talend.core.model.process.INode#useData(java.lang.String)
   */
  public boolean useData(String name) {

    for (IElementParameter param : this.getElementParameters()) {
      if (param.getFieldType() == EParameterFieldType.IMAGE) {
        continue;
      }
      if (param.getName().equals("UNIQUE_NAME")) { // $NON-NLS-1$
        continue;
      }
      if (ParameterValueUtil.isUseData(param, name)) {
        return true;
      }
    }
    return false;
  }
  @SuppressWarnings("unchecked")
  private static String getDisplayValue(final IElementParameter param) {
    Object value = param.getValue();

    if (value instanceof String) {

      if (param.getName().equals("PROCESS_TYPE_VERSION")
          && value.equals(RelationshipItemBuilder.LATEST_VERSION)) { // $NON-NLS-1$
        String jobId =
            (String)
                param
                    .getParentParameter()
                    .getChildParameters()
                    .get("PROCESS_TYPE_PROCESS")
                    .getValue(); //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId);
        if (processItem == null) {
          return ""; //$NON-NLS-1$
        }
        return processItem.getProperty().getVersion();
      }
      if (param.getName().equals("PROCESS_TYPE_CONTEXT")) { // $NON-NLS-1$
        String jobId =
            (String)
                param
                    .getParentParameter()
                    .getChildParameters()
                    .get("PROCESS_TYPE_PROCESS")
                    .getValue(); //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId);
        if (processItem == null) {
          return ""; //$NON-NLS-1$
        }
        // check if the selected context exists, if not, use the default context of the job.
        boolean contextExists = false;
        for (Object object : processItem.getProcess().getContext()) {
          if (object instanceof ContextType) {
            if (((ContextType) object).getName() != null
                && ((ContextType) object).getName().equals(value)) {
              contextExists = true;
              continue;
            }
          }
        }
        if (!contextExists) {
          return processItem.getProcess().getDefaultContext();
        }
        return (String) value;
      }
      // hywang add for 6484
      if ("SELECTED_FILE".equals(param.getRepositoryValue())) { // $NON-NLS-N$ //$NON-NLS-1$
        IElementParameter propertyParam =
            param
                .getElement()
                .getElementParameter(
                    "PROPERTY:REPOSITORY_PROPERTY_TYPE"); // $NON-NLS-N$ //$NON-NLS-1$
        if (propertyParam != null
            && propertyParam.getValue() != null
            && !propertyParam.getValue().equals("")) { // $NON-NLS-1$
          try {
            IRepositoryViewObject object =
                CoreRuntimePlugin.getInstance()
                    .getProxyRepositoryFactory()
                    .getLastVersion((String) propertyParam.getValue());
            if (object != null) {
              Item item = object.getProperty().getItem();
              String extension = null;

              String rule = ""; // $NON-NLS-1$
              String processLabelAndVersion = null;
              if (item instanceof RulesItem) {
                RulesItem rulesItem = (RulesItem) item;
                extension = rulesItem.getExtension();
                if (param.getElement() instanceof INode) {
                  INode node = (INode) param.getElement();
                  IProcess process = node.getProcess();
                  String jobLabel = process.getName();
                  String jobVersion = process.getVersion();
                  processLabelAndVersion =
                      JavaResourcesHelper.getJobFolderName(jobLabel, jobVersion);
                }

                rule =
                    "rules/final/"
                        + processLabelAndVersion
                        + "/"
                        + rulesItem.getProperty().getLabel() // $NON-NLS-1$ //$NON-NLS-2$
                        + rulesItem.getProperty().getVersion()
                        + extension;
              }
              return TalendQuoteUtils.addQuotes(rule);
            } else {
              return param.getValue().toString();
            }
          } catch (Exception e) {
            ExceptionHandler.process(e);
          }
        }
      }

      return (String) value;
    }
    if (param.getFieldType() == EParameterFieldType.RADIO
        || param.getFieldType() == EParameterFieldType.CHECK
        || param.getFieldType() == EParameterFieldType.AS400_CHECK) {
      if (value instanceof Boolean) {
        return ((Boolean) param.getValue()).toString();
      } else {
        return Boolean.FALSE.toString();
      }
    }

    if (param.getFieldType() == EParameterFieldType.TABLE) {
      List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
      String[] items = param.getListItemsDisplayCodeName();
      String stringValues = "{"; // $NON-NLS-1$
      for (int i = 0; i < tableValues.size(); i++) {
        Map<String, Object> lineValues = tableValues.get(i);
        stringValues += "["; // $NON-NLS-1$
        for (int j = 0; j < items.length; j++) {

          Object currentValue = lineValues.get(items[j]);
          if (currentValue instanceof Integer) {
            IElementParameter tmpParam = (IElementParameter) param.getListItemsValue()[j];
            if (tmpParam.getListItemsDisplayName().length != 0) {
              stringValues += tmpParam.getListItemsDisplayName()[(Integer) currentValue];
            }
          } else {
            stringValues += currentValue;
          }

          if (j != (items.length - 1)) {
            stringValues += ","; // $NON-NLS-1$
          }
        }
        stringValues += "]"; // $NON-NLS-1$
        if (i != (tableValues.size() - 1)) {
          stringValues += ","; // $NON-NLS-1$
        }
      }
      stringValues += "}"; // $NON-NLS-1$
      return stringValues;
    }

    return new String(""); // $NON-NLS-1$
  }
 /**
  * see bug 4733
  *
  * <p>DOC YeXiaowei Comment method "isSQLQueryParameter".
  *
  * @param parameter
  * @return
  */
 private boolean isSQLQueryParameter(final IElementParameter parameter) {
   return parameter.getFieldType().equals(EParameterFieldType.MEMO_SQL)
       && parameter.getName().equals("QUERY"); // $NON-NLS-1$
 }