Program: 120077
Project: 120077
Buggy source:
public void initModel(){
  int i=0;
  List<? extends IConnection> incomingConnections=NodeUtil.getIncomingConnections(hl7Component,IConnectionCategory.FLOW);
  List<Map<String,String>> maps=(List<Map<String,String>>)ElementParameterParser.getObjectValue(hl7Component,"String_Node_Str");
  List<String> schemaList=new ArrayList<String>();
  List<Map<String,String>> rootTable=(List<Map<String,String>>)hl7Component.getTableList(HL7InputComponent.ROOT);
  List<String> columnList=new ArrayList<String>();
  if (rootTable != null && rootTable.size() > 0) {
    for (    Map<String,String> rootMap : rootTable) {
      String columnName=rootMap.get(HL7InputComponent.COLUMN);
      if (columnName.contains("String_Node_Str")) {
        columnName=columnName.substring(0,columnName.indexOf("String_Node_Str"));
      }
      if (!columnList.contains(columnName) && !"String_Node_Str".equals(columnName)) {
        columnList.add(columnName);
      }
    }
    HL7TreeNode rootNode=null;
    for (    String rowName : columnList) {
      IMetadataTable metadataTable=null;
      String metadataTableName=rowName;
      for (      IConnection connection : incomingConnections) {
        if (connection.getUniqueName().equals(rowName)) {
          metadataTable=connection.getMetadataTable();
          metadataTable.setLabel(connection.getUniqueName());
          metadataTableName=metadataTable.getLabel();
        }
      }
      treeData=new ArrayList<HL7TreeNode>();
      if (i == 0)       currentSchema=metadataTableName;
      HL7TreeNode current=null;
      HL7TreeNode temp=null;
      HL7TreeNode mainNode=null;
      String mainPath=null;
      String currentPath=null;
      String defaultValue=null;
      int nodeOrder=0;
      boolean haveOrder=true;
      String schemaId=rowName + "String_Node_Str";
      for (      Map<String,String> rootMap : rootTable) {
        String newPath=rootMap.get(HL7InputComponent.PATH);
        String columnName=rootMap.get(HL7InputComponent.COLUMN);
        defaultValue=rootMap.get(HL7InputComponent.VALUE);
        String orderValue=rootMap.get(HL7InputComponent.ORDER);
        boolean repeatable=Boolean.valueOf(rootMap.get("String_Node_Str"));
        if (orderValue == null || "String_Node_Str".equals(orderValue)) {
          haveOrder=false;
        }
        if (haveOrder) {
          nodeOrder=Integer.valueOf(rootMap.get(HL7InputComponent.ORDER)).intValue();
        }
        String flag=columnName + "String_Node_Str";
        if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + "String_Node_Str")) {
          continue;
        }
        if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
          temp=new Attribute(newPath);
          temp.setDefaultValue(defaultValue);
          current.addChild(temp);
        }
 else         if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
          temp=new NameSpaceNode(newPath);
          temp.setDefaultValue(defaultValue);
          current.addChild(temp);
        }
 else {
          temp=addElement(current,currentPath,newPath,defaultValue);
          if (rootNode == null) {
            rootNode=temp;
          }
 else           if (rowName.equals(columnName) && rowName.equals(temp.getLabel())) {
            if (!rootNode.getChildren().contains(temp)) {
              rootNode.addChild(temp);
            }
          }
          if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
            temp.setMain(true);
            mainNode=temp;
            mainPath=newPath;
          }
          current=temp;
          currentPath=newPath;
        }
        temp.setRepetable(repeatable);
        if (haveOrder) {
          temp.setOrder(nodeOrder);
        }
        if (columnName != null && columnName.length() > 0) {
        }
        if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
          columnName=columnName.replace(schemaId,"String_Node_Str");
          if (metadataTable == null) {
            IMetadataTable metadataTableTemp=null;
            for (            IConnection connection : incomingConnections) {
              metadataTableTemp=connection.getMetadataTable();
              if (columnName.startsWith(metadataTableTemp.getLabel())) {
                break;
              }
            }
            if (metadataTableTemp != null) {
              temp.setColumn(metadataTableTemp.getColumn(columnName));
              temp.setTable(metadataTableTemp);
            }
          }
 else {
            temp.setColumn(metadataTable.getColumn(columnName));
            temp.setTable(metadataTable);
          }
        }
      }
      if (rootNode == null) {
        rootNode=new Element("String_Node_Str");
      }
      if (haveOrder) {
        orderNode(rootNode);
      }
      i++;
    }
    if (rootNode != null && treeData != null) {
      treeData.add(rootNode);
      contents.put(rootNode.getColumnLabel(),treeData);
    }
    initCurrentSchema();
  }
 else   if (rootTable != null && rootTable.size() <= 0) {
    for (    IConnection connection : incomingConnections) {
      IMetadataTable metadataTable=connection.getMetadataTable();
      metadataTable.setLabel(connection.getUniqueName());
      String metadataTableName=metadataTable.getLabel();
      String rowName=metadataTable.getLabel();
      for (      Map<String,String> map : maps) {
        if (map.containsValue(rowName)) {
          if (map.get("String_Node_Str") != null && map.get("String_Node_Str").equals(rowName)) {
            String schemaName=map.get("String_Node_Str");
            int first=schemaName.indexOf("String_Node_Str");
            int second=schemaName.lastIndexOf("String_Node_Str");
            if (first > 0 && first < second) {
              schemaName=schemaName.substring(first + 1,second);
            }
            if (!schemaList.contains(schemaName)) {
              schemaList.add(schemaName);
              rowName=schemaName;
              schemaMap.put(metadataTableName,rowName);
              break;
            }
          }
        }
      }
      treeData=new ArrayList<HL7TreeNode>();
      if (i == 0)       currentSchema=metadataTableName;
      HL7TreeNode rootNode=null;
      HL7TreeNode current=null;
      HL7TreeNode temp=null;
      HL7TreeNode mainNode=null;
      String mainPath=null;
      String currentPath=null;
      String defaultValue=null;
      int nodeOrder=0;
      boolean haveOrder=true;
      String schemaId=rowName + "String_Node_Str";
      if (rootTable != null) {
        for (        Map<String,String> rootMap : rootTable) {
          String newPath=rootMap.get(HL7InputComponent.PATH);
          String columnName=rootMap.get(HL7InputComponent.COLUMN);
          defaultValue=rootMap.get(HL7InputComponent.VALUE);
          String orderValue=rootMap.get(HL7InputComponent.ORDER);
          boolean repeatable=Boolean.valueOf(rootMap.get("String_Node_Str"));
          if (orderValue == null || "String_Node_Str".equals(orderValue)) {
            haveOrder=false;
          }
          if (haveOrder) {
            nodeOrder=Integer.valueOf(rootMap.get(HL7InputComponent.ORDER)).intValue();
          }
          String flag=columnName + "String_Node_Str";
          if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + "String_Node_Str")) {
            continue;
          }
          if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
            temp=new Attribute(newPath);
            temp.setDefaultValue(defaultValue);
            current.addChild(temp);
          }
 else           if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
            temp=new NameSpaceNode(newPath);
            temp.setDefaultValue(defaultValue);
            current.addChild(temp);
          }
 else {
            temp=addElement(current,currentPath,newPath,defaultValue);
            if (rootNode == null) {
              rootNode=temp;
            }
            if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
              temp.setMain(true);
              mainNode=temp;
              mainPath=newPath;
            }
            current=temp;
            currentPath=newPath;
          }
          if (haveOrder) {
            temp.setOrder(nodeOrder);
          }
          temp.setRepetable(repeatable);
          temp.setRow(rowName);
          if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
            columnName=columnName.replace(schemaId,"String_Node_Str");
            temp.setColumn(metadataTable.getColumn(columnName));
            temp.setTable(metadataTable);
          }
        }
        if (rootNode == null) {
          rootNode=new Element("String_Node_Str");
        }
        if (haveOrder) {
          orderNode(rootNode);
        }
        treeData.add(rootNode);
        rootNode.setRow(rowName);
        contents.put(metadataTableName,treeData);
        i++;
      }
    }
  }
}

Fixed version (ground truth):
public void initModel(){
  int i=0;
  List<? extends IConnection> incomingConnections=NodeUtil.getIncomingConnections(hl7Component,IConnectionCategory.FLOW);
  List<Map<String,String>> maps=(List<Map<String,String>>)ElementParameterParser.getObjectValue(hl7Component,"String_Node_Str");
  List<String> schemaList=new ArrayList<String>();
  List<Map<String,String>> rootTable=(List<Map<String,String>>)hl7Component.getTableList(HL7InputComponent.ROOT);
  List<String> columnList=new ArrayList<String>();
  Map<String,HL7TreeNode> mapNodes=new HashMap<String,HL7TreeNode>();
  if (rootTable != null && rootTable.size() > 0) {
    for (    Map<String,String> rootMap : rootTable) {
      String columnName=rootMap.get(HL7InputComponent.COLUMN);
      if (columnName.contains("String_Node_Str")) {
        columnName=columnName.substring(0,columnName.indexOf("String_Node_Str"));
      }
      if (!columnList.contains(columnName) && !"String_Node_Str".equals(columnName)) {
        columnList.add(columnName);
      }
    }
    HL7TreeNode rootNode=null;
    for (    String rowName : columnList) {
      IMetadataTable metadataTable=null;
      String metadataTableName=rowName;
      for (      IConnection connection : incomingConnections) {
        if (connection.getUniqueName().equals(rowName)) {
          metadataTable=connection.getMetadataTable();
          metadataTable.setLabel(connection.getUniqueName());
          metadataTableName=metadataTable.getLabel();
        }
      }
      treeData=new ArrayList<HL7TreeNode>();
      if (i == 0)       currentSchema=metadataTableName;
      HL7TreeNode current=null;
      HL7TreeNode temp=null;
      HL7TreeNode mainNode=null;
      String mainPath=null;
      String currentPath=null;
      String defaultValue=null;
      int nodeOrder=0;
      boolean haveOrder=true;
      String schemaId=rowName + "String_Node_Str";
      for (      Map<String,String> rootMap : rootTable) {
        String newPath=rootMap.get(HL7InputComponent.PATH);
        String columnName=rootMap.get(HL7InputComponent.COLUMN);
        defaultValue=rootMap.get(HL7InputComponent.VALUE);
        String orderValue=rootMap.get(HL7InputComponent.ORDER);
        boolean repeatable=Boolean.valueOf(rootMap.get("String_Node_Str"));
        if (orderValue == null || "String_Node_Str".equals(orderValue)) {
          haveOrder=false;
        }
        if (haveOrder) {
          nodeOrder=Integer.valueOf(rootMap.get(HL7InputComponent.ORDER)).intValue();
        }
        String flag=columnName + "String_Node_Str";
        if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + "String_Node_Str")) {
          continue;
        }
        if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
          temp=new Attribute(newPath);
          temp.setDefaultValue(defaultValue);
          current.addChild(temp);
        }
 else         if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
          temp=new NameSpaceNode(newPath);
          temp.setDefaultValue(defaultValue);
          current.addChild(temp);
        }
 else {
          temp=addElement(current,currentPath,newPath,defaultValue,mapNodes);
          if (rootNode == null) {
            rootNode=temp;
          }
          if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
            temp.setMain(true);
            mainNode=temp;
            mainPath=newPath;
          }
          current=temp;
          currentPath=newPath;
        }
        temp.setRepetable(repeatable);
        if (haveOrder) {
          temp.setOrder(nodeOrder);
        }
        if (columnName != null && columnName.length() > 0) {
          temp.setRow(rowName);
        }
        if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
          columnName=columnName.replace(schemaId,"String_Node_Str");
          if (metadataTable == null) {
            IMetadataTable metadataTableTemp=null;
            for (            IConnection connection : incomingConnections) {
              metadataTableTemp=connection.getMetadataTable();
              String connectionName=metadataTableTemp.getLabel();
              if (connectionName == null) {
                connectionName=connection.getUniqueName();
              }
              if (columnName.startsWith(connectionName)) {
                break;
              }
            }
            if (metadataTableTemp != null) {
              temp.setColumnName(columnName);
              temp.setColumn(metadataTableTemp.getColumn(columnName));
              temp.setTable(metadataTableTemp);
            }
          }
 else {
            temp.setColumnName(columnName);
            temp.setColumn(metadataTable.getColumn(columnName));
            temp.setTable(metadataTable);
          }
        }
      }
      if (rootNode == null) {
        rootNode=new Element("String_Node_Str");
      }
      if (haveOrder) {
        orderNode(rootNode);
      }
      i++;
    }
    if (rootNode != null && treeData != null) {
      treeData.add(rootNode);
      contents.put(rootNode.getColumnLabel(),treeData);
    }
    initCurrentSchema();
  }
 else   if (rootTable != null && rootTable.size() <= 0) {
    for (    IConnection connection : incomingConnections) {
      IMetadataTable metadataTable=connection.getMetadataTable();
      metadataTable.setLabel(connection.getUniqueName());
      String metadataTableName=metadataTable.getLabel();
      String rowName=metadataTable.getLabel();
      for (      Map<String,String> map : maps) {
        if (map.containsValue(rowName)) {
          if (map.get("String_Node_Str") != null && map.get("String_Node_Str").equals(rowName)) {
            String schemaName=map.get("String_Node_Str");
            int first=schemaName.indexOf("String_Node_Str");
            int second=schemaName.lastIndexOf("String_Node_Str");
            if (first > 0 && first < second) {
              schemaName=schemaName.substring(first + 1,second);
            }
            if (!schemaList.contains(schemaName)) {
              schemaList.add(schemaName);
              rowName=schemaName;
              schemaMap.put(metadataTableName,rowName);
              break;
            }
          }
        }
      }
      treeData=new ArrayList<HL7TreeNode>();
      if (i == 0)       currentSchema=metadataTableName;
      HL7TreeNode rootNode=null;
      HL7TreeNode current=null;
      HL7TreeNode temp=null;
      HL7TreeNode mainNode=null;
      String mainPath=null;
      String currentPath=null;
      String defaultValue=null;
      int nodeOrder=0;
      boolean haveOrder=true;
      String schemaId=rowName + "String_Node_Str";
      if (rootTable != null) {
        for (        Map<String,String> rootMap : rootTable) {
          String newPath=rootMap.get(HL7InputComponent.PATH);
          String columnName=rootMap.get(HL7InputComponent.COLUMN);
          defaultValue=rootMap.get(HL7InputComponent.VALUE);
          String orderValue=rootMap.get(HL7InputComponent.ORDER);
          boolean repeatable=Boolean.valueOf(rootMap.get("String_Node_Str"));
          if (orderValue == null || "String_Node_Str".equals(orderValue)) {
            haveOrder=false;
          }
          if (haveOrder) {
            nodeOrder=Integer.valueOf(rootMap.get(HL7InputComponent.ORDER)).intValue();
          }
          String flag=columnName + "String_Node_Str";
          if (columnName != null && columnName.length() > 0 && !flag.startsWith(rowName + "String_Node_Str")) {
            continue;
          }
          if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
            temp=new Attribute(newPath);
            temp.setDefaultValue(defaultValue);
            current.addChild(temp);
          }
 else           if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
            temp=new NameSpaceNode(newPath);
            temp.setDefaultValue(defaultValue);
            current.addChild(temp);
          }
 else {
            temp=addElement(current,currentPath,newPath,defaultValue,mapNodes);
            if (rootNode == null) {
              rootNode=temp;
            }
            if (rootMap.get(HL7InputComponent.ATTRIBUTE).equals("String_Node_Str")) {
              temp.setMain(true);
              mainNode=temp;
              mainPath=newPath;
            }
            current=temp;
            currentPath=newPath;
          }
          if (haveOrder) {
            temp.setOrder(nodeOrder);
          }
          temp.setRepetable(repeatable);
          temp.setRow(rowName);
          if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
            columnName=columnName.replace(schemaId,"String_Node_Str");
            temp.setColumn(metadataTable.getColumn(columnName));
            temp.setTable(metadataTable);
          }
        }
        if (rootNode == null) {
          rootNode=new Element("String_Node_Str");
        }
        if (haveOrder) {
          orderNode(rootNode);
        }
        treeData.add(rootNode);
        rootNode.setRow(rowName);
        contents.put(metadataTableName,treeData);
        i++;
      }
    }
  }
}