Program: 118647
Project: 118647
Buggy source:
/** 
 * DOC bqian Comment method "getChangeMetadataCommand".
 * @param selectedNode
 * @param node
 * @param list
 * @param connectionItem
 */
private void getChangeMetadataCommand(CompoundCommand cc,RepositoryNode selectedNode,Node node,ConnectionItem connectionItem){
  if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
    String etlSchema=null;
    if (connectionItem.getConnection() instanceof DatabaseConnection) {
      DatabaseConnection connection=(DatabaseConnection)connectionItem.getConnection();
      if (connection instanceof DatabaseConnection) {
        etlSchema=connection.getUiSchema();
      }
      if (!"String_Node_Str".equals(etlSchema)) {
        IElementParameter e=node.getElementParameter("String_Node_Str");
        if (e != null) {
          if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
            e.setValue(etlSchema);
          }
 else {
            e.setValue(TalendTextUtils.addQuotes(etlSchema));
          }
        }
      }
    }
    IRepositoryViewObject object=selectedNode.getObject();
    MetadataTable table=null;
    if (object instanceof MetadataTableRepositoryObject) {
      table=((MetadataTableRepositoryObject)object).getTable();
    }
 else     if (object instanceof SalesforceModuleRepositoryObject) {
      table=((SalesforceModuleRepositoryObject)object).getDefaultTable();
      IRepositoryViewObject obj=null;
      if (selectedNode.getChildren() != null) {
        for (        IRepositoryNode repositoryNode : selectedNode.getChildren()) {
          obj=repositoryNode.getObject();
          if (obj instanceof MetadataTableRepositoryObject) {
            table=((MetadataTableRepositoryObject)obj).getTable();
            break;
          }
        }
      }
    }
    if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
      getSAPCommand(cc,object,connectionItem,table,node);
      return;
    }
    if (table != null) {
      String value=connectionItem.getProperty().getId() + "String_Node_Str" + table.getLabel();
      IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
      if (schemaParam == null) {
        schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
      }
      IElementParameter queryParam=node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
      if (queryParam != null) {
        queryParam=queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
        if (queryParam != null) {
          queryParam.setValue(EmfComponent.BUILTIN);
        }
      }
      if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
        Command hl7Cmd=new RepositoryChangeMetadataForHL7Command(node,IEbcdicConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
        cc.add(hl7Cmd);
        return;
      }
      if (schemaParam == null) {
        return;
      }
      if (node.isELTComponent()) {
        node.setPropertyValue(EParameterName.LABEL.getName(),"String_Node_Str");
      }
      schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
      RepositoryChangeMetadataCommand command2=new RepositoryChangeMetadataCommand(node,schemaParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),value,ConvertionHelper.convert(table),null,connectionItem.getConnection());
      cc.add(command2);
      return;
    }
  }
}

Fixed version (ground truth):
/** 
 * DOC bqian Comment method "getChangeMetadataCommand".
 * @param selectedNode
 * @param node
 * @param list
 * @param connectionItem
 */
private void getChangeMetadataCommand(CompoundCommand cc,RepositoryNode selectedNode,Node node,ConnectionItem connectionItem){
  if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_COLUMN) {
    RepositoryNode columnParentNode=selectedNode.getParent().getParent();
    if (columnParentNode != null) {
      selectedNode=columnParentNode;
    }
  }
  if (selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_CON_TABLE || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SAP_FUNCTION || selectedNode.getProperties(EProperties.CONTENT_TYPE) == ERepositoryObjectType.METADATA_SALESFORCE_MODULE) {
    String etlSchema=null;
    if (connectionItem.getConnection() instanceof DatabaseConnection) {
      DatabaseConnection connection=(DatabaseConnection)connectionItem.getConnection();
      if (connection instanceof DatabaseConnection) {
        etlSchema=connection.getUiSchema();
      }
      if (!"String_Node_Str".equals(etlSchema)) {
        IElementParameter e=node.getElementParameter("String_Node_Str");
        if (e != null) {
          if (connection.isContextMode() && ContextParameterUtils.isContainContextParam(etlSchema)) {
            e.setValue(etlSchema);
          }
 else {
            e.setValue(TalendTextUtils.addQuotes(etlSchema));
          }
        }
      }
    }
    IRepositoryViewObject object=selectedNode.getObject();
    MetadataTable table=null;
    if (object instanceof MetadataTableRepositoryObject) {
      table=((MetadataTableRepositoryObject)object).getTable();
    }
 else     if (object instanceof SalesforceModuleRepositoryObject) {
      table=((SalesforceModuleRepositoryObject)object).getDefaultTable();
      IRepositoryViewObject obj=null;
      if (selectedNode.getChildren() != null) {
        for (        IRepositoryNode repositoryNode : selectedNode.getChildren()) {
          obj=repositoryNode.getObject();
          if (obj instanceof MetadataTableRepositoryObject) {
            table=((MetadataTableRepositoryObject)obj).getTable();
            break;
          }
        }
      }
    }
    if (PluginChecker.isSAPWizardPluginLoaded() && connectionItem instanceof SAPConnectionItem) {
      getSAPCommand(cc,object,connectionItem,table,node);
      return;
    }
    if (table != null) {
      String value=connectionItem.getProperty().getId() + "String_Node_Str" + table.getLabel();
      IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
      if (schemaParam == null) {
        schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
      }
      IElementParameter queryParam=node.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE);
      if (queryParam != null) {
        queryParam=queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
        if (queryParam != null) {
          queryParam.setValue(EmfComponent.BUILTIN);
        }
      }
      if (PluginChecker.isHL7PluginLoaded() && connectionItem instanceof HL7ConnectionItem) {
        Command hl7Cmd=new RepositoryChangeMetadataForHL7Command(node,IEbcdicConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table));
        cc.add(hl7Cmd);
        return;
      }
      if (schemaParam == null) {
        return;
      }
      if (node.isELTComponent()) {
        node.setPropertyValue(EParameterName.LABEL.getName(),"String_Node_Str");
      }
      schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
      RepositoryChangeMetadataCommand command2=new RepositoryChangeMetadataCommand(node,schemaParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),value,ConvertionHelper.convert(table),null,connectionItem.getConnection());
      cc.add(command2);
      return;
    }
  }
}