Program: 115308
Project: 115308
Buggy source:
/** 
 * createODMfile, added by tbh, 01/2009
 */
public HashMap<String,Integer> createODMFile(String odmVersion,long sysTimeBegin,String generalFileDir,DatasetBean datasetBean,StudyBean currentStudy,String generalFileDirCopy,ExtractBean eb,Integer currentStudyId,Integer parentStudyId,String studySubjectNumber,boolean zipped){
  Integer ssNumber=getStudySubjectNumber(studySubjectNumber);
  MetaDataCollector mdc=new MetaDataCollector(ds,datasetBean,currentStudy);
  AdminDataCollector adc=new AdminDataCollector(ds,datasetBean,currentStudy);
  ClinicalDataCollector cdc=new ClinicalDataCollector(ds,datasetBean,currentStudy);
  MetaDataCollector.setTextLength(200);
  if (odmVersion != null) {
    if ("String_Node_Str".equals(odmVersion)) {
      ODMBean odmb=new ODMBean();
      odmb.setSchemaLocation("String_Node_Str");
      ArrayList<String> xmlnsList=new ArrayList<String>();
      xmlnsList.add("String_Node_Str");
      odmb.setXmlnsList(xmlnsList);
      odmb.setODMVersion("String_Node_Str");
      mdc.setODMBean(odmb);
      adc.setOdmbean(odmb);
      cdc.setODMBean(odmb);
    }
 else     if ("String_Node_Str".equals(odmVersion)) {
      ODMBean odmb=new ODMBean();
      odmb.setSchemaLocation("String_Node_Str");
      ArrayList<String> xmlnsList=new ArrayList<String>();
      xmlnsList.add("String_Node_Str");
      xmlnsList.add("String_Node_Str");
      odmb.setXmlnsList(xmlnsList);
      odmb.setODMVersion("String_Node_Str");
      mdc.setODMBean(odmb);
      adc.setOdmbean(odmb);
      cdc.setODMBean(odmb);
    }
 else     if ("String_Node_Str".equals(odmVersion)) {
      ODMBean odmb=mdc.getODMBean();
      odmb.setSchemaLocation("String_Node_Str");
      ArrayList<String> xmlnsList=new ArrayList<String>();
      xmlnsList.add("String_Node_Str");
      xmlnsList.add("String_Node_Str");
      odmb.setXmlnsList(xmlnsList);
      odmb.setODMVersion("String_Node_Str");
      mdc.setODMBean(odmb);
      adc.setOdmbean(odmb);
      cdc.setODMBean(odmb);
    }
  }
  mdc.collectFileData();
  MetaDataReportBean metaReport=new MetaDataReportBean(mdc.getOdmStudyMap());
  metaReport.setODMVersion(odmVersion);
  metaReport.setOdmBean(mdc.getODMBean());
  metaReport.createChunkedOdmXml(Boolean.TRUE);
  long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
  String ODMXMLFileName=mdc.getODMBean().getFileOID() + "String_Node_Str";
  int fId=this.createFileK(ODMXMLFileName,generalFileDir,metaReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  if (!"String_Node_Str".equals(generalFileDirCopy)) {
    int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,metaReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  }
  adc.collectFileData();
  AdminDataReportBean adminReport=new AdminDataReportBean(adc.getOdmAdminDataMap());
  adminReport.setODMVersion(odmVersion);
  adminReport.setOdmBean(mdc.getODMBean());
  adminReport.createChunkedOdmXml(Boolean.TRUE);
  sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
  fId=this.createFileK(ODMXMLFileName,generalFileDir,adminReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  if (!"String_Node_Str".equals(generalFileDirCopy)) {
    int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,adminReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  }
  DatasetDAO dsdao=new DatasetDAO(ds);
  String sql=eb.getDataset().getSQLStatement();
  String st_sed_in=dsdao.parseSQLDataset(sql,true,true);
  String st_itemid_in=dsdao.parseSQLDataset(sql,false,true);
  int datasetItemStatusId=eb.getDataset().getDatasetItemStatus().getId();
  String ecStatusConstraint=dsdao.getECStatusConstraint(datasetItemStatusId);
  String itStatusConstraint=dsdao.getItemDataStatusConstraint(datasetItemStatusId);
  Iterator<OdmStudyBase> it=cdc.getStudyBaseMap().values().iterator();
  while (it.hasNext()) {
    OdmStudyBase u=it.next();
    ArrayList newRows=dsdao.selectStudySubjects(u.getStudy().getId(),0,st_sed_in,st_itemid_in,dsdao.genDatabaseDateConstraint(eb),ecStatusConstraint,itStatusConstraint);
    int fromIndex=0;
    boolean firstIteration=true;
    while (fromIndex < newRows.size()) {
      int toIndex=fromIndex + ssNumber < newRows.size() ? fromIndex + ssNumber : newRows.size() - 1;
      List x=newRows.subList(fromIndex,toIndex + 1);
      fromIndex=toIndex + 1;
      String studySubjectIds="String_Node_Str";
      for (int i=0; i < x.size(); i++) {
        StudySubjectBean sub=new StudySubjectBean();
        sub=(StudySubjectBean)x.get(i);
        studySubjectIds+="String_Node_Str" + sub.getId();
      }
      studySubjectIds=studySubjectIds.replaceFirst("String_Node_Str","String_Node_Str");
      ClinicalDataUnit cdata=new ClinicalDataUnit(ds,datasetBean,cdc.getOdmbean(),u.getStudy(),cdc.getCategory(),studySubjectIds);
      cdata.setCategory(cdc.getCategory());
      cdata.collectOdmClinicalData();
      FullReportBean report=new FullReportBean();
      report.setClinicalData(cdata.getOdmClinicalData());
      report.setOdmStudyMap(mdc.getOdmStudyMap());
      report.setODMVersion(odmVersion);
      report.setOdmBean(mdc.getODMBean());
      if (firstIteration && fromIndex >= newRows.size()) {
        report.createChunkedOdmXml(Boolean.TRUE,true,true);
        firstIteration=false;
      }
 else       if (firstIteration) {
        report.createChunkedOdmXml(Boolean.TRUE,true,false);
        firstIteration=false;
      }
 else       if (fromIndex >= newRows.size()) {
        report.createChunkedOdmXml(Boolean.TRUE,false,true);
      }
 else {
        report.createChunkedOdmXml(Boolean.TRUE,false,false);
      }
      fId=this.createFileK(ODMXMLFileName,generalFileDir,report.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
      if (!"String_Node_Str".equals(generalFileDirCopy)) {
        int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,report.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
      }
    }
  }
  sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
  fId=this.createFileK(ODMXMLFileName,generalFileDir,"String_Node_Str",datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,true,zipped);
  if (!"String_Node_Str".equals(generalFileDirCopy)) {
    int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,"String_Node_Str",datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  }
  HashMap answerMap=new HashMap<String,Integer>();
  answerMap.put(ODMXMLFileName,new Integer(fId));
  return answerMap;
}

Fixed version (ground truth):
/** 
 * createODMfile, added by tbh, 01/2009
 */
public HashMap<String,Integer> createODMFile(String odmVersion,long sysTimeBegin,String generalFileDir,DatasetBean datasetBean,StudyBean currentStudy,String generalFileDirCopy,ExtractBean eb,Integer currentStudyId,Integer parentStudyId,String studySubjectNumber,boolean zipped,boolean saveToDB){
  Integer ssNumber=getStudySubjectNumber(studySubjectNumber);
  MetaDataCollector mdc=new MetaDataCollector(ds,datasetBean,currentStudy);
  AdminDataCollector adc=new AdminDataCollector(ds,datasetBean,currentStudy);
  ClinicalDataCollector cdc=new ClinicalDataCollector(ds,datasetBean,currentStudy);
  MetaDataCollector.setTextLength(200);
  if (odmVersion != null) {
    if ("String_Node_Str".equals(odmVersion)) {
      ODMBean odmb=new ODMBean();
      odmb.setSchemaLocation("String_Node_Str");
      ArrayList<String> xmlnsList=new ArrayList<String>();
      xmlnsList.add("String_Node_Str");
      odmb.setXmlnsList(xmlnsList);
      odmb.setODMVersion("String_Node_Str");
      mdc.setODMBean(odmb);
      adc.setOdmbean(odmb);
      cdc.setODMBean(odmb);
    }
 else     if ("String_Node_Str".equals(odmVersion)) {
      ODMBean odmb=new ODMBean();
      odmb.setSchemaLocation("String_Node_Str");
      ArrayList<String> xmlnsList=new ArrayList<String>();
      xmlnsList.add("String_Node_Str");
      xmlnsList.add("String_Node_Str");
      odmb.setXmlnsList(xmlnsList);
      odmb.setODMVersion("String_Node_Str");
      mdc.setODMBean(odmb);
      adc.setOdmbean(odmb);
      cdc.setODMBean(odmb);
    }
 else     if ("String_Node_Str".equals(odmVersion)) {
      ODMBean odmb=mdc.getODMBean();
      odmb.setSchemaLocation("String_Node_Str");
      ArrayList<String> xmlnsList=new ArrayList<String>();
      xmlnsList.add("String_Node_Str");
      xmlnsList.add("String_Node_Str");
      odmb.setXmlnsList(xmlnsList);
      odmb.setODMVersion("String_Node_Str");
      mdc.setODMBean(odmb);
      adc.setOdmbean(odmb);
      cdc.setODMBean(odmb);
    }
  }
  mdc.collectFileData();
  MetaDataReportBean metaReport=new MetaDataReportBean(mdc.getOdmStudyMap());
  metaReport.setODMVersion(odmVersion);
  metaReport.setOdmBean(mdc.getODMBean());
  metaReport.createChunkedOdmXml(Boolean.TRUE);
  long sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
  String ODMXMLFileName=mdc.getODMBean().getFileOID() + "String_Node_Str";
  int fId=this.createFileK(ODMXMLFileName,generalFileDir,metaReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  if (!"String_Node_Str".equals(generalFileDirCopy)) {
    int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,metaReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  }
  adc.collectFileData();
  AdminDataReportBean adminReport=new AdminDataReportBean(adc.getOdmAdminDataMap());
  adminReport.setODMVersion(odmVersion);
  adminReport.setOdmBean(mdc.getODMBean());
  adminReport.createChunkedOdmXml(Boolean.TRUE);
  sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
  fId=this.createFileK(ODMXMLFileName,generalFileDir,adminReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  if (!"String_Node_Str".equals(generalFileDirCopy)) {
    int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,adminReport.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  }
  DatasetDAO dsdao=new DatasetDAO(ds);
  String sql=eb.getDataset().getSQLStatement();
  String st_sed_in=dsdao.parseSQLDataset(sql,true,true);
  String st_itemid_in=dsdao.parseSQLDataset(sql,false,true);
  int datasetItemStatusId=eb.getDataset().getDatasetItemStatus().getId();
  String ecStatusConstraint=dsdao.getECStatusConstraint(datasetItemStatusId);
  String itStatusConstraint=dsdao.getItemDataStatusConstraint(datasetItemStatusId);
  Iterator<OdmStudyBase> it=cdc.getStudyBaseMap().values().iterator();
  while (it.hasNext()) {
    OdmStudyBase u=it.next();
    ArrayList newRows=dsdao.selectStudySubjects(u.getStudy().getId(),0,st_sed_in,st_itemid_in,dsdao.genDatabaseDateConstraint(eb),ecStatusConstraint,itStatusConstraint);
    int fromIndex=0;
    boolean firstIteration=true;
    while (fromIndex < newRows.size()) {
      int toIndex=fromIndex + ssNumber < newRows.size() ? fromIndex + ssNumber : newRows.size() - 1;
      List x=newRows.subList(fromIndex,toIndex + 1);
      fromIndex=toIndex + 1;
      String studySubjectIds="String_Node_Str";
      for (int i=0; i < x.size(); i++) {
        StudySubjectBean sub=new StudySubjectBean();
        sub=(StudySubjectBean)x.get(i);
        studySubjectIds+="String_Node_Str" + sub.getId();
      }
      studySubjectIds=studySubjectIds.replaceFirst("String_Node_Str","String_Node_Str");
      ClinicalDataUnit cdata=new ClinicalDataUnit(ds,datasetBean,cdc.getOdmbean(),u.getStudy(),cdc.getCategory(),studySubjectIds);
      cdata.setCategory(cdc.getCategory());
      cdata.collectOdmClinicalData();
      FullReportBean report=new FullReportBean();
      report.setClinicalData(cdata.getOdmClinicalData());
      report.setOdmStudyMap(mdc.getOdmStudyMap());
      report.setODMVersion(odmVersion);
      report.setOdmBean(mdc.getODMBean());
      if (firstIteration && fromIndex >= newRows.size()) {
        report.createChunkedOdmXml(Boolean.TRUE,true,true);
        firstIteration=false;
      }
 else       if (firstIteration) {
        report.createChunkedOdmXml(Boolean.TRUE,true,false);
        firstIteration=false;
      }
 else       if (fromIndex >= newRows.size()) {
        report.createChunkedOdmXml(Boolean.TRUE,false,true);
      }
 else {
        report.createChunkedOdmXml(Boolean.TRUE,false,false);
      }
      fId=this.createFileK(ODMXMLFileName,generalFileDir,report.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
      if (!"String_Node_Str".equals(generalFileDirCopy)) {
        int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,report.getXmlOutput().toString(),datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
      }
    }
  }
  sysTimeEnd=System.currentTimeMillis() - sysTimeBegin;
  fId=this.createFileK(ODMXMLFileName,generalFileDir,"String_Node_Str",datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,saveToDB,zipped);
  if (!"String_Node_Str".equals(generalFileDirCopy)) {
    int fId2=this.createFileK(ODMXMLFileName,generalFileDirCopy,"String_Node_Str",datasetBean,sysTimeEnd,ExportFormatBean.XMLFILE,false,zipped);
  }
  HashMap answerMap=new HashMap<String,Integer>();
  answerMap.put(ODMXMLFileName,new Integer(fId));
  return answerMap;
}