Program: 129242
Project: 129242
Buggy source:
/** 
 * DOC qiang.zhang Comment method "getXMLMappingValue".
 * @param repositoryConnection
 * @param metadataTable
 * @return
 */
public static List<Map<String,Object>> getXMLMappingValue(Connection connection,List<IMetadataTable> metadataTables){
  if (metadataTables == null || metadataTables.isEmpty()) {
    return new ArrayList<Map<String,Object>>();
  }
  if (connection instanceof XmlFileConnection) {
    IMetadataTable metadataTable=metadataTables.get(0);
    XmlFileConnection xmlConnection=(XmlFileConnection)connection;
    EList objectList=xmlConnection.getSchema();
    XmlXPathLoopDescriptor xmlDesc=(XmlXPathLoopDescriptor)objectList.get(0);
    if (metadataTable != null) {
      if (xmlDesc != null) {
        List<SchemaTarget> schemaTargets=xmlDesc.getSchemaTargets();
        List<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
        for (int i=0; i < schemaTargets.size(); i++) {
          Map<String,Object> map=new HashMap<String,Object>();
          SchemaTarget sch=schemaTargets.get(i);
          map.put("String_Node_Str",TalendQuoteUtils.addQuotes(sch.getRelativeXPathQuery()));
          maps.add(map);
        }
        return maps;
      }
    }
  }
  if (connection instanceof MDMConnection) {
    IMetadataTable metadataTable=metadataTables.get(0);
    MDMConnection xmlConnection=(MDMConnection)connection;
    EList objectList=xmlConnection.getSchemas();
    if (metadataTable != null) {
      for (      Concept concept : (List<Concept>)objectList) {
        if (concept != null && (concept.getLabel() == null || concept.getLabel().equals(metadataTable.getLabel()))) {
          List<ConceptTarget> conceptTargets=concept.getConceptTargets();
          List<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
          for (          IMetadataColumn col : metadataTable.getListColumns()) {
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("String_Node_Str",null);
            for (int i=0; i < conceptTargets.size(); i++) {
              ConceptTarget cpt=conceptTargets.get(i);
              if (col.getLabel().equals(cpt.getTargetName())) {
                map.put("String_Node_Str",TalendQuoteUtils.addQuotes(cpt.getRelativeLoopExpression()));
              }
            }
            maps.add(map);
          }
          return maps;
        }
      }
    }
  }
  if (connection instanceof HL7Connection) {
    HL7Connection hl7Connection=(HL7Connection)connection;
    Set objectList=ConnectionHelper.getTables(hl7Connection);
    List<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
    for (    IMetadataTable tableOfNode : metadataTables) {
      Map<String,Object> map=new HashMap<String,Object>();
      for (      MetadataTable table : (Set<MetadataTable>)objectList) {
        if (table != null && (table.getLabel() == null || table.getLabel().equals(tableOfNode.getLabel()))) {
          String xpathValue="String_Node_Str";
          for (          MetadataColumn col : (List<MetadataColumn>)table.getColumns()) {
            String original=col.getOriginalField();
            if (original != null && !"String_Node_Str".equals(original)) {
              if (original.indexOf(TalendQuoteUtils.LBRACKET) != -1) {
                original=original.substring(0,original.indexOf(TalendQuoteUtils.LBRACKET));
              }
              original=TalendQuoteUtils.addQuotes(original);
              xpathValue+=original;
            }
            if (table.getColumns().indexOf(col) < table.getColumns().size() - 1) {
              xpathValue+="String_Node_Str";
            }
          }
          map.put("String_Node_Str",xpathValue);
          map.put("String_Node_Str",tableOfNode.getTableName());
          maps.add(map);
        }
      }
    }
    return maps;
  }
  return null;
}

Fixed version (ground truth):
/** 
 * DOC qiang.zhang Comment method "getXMLMappingValue".
 * @param repositoryConnection
 * @param metadataTable
 * @return
 */
public static List<Map<String,Object>> getXMLMappingValue(Connection connection,List<IMetadataTable> metadataTables){
  if (metadataTables == null || metadataTables.isEmpty()) {
    return new ArrayList<Map<String,Object>>();
  }
  if (connection instanceof XmlFileConnection) {
    IMetadataTable metadataTable=metadataTables.get(0);
    XmlFileConnection xmlConnection=(XmlFileConnection)connection;
    EList objectList=xmlConnection.getSchema();
    XmlXPathLoopDescriptor xmlDesc=(XmlXPathLoopDescriptor)objectList.get(0);
    if (metadataTable != null) {
      if (xmlDesc != null) {
        List<SchemaTarget> schemaTargets=xmlDesc.getSchemaTargets();
        List<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
        for (int i=0; i < schemaTargets.size(); i++) {
          Map<String,Object> map=new HashMap<String,Object>();
          SchemaTarget sch=schemaTargets.get(i);
          map.put("String_Node_Str",TalendQuoteUtils.addQuotes(sch.getRelativeXPathQuery()));
          maps.add(map);
        }
        return maps;
      }
    }
  }
  if (connection instanceof MDMConnection) {
    IMetadataTable metadataTable=metadataTables.get(0);
    MDMConnection xmlConnection=(MDMConnection)connection;
    EList objectList=xmlConnection.getSchemas();
    if (metadataTable != null) {
      for (      Concept concept : (List<Concept>)objectList) {
        if (concept != null && concept.getLabel() != null && concept.getLabel().equals(metadataTable.getLabel())) {
          List<ConceptTarget> conceptTargets=concept.getConceptTargets();
          List<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
          for (          IMetadataColumn col : metadataTable.getListColumns()) {
            Map<String,Object> map=new HashMap<String,Object>();
            map.put("String_Node_Str",null);
            for (int i=0; i < conceptTargets.size(); i++) {
              ConceptTarget cpt=conceptTargets.get(i);
              if (col.getLabel().equals(cpt.getTargetName())) {
                map.put("String_Node_Str",TalendQuoteUtils.addQuotes(cpt.getRelativeLoopExpression()));
              }
            }
            maps.add(map);
          }
          return maps;
        }
      }
    }
  }
  if (connection instanceof HL7Connection) {
    HL7Connection hl7Connection=(HL7Connection)connection;
    Set objectList=ConnectionHelper.getTables(hl7Connection);
    List<Map<String,Object>> maps=new ArrayList<Map<String,Object>>();
    for (    IMetadataTable tableOfNode : metadataTables) {
      Map<String,Object> map=new HashMap<String,Object>();
      for (      MetadataTable table : (Set<MetadataTable>)objectList) {
        if (table != null && (table.getLabel() == null || table.getLabel().equals(tableOfNode.getLabel()))) {
          String xpathValue="String_Node_Str";
          for (          MetadataColumn col : table.getColumns()) {
            String original=col.getOriginalField();
            if (original != null && !"String_Node_Str".equals(original)) {
              if (original.indexOf(TalendQuoteUtils.LBRACKET) != -1) {
                original=original.substring(0,original.indexOf(TalendQuoteUtils.LBRACKET));
              }
              original=TalendQuoteUtils.addQuotes(original);
              xpathValue+=original;
            }
            if (table.getColumns().indexOf(col) < table.getColumns().size() - 1) {
              xpathValue+="String_Node_Str";
            }
          }
          map.put("String_Node_Str",xpathValue);
          map.put("String_Node_Str",tableOfNode.getTableName());
          maps.add(map);
        }
      }
    }
    return maps;
  }
  return null;
}