Program: 118729
Project: 118729
Buggy source:
/** 
 * Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
 * @param object
 * @param connectionItem
 * @param table
 * @param node
 * @return
 */
private void getSAPCommand(CompoundCommand cc,IRepositoryViewObject object,ConnectionItem connectionItem,MetadataTable table,Node node){
  SAPFunctionUnit functionUnit=null;
  if (object instanceof MetadataTableRepositoryObject) {
    IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
    if (table.eContainer() instanceof SAPFunctionUnit) {
      functionUnit=(SAPFunctionUnit)table.eContainer();
      String sapComponentName=node.getComponent().getName();
      if ("String_Node_Str".equals(sapComponentName)) {
        RepositoryChangeMetadataForSAPBapi command=new RepositoryChangeMetadataForSAPBapi(node,(SAPFunctionUnit)table.eContainer(),ConvertionHelper.convert(table),null);
        cc.add(command);
      }
 else {
        if (schemaParam != null) {
          String type=table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
          String value=connectionItem.getProperty().getId() + "String_Node_Str" + functionUnit.getLabel()+ "String_Node_Str"+ type+ "String_Node_Str"+ table.getLabel();
          RepositoryChangeMetadataCommand changeValueCmd=new RepositoryChangeMetadataCommand(node,schemaParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),value,ConvertionHelper.convert(table),null,connectionItem.getConnection());
          cc.add(changeValueCmd);
        }
        IElementParameter schemasParam=node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
        if (schemasParam != null) {
          Command sapCmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table),functionUnit);
          cc.add(sapCmd);
        }
      }
    }
 else {
      if (schemaParam != null) {
        String value=connectionItem.getProperty().getId() + "String_Node_Str" + table.getLabel();
        RepositoryChangeMetadataCommand changeValueCmd=new RepositoryChangeMetadataCommand(node,schemaParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),value,ConvertionHelper.convert(table),null,connectionItem.getConnection());
        cc.add(changeValueCmd);
      }
    }
  }
 else   if (object instanceof SAPFunctionRepositoryObject) {
    functionUnit=(SAPFunctionUnit)((SAPFunctionRepositoryObject)object).getAbstractMetadataObject();
    if (node.getComponent() != null && node.getComponent().getName().equals("String_Node_Str")) {
      RepositoryChangeMetadataForSAPBapi command=new RepositoryChangeMetadataForSAPBapi(node,functionUnit,null,null);
      cc.add(command);
    }
 else {
      for (      MetadataTable metadataTable : functionUnit.getTables()) {
        Command sapCmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,metadataTable.getLabel(),ConvertionHelper.convert(metadataTable),functionUnit);
        cc.add(sapCmd);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Added by Marvin Wang on July 12, 2012 for getting the command of SAP.
 * @param object
 * @param connectionItem
 * @param table
 * @param node
 * @return
 */
private void getSAPCommand(CompoundCommand cc,IRepositoryViewObject object,ConnectionItem connectionItem,MetadataTable table,Node node){
  SAPFunctionUnit functionUnit=null;
  if (object instanceof MetadataTableRepositoryObject) {
    IElementParameter schemaParam=node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
    if (table.eContainer() instanceof SAPFunctionUnit) {
      functionUnit=(SAPFunctionUnit)table.eContainer();
      String sapComponentName=node.getComponent().getName();
      if ("String_Node_Str".equals(sapComponentName)) {
        RepositoryChangeMetadataForSAPBapi command=new RepositoryChangeMetadataForSAPBapi(node,(SAPFunctionUnit)table.eContainer(),ConvertionHelper.convert(table),null);
        cc.add(command);
      }
 else {
        if (schemaParam != null) {
          String type=table.getTableType() == null ? MetadataSchemaType.OUTPUT.name() : table.getTableType();
          String value=connectionItem.getProperty().getId() + "String_Node_Str" + functionUnit.getLabel()+ "String_Node_Str"+ type+ "String_Node_Str"+ table.getLabel();
          RepositoryChangeMetadataCommand changeValueCmd=new RepositoryChangeMetadataCommand(node,schemaParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),value,ConvertionHelper.convert(table),null,connectionItem.getConnection());
          cc.add(changeValueCmd);
        }
        IElementParameter schemasParam=node.getElementParameter(ISAPConstant.TABLE_SCHEMAS);
        if (schemasParam != null) {
          Command sapCmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,table.getLabel(),ConvertionHelper.convert(table),functionUnit);
          cc.add(sapCmd);
        }
      }
    }
 else {
      if (schemaParam != null) {
        String value=connectionItem.getProperty().getId() + "String_Node_Str" + table.getLabel();
        RepositoryChangeMetadataCommand changeValueCmd=new RepositoryChangeMetadataCommand(node,schemaParam.getName() + "String_Node_Str" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(),value,ConvertionHelper.convert(table),null,connectionItem.getConnection(),table);
        cc.add(changeValueCmd);
      }
    }
  }
 else   if (object instanceof SAPFunctionRepositoryObject) {
    functionUnit=(SAPFunctionUnit)((SAPFunctionRepositoryObject)object).getAbstractMetadataObject();
    if (node.getComponent() != null && node.getComponent().getName().equals("String_Node_Str")) {
      RepositoryChangeMetadataForSAPBapi command=new RepositoryChangeMetadataForSAPBapi(node,functionUnit,null,null);
      cc.add(command);
    }
 else {
      for (      MetadataTable metadataTable : functionUnit.getTables()) {
        Command sapCmd=new RepositoryChangeMetadataForSAPCommand(node,ISAPConstant.TABLE_SCHEMAS,metadataTable.getLabel(),ConvertionHelper.convert(metadataTable),functionUnit);
        cc.add(sapCmd);
      }
    }
  }
}