Program: 118728
Project: 118728
Buggy source:
/** 
 * nrousseau Comment method "checkNodeSchemaFromRepository".
 * @param nc
 * @param metadataTable
 * @return true if the data have been modified
 */
private List<UpdateResult> checkNodeSchemaFromRepository(final Node node,boolean onlySimpleShow){
  if (node == null) {
    return Collections.emptyList();
  }
  List<UpdateResult> schemaResults=new ArrayList<UpdateResult>();
  List<IProcess2> openedProcesses=UpdateManagerUtils.getOpenedProcess();
  if (PluginChecker.isEBCDICPluginLoaded()) {
    List<UpdateResult> resultForEBCDIC=checkNodeSchemaFromRepositoryForEBCDIC(node,onlySimpleShow);
    if (resultForEBCDIC != null && !resultForEBCDIC.isEmpty()) {
      return resultForEBCDIC;
    }
  }
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
    List<UpdateResult> resultForTMap=checkNodeSchemaFromRepositoryForTMap(node,onlySimpleShow);
    if (resultForTMap != null && resultForTMap.size() > 0) {
      schemaResults.addAll(resultForTMap);
    }
  }
  List<IElementParameter> schemaTypeParams=node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
  if (schemaTypeParams != null) {
    for (    IElementParameter schemaTypeParam : schemaTypeParams) {
      UpdateCheckResult result=null;
      IElementParameter schemaParam=schemaTypeParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
      if (schemaParam != null && ((ElementParameter)schemaTypeParam).isDisplayedByDefault()) {
        if (schemaParam.getValue().equals(EmfComponent.REPOSITORY)) {
          String propertyValue=(String)schemaTypeParam.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()).getValue();
          ConnectionItem connectionItem=null;
          String schemaName=null;
          String[] names=UpdateManagerUtils.getSourceIdAndChildName(propertyValue);
          if (names != null && names.length > 1) {
            connectionItem=UpdateRepositoryUtils.getConnectionItemByItemId(names[0]);
            schemaName=names[1];
          }
          boolean builtIn=true;
          if (connectionItem != null) {
            final String uniqueName=node.getUniqueName();
            String newSourceId=getSchemaRenamedMap().get(propertyValue);
            Map<String,EUpdateResult> deletedOrReselect=getDeletedOrReselectTablesMap();
            String connectionId=(String)node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            List<Object> parameter=null;
            if (newSourceId != null && !newSourceId.equals(propertyValue)) {
              String[] newSourceIdAndName=UpdateManagerUtils.getSourceIdAndChildName(newSourceId);
              if (newSourceIdAndName != null) {
                IMetadataTable table=UpdateRepositoryUtils.getTableByName(connectionItem,newSourceIdAndName[1]);
                if (table != null) {
                  String source=UpdateRepositoryUtils.getRepositorySourceName(connectionItem);
                  final IMetadataTable copyOfrepositoryMetadata=table.clone();
                  copyOfrepositoryMetadata.setTableName(uniqueName);
                  copyOfrepositoryMetadata.setAttachedConnector(schemaTypeParam.getContext());
                  parameter=new ArrayList<Object>();
                  parameter.add(copyOfrepositoryMetadata);
                  parameter.add(propertyValue);
                  parameter.add(newSourceId);
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.RENAME,parameter,source);
                  builtIn=false;
                }
              }
            }
 else             if (!deletedOrReselect.isEmpty() && connectionId != null) {
              String source=UpdateRepositoryUtils.getRepositorySourceName(connectionItem);
              EUpdateResult status=deletedOrReselect.get(propertyValue);
              if (status != null) {
                if (status.equals(EUpdateResult.DELETE)) {
                  parameter=new ArrayList<Object>();
                  String tableName=propertyValue.split(UpdatesConstants.SEGMENT_LINE)[1];
                  parameter.add(tableName);
                  parameter.add(status);
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.DELETE,parameter,source);
                  builtIn=false;
                }
 else                 if (status.equals(EUpdateResult.RELOAD)) {
                  parameter=new ArrayList<Object>();
                  String tableName=propertyValue.split(UpdatesConstants.SEGMENT_LINE)[1];
                  parameter.add(tableName);
                  parameter.add(status);
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.RELOAD,parameter,source);
                  builtIn=false;
                }
              }
            }
 else {
              IMetadataTable table=null;
              IGenericWizardService wizardService=null;
              if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
                wizardService=(IGenericWizardService)GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
              }
              if (wizardService != null && wizardService.isGenericItem(connectionItem)) {
                List<MetadataTable> metadataTables=wizardService.getMetadataTables(connectionItem.getConnection());
                for (                MetadataTable metadataTable : metadataTables) {
                  if (metadataTable.getLabel().equals(schemaName)) {
                    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
                      IMetadataManagmentService mmService=(IMetadataManagmentService)GlobalServiceRegister.getDefault().getService(IMetadataManagmentService.class);
                      table=mmService.convertMetadataTable(metadataTable);
                    }
                  }
                }
              }
 else {
                table=UpdateRepositoryUtils.getTableByName(connectionItem,schemaName);
              }
              if (table != null) {
                String source=UpdateRepositoryUtils.getRepositorySourceName(connectionItem) + UpdatesConstants.SEGMENT_LINE + schemaName;
                final IMetadataTable copyOfrepositoryMetadata=table.clone();
                copyOfrepositoryMetadata.setTableName(uniqueName);
                copyOfrepositoryMetadata.setAttachedConnector(schemaTypeParam.getContext());
                final IMetadataTable metadataTable=node.getMetadataFromConnector(schemaTypeParam.getContext());
                if (this.isAddColumn) {
                  Display.getDefault().syncExec(new Runnable(){
                    @Override public void run(){
                      isColumnUsed=MessageDialog.openQuestion(Display.getDefault().getActiveShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
                      copyUsefulAttribute(copyOfrepositoryMetadata,metadataTable,isColumnUsed);
                    }
                  }
);
                  this.isAddColumn=false;
                }
 else {
                  copyUsefulAttribute(copyOfrepositoryMetadata,metadataTable,isColumnUsed);
                }
                if (onlySimpleShow || !metadataTable.sameMetadataAs(copyOfrepositoryMetadata,IMetadataColumn.OPTIONS_IGNORE_DBTYPE) || connectionItem instanceof GenericSchemaConnectionItem && !metadataTable.sameMetadataAs(copyOfrepositoryMetadata,IMetadataColumn.OPTIONS_NONE)) {
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.UPDATE,copyOfrepositoryMetadata,source);
                  result.setContextModeConnectionItem(connectionItem);
                }
                builtIn=false;
              }
            }
          }
          if (builtIn) {
            result=new UpdateCheckResult(node);
            result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.BUIL_IN,schemaTypeParam.getContext());
          }
          if (result != null) {
            if (!openedProcesses.contains(getProcess())) {
              result.setFromItem(true);
            }
            result.setJob(getProcess());
            setConfigrationForReadOnlyJob(result);
            schemaResults.add(result);
          }
        }
      }
    }
  }
  return schemaResults;
}

Fixed version (ground truth):
/** 
 * nrousseau Comment method "checkNodeSchemaFromRepository".
 * @param nc
 * @param metadataTable
 * @return true if the data have been modified
 */
private List<UpdateResult> checkNodeSchemaFromRepository(final Node node,boolean onlySimpleShow){
  if (node == null) {
    return Collections.emptyList();
  }
  List<UpdateResult> schemaResults=new ArrayList<UpdateResult>();
  List<IProcess2> openedProcesses=UpdateManagerUtils.getOpenedProcess();
  if (PluginChecker.isEBCDICPluginLoaded()) {
    List<UpdateResult> resultForEBCDIC=checkNodeSchemaFromRepositoryForEBCDIC(node,onlySimpleShow);
    if (resultForEBCDIC != null && !resultForEBCDIC.isEmpty()) {
      return resultForEBCDIC;
    }
  }
  if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
    List<UpdateResult> resultForTMap=checkNodeSchemaFromRepositoryForTMap(node,onlySimpleShow);
    if (resultForTMap != null && resultForTMap.size() > 0) {
      schemaResults.addAll(resultForTMap);
    }
  }
  List<IElementParameter> schemaTypeParams=node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
  if (schemaTypeParams != null) {
    for (    IElementParameter schemaTypeParam : schemaTypeParams) {
      UpdateCheckResult result=null;
      IElementParameter schemaParam=schemaTypeParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName());
      if (schemaParam != null && ((ElementParameter)schemaTypeParam).isDisplayedByDefault()) {
        if (schemaParam.getValue().equals(EmfComponent.REPOSITORY)) {
          String propertyValue=(String)schemaTypeParam.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()).getValue();
          ConnectionItem connectionItem=null;
          String schemaName=null;
          String[] names=UpdateManagerUtils.getSourceIdAndChildName(propertyValue);
          if (names != null && names.length > 1) {
            connectionItem=UpdateRepositoryUtils.getConnectionItemByItemId(names[0]);
            schemaName=names[1];
          }
          boolean builtIn=true;
          if (connectionItem != null) {
            final String uniqueName=node.getUniqueName();
            String newSourceId=getSchemaRenamedMap().get(propertyValue);
            Map<String,EUpdateResult> deletedOrReselect=getDeletedOrReselectTablesMap();
            String connectionId=(String)node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
            List<Object> parameter=null;
            if (newSourceId != null && !newSourceId.equals(propertyValue)) {
              String[] newSourceIdAndName=UpdateManagerUtils.getSourceIdAndChildName(newSourceId);
              if (newSourceIdAndName != null) {
                IMetadataTable table=UpdateRepositoryUtils.getTableByName(connectionItem,newSourceIdAndName[1]);
                if (table != null) {
                  String source=UpdateRepositoryUtils.getRepositorySourceName(connectionItem);
                  final IMetadataTable copyOfrepositoryMetadata=table.clone();
                  copyOfrepositoryMetadata.setTableName(uniqueName);
                  copyOfrepositoryMetadata.setAttachedConnector(schemaTypeParam.getContext());
                  parameter=new ArrayList<Object>();
                  parameter.add(copyOfrepositoryMetadata);
                  parameter.add(propertyValue);
                  parameter.add(newSourceId);
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.RENAME,parameter,source);
                  builtIn=false;
                }
              }
            }
 else             if (!deletedOrReselect.isEmpty() && connectionId != null) {
              String source=UpdateRepositoryUtils.getRepositorySourceName(connectionItem);
              EUpdateResult status=deletedOrReselect.get(propertyValue);
              if (status != null) {
                if (status.equals(EUpdateResult.DELETE)) {
                  parameter=new ArrayList<Object>();
                  String tableName=propertyValue.split(UpdatesConstants.SEGMENT_LINE)[1];
                  parameter.add(tableName);
                  parameter.add(status);
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.DELETE,parameter,source);
                  builtIn=false;
                }
 else                 if (status.equals(EUpdateResult.RELOAD)) {
                  parameter=new ArrayList<Object>();
                  String tableName=propertyValue.split(UpdatesConstants.SEGMENT_LINE)[1];
                  parameter.add(tableName);
                  parameter.add(status);
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.RELOAD,parameter,source);
                  builtIn=false;
                }
              }
            }
 else {
              IMetadataTable table=null;
              IGenericWizardService wizardService=null;
              if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
                wizardService=(IGenericWizardService)GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
              }
              if (wizardService != null && wizardService.isGenericItem(connectionItem)) {
                List<MetadataTable> metadataTables=wizardService.getMetadataTables(connectionItem.getConnection());
                for (                MetadataTable metadataTable : metadataTables) {
                  if (metadataTable.getLabel().equals(schemaName)) {
                    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
                      IMetadataManagmentService mmService=(IMetadataManagmentService)GlobalServiceRegister.getDefault().getService(IMetadataManagmentService.class);
                      table=mmService.convertMetadataTable(metadataTable);
                    }
                  }
                }
              }
 else {
                IElementParameter param=node.getElementParameter("String_Node_Str");
                String innerIOType=null;
                if (param != null) {
                  innerIOType=(String)param.getValue();
                }
                if (innerIOType != null) {
                  if (innerIOType.equals("String_Node_Str")) {
                    innerIOType="String_Node_Str";
                  }
                  if (innerIOType.equals("String_Node_Str")) {
                    innerIOType="String_Node_Str";
                  }
                  Connection connection=connectionItem.getConnection();
                  if (connection != null) {
                    final EList tables=MetadataToolHelper.getMetadataTableFromConnection(connection,schemaName);
                    if (tables != null && tables.size() > 0) {
                      Object tableObject=tables.get(0);
                      if (tableObject instanceof SAPBWTable) {
                        for (                        SAPBWTable bwTable : (List<SAPBWTable>)tables) {
                          if (bwTable.getLabel().equals(schemaName) && innerIOType.equals(bwTable.getInnerIOType())) {
                            if (GlobalServiceRegister.getDefault().isServiceRegistered(IMetadataManagmentService.class)) {
                              IMetadataManagmentService mmService=(IMetadataManagmentService)GlobalServiceRegister.getDefault().getService(IMetadataManagmentService.class);
                              table=mmService.convertMetadataTable(bwTable);
                            }
                          }
                        }
                      }
                    }
                  }
                }
 else {
                  table=UpdateRepositoryUtils.getTableByName(connectionItem,schemaName);
                }
              }
              if (table != null) {
                String source=UpdateRepositoryUtils.getRepositorySourceName(connectionItem) + UpdatesConstants.SEGMENT_LINE + schemaName;
                final IMetadataTable copyOfrepositoryMetadata=table.clone();
                copyOfrepositoryMetadata.setTableName(uniqueName);
                copyOfrepositoryMetadata.setAttachedConnector(schemaTypeParam.getContext());
                final IMetadataTable metadataTable=node.getMetadataFromConnector(schemaTypeParam.getContext());
                if (this.isAddColumn) {
                  Display.getDefault().syncExec(new Runnable(){
                    @Override public void run(){
                      isColumnUsed=MessageDialog.openQuestion(Display.getDefault().getActiveShell(),Messages.getString("String_Node_Str"),Messages.getString("String_Node_Str"));
                      copyUsefulAttribute(copyOfrepositoryMetadata,metadataTable,isColumnUsed);
                    }
                  }
);
                  this.isAddColumn=false;
                }
 else {
                  copyUsefulAttribute(copyOfrepositoryMetadata,metadataTable,isColumnUsed);
                }
                if (onlySimpleShow || !metadataTable.sameMetadataAs(copyOfrepositoryMetadata,IMetadataColumn.OPTIONS_IGNORE_DBTYPE) || connectionItem instanceof GenericSchemaConnectionItem && !metadataTable.sameMetadataAs(copyOfrepositoryMetadata,IMetadataColumn.OPTIONS_NONE)) {
                  result=new UpdateCheckResult(node);
                  result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.UPDATE,copyOfrepositoryMetadata,source);
                  result.setContextModeConnectionItem(connectionItem);
                }
                builtIn=false;
              }
            }
          }
          if (builtIn) {
            result=new UpdateCheckResult(node);
            result.setResult(EUpdateItemType.NODE_SCHEMA,EUpdateResult.BUIL_IN,schemaTypeParam.getContext());
          }
          if (result != null) {
            if (!openedProcesses.contains(getProcess())) {
              result.setFromItem(true);
            }
            result.setJob(getProcess());
            setConfigrationForReadOnlyJob(result);
            schemaResults.add(result);
          }
        }
      }
    }
  }
  return schemaResults;
}