Program: 115212
Project: 115212
Buggy source:
/** 
 * Metadata for ODM_1.2 OpenClinica extension and partial ODM_1.3 OpenClinica extension 
 * @param parentStudyId
 * @param studyId
 * @param metadata
 * @param odmVersion
 */
public void getOCMetadata(int parentStudyId,int studyId,MetaDataVersionBean metadata,String odmVersion){
  this.getODMMetadata(parentStudyId,studyId,metadata,odmVersion);
  String cvIds=metadata.getCvIds();
  if (odmVersion.startsWith("String_Node_Str")) {
    HashMap<String,String> itDefCVs=new HashMap<String,String>();
    this.setItemCVOIDsTypesExpected();
    ArrayList al=this.select(this.getItemCVOIDsSql(cvIds));
    Iterator iter=al.iterator();
    while (iter.hasNext()) {
      HashMap row=(HashMap)iter.next();
      Integer cId=(Integer)row.get("String_Node_Str");
      Integer cvId=(Integer)row.get("String_Node_Str");
      Integer itId=(Integer)row.get("String_Node_Str");
      String cvOID=(String)row.get("String_Node_Str");
      String itOID=(String)row.get("String_Node_Str");
      if (itDefCVs.containsKey(itOID)) {
        String cvs=itDefCVs.get(itOID);
        if (!cvs.contains(cvOID + "String_Node_Str")) {
          cvs+=cvOID + "String_Node_Str";
        }
        itDefCVs.put(itOID,cvs);
      }
 else {
        itDefCVs.put(itOID,cvOID + "String_Node_Str");
      }
    }
    for (    ItemDefBean itdef : metadata.getItemDefs()) {
      String key=itdef.getOid();
      if (itDefCVs.containsKey(key)) {
        String cvs=itDefCVs.get(key);
        itdef.setFormOIDs(cvs.substring(0,cvs.length() - 1));
      }
    }
    this.setStudyGroupClassTypesExpected();
    logger.debug("String_Node_Str");
    logger.error("String_Node_Str" + getStudyGroupClassSql(parentStudyId));
    ArrayList rows=select(this.getStudyGroupClassSql(parentStudyId));
    Iterator it=rows.iterator();
    ArrayList<StudyGroupClassListBean> sgcLists=(ArrayList<StudyGroupClassListBean>)metadata.getStudyGroupClassLists();
    String sgcprev="String_Node_Str";
    while (it.hasNext()) {
      HashMap row=(HashMap)it.next();
      Integer sgcid=(Integer)row.get("String_Node_Str");
      String sgcname=(String)row.get("String_Node_Str");
      String sgctype=(String)row.get("String_Node_Str");
      Integer statusid=(Integer)row.get("String_Node_Str");
      String subassign=(String)row.get("String_Node_Str");
      String sgname=(String)row.get("String_Node_Str");
      String des=(String)row.get("String_Node_Str");
      if (sgcprev.equals(sgcid + "String_Node_Str")) {
        StudyGroupItemBean sg=new StudyGroupItemBean();
        sg.setName(sgname);
        sg.setDescription(des);
        StudyGroupClassListBean sgc=sgcLists.get(sgcLists.size() - 1);
        sgc.getStudyGroupItems().add(sg);
      }
 else {
        sgcprev=sgcid + "String_Node_Str";
        StudyGroupClassListBean sgc=new StudyGroupClassListBean();
        sgc.setID("String_Node_Str" + sgcid);
        sgc.setName(sgcname);
        sgc.setType(sgctype);
        sgc.setStatus(Status.get(statusid).getName());
        sgc.setSubjectAssignment(subassign);
        StudyGroupItemBean sg=new StudyGroupItemBean();
        sg.setName(sgname);
        sg.setDescription(des);
        sgc.getStudyGroupItems().add(sg);
        sgcLists.add(sgc);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Metadata for ODM_1.2 OpenClinica extension and partial ODM_1.3 OpenClinica extension 
 * @param parentStudyId
 * @param studyId
 * @param metadata
 * @param odmVersion
 */
public void getOCMetadata(int parentStudyId,int studyId,MetaDataVersionBean metadata,String odmVersion){
  this.getODMMetadata(parentStudyId,studyId,metadata,odmVersion);
  String cvIds=metadata.getCvIds();
  if (odmVersion.startsWith("String_Node_Str")) {
    HashMap<String,String> itDefCVs=new HashMap<String,String>();
    this.setItemCVOIDsTypesExpected();
    ArrayList al=this.select(this.getItemCVOIDsSql(cvIds));
    Iterator iter=al.iterator();
    while (iter.hasNext()) {
      HashMap row=(HashMap)iter.next();
      Integer cId=(Integer)row.get("String_Node_Str");
      Integer cvId=(Integer)row.get("String_Node_Str");
      Integer itId=(Integer)row.get("String_Node_Str");
      String cvOID=(String)row.get("String_Node_Str");
      String itOID=(String)row.get("String_Node_Str");
      if (itDefCVs.containsKey(itOID)) {
        String cvs=itDefCVs.get(itOID);
        if (!cvs.contains(cvOID + "String_Node_Str")) {
          cvs+=cvOID + "String_Node_Str";
        }
        itDefCVs.put(itOID,cvs);
      }
 else {
        itDefCVs.put(itOID,cvOID + "String_Node_Str");
      }
    }
    for (    ItemDefBean itdef : metadata.getItemDefs()) {
      String key=itdef.getOid();
      if (itDefCVs.containsKey(key)) {
        String cvs=itDefCVs.get(key);
        itdef.setFormOIDs(cvs.substring(0,cvs.length() - 1));
      }
    }
    this.setStudyGroupClassTypesExpected();
    logger.debug("String_Node_Str");
    logger.debug("String_Node_Str" + getStudyGroupClassSql(parentStudyId));
    ArrayList rows=select(this.getStudyGroupClassSql(parentStudyId));
    Iterator it=rows.iterator();
    ArrayList<StudyGroupClassListBean> sgcLists=(ArrayList<StudyGroupClassListBean>)metadata.getStudyGroupClassLists();
    String sgcprev="String_Node_Str";
    while (it.hasNext()) {
      HashMap row=(HashMap)it.next();
      Integer sgcid=(Integer)row.get("String_Node_Str");
      String sgcname=(String)row.get("String_Node_Str");
      String sgctype=(String)row.get("String_Node_Str");
      Integer statusid=(Integer)row.get("String_Node_Str");
      String subassign=(String)row.get("String_Node_Str");
      String sgname=(String)row.get("String_Node_Str");
      String des=(String)row.get("String_Node_Str");
      if (sgcprev.equals(sgcid + "String_Node_Str")) {
        StudyGroupItemBean sg=new StudyGroupItemBean();
        sg.setName(sgname);
        sg.setDescription(des);
        StudyGroupClassListBean sgc=sgcLists.get(sgcLists.size() - 1);
        sgc.getStudyGroupItems().add(sg);
      }
 else {
        sgcprev=sgcid + "String_Node_Str";
        StudyGroupClassListBean sgc=new StudyGroupClassListBean();
        sgc.setID("String_Node_Str" + sgcid);
        sgc.setName(sgcname);
        sgc.setType(sgctype);
        sgc.setStatus(Status.get(statusid).getName());
        sgc.setSubjectAssignment(subassign);
        StudyGroupItemBean sg=new StudyGroupItemBean();
        sg.setName(sgname);
        sg.setDescription(des);
        sgc.getStudyGroupItems().add(sg);
        sgcLists.add(sgc);
      }
    }
  }
}