public static void convertVarNodesToDefineFunctions(VarTable varTable, List<INode> iNodes) {
   // Send back the change to the tPigLoad node if you modified the configure of define dunctions
   for (INode iNode : iNodes) {
     IElementParameter elementParameter =
         iNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION);
     if (elementParameter != null && elementParameter.getValue() instanceof List) {
       List<Map<String, String>> defineFunctions =
           (List<Map<String, String>>) elementParameter.getValue();
       defineFunctions.clear();
       defineFunctionsAlias.clear();
       for (VarNode varNode : varTable.getNodes()) {
         if (iNode.getUniqueName().equals(varNode.getType())) {
           Map<String, String> item = new HashMap<String, String>();
           item.put(
               PigMapConstants.FUNCTION_ALIAS,
               TalendQuoteUtils.addQuotesIfNotExist(varNode.getName()));
           if (varNode.getExpression() != null) {
             String newString = varNode.getExpression().trim();
             if (newString.length() > 0) {
               newString = TalendQuoteUtils.addQuotesIfNotExist(newString);
             }
             item.put(PigMapConstants.UDF_FUNCTION, newString);
           } else {
             item.put(PigMapConstants.UDF_FUNCTION, ""); // $NON-NLS-1$
           }
           defineFunctions.add(item);
           String key = varNode.getName();
           if (!defineFunctionsAlias.containsKey(key)) {
             defineFunctionsAlias.put(key, varNode.getExpression());
           }
         }
       }
     }
   }
 }
 public static void checkPigLoadIfDefineFunctions(INode iNode, List<INode> iNodes) {
   if (iNode != null) {
     List<? extends IConnection> connections = iNode.getIncomingConnections();
     for (IConnection conn : connections) {
       INode oriNode = conn.getSource();
       if (oriNode != null) {
         if (oriNode.getUniqueName() != null
             && oriNode.getUniqueName().startsWith(PigMapConstants.TPIGLOAD_NODE)) {
           IElementParameter elementParameter =
               oriNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION);
           if (elementParameter != null && elementParameter.getValue() instanceof List) {
             // we can add this direct.
             List<Map<String, String>> defineFunctions =
                 (List<Map<String, String>>) elementParameter.getValue();
             if (defineFunctions.size() >= 0) {
               iNodes.add(oriNode);
             }
           }
         }
         if (iNode.getIncomingConnections().size() > 0) {
           checkPigLoadIfDefineFunctions(oriNode, iNodes);
         }
       }
     }
   }
 }
 public static List<VarNode> convertDefineFunctionsToVarNodes(
     MapperManager mapperManger, List<INode> iNodes) {
   List<VarNode> varNodes = new ArrayList<VarNode>();
   if (mapperManger != null) {
     PigMapComponent mapperComponent = mapperManger.getMapperComponent();
     iNodesDefineFunctions.clear();
     defineFunctionsAlias.clear();
     checkPigLoadIfDefineFunctions(mapperComponent, iNodes);
     iNodesDefineFunctions.addAll(iNodes);
     for (INode iNode : iNodes) {
       IElementParameter elementParameter =
           iNode.getElementParameter(PigMapConstants.DEFINE_FUNCTION);
       if (elementParameter != null && elementParameter.getValue() instanceof List) {
         List<Map<String, String>> defineFunctions =
             (List<Map<String, String>>) elementParameter.getValue();
         if (defineFunctions.size() > 0) {
           for (Map<String, String> item : defineFunctions) {
             VarNode newVarNode = PigmapFactory.eINSTANCE.createVarNode();
             newVarNode.setType(iNode.getUniqueName());
             newVarNode.setName(item.get(PigMapConstants.FUNCTION_ALIAS));
             newVarNode.setExpression(item.get(PigMapConstants.UDF_FUNCTION));
             varNodes.add(newVarNode);
             String key = item.get(PigMapConstants.FUNCTION_ALIAS);
             if (!defineFunctionsAlias.containsKey(key)) {
               defineFunctionsAlias.put(key, item.get(PigMapConstants.UDF_FUNCTION));
             }
           }
         }
       }
     }
   }
   return varNodes;
 }
  @Override
  public void execute() {
    oldType = (String) paramEncoding.getValue();

    String tempValue = newRealValue;
    tempValue = tempValue.replaceAll("'", ""); // $NON-NLS-1$ //$NON-NLS-2$
    tempValue = tempValue.replaceAll("\"", ""); // $NON-NLS-1$ //$NON-NLS-2$

    boolean newIsCustomAndoldIsNotCustom =
        tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)
            && !paramEncoding.getValue().equals(EmfComponent.ENCODING_TYPE_CUSTOM);
    boolean newIsNotCustomAndoldIsCustom =
        !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)
            && paramEncoding.getValue().equals(EmfComponent.ENCODING_TYPE_CUSTOM);
    boolean toRefresh = false;
    if (fromCombo && (newIsCustomAndoldIsNotCustom || newIsNotCustomAndoldIsCustom)) {
      toRefresh = true;
    }
    if (ArrayUtils.contains(paramEncoding.getListItemsValue(), tempValue)) {
      paramEncoding.setValue(tempValue);
    }
    if (toRefresh) {
      getElement().setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
      if (DynamicTabbedPropertySection.getLastPropertyUsed() != null) {
        DynamicTabbedPropertySection.getLastPropertyUsed().refresh();
      }
    }
    super.execute();
  }
 /*
  * use to synchronize column list for output connections.
  */
 private void syncOutputNodeColumnsList(List<ColumnNameChanged> columnNameChanged) {
   if (outputdataContainer == null) {
     return;
   }
   for (IConnection conn : node.getOutgoingConnections()) {
     INode targetNode = conn.getTarget();
     EConnectionType connStyle = conn.getLineStyle();
     if (EConnectionType.FLOW_MAIN.equals(connStyle)
         || EConnectionType.FLOW_MERGE.equals(connStyle)
         || EConnectionType.FLOW_REF.equals(connStyle)) {
       ColumnListController.updateColumnList(targetNode, columnNameChanged);
       // fix for TDI-23202
       // reset value in order to call "firePropertyChange(RETURNS_CHANGED, null, null)"
       IElementParameter defaultMap =
           targetNode.getElementParameter(EParameterName.DEFAULT_MAP.getName());
       if (defaultMap != null) {
         if ("tFlowToIterate".equals(targetNode.getComponent().getName())) {
           // update target properties incase any old columns are removed
           IElementParameter elementParameter = targetNode.getElementParameter("MAP");
           if (elementParameter != null) {
             Object value = elementParameter.getValue();
             if (value instanceof List) {
               for (Object obj : (List) value) {
                 if (obj instanceof Map) {
                   Object object = ((Map) obj).get("VALUE");
                   if (newOutputMetadata != null
                       && !newOutputMetadata.getListColumns().isEmpty()) {
                     boolean found = false;
                     for (IMetadataColumn column : newOutputMetadata.getListColumns()) {
                       if (column.getLabel().equals(object)) {
                         found = true;
                       }
                     }
                     if (!found) {
                       ((Map) obj)
                           .put("VALUE", newOutputMetadata.getListColumns().get(0).getLabel());
                     }
                   } else {
                     ((Map) obj).put("VALUE", "");
                   }
                 }
               }
             }
           }
         }
         targetNode.setPropertyValue(EParameterName.DEFAULT_MAP.getName(), defaultMap.getValue());
       }
     }
   }
 }
  @SuppressWarnings("unchecked")
  protected void updateColumnList(IMetadataTable oldTable, IMetadataTable newTable) {
    final List<ColumnNameChanged> columnNameChanged =
        MetadataToolHelper.getColumnNameChanged(oldTable, newTable);

    if (inputNode != null) {
      List<IElementParameter> eps = (List<IElementParameter>) inputNode.getElementParameters();
      if (eps != null) {
        boolean end = false;
        for (int i = 0; i < eps.size() && !end; i++) {
          IElementParameter parameter = eps.get(i);
          if (parameter.getFieldType() == EParameterFieldType.TABLE) {
            end = true;
            if (parameter != null) {
              List<Map<String, Object>> map2 = (List<Map<String, Object>>) parameter.getValue();
              if (map2 != null
                  && inputNode.getMetadataList().get(0).getListColumns().size() != map2.size()) {
                ColumnListController.updateColumnList(inputNode, columnNameChanged);
              }
            }
          }
        }
      }
      inputNode.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
    }
    node.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
  }
 public static Object getParameterValue(Element elem, String paramName) {
   IElementParameter param = elem.getElementParameter(paramName);
   if (param != null) {
     return param.getValue();
   }
   return null;
 }
 /*
  * (non-Javadoc)
  *
  * @see
  * org.talend.designer.core.ICheckNodesService#checkNode(org.talend.designer
  * .core.ui.editor.nodes.Node)
  */
 public void checkNode(Node node) {
   if (!node.getComponent().getName().equals("cJMS")) { // $NON-NLS-1$
     return;
   }
   List<? extends IElementParameter> parameters = node.getElementParameters();
   for (IElementParameter param : parameters) {
     if (param.getFieldType() == EParameterFieldType.ROUTE_COMPONENT_TYPE) {
       IElementParameter idParam =
           param.getChildParameters().get(EParameterName.ROUTE_COMPONENT_TYPE_ID.getName());
       if (idParam == null
           || idParam.getValue() == null
           || idParam.getValue().toString().isEmpty()) {
         String errorMessage =
             MessageFormat.format(
                 CamelDesignerMessages.getString(
                     "CheckJMSNodesService_emptyParaError") //$NON-NLS-1$
                 ,
                 param.getDisplayName());
         Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
       } else {
         List<? extends INode> graphicalNodes = node.getProcess().getGraphicalNodes();
         boolean has = false;
         for (INode n : graphicalNodes) {
           if (n.getUniqueName().equals(idParam.getValue())) {
             has = true;
             break;
           }
         }
         if (!has) {
           String errorMessage =
               MessageFormat.format(
                   CamelDesignerMessages.getString("CheckJMSNodesService_nonExistError"),
                   param.getDisplayName()); // $NON-NLS-1$
           Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
         }
       }
     }
   }
 }
 /** qzhang Comment method "setXMLMAPPING". */
 protected void setXMLMAPPING() {
   if (getConnection() != null) {
     for (IElementParameter parameter : node.getElementParameters()) {
       if (parameter.getFieldType() == EParameterFieldType.TABLE
           && parameter.getRepositoryValue() != null
           && parameter.getRepositoryValue().equals("XML_MAPPING")) { // $NON-NLS-1$
         List<Map<String, Object>> value2 = (List<Map<String, Object>>) parameter.getValue();
         RepositoryToComponentProperty.getTableXMLMappingValue(
             getConnection(), value2, newOutputMetadata, getColumnRenameMap());
         IElementParameter elementParameter =
             node.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
         if (elementParameter != null) {
           if (EmfComponent.BUILTIN.equals(elementParameter.getValue())) {
             parameter.setRepositoryValueUsed(false);
           } else {
             parameter.setRepositoryValueUsed(true);
           }
         }
       }
     }
   }
 }
 private void setDBVersionForMysql(IElementParameter dbVersionParam, String dbType) {
   if ("MYSQL".equals(dbType)) {
     String[] drivers = StatsAndLogsConstants.MYSQL_VERSION_DRIVER;
     // if driver is not set , set to the default
     boolean found = false;
     for (String driver : drivers) {
       if (driver.equals(dbVersionParam.getValue())) {
         found = true;
       }
     }
     if (!found) {
       dbVersionParam.setValue(drivers[0]);
     }
   }
 }
 @Override
 public void refresh(IElementParameter param, boolean checkErrorsWhenViewRefreshed) {
   Text text = (Text) hashCurControls.get(param.getName());
   if (text == null || text.isDisposed()) {
     return;
   }
   Object value = param.getValue();
   if (value == null) {
     text.setText(""); // $NON-NLS-1$
   } else {
     if (!value.equals(text.getText())) {
       text.setText((String) value);
     }
   }
   if (checkErrorsWhenViewRefreshed) {
     checkErrorsForPropertiesOnly(text);
   }
 }
  @Override
  public void refresh(IElementParameter param, boolean check) {
    CCombo combo = (CCombo) hashCurControls.get(param.getName());
    if (combo == null || combo.isDisposed()) {
      return;
    }
    updateData();

    String[] curNameList = param.getListItemsDisplayName();

    Object value = param.getValue();

    combo.setItems(curNameList);
    if (value instanceof String) {
      combo.setText(TalendTextUtils.removeQuotes((String) value));
    }

    if (param.isContextMode()) {
      Button buttonEdit = (Button) hashCurControls.get(param.getName() + BUTTON_EDIT);
      combo.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
      combo.setEnabled(false);
      buttonEdit.setEnabled(false);
    }
  }
  /**
   * DOC qzhang Comment method "changeTableNameParameter".
   *
   * @param newdbTableName
   * @param olddbTableName
   * @param uniqueName
   * @param dbTableElementField
   */
  private void changeTableNameParameter(
      String newdbTableName,
      String olddbTableName,
      String uniqueName,
      IElementParameter dbTableElementField) {
    if (dbTableElementField != null) {
      if (isNotSim) {
        newdbTableName = newdbTableName == null ? "" : newdbTableName; // $NON-NLS-1$
        dbTableElementField.setValue(TalendTextUtils.addQuotes(newdbTableName));
        return;
      }
      Object value = dbTableElementField.getValue();
      String removeQuotes = TalendTextUtils.removeQuotes((String) value);
      boolean b = value == null || removeQuotes.equals(""); // $NON-NLS-1$
      // add the code for table name equals uniqueName
      b = b || uniqueName.equals(olddbTableName);
      b = b || value != null && removeQuotes.toString().equals(olddbTableName);

      if (b) {
        newdbTableName = newdbTableName == null ? "" : newdbTableName; // $NON-NLS-1$
        dbTableElementField.setValue(TalendTextUtils.addQuotes(newdbTableName));
      }
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.talend.designer.core.ICheckNodesService#checkNode(org.talend.designer
   * .core.ui.editor.nodes.Node)
   */
  public void checkNode(Node node) {
    if (!node.getComponent().getName().equals("cCXF")) { // $NON-NLS-1$
      return;
    }
    IElementParameter resourceParam =
        node.getElementParameter(EParameterName.ROUTE_RESOURCE_TYPE_ID.getName());
    IElementParameter wsdlFileParam = node.getElementParameter("WSDL_FILE"); // $NON-NLS-1$
    IElementParameter serviceParam = node.getElementParameter("SERVICE_TYPE"); // $NON-NLS-1$
    IElementParameter wsdlTypeParam = node.getElementParameter("WSDL_TYPE"); // $NON-NLS-1$
    IElementParameter clazzParam = node.getElementParameter("SERVICE_CLASS"); // $NON-NLS-1$

    // Select WSDL
    if (serviceParam != null && "wsdlURL".equals(serviceParam.getValue())) { // $NON-NLS-1$
      // Select File
      if (wsdlTypeParam != null && "file".equals(wsdlTypeParam.getValue())) { // $NON-NLS-1$
        // WSDL file is empty
        if (wsdlFileParam == null
            || wsdlFileParam.getValue() == null
            || wsdlFileParam.getValue().toString().isEmpty()
            || wsdlFileParam.getValue().toString().equals("\"\"")) { // $NON-NLS-1$
          String errorMessage =
              MessageFormat.format(
                  CamelDesignerMessages.getString("CheckCXFNodesService_emptyError") // $NON-NLS-1$
                  ,
                  wsdlFileParam == null ? "" : wsdlFileParam.getDisplayName());
          Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
        }
      } // Select Repository
      else if (wsdlTypeParam != null && "repo".equals(wsdlTypeParam.getValue())) { // $NON-NLS-1$
        // WSDL file is empty
        String errorMessage = ""; // $NON-NLS-1$
        if (resourceParam == null
            || resourceParam.getValue() == null
            || resourceParam.getValue().toString().isEmpty()) {
          errorMessage =
              MessageFormat.format(
                  CamelDesignerMessages.getString("CheckCXFNodesService_emptyError") // $NON-NLS-1$
                  ,
                  wsdlFileParam.getDisplayName());
          Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
        } else {
          String id = (String) resourceParam.getValue();
          try {
            IRepositoryViewObject lastVersion =
                ProxyRepositoryFactory.getInstance().getLastVersion(id);
            if (lastVersion == null) {
              errorMessage =
                  MessageFormat.format(
                      CamelDesignerMessages.getString(
                          "CheckCXFNodesService_nonexistError") //$NON-NLS-1$
                      ,
                      wsdlFileParam.getDisplayName());
              Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
            } else if (lastVersion.isDeleted()) {
              errorMessage =
                  MessageFormat.format(
                      CamelDesignerMessages.getString(
                          "CheckCXFNodesService_removedError") //$NON-NLS-1$
                      ,
                      resourceParam.getDisplayName());
              Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
            }
          } catch (PersistenceException e) {
            errorMessage =
                MessageFormat.format(
                    CamelDesignerMessages.getString(
                        "CheckCXFNodesService_emptyError") //$NON-NLS-1$
                    ,
                    wsdlFileParam.getDisplayName());
            Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
          }
        }
      }
    }
    // Select Service class
    else if (serviceParam != null
        && "serviceClass".equals(serviceParam.getValue())) { // $NON-NLS-1$
      // Service class is empty
      if (clazzParam == null
          || clazzParam.getValue() == null
          || clazzParam.getValue().toString().isEmpty()) {
        String errorMessage =
            MessageFormat.format(
                CamelDesignerMessages.getString("CheckCXFNodesService_emptyError") // $NON-NLS-1$
                ,
                wsdlFileParam.getDisplayName());
        Problems.add(ProblemStatus.ERROR, (Element) node, errorMessage);
      }
    }
  }
  public static ElementParameterType getElemeterParameterType(IElementParameter param) {
    if (param == null) {
      return null;
    }
    ElementParameterType targetPramType = TalendFileFactory.eINSTANCE.createElementParameterType();
    if (param.getParentParameter() != null) {
      targetPramType.setName(
          param.getParentParameter().getName() + ":" + param.getName()); // $NON-NLS-1$
    } else {
      targetPramType.setName(param.getName());
    }
    targetPramType.setField(param.getFieldType().getName());
    targetPramType.setContextMode(param.isContextMode());
    Object value = param.getValue();
    if (param.getFieldType().equals(EParameterFieldType.TABLE) && value != null) {
      List<Map<String, Object>> tableValues = (List<Map<String, Object>>) value;
      for (Map<String, Object> currentLine : tableValues) {
        for (int i = 0; i < param.getListItemsDisplayCodeName().length; i++) {
          ElementValueType elementValue = TalendFileFactory.eINSTANCE.createElementValueType();
          elementValue.setElementRef(param.getListItemsDisplayCodeName()[i]);
          Object o = currentLine.get(param.getListItemsDisplayCodeName()[i]);

          IElementParameter tmpParam = null;
          Object[] listItemsValue = param.getListItemsValue();
          if (listItemsValue.length > i) {
            tmpParam = (IElementParameter) listItemsValue[i];
          }
          String strValue = ""; // $NON-NLS-1$
          if (o instanceof Integer && tmpParam != null) {
            if (tmpParam.getListItemsValue().length == 0) {
              strValue = ""; // $NON-NLS-1$
            } else {
              strValue = (String) tmpParam.getListItemsValue()[(Integer) o];
            }
          } else {
            if (o instanceof String) {
              strValue = (String) o;
            } else {
              if (o instanceof Boolean) {
                strValue = ((Boolean) o).toString();
              }
            }
          }
          if (tmpParam != null && tmpParam.getFieldType().equals(EParameterFieldType.PASSWORD)) {
            elementValue.setValue(strValue, true);
          } else {
            elementValue.setValue(strValue);
          }
          //
          Object object =
              currentLine.get(param.getListItemsDisplayCodeName()[i] + IEbcdicConstant.REF_TYPE);
          if (object != null) {
            elementValue.setType((String) object);
          }
          targetPramType.getElementValue().add(elementValue);
        }
      }
    } else {
      if (value == null) {
        targetPramType.setValue(""); // $NON-NLS-1$
      } else {
        if (value instanceof Boolean) {
          targetPramType.setValue(((Boolean) value).toString());
        } else {
          if (value instanceof String) {
            targetPramType.setRawValue(value.toString());
          }
        }
      }
    }

    return targetPramType;
  }
  /**
   * load the Element's parameters to EMF Model
   *
   * @param elemParam
   * @param paType
   */
  public static void loadElementParameters(
      Element elemParam, ParametersType paType, String repParamName) {
    if (paType == null || elemParam == null) {
      return;
    }
    EList listParamType = paType.getElementParameter();
    ElementParameterType repositoryParam = null;
    if (repParamName != null && !repParamName.equals("")) {
      repositoryParam = findElementParameterType(paType, repParamName);
    } else {
      repositoryParam =
          findElementParameterType(
              paType,
              EParameterName.PROPERTY_TYPE.getName()
                  + ":"
                  + EParameterName.PROPERTY_TYPE.getName());
    }

    IElementParameter statsDBType = null;
    IElementParameter implicitDBType = null;
    IElementParameter statsDBVersion = null;
    IElementParameter implicitDBVersion = null;

    for (int j = 0; j < listParamType.size(); j++) {
      ElementParameterType pType = (ElementParameterType) listParamType.get(j);
      if (pType != null) {
        String pTypeName = pType.getName();
        if (pTypeName != null && !"".equals(pTypeName)) {
          IElementParameter param = elemParam.getElementParameter(pTypeName);
          if (pTypeName.equals("DB_TYPE")) { // $NON-NLS-1$
            statsDBType = param;
          } else if (pTypeName.equals("DB_VERSION")) { // $NON-NLS-1$
            statsDBVersion = param;
          } else if (pTypeName.equals("DB_TYPE_IMPLICIT_CONTEXT")) { // $NON-NLS-1$
            implicitDBType = param;
          } else if (pTypeName.equals("DB_VERSION_IMPLICIT_CONTEXT")) { // $NON-NLS-1$
            implicitDBVersion = param;
          }
          if (param != null) {
            String name = param.getName();
            param.setContextMode(pType.isContextMode());
            if (param.isReadOnly()
                && !(EParameterName.UNIQUE_NAME.getName().equals(name)
                    || EParameterName.VERSION.getName().equals(name))) {
              continue; // if the parameter is read only, don't load
              // it (this will prevent to overwrite the
              // value)
            }
            String value = null;
            if ("STATANDLOG_USE_PROJECT_SETTINGS".equals(name) // $NON-NLS-1$
                || "IMPLICITCONTEXT_USE_PROJECT_SETTINGS".equals(name)) { // $NON-NLS-1$
              Object value2 = param.getValue();
              if (value2 != null) {
                value = value2.toString();
              }
            } else {
              value = pType.getValue();
            }
            if (param.getFieldType().equals(EParameterFieldType.CHECK)
                || param.getFieldType().equals(EParameterFieldType.RADIO)) {
              if (Boolean.FALSE.toString().equalsIgnoreCase(value)
                  || Boolean.TRUE.toString().equalsIgnoreCase(value)
                  || !pType.isContextMode()) {
                Boolean boolean1 = new Boolean(value);
                elemParam.setPropertyValue(pTypeName, boolean1);
              } else {
                elemParam.setPropertyValue(pTypeName, value);
              }
              // if (EParameterName.ACTIVATE.getName().equals(param.getName())) {
              // if ((elemParam instanceof Node) && !boolean1) {
              // ((Node) elemParam).setDummy(!boolean1);
              // }
              // }
            } else if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)) {
              boolean valueSet = false;
              if (!ArrayUtils.contains(param.getListItemsValue(), value)) {
                if (ArrayUtils.contains(param.getListItemsDisplayName(), value)) {
                  valueSet = true;
                  int index = ArrayUtils.indexOf(param.getListItemsDisplayName(), value);
                  if (index > -1) {
                    elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[index]);
                  }
                } else if (value.equals("")
                    && name != null
                    && (name.equals("LOAD_NEW_VARIABLE") || name.equals("NOT_LOAD_OLD_VARIABLE"))) {
                  valueSet = true;
                  elemParam.setPropertyValue(pTypeName, param.getListItemsValue()[1]);
                }
              }
              if (!valueSet) {
                elemParam.setPropertyValue(pTypeName, value);
              }
            } else if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
              List<Map<String, Object>> tableValues = new ArrayList<Map<String, Object>>();
              String[] codeList = param.getListItemsDisplayCodeName();
              Map<String, Object> lineValues = null;
              for (ElementValueType elementValue :
                  (List<ElementValueType>) pType.getElementValue()) {
                boolean found = false;
                int length = codeList.length;
                if (length > 0) {
                  for (int i = 0; i < length && !found; i++) {
                    if (codeList[i].equals(elementValue.getElementRef())) {
                      found = true;
                    }
                  }
                }
                IElementParameter tmpParam = null;
                for (Object o : param.getListItemsValue()) {
                  if (o instanceof IElementParameter) {
                    IElementParameter tableParam = (IElementParameter) o;
                    if (tableParam.getName().equals(elementValue.getElementRef())) {
                      tmpParam = tableParam;
                      break;
                    }
                  }
                }
                if (found) {
                  if ((lineValues == null)
                      || (lineValues.get(elementValue.getElementRef()) != null)) {
                    lineValues = new HashMap<String, Object>();
                    tableValues.add(lineValues);
                  }
                  String elemValue = elementValue.getValue();
                  if (tmpParam != null
                      && EParameterFieldType.PASSWORD.equals(tmpParam.getFieldType())) {
                    elemValue = elementValue.getRawValue();
                  }
                  lineValues.put(elementValue.getElementRef(), elemValue);
                  if (elementValue.getType() != null) {
                    lineValues.put(
                        elementValue.getElementRef() + IEbcdicConstant.REF_TYPE,
                        elementValue.getType());
                  }
                }
              }
              elemParam.setPropertyValue(pTypeName, tableValues);
            } else if (param.getFieldType().equals(EParameterFieldType.PASSWORD)) {
              param.setValue(pType.getRawValue());
            } else if (param.getFieldType().equals(EParameterFieldType.ENCODING_TYPE)) {
              // fix for bug 2193
              boolean setToCustom = false;
              if (EmfComponent.REPOSITORY.equals(
                      elemParam.getPropertyValue(EParameterName.PROPERTY_TYPE.getName()))
                  && param.getRepositoryValue() != null
                  && param.getRepositoryValue().equals("ENCODING")) { // $NON-NLS-1$
                setToCustom = true;
              }
              String tempValue = null;
              IElementParameter iElementParameter = null;
              Map<String, IElementParameter> childParameters = param.getChildParameters();
              if (childParameters != null) {
                iElementParameter = childParameters.get(EParameterName.ENCODING_TYPE.getName());
                if (iElementParameter != null) {
                  tempValue = (String) iElementParameter.getValue();
                }
              }
              if (tempValue != null && !tempValue.equals(EmfComponent.ENCODING_TYPE_CUSTOM)) {
                tempValue = tempValue.replaceAll("'", ""); // $NON-NLS-1$ //$NON-NLS-2$
                tempValue = tempValue.replaceAll("\"", ""); // $NON-NLS-1$ //$NON-NLS-2$
                tempValue = TalendTextUtils.addQuotes(tempValue);
                if (!tempValue.equals(value)) {
                  setToCustom = true;
                }
              }

              if (iElementParameter != null && setToCustom) {
                iElementParameter.setValue(EmfComponent.ENCODING_TYPE_CUSTOM);
              }
              elemParam.setPropertyValue(pTypeName, value);
              // end of fix for bug 2193
            } else if (!param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE)) {
              if (param.getRepositoryValue() != null
                  && !param.getFieldType().equals(EParameterFieldType.PROPERTY_TYPE)) {
                if (repositoryParam != null
                    && EmfComponent.REPOSITORY.equals(repositoryParam.getValue())) {
                  param.setRepositoryValueUsed(true);
                } else {
                  param.setRepositoryValueUsed(false);
                }
              }
              elemParam.setPropertyValue(pTypeName, value);
            }
          } else if (UpdateTheJobsActionsOnTable.isClear
              && "CLEAR_TABLE".equals(pTypeName) // $NON-NLS-1$
              && "true".equals(pType.getValue()) // $NON-NLS-1$
              && "NONE"
                  .equals(
                      elemParam
                          .getElementParameter(Process.TABLE_ACTION)
                          .getValue())) { //$NON-NLS-1$
            elemParam.setPropertyValue(Process.TABLE_ACTION, "CLEAR"); // $NON-NLS-1$
            UpdateTheJobsActionsOnTable.isClear = false;
          }
        }
      }
    }

    // update combo list for dbversion
    if (statsDBType != null && statsDBVersion != null) {
      JobSettingVersionUtil.setDbVersion(
          statsDBVersion,
          String.valueOf(statsDBType.getValue()),
          String.valueOf(statsDBVersion.getValue()));
    }
    if (implicitDBType != null && implicitDBVersion != null) {
      JobSettingVersionUtil.setDbVersion(
          implicitDBVersion,
          String.valueOf(implicitDBType.getValue()),
          String.valueOf(implicitDBVersion.getValue()));
    }
  }
  @Override
  public void execute() {
    propagatedChange.clear();

    propagateDatas(true);
    if (currentInputMetadata != null) {
      if (!currentInputMetadata.sameMetadataAs(newInputMetadata, IMetadataColumn.OPTIONS_NONE)) {
        if (!currentInputMetadata.sameMetadataAs(
            newInputMetadata, IMetadataColumn.OPTIONS_IGNORE_USED)) {
          String type = (String) inputNode.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
          if (type != null) {
            if (type.equals(EmfComponent.REPOSITORY)) {
              inputWasRepository = true;
              inputNode.setPropertyValue(
                  EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
            }
          }
        }
        MetadataToolHelper.copyTable(newInputMetadata, currentInputMetadata);
      }
    }

    if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_NONE)) {
      if (!currentOutputMetadata.sameMetadataAs(
          newOutputMetadata, IMetadataColumn.OPTIONS_IGNORE_USED)) {
        String type = (String) node.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
        if (type != null && type.equals(EmfComponent.REPOSITORY) && !repositoryMode) {
          // for one node has several schema_type,set mode for the current one
          if ((node.getElementParameter("SCHEMA_TYPE")
              .getContext()
              .equals(currentOutputMetadata.getAttachedConnector()))) {
            outputWasRepository = true;
            node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
          }
        }
      }
      MetadataToolHelper.copyTable(newOutputMetadata, currentOutputMetadata);
    }
    if (inputSchemaParam != null
        && inputSchemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()) != null
        && EmfComponent.REPOSITORY.equals(
            inputSchemaParam
                .getChildParameters()
                .get(EParameterName.SCHEMA_TYPE.getName())
                .getValue())) {
      // add by wzhang to fix bug 7898.
      IElementParameter elementParameter =
          node.getElementParameter(EParameterName.MAPPING.getName());
      if (elementParameter != null) {
        if (elementParameter.getValue() instanceof String) {
          String value = (String) elementParameter.getValue();
          if (!isDBComponent(value)) {
            schemaParam
                .getChildParameters()
                .get(EParameterName.SCHEMA_TYPE.getName())
                .setValue(EmfComponent.REPOSITORY);
            schemaParam
                .getChildParameters()
                .get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName())
                .setValue(
                    inputSchemaParam
                        .getChildParameters()
                        .get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName())
                        .getValue());
          }
        }
      }
    }

    for (INodeConnector connector : node.getListConnector()) {
      if ((!connector.getName().equals(currentConnector))
          && connector.getBaseSchema().equals(currentConnector)) {
        if (node.getComponent() != null
            && "tSalesforceOutput".equals(node.getComponent().getName())
            && "REJECT".equals(connector.getName())) {
          IMetadataTable clone = newOutputMetadata.clone(true);
          Iterator<IMetadataColumn> iterator = clone.getListColumns().iterator();
          while (iterator.hasNext()) {
            IMetadataColumn column = iterator.next();
            if (column.isCustom()) {
              iterator.remove();
            }
          }
          MetadataToolHelper.copyTable(clone, node.getMetadataFromConnector(connector.getName()));
        } else {
          // if there is some other schema dependant of this one, modify them
          MetadataToolHelper.copyTable(
              newOutputMetadata, node.getMetadataFromConnector(connector.getName()));
        }
      }
    }

    List<ColumnNameChanged> columnNameChanged =
        MetadataToolHelper.getColumnNameChanged(oldOutputMetadata, newOutputMetadata);
    ColumnListController.updateColumnList(node, columnNameChanged, true);

    if (inputNode != null) {
      List<ColumnNameChanged> inputColumnNameChangedExt =
          MetadataToolHelper.getColumnNameChangedExt(inputNode, oldInputMetadata, newInputMetadata);
      ColumnListController.updateColumnList(node, inputColumnNameChangedExt);
    }
    //
    List<ColumnNameChanged> outputColumnNameChangedExt =
        MetadataToolHelper.getColumnNameChangedExt(node, oldOutputMetadata, newOutputMetadata);
    syncOutputNodeColumnsList(outputColumnNameChangedExt);

    setXMLMAPPING();

    if (!internal) {
      updateColumnList(oldOutputMetadata, newOutputMetadata);
      ((Process) node.getProcess()).checkProcess();
    }
    refreshMetadataChanged();
  }
  @Override
  public void execute() {
    if (result == null) {
      return;
    }
    Object job = result.getJob();
    if (job == null) {
      return;
    }
    if (job instanceof IProcess2) {
      Process process = (Process) job;

      EComponentCategory category = null;
      IUpdateItemType updateType = result.getUpdateType();
      if (updateType instanceof EUpdateItemType) {
        switch ((EUpdateItemType) updateType) {
          case JOB_PROPERTY_EXTRA:
            category = EComponentCategory.EXTRA;
            break;
          case JOB_PROPERTY_STATS_LOGS:
            category = EComponentCategory.STATSANDLOGS;
            break;
          case JOB_PROPERTY_HEADERFOOTER:
            category = EComponentCategory.HEADERFOOTER;
            break;
          case JOB_PROPERTY_MAPREDUCE:
            category = EComponentCategory.MAPREDUCE_JOB_CONFIG_FOR_HADOOP;
            break;
          default:
        }
        if (category == EComponentCategory.HEADERFOOTER) {
          if (result.getResultType() == EUpdateResult.UPDATE) {

            if (result.isChecked()) {
              for (IElementParameter param : process.getElementParameters()) {
                if (param.getCategory() == EComponentCategory.HEADERFOOTER) {
                  IElementParameter headerIDParameter =
                      process.getElementParameter(EParameterName.HEADERFOOTER_HEADERID.getName());
                  if (headerIDParameter != null) {
                    IRepositoryViewObject lastVersion =
                        UpdateRepositoryUtils.getRepositoryObjectById(
                            (String) headerIDParameter.getValue());
                    HeaderFooterConnection repositoryConnection = null;
                    if (lastVersion != null) {
                      final Item item = lastVersion.getProperty().getItem();
                      if (item != null && item instanceof ConnectionItem) {
                        repositoryConnection =
                            (HeaderFooterConnection)
                                ((HeaderFooterConnectionItem) item).getConnection();
                        if (repositoryConnection != null) {
                          Boolean isHeader = repositoryConnection.isIsHeader();
                          String libraries = repositoryConnection.getLibraries();
                          String mainCode = repositoryConnection.getMainCode();
                          String imports = repositoryConnection.getImports();
                          process
                              .getElementParameter(EParameterName.HEADER_ENABLED.getName())
                              .setValue(isHeader);
                          process
                              .getElementParameter(EParameterName.HEADER_LIBRARY.getName())
                              .setValue(libraries);
                          process
                              .getElementParameter(EParameterName.HEADER_CODE.getName())
                              .setValue(mainCode);
                          process
                              .getElementParameter(EParameterName.HEADER_IMPORT.getName())
                              .setValue(imports);
                        }
                      }
                    }
                  }

                  IElementParameter footerIDParameter =
                      process.getElementParameter(EParameterName.HEADERFOOTER_FOOTERID.getName());
                  if (footerIDParameter != null) {
                    IRepositoryViewObject lastVersion =
                        UpdateRepositoryUtils.getRepositoryObjectById(
                            (String) footerIDParameter.getValue());
                    HeaderFooterConnection repositoryConnection = null;
                    if (lastVersion != null) {
                      final Item item = lastVersion.getProperty().getItem();
                      if (item != null && item instanceof ConnectionItem) {
                        repositoryConnection =
                            (HeaderFooterConnection)
                                ((HeaderFooterConnectionItem) item).getConnection();
                        if (repositoryConnection != null) {
                          Boolean isHeader = repositoryConnection.isIsHeader();
                          String libraries = repositoryConnection.getLibraries();
                          String mainCode = repositoryConnection.getMainCode();
                          String imports = repositoryConnection.getImports();
                          process
                              .getElementParameter(EParameterName.FOOTER_ENABLED.getName())
                              .setValue(!isHeader);
                          process
                              .getElementParameter(EParameterName.FOOTER_LIBRARY.getName())
                              .setValue(libraries);
                          process
                              .getElementParameter(EParameterName.FOOTER_CODE.getName())
                              .setValue(mainCode);
                          process
                              .getElementParameter(EParameterName.FOOTER_IMPORT.getName())
                              .setValue(imports);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        } else if (category != null) {
          boolean repository = false;

          if (result.getResultType() == EUpdateResult.UPDATE) {
            // upgrade from repository
            if (result.isChecked()) {
              IElementParameter property =
                  process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
              if (property != null) {
                Map<String, IElementParameter> childParameters = property.getChildParameters();
                if (childParameters != null) {
                  IElementParameter elementParameter =
                      childParameters.get(EParameterName.PROPERTY_TYPE.getName());
                  // is repository
                  if (elementParameter != null
                      && EmfComponent.REPOSITORY.equals(elementParameter.getValue())) {
                    for (IElementParameter param : process.getElementParameters()) {
                      if (param.getCategory() != category) {
                        continue;
                      }
                      String repositoryValue = param.getRepositoryValue();
                      if (param.isShow(process.getElementParameters())
                          && (repositoryValue != null)
                          && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName()))) {
                        Object objectValue =
                            RepositoryToComponentProperty.getValue(
                                (org.talend.core.model.metadata.builder.connection.Connection)
                                    result.getParameter(),
                                repositoryValue,
                                null);
                        if (objectValue != null) {
                          if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST)
                              && repositoryValue.equals(UpdatesConstants.TYPE)) {
                            boolean found = false;
                            String[] items = param.getListRepositoryItems();
                            for (int i = 0; (i < items.length) && (!found); i++) {
                              if (objectValue.equals(items[i])) {
                                found = true;
                                process.setPropertyValue(
                                    param.getName(), param.getListItemsValue()[i]);
                              }
                            }
                          } else if (EParameterName.HADOOP_ADVANCED_PROPERTIES
                              .getName()
                              .equals(param.getName())) {
                            List<Map> list = (ArrayList) param.getValue();
                            for (Map map : list) {
                              if (map.get("BUILDIN") != null && map.get("BUILDIN").equals("TRUE")) {
                                if (objectValue instanceof List) {
                                  ((List) objectValue).add(map);
                                }
                              }
                            }
                            process.setPropertyValue(param.getName(), objectValue);

                          } else {
                            process.setPropertyValue(param.getName(), objectValue);
                          }
                          param.setRepositoryValueUsed(true);
                          param.setReadOnly(true);
                          repository = true;
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          if (!repository) {
            IElementParameter property =
                process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
            if (property != null) {
              Map<String, IElementParameter> childParameters = property.getChildParameters();
              if (childParameters != null) {
                IElementParameter elementParameter =
                    childParameters.get(EParameterName.PROPERTY_TYPE.getName());
                elementParameter.setValue(EmfComponent.BUILTIN);
              }
            }

            // built-in
            IElementParameter dbTypeParam = null;
            IElementParameter impliciteDbType = null;
            for (IElementParameter param : process.getElementParameters()) {
              if (param.getCategory() != category) {
                continue;
              }
              String repositoryValue = param.getRepositoryValue();
              if (param.isShow(process.getElementParameters()) && (repositoryValue != null)) {
                // for mysql db verion
                if (EParameterName.DB_TYPE.getName().equals(param.getName())
                    && "TYPE".equals(repositoryValue)) {
                  dbTypeParam = param;
                }
                if ("DB_TYPE_IMPLICIT_CONTEXT".equals(param.getName())
                    && "TYPE".equals(repositoryValue)) {
                  impliciteDbType = param;
                }
                if (EParameterName.DB_VERSION.getName().equals(repositoryValue)
                    && dbTypeParam != null
                    && dbTypeParam.getValue() != null) {
                  final int indexOfItem =
                      dbTypeParam.getIndexOfItemFromList(dbTypeParam.getValue().toString());
                  String dbType = dbTypeParam.getListItemsDisplayCodeName()[indexOfItem];
                  setDBVersionForMysql(param, dbType);
                } else if (EParameterName.DB_VERSION.getName().equals(repositoryValue)
                    && impliciteDbType != null
                    && impliciteDbType.getValue() != null) {
                  final int indexOfItem =
                      impliciteDbType.getIndexOfItemFromList(impliciteDbType.getValue().toString());
                  String dbType = impliciteDbType.getListItemsDisplayCodeName()[indexOfItem];
                  setDBVersionForMysql(param, dbType);
                }
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
              }
            }
          }
        }
      } // else { // for extension
    }
  }