Program: 114985
Project: 114985
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void restoreStudyEventDefn(int defId,int userId){
  StudyEventDefinitionBean sed=(StudyEventDefinitionBean)getStudyEventDefinitionDao().findByPK(defId);
  UserAccountBean ub=(UserAccountBean)getUserAccountDao().findByPK(userId);
  ArrayList<EventDefinitionCRFBean> eventDefinitionCRFs=(ArrayList)getEventDefinitionCRFDao().findAllByDefinition(defId);
  ArrayList<StudyEventBean> events=(ArrayList)getStudyEventDao().findAllByDefinition(sed.getId());
  sed.setStatus(Status.AVAILABLE);
  sed.setUpdater(ub);
  sed.setUpdatedDate(new Date());
  getStudyEventDefinitionDao().update(sed);
  for (int j=0; j < eventDefinitionCRFs.size(); j++) {
    EventDefinitionCRFBean edc=(EventDefinitionCRFBean)eventDefinitionCRFs.get(j);
    CRFBean crf=(CRFBean)getCrfDao().findByPK(edc.getCrfId());
    if (edc.getStatus().equals(Status.AUTO_DELETED) || edc.getStatus().equals(Status.DELETED)) {
      edc.setStatus(Status.AVAILABLE);
      edc.setUpdater(ub);
      edc.setUpdatedDate(new Date());
      getEventDefinitionCRFDao().update(edc);
    }
  }
  for (int j=0; j < events.size(); j++) {
    StudyEventBean event=(StudyEventBean)events.get(j);
    if (event.getStatus().equals(Status.AUTO_DELETED) || event.getStatus().equals(Status.DELETED)) {
      event.setStatus(Status.AVAILABLE);
      event.setUpdater(ub);
      event.setUpdatedDate(new Date());
      getStudyEventDao().update(event);
      ArrayList eventCRFs=getEventCRFDao().findAllByStudyEvent(event);
      for (int k=0; k < eventCRFs.size(); k++) {
        EventCRFBean eventCRF=(EventCRFBean)eventCRFs.get(k);
        if (eventCRF.getStatus().equals(Status.AUTO_DELETED) || eventCRF.getStatus().equals(Status.DELETED)) {
          eventCRF.setStatus(Status.AVAILABLE);
          eventCRF.setUpdater(ub);
          eventCRF.setUpdatedDate(new Date());
          getEventCRFDao().update(eventCRF);
          ArrayList itemDatas=getItemDataDao().findAllByEventCRFId(eventCRF.getId());
          for (int a=0; a < itemDatas.size(); a++) {
            ItemDataBean item=(ItemDataBean)itemDatas.get(a);
            if (item.getStatus().equals(Status.AUTO_DELETED) || item.getStatus().equals(Status.DELETED)) {
              item.setStatus(Status.AVAILABLE);
              item.setUpdater(ub);
              item.setUpdatedDate(new Date());
              getItemDataDao().update(item);
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public void restoreStudyEventDefn(int defId,int userId){
  StudyEventDefinitionBean sed=(StudyEventDefinitionBean)getStudyEventDefinitionDao().findByPK(defId);
  UserAccountBean ub=(UserAccountBean)getUserAccountDao().findByPK(userId);
  ArrayList<EventDefinitionCRFBean> eventDefinitionCRFs=(ArrayList)getEventDefinitionCRFDao().findAllByDefinition(defId);
  ArrayList<StudyEventBean> events=(ArrayList)getStudyEventDao().findAllByDefinition(sed.getId());
  sed.setStatus(Status.AVAILABLE);
  sed.setUpdater(ub);
  sed.setUpdatedDate(new Date());
  getStudyEventDefinitionDao().update(sed);
  for (int j=0; j < eventDefinitionCRFs.size(); j++) {
    EventDefinitionCRFBean edc=(EventDefinitionCRFBean)eventDefinitionCRFs.get(j);
    CRFBean crf=(CRFBean)getCrfDao().findByPK(edc.getCrfId());
    if (edc.getStatus().equals(Status.AUTO_DELETED) || edc.getStatus().equals(Status.DELETED)) {
      edc.setStatus(Status.AVAILABLE);
      edc.setUpdater(ub);
      edc.setUpdatedDate(new Date());
      edc=(EventDefinitionCRFBean)getEventDefinitionCRFDao().update(edc);
      odmImportService.restoreSiteDefinitions(edc.getId(),userId);
    }
  }
  for (int j=0; j < events.size(); j++) {
    StudyEventBean event=(StudyEventBean)events.get(j);
    if (event.getStatus().equals(Status.AUTO_DELETED) || event.getStatus().equals(Status.DELETED)) {
      event.setStatus(Status.AVAILABLE);
      event.setUpdater(ub);
      event.setUpdatedDate(new Date());
      getStudyEventDao().update(event);
      ArrayList eventCRFs=getEventCRFDao().findAllByStudyEvent(event);
      for (int k=0; k < eventCRFs.size(); k++) {
        EventCRFBean eventCRF=(EventCRFBean)eventCRFs.get(k);
        if (eventCRF.getStatus().equals(Status.AUTO_DELETED) || eventCRF.getStatus().equals(Status.DELETED)) {
          eventCRF.setStatus(Status.AVAILABLE);
          eventCRF.setUpdater(ub);
          eventCRF.setUpdatedDate(new Date());
          getEventCRFDao().update(eventCRF);
          ArrayList itemDatas=getItemDataDao().findAllByEventCRFId(eventCRF.getId());
          for (int a=0; a < itemDatas.size(); a++) {
            ItemDataBean item=(ItemDataBean)itemDatas.get(a);
            if (item.getStatus().equals(Status.AUTO_DELETED) || item.getStatus().equals(Status.DELETED)) {
              item.setStatus(Status.AVAILABLE);
              item.setUpdater(ub);
              item.setUpdatedDate(new Date());
              getItemDataDao().update(item);
            }
          }
        }
      }
    }
  }
}