Program: 119533
Project: 119533
Buggy source:
/** 
 * DOC bqian Comment method "createRefreshingPropertiesCommand".
 * @param selectedNode
 * @param node
 */
private List<Command> createRefreshingPropertiesCommand(RepositoryNode selectedNode,Node node){
  List<Command> list=new ArrayList<Command>();
  if (selectedNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
    String propertyId=selectedNode.getObject().getProperty().getId();
    ConnectionItem originalConnectionItem=(ConnectionItem)selectedNode.getObject().getProperty().getItem();
    ConnectionItem connectionItem=originalConnectionItem;
    Connection originalConnection=connectionItem.getConnection();
    Connection connection=connectionItem.getConnection();
    if (node.getComponent().getName().contains("String_Node_Str")) {
      if (selectedNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem) {
        final DatabaseConnection databaseConnection=(DatabaseConnection)connection;
        CDCConnection cdcConn=databaseConnection.getCdcConns();
        if (cdcConn != null) {
          EList cdcTypes=cdcConn.getCdcTypes();
          if (cdcTypes != null && !cdcTypes.isEmpty()) {
            CDCType cdcType=(CDCType)cdcTypes.get(0);
            propertyId=cdcType.getLinkDB();
            try {
              IRepositoryViewObject object=ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
              if (object != null) {
                if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                  DatabaseConnectionItem dbConnItem=(DatabaseConnectionItem)object.getProperty().getItem();
                  connectionItem=dbConnItem;
                  connection=dbConnItem.getConnection();
                }
              }
            }
 catch (            PersistenceException e) {
              ExceptionHandler.process(e);
            }
            IElementParameter logModeParam=node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
            if (logModeParam != null) {
              String cdcTypeMode=((DatabaseConnection)originalConnection).getCdcTypeMode();
              Command logModeCmd=new PropertyChangeCommand(node,EParameterName.CDC_TYPE_MODE.getName(),CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
              list.add(logModeCmd);
            }
            final String name="String_Node_Str";
            IElementParameter libParam=node.getElementParameter(name);
            if (libParam != null) {
              Command libSettingCmd=new PropertyChangeCommand(node,name,TalendTextUtils.addQuotes(databaseConnection.getSID()));
              list.add(libSettingCmd);
            }
          }
        }
      }
    }
    if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_SAP_FUNCTION && PluginChecker.isSAPWizardPluginLoaded()) {
      SAPFunctionUnit functionUnit=(SAPFunctionUnit)((SAPFunctionRepositoryObject)selectedNode.getObject()).getAbstractMetadataObject();
      for (      MetadataTable table : functionUnit.getTables()) {
        Command sapCmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table),functionUnit);
        list.add(sapCmd);
      }
    }
    if ((connectionItem instanceof EbcdicConnectionItem) && PluginChecker.isEBCDICPluginLoaded()) {
      IRepositoryViewObject object=selectedNode.getObject();
      if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_EBCDIC) {
        for (        MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
          Command ebcdicCmd=new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
          list.add(ebcdicCmd);
        }
      }
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
        MetadataTable table=null;
        if (object instanceof MetadataTableRepositoryObject) {
          table=((MetadataTableRepositoryObject)object).getTable();
        }
        Command ebcdicCmd=new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
        list.add(ebcdicCmd);
      }
    }
    if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded())) {
      if (originalConnection instanceof HL7ConnectionImpl) {
        if (((HL7ConnectionImpl)originalConnection).getRoot() != null) {
          List<Map<String,String>> mapList=new ArrayList<Map<String,String>>();
          for (          Object obj : ((HL7ConnectionImpl)originalConnection).getRoot()) {
            if (obj instanceof HL7FileNode) {
              Map<String,String> newMap=new HashMap<String,String>();
              newMap.put(IHL7Constant.ATTRIBUTE,((HL7FileNode)obj).getAttribute());
              newMap.put(IHL7Constant.PATH,((HL7FileNode)obj).getFilePath());
              newMap.put(IHL7Constant.COLUMN,((HL7FileNode)obj).getRelatedColumn());
              newMap.put(IHL7Constant.ORDER,String.valueOf(((HL7FileNode)obj).getOrder()));
              newMap.put(IHL7Constant.VALUE,((HL7FileNode)obj).getDefaultValue());
              newMap.put(IHL7Constant.REPEATABLE,String.valueOf(((HL7FileNode)obj).isRepeatable()));
              mapList.add(newMap);
            }
          }
          IExternalNode externalNode=ExternalUtilities.getExternalNodeReadyToOpen(node);
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(mapList);
          }
          String fileName=((HL7ConnectionImpl)originalConnection).getOutputFilePath();
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null && fileName != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(TalendTextUtils.addQuotes(fileName));
          }
        }
      }
      if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) {
        for (        MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
          Command hl7Cmd=new RepositoryChangeMetadataForHL7Command(node,IHL7Constant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
          list.add(hl7Cmd);
        }
      }
    }
    if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded())) {
      if (originalConnection instanceof BRMSConnectionImpl) {
        if (((BRMSConnectionImpl)originalConnection).getRoot() != null) {
          List<Map<String,String>> rootList=new ArrayList<Map<String,String>>();
          List<Map<String,String>> loopList=new ArrayList<Map<String,String>>();
          List<Map<String,String>> groupList=new ArrayList<Map<String,String>>();
          for (          Object obj : ((BRMSConnectionImpl)originalConnection).getRoot()) {
            if (obj instanceof XMLFileNode) {
              Map<String,String> rootMap=new HashMap<String,String>();
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getAttribute());
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getXMLPath());
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getRelatedColumn());
              rootMap.put("String_Node_Str",String.valueOf(((XMLFileNode)obj).getOrder()));
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getDefaultValue());
              rootList.add(rootMap);
            }
          }
          for (          Object obj : ((BRMSConnectionImpl)originalConnection).getLoop()) {
            if (obj instanceof XMLFileNode) {
              Map<String,String> loopMap=new HashMap<String,String>();
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getAttribute());
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getXMLPath());
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getRelatedColumn());
              loopMap.put("String_Node_Str",String.valueOf(((XMLFileNode)obj).getOrder()));
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getDefaultValue());
              loopList.add(loopMap);
            }
          }
          for (          Object obj : ((BRMSConnectionImpl)originalConnection).getGroup()) {
            if (obj instanceof XMLFileNode) {
              Map<String,String> groupMap=new HashMap<String,String>();
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getAttribute());
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getXMLPath());
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getRelatedColumn());
              groupMap.put("String_Node_Str",String.valueOf(((XMLFileNode)obj).getOrder()));
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getDefaultValue());
              groupList.add(groupMap);
            }
          }
          IExternalNode externalNode=ExternalUtilities.getExternalNodeReadyToOpen(node);
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(rootList);
          }
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(loopList);
          }
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(groupList);
          }
        }
      }
    }
    IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (propertyParam != null) {
      propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
      propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).setValue(propertyId);
    }
    IProxyRepositoryFactory factory=DesignerPlugin.getDefault().getProxyRepositoryFactory();
    Map<String,IMetadataTable> repositoryTableMap=new HashMap<String,IMetadataTable>();
    if (!originalConnection.isReadOnly()) {
      for (      Object tableObj : ConnectionHelper.getTables(originalConnection)) {
        org.talend.core.model.metadata.builder.connection.MetadataTable table;
        table=(org.talend.core.model.metadata.builder.connection.MetadataTable)tableObj;
        if (factory.getStatus(originalConnectionItem) != ERepositoryStatus.DELETED) {
          if (!factory.isDeleted(table)) {
            String value=table.getId();
            IMetadataTable newTable=ConvertionHelper.convert(table);
            repositoryTableMap.put(value,newTable);
          }
        }
      }
    }
    if (propertyParam != null) {
      IMetadataTable metadataTable=null;
      if (selectedNode.getObject() instanceof IMetadataTable) {
        metadataTable=(IMetadataTable)selectedNode.getObject();
        if (metadataTable != null && repositoryTableMap.get(metadataTable.getId()) != null) {
          metadataTable=repositoryTableMap.get(metadataTable.getId());
        }
      }
      ChangeValuesFromRepository command1=new ChangeValuesFromRepository(node,connection,metadataTable,propertyParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(),propertyId,true);
      command1.setMaps(repositoryTableMap);
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) != ERepositoryObjectType.METADATA_CON_QUERY) {
        command1.setGuessQuery(true);
      }
      if (selectedNode.getParent() != null && selectedNode.getParent().getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION) {
        IRepositoryViewObject functionObject=selectedNode.getParent().getObject();
        if (functionObject instanceof SAPFunctionRepositoryObject) {
          SAPFunctionRepositoryObject sapObj=(SAPFunctionRepositoryObject)functionObject;
          String connectionId=connection.getId();
          String functionId=selectedNode.getParent().getObject().getId();
          String tableName=selectedNode.getObject().getLabel();
          MetadataTableRepositoryObject object=(MetadataTableRepositoryObject)selectedNode.getObject();
          if ("String_Node_Str".equals(node.getComponent().getName())) {
            MetadataToolHelper.copyTable(ConvertionHelper.convert(object.getTable()),node.getMetadataList().get(0));
          }
          command1.setSapFunctionLabel(((SAPFunctionUnit)sapObj.getAbstractMetadataObject()).getLabel());
          command1.setCurrentTableName(selectedNode.getObject().getLabel());
        }
      }
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION) {
        IRepositoryViewObject selectedObj=selectedNode.getObject();
        if (selectedObj instanceof SAPFunctionRepositoryObject) {
          SAPFunctionRepositoryObject sapObj=(SAPFunctionRepositoryObject)selectedObj;
          command1.setSapFunctionLabel(((SAPFunctionUnit)sapObj.getAbstractMetadataObject()).getLabel());
          List<IRepositoryNode> nodes=selectedNode.getChildren();
          if (nodes != null && nodes.size() > 0) {
            String firstTableName=nodes.get(0).getObject().getLabel();
            command1.setCurrentTableName(firstTableName);
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
              schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            }
 else {
            }
          }
 else {
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
              schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.BUILTIN);
              command1.setCurrentTableName(null);
            }
 else {
            }
          }
        }
      }
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_IDOC) {
        IRepositoryViewObject selectedObj=selectedNode.getObject();
        if (selectedObj instanceof SAPIDocRepositoryObject) {
          SAPIDocRepositoryObject sapObj=(SAPIDocRepositoryObject)selectedObj;
          command1.setSapIDocLabel(((SAPIDocUnit)sapObj.getAbstractMetadataObject()).getLabel());
        }
      }
      SalesforceModuleRepositoryObject sfObject=null;
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
        sfObject=(SalesforceModuleRepositoryObject)selectedNode.getObject();
      }
 else       if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
        IRepositoryViewObject object=selectedNode.getParent().getObject();
        if (object instanceof SalesforceModuleRepositoryObject) {
          sfObject=(SalesforceModuleRepositoryObject)object;
        }
      }
      if (sfObject != null) {
        ModelElement modelElement=sfObject.getModelElement();
        if (modelElement instanceof SalesforceModuleUnit) {
          command1.setSalesForceModuleUnit((SalesforceModuleUnit)modelElement);
        }
      }
      list.add(command1);
    }
    Command command=getChangeMetadataCommand(selectedNode,node,originalConnectionItem);
    if (command != null) {
      list.add(command);
    }
    if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_QUERY) {
      IElementParameter queryParam=node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
      QueryRepositoryObject object=(QueryRepositoryObject)selectedNode.getObject();
      Query query=object.getQuery();
      String value=originalConnectionItem.getProperty().getId() + "String_Node_Str" + query.getLabel();
      if (queryParam != null) {
        RepositoryChangeQueryCommand command3=new RepositoryChangeQueryCommand(node,query,queryParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(),value);
        list.add(command3);
      }
    }
 else {
      if (connection instanceof DatabaseConnection && hasQuery(node)) {
        DatabaseConnection connection2=(DatabaseConnection)connection;
        String schema=connection2.getUiSchema();
        String dbType=connection2.getDatabaseType();
        QueryGuessCommand queryGuessCommand=null;
        if (node.getMetadataList().size() == 0) {
          queryGuessCommand=new QueryGuessCommand(node,null,schema,dbType);
        }
 else {
          queryGuessCommand=new QueryGuessCommand(node,node.getMetadataList().get(0),schema,dbType,connection);
        }
        if (queryGuessCommand != null) {
          list.add(queryGuessCommand);
        }
      }
    }
  }
 else   if (selectedNode.getObject().getProperty().getItem() instanceof ProcessItem) {
    ProcessItem processItem=(ProcessItem)selectedNode.getObject().getProperty().getItem();
    String value=processItem.getProperty().getId();
    PropertyChangeCommand command4=new PropertyChangeCommand(node,EParameterName.PROCESS_TYPE_PROCESS.getName(),value);
    list.add(command4);
    PropertyChangeCommand command5=new PropertyChangeCommand(node,EParameterName.PROCESS_TYPE_CONTEXT.getName(),processItem.getProcess().getDefaultContext());
    list.add(command5);
  }
 else   if (selectedNode.getObject().getProperty().getItem() instanceof FileItem) {
    if (selectedNode.getObject().getProperty().getItem() instanceof RulesItem) {
      RulesItem rulesItem=(RulesItem)selectedNode.getObject().getProperty().getItem();
      IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
      if (propertyParam != null) {
        propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
        final String showId=rulesItem.getProperty().getId();
        PropertyChangeCommand command6=new PropertyChangeCommand(node,EParameterName.REPOSITORY_PROPERTY_TYPE.getName(),showId);
        list.add(command6);
      }
    }
  }
 else   if (selectedNode.getObject().getProperty().getItem() instanceof LinkRulesItem) {
    LinkRulesItem linkItem=(LinkRulesItem)selectedNode.getObject().getProperty().getItem();
    IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (propertyParam != null) {
      propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
      final String showId=linkItem.getProperty().getId();
      PropertyChangeCommand command7=new PropertyChangeCommand(node,EParameterName.REPOSITORY_PROPERTY_TYPE.getName(),showId);
      list.add(command7);
    }
  }
  return list;
}

Fixed version (ground truth):
/** 
 * DOC bqian Comment method "createRefreshingPropertiesCommand".
 * @param selectedNode
 * @param node
 */
private List<Command> createRefreshingPropertiesCommand(RepositoryNode selectedNode,Node node){
  List<Command> list=new ArrayList<Command>();
  if (selectedNode.getObject().getProperty().getItem() instanceof ConnectionItem) {
    String propertyId=selectedNode.getObject().getProperty().getId();
    ConnectionItem originalConnectionItem=(ConnectionItem)selectedNode.getObject().getProperty().getItem();
    ConnectionItem connectionItem=originalConnectionItem;
    Connection originalConnection=connectionItem.getConnection();
    Connection connection=connectionItem.getConnection();
    if (node.getComponent().getName().contains("String_Node_Str")) {
      if (selectedNode.getObject().getProperty().getItem() instanceof DatabaseConnectionItem) {
        final DatabaseConnection databaseConnection=(DatabaseConnection)connection;
        CDCConnection cdcConn=databaseConnection.getCdcConns();
        if (cdcConn != null) {
          EList cdcTypes=cdcConn.getCdcTypes();
          if (cdcTypes != null && !cdcTypes.isEmpty()) {
            CDCType cdcType=(CDCType)cdcTypes.get(0);
            propertyId=cdcType.getLinkDB();
            try {
              IRepositoryViewObject object=ProxyRepositoryFactory.getInstance().getLastVersion(propertyId);
              if (object != null) {
                if (object.getProperty().getItem() instanceof DatabaseConnectionItem) {
                  DatabaseConnectionItem dbConnItem=(DatabaseConnectionItem)object.getProperty().getItem();
                  connectionItem=dbConnItem;
                  connection=dbConnItem.getConnection();
                }
              }
            }
 catch (            PersistenceException e) {
              ExceptionHandler.process(e);
            }
            IElementParameter logModeParam=node.getElementParameter(EParameterName.CDC_TYPE_MODE.getName());
            if (logModeParam != null) {
              String cdcTypeMode=((DatabaseConnection)originalConnection).getCdcTypeMode();
              Command logModeCmd=new PropertyChangeCommand(node,EParameterName.CDC_TYPE_MODE.getName(),CDCTypeMode.LOG_MODE.getName().equals(cdcTypeMode));
              list.add(logModeCmd);
            }
            final String name="String_Node_Str";
            IElementParameter libParam=node.getElementParameter(name);
            if (libParam != null) {
              Object propValue;
              if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(databaseConnection.getSID())) {
                propValue=databaseConnection.getSID();
              }
 else {
                propValue=TalendTextUtils.addQuotes(databaseConnection.getSID());
              }
              Command libSettingCmd=new PropertyChangeCommand(node,name,propValue);
              list.add(libSettingCmd);
            }
          }
        }
      }
    }
    if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_SAP_FUNCTION && PluginChecker.isSAPWizardPluginLoaded()) {
      SAPFunctionUnit functionUnit=(SAPFunctionUnit)((SAPFunctionRepositoryObject)selectedNode.getObject()).getAbstractMetadataObject();
      for (      MetadataTable table : functionUnit.getTables()) {
        Command sapCmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table),functionUnit);
        list.add(sapCmd);
      }
    }
    if ((connectionItem instanceof EbcdicConnectionItem) && PluginChecker.isEBCDICPluginLoaded()) {
      IRepositoryViewObject object=selectedNode.getObject();
      if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_EBCDIC) {
        for (        MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
          Command ebcdicCmd=new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
          list.add(ebcdicCmd);
        }
      }
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
        MetadataTable table=null;
        if (object instanceof MetadataTableRepositoryObject) {
          table=((MetadataTableRepositoryObject)object).getTable();
        }
        Command ebcdicCmd=new RepositoryChangeMetadataForEBCDICCommand(node,IEbcdicConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
        list.add(ebcdicCmd);
      }
    }
    if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded())) {
      if (originalConnection instanceof HL7ConnectionImpl) {
        if (((HL7ConnectionImpl)originalConnection).getRoot() != null) {
          List<Map<String,String>> mapList=new ArrayList<Map<String,String>>();
          for (          Object obj : ((HL7ConnectionImpl)originalConnection).getRoot()) {
            if (obj instanceof HL7FileNode) {
              Map<String,String> newMap=new HashMap<String,String>();
              newMap.put(IHL7Constant.ATTRIBUTE,((HL7FileNode)obj).getAttribute());
              newMap.put(IHL7Constant.PATH,((HL7FileNode)obj).getFilePath());
              newMap.put(IHL7Constant.COLUMN,((HL7FileNode)obj).getRelatedColumn());
              newMap.put(IHL7Constant.ORDER,String.valueOf(((HL7FileNode)obj).getOrder()));
              newMap.put(IHL7Constant.VALUE,((HL7FileNode)obj).getDefaultValue());
              newMap.put(IHL7Constant.REPEATABLE,String.valueOf(((HL7FileNode)obj).isRepeatable()));
              mapList.add(newMap);
            }
          }
          IExternalNode externalNode=ExternalUtilities.getExternalNodeReadyToOpen(node);
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(mapList);
          }
          String fileName=((HL7ConnectionImpl)originalConnection).getOutputFilePath();
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null && fileName != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(TalendTextUtils.addQuotes(fileName));
          }
        }
      }
      if (selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_HL7 && PluginChecker.isHL7PluginLoaded()) {
        for (        MetadataTable table : ConnectionHelper.getTables(originalConnection)) {
          Command hl7Cmd=new RepositoryChangeMetadataForHL7Command(node,IHL7Constant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
          list.add(hl7Cmd);
        }
      }
    }
    if ((selectedNode.getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded()) || (selectedNode.getParent() != null && selectedNode.getParent().getObjectType() == ERepositoryObjectType.METADATA_FILE_BRMS && PluginChecker.isBRMSPluginLoaded())) {
      if (originalConnection instanceof BRMSConnectionImpl) {
        if (((BRMSConnectionImpl)originalConnection).getRoot() != null) {
          List<Map<String,String>> rootList=new ArrayList<Map<String,String>>();
          List<Map<String,String>> loopList=new ArrayList<Map<String,String>>();
          List<Map<String,String>> groupList=new ArrayList<Map<String,String>>();
          for (          Object obj : ((BRMSConnectionImpl)originalConnection).getRoot()) {
            if (obj instanceof XMLFileNode) {
              Map<String,String> rootMap=new HashMap<String,String>();
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getAttribute());
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getXMLPath());
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getRelatedColumn());
              rootMap.put("String_Node_Str",String.valueOf(((XMLFileNode)obj).getOrder()));
              rootMap.put("String_Node_Str",((XMLFileNode)obj).getDefaultValue());
              rootList.add(rootMap);
            }
          }
          for (          Object obj : ((BRMSConnectionImpl)originalConnection).getLoop()) {
            if (obj instanceof XMLFileNode) {
              Map<String,String> loopMap=new HashMap<String,String>();
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getAttribute());
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getXMLPath());
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getRelatedColumn());
              loopMap.put("String_Node_Str",String.valueOf(((XMLFileNode)obj).getOrder()));
              loopMap.put("String_Node_Str",((XMLFileNode)obj).getDefaultValue());
              loopList.add(loopMap);
            }
          }
          for (          Object obj : ((BRMSConnectionImpl)originalConnection).getGroup()) {
            if (obj instanceof XMLFileNode) {
              Map<String,String> groupMap=new HashMap<String,String>();
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getAttribute());
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getXMLPath());
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getRelatedColumn());
              groupMap.put("String_Node_Str",String.valueOf(((XMLFileNode)obj).getOrder()));
              groupMap.put("String_Node_Str",((XMLFileNode)obj).getDefaultValue());
              groupList.add(groupMap);
            }
          }
          IExternalNode externalNode=ExternalUtilities.getExternalNodeReadyToOpen(node);
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(rootList);
          }
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(loopList);
          }
          if (externalNode != null && externalNode.getElementParameter("String_Node_Str") != null) {
            externalNode.getElementParameter("String_Node_Str").setValue(groupList);
          }
        }
      }
    }
    IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (propertyParam != null) {
      propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
      propertyParam.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName()).setValue(propertyId);
    }
    IProxyRepositoryFactory factory=DesignerPlugin.getDefault().getProxyRepositoryFactory();
    Map<String,IMetadataTable> repositoryTableMap=new HashMap<String,IMetadataTable>();
    if (!originalConnection.isReadOnly()) {
      for (      Object tableObj : ConnectionHelper.getTables(originalConnection)) {
        org.talend.core.model.metadata.builder.connection.MetadataTable table;
        table=(org.talend.core.model.metadata.builder.connection.MetadataTable)tableObj;
        if (factory.getStatus(originalConnectionItem) != ERepositoryStatus.DELETED) {
          if (!factory.isDeleted(table)) {
            String value=table.getId();
            IMetadataTable newTable=ConvertionHelper.convert(table);
            repositoryTableMap.put(value,newTable);
          }
        }
      }
    }
    if (propertyParam != null) {
      IMetadataTable metadataTable=null;
      if (selectedNode.getObject() instanceof IMetadataTable) {
        metadataTable=(IMetadataTable)selectedNode.getObject();
        if (metadataTable != null && repositoryTableMap.get(metadataTable.getId()) != null) {
          metadataTable=repositoryTableMap.get(metadataTable.getId());
        }
      }
      ChangeValuesFromRepository command1=new ChangeValuesFromRepository(node,connection,metadataTable,propertyParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(),propertyId,true);
      command1.setMaps(repositoryTableMap);
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) != ERepositoryObjectType.METADATA_CON_QUERY) {
        command1.setGuessQuery(true);
      }
      if (selectedNode.getParent() != null && selectedNode.getParent().getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION) {
        IRepositoryViewObject functionObject=selectedNode.getParent().getObject();
        if (functionObject instanceof SAPFunctionRepositoryObject) {
          SAPFunctionRepositoryObject sapObj=(SAPFunctionRepositoryObject)functionObject;
          String connectionId=connection.getId();
          String functionId=selectedNode.getParent().getObject().getId();
          String tableName=selectedNode.getObject().getLabel();
          MetadataTableRepositoryObject object=(MetadataTableRepositoryObject)selectedNode.getObject();
          if ("String_Node_Str".equals(node.getComponent().getName())) {
            MetadataToolHelper.copyTable(ConvertionHelper.convert(object.getTable()),node.getMetadataList().get(0));
          }
          command1.setSapFunctionLabel(((SAPFunctionUnit)sapObj.getAbstractMetadataObject()).getLabel());
          command1.setCurrentTableName(selectedNode.getObject().getLabel());
        }
      }
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION) {
        IRepositoryViewObject selectedObj=selectedNode.getObject();
        if (selectedObj instanceof SAPFunctionRepositoryObject) {
          SAPFunctionRepositoryObject sapObj=(SAPFunctionRepositoryObject)selectedObj;
          command1.setSapFunctionLabel(((SAPFunctionUnit)sapObj.getAbstractMetadataObject()).getLabel());
          List<IRepositoryNode> nodes=selectedNode.getChildren();
          if (nodes != null && nodes.size() > 0) {
            String firstTableName=nodes.get(0).getObject().getLabel();
            command1.setCurrentTableName(firstTableName);
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
              schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
            }
 else {
            }
          }
 else {
            if ("String_Node_Str".equals(node.getComponent().getName())) {
              IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
              schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.BUILTIN);
              command1.setCurrentTableName(null);
            }
 else {
            }
          }
        }
      }
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_IDOC) {
        IRepositoryViewObject selectedObj=selectedNode.getObject();
        if (selectedObj instanceof SAPIDocRepositoryObject) {
          SAPIDocRepositoryObject sapObj=(SAPIDocRepositoryObject)selectedObj;
          command1.setSapIDocLabel(((SAPIDocUnit)sapObj.getAbstractMetadataObject()).getLabel());
        }
      }
      SalesforceModuleRepositoryObject sfObject=null;
      if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
        sfObject=(SalesforceModuleRepositoryObject)selectedNode.getObject();
      }
 else       if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE) {
        IRepositoryViewObject object=selectedNode.getParent().getObject();
        if (object instanceof SalesforceModuleRepositoryObject) {
          sfObject=(SalesforceModuleRepositoryObject)object;
        }
      }
      if (sfObject != null) {
        ModelElement modelElement=sfObject.getModelElement();
        if (modelElement instanceof SalesforceModuleUnit) {
          command1.setSalesForceModuleUnit((SalesforceModuleUnit)modelElement);
        }
      }
      list.add(command1);
    }
    Command command=getChangeMetadataCommand(selectedNode,node,originalConnectionItem);
    if (command != null) {
      list.add(command);
    }
    if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_QUERY) {
      IElementParameter queryParam=node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
      QueryRepositoryObject object=(QueryRepositoryObject)selectedNode.getObject();
      Query query=object.getQuery();
      String value=originalConnectionItem.getProperty().getId() + "String_Node_Str" + query.getLabel();
      if (queryParam != null) {
        RepositoryChangeQueryCommand command3=new RepositoryChangeQueryCommand(node,query,queryParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName(),value);
        list.add(command3);
      }
    }
 else {
      if (connection instanceof DatabaseConnection && hasQuery(node)) {
        DatabaseConnection connection2=(DatabaseConnection)connection;
        String schema=connection2.getUiSchema();
        String dbType=connection2.getDatabaseType();
        QueryGuessCommand queryGuessCommand=null;
        if (node.getMetadataList().size() == 0) {
          queryGuessCommand=new QueryGuessCommand(node,null,schema,dbType);
        }
 else {
          queryGuessCommand=new QueryGuessCommand(node,node.getMetadataList().get(0),schema,dbType,connection);
        }
        if (queryGuessCommand != null) {
          list.add(queryGuessCommand);
        }
      }
    }
  }
 else   if (selectedNode.getObject().getProperty().getItem() instanceof ProcessItem) {
    ProcessItem processItem=(ProcessItem)selectedNode.getObject().getProperty().getItem();
    String value=processItem.getProperty().getId();
    PropertyChangeCommand command4=new PropertyChangeCommand(node,EParameterName.PROCESS_TYPE_PROCESS.getName(),value);
    list.add(command4);
    PropertyChangeCommand command5=new PropertyChangeCommand(node,EParameterName.PROCESS_TYPE_CONTEXT.getName(),processItem.getProcess().getDefaultContext());
    list.add(command5);
  }
 else   if (selectedNode.getObject().getProperty().getItem() instanceof FileItem) {
    if (selectedNode.getObject().getProperty().getItem() instanceof RulesItem) {
      RulesItem rulesItem=(RulesItem)selectedNode.getObject().getProperty().getItem();
      IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
      if (propertyParam != null) {
        propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
        final String showId=rulesItem.getProperty().getId();
        PropertyChangeCommand command6=new PropertyChangeCommand(node,EParameterName.REPOSITORY_PROPERTY_TYPE.getName(),showId);
        list.add(command6);
      }
    }
  }
 else   if (selectedNode.getObject().getProperty().getItem() instanceof LinkRulesItem) {
    LinkRulesItem linkItem=(LinkRulesItem)selectedNode.getObject().getProperty().getItem();
    IElementParameter propertyParam=node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (propertyParam != null) {
      propertyParam.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
      final String showId=linkItem.getProperty().getId();
      PropertyChangeCommand command7=new PropertyChangeCommand(node,EParameterName.REPOSITORY_PROPERTY_TYPE.getName(),showId);
      list.add(command7);
    }
  }
  return list;
}