Program: 127757
Project: 127757
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 (        IMetadataColumn col : metadataTable.getListColumns()) {
          Map<String,Object> map=new HashMap<String,Object>();
          map.put("String_Node_Str",null);
          for (int i=0; i < schemaTargets.size(); i++) {
            SchemaTarget sch=schemaTargets.get(i);
            if (col.getLabel().equals(sch.getTagName())) {
              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;
}

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 (        IMetadataColumn col : metadataTable.getListColumns()) {
          Map<String,Object> map=new HashMap<String,Object>();
          map.put("String_Node_Str",null);
          for (int i=0; i < schemaTargets.size(); i++) {
            SchemaTarget sch=schemaTargets.get(i);
            if (col.getLabel().equals(sch.getTagName())) {
              map.put("String_Node_Str",TalendQuoteUtils.addQuotes(sch.getRelativeXPathQuery()));
            }
          }
          if (map.get(UpdatesConstants.QUERY) == null) {
            if (col.getLabel() != null && col.getLabel().startsWith("String_Node_Str")) {
              String temp=col.getLabel().substring(6,col.getLabel().length());
              if (temp != null) {
                char c[]=temp.toCharArray();
                boolean flag=true;
                for (                char element : c) {
                  if (element < '0' || element > '9') {
                    flag=false;
                    break;
                  }
                }
                if (flag) {
                  int j=Integer.parseInt(temp);
                  SchemaTarget schema=schemaTargets.get(j);
                  if (schema != null && KeywordsValidator.isKeyword(schema.getTagName())) {
                    map.put("String_Node_Str",TalendQuoteUtils.addQuotes(schema.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;
}