Program: 115093
Project: 115093
Buggy source:
protected boolean writeToDB(ItemDataBean itemData,DisplayItemBean dib,ItemDataDAO iddao,int ordinal,HttpServletRequest request){
  ItemDataBean idb=itemData;
  UserAccountBean ub=(UserAccountBean)request.getSession().getAttribute(USER_BEAN_NAME);
  StudyBean currentStudy=(StudyBean)request.getSession().getAttribute("String_Node_Str");
  EventCRFBean ecb=(EventCRFBean)request.getAttribute(INPUT_EVENT_CRF);
  idb.setItemId(dib.getItem().getId());
  idb.setEventCRFId(ecb.getId());
  if (idb.getValue().equals("String_Node_Str")) {
    idb.setStatus(getBlankItemStatus());
  }
 else {
    idb.setStatus(getNonBlankItemStatus(request));
  }
  if (StringUtil.isBlank(dib.getEditFlag())) {
    if (!idb.isActive()) {
      idb.setOrdinal(ordinal);
      idb.setCreatedDate(new Date());
      idb.setOwner(ub);
      idb=(ItemDataBean)iddao.create(idb);
    }
 else {
      idb.setUpdater(ub);
      LOGGER.debug("String_Node_Str" + idb.getUpdater().getId());
      idb=(ItemDataBean)iddao.updateValue(idb);
    }
  }
 else {
    if ("String_Node_Str".equalsIgnoreCase(dib.getEditFlag())) {
      idb.setOrdinal(ordinal);
      idb.setCreatedDate(new Date());
      idb.setOwner(ub);
      LOGGER.debug("String_Node_Str" + idb.getItemId() + idb.getValue());
      idb.setUpdater(ub);
      idb=(ItemDataBean)iddao.upsert(idb);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(dib.getEditFlag())) {
      idb.setUpdater(ub);
      LOGGER.debug("String_Node_Str" + idb.getUpdater().getId());
      if (idb.getId() != 0) {
        idb.setUpdatedDate(new Date());
        idb=(ItemDataBean)iddao.updateValue(idb);
      }
 else {
        idb.setCreatedDate(new Date());
        idb.setOrdinal(ordinal);
        idb.setOwner(ub);
        idb=(ItemDataBean)iddao.upsert(idb);
        LOGGER.debug("String_Node_Str" + idb.getId());
      }
    }
 else     if ("String_Node_Str".equalsIgnoreCase(dib.getEditFlag())) {
      LOGGER.debug("String_Node_Str" + idb.getItemId() + idb.getValue());
      idb.setUpdater(ub);
      idb.setStatus(Status.DELETED);
      idb=(ItemDataBean)iddao.updateValueForRemoved(idb);
      DiscrepancyNoteDAO dnDao=new DiscrepancyNoteDAO(getDataSource());
      List dnNotesOfRemovedItem=dnDao.findExistingNotesForItemData(idb.getId());
      if (!dnNotesOfRemovedItem.isEmpty()) {
        DiscrepancyNoteBean itemParentNote=null;
        for (        Object obj : dnNotesOfRemovedItem) {
          if (((DiscrepancyNoteBean)obj).getParentDnId() == 0) {
            itemParentNote=(DiscrepancyNoteBean)obj;
          }
        }
        DiscrepancyNoteBean dnb=new DiscrepancyNoteBean();
        if (itemParentNote != null) {
          dnb.setParentDnId(itemParentNote.getId());
          dnb.setDiscrepancyNoteTypeId(itemParentNote.getDiscrepancyNoteTypeId());
        }
        dnb.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
        dnb.setStudyId(currentStudy.getId());
        dnb.setAssignedUserId(ub.getId());
        dnb.setOwner(ub);
        dnb.setEntityType(DiscrepancyNoteBean.ITEM_DATA);
        dnb.setEntityId(idb.getId());
        dnb.setCreatedDate(new Date());
        dnb.setColumn("String_Node_Str");
        dnb.setDescription("String_Node_Str");
        dnDao.create(dnb);
        dnDao.createMapping(dnb);
        itemParentNote.setResolutionStatusId(ResolutionStatus.CLOSED.getId());
        dnDao.update(itemParentNote);
      }
    }
  }
  return idb.isActive();
}

Fixed version (ground truth):
protected boolean writeToDB(ItemDataBean itemData,DisplayItemBean dib,ItemDataDAO iddao,int ordinal,HttpServletRequest request){
  ItemDataBean idb=itemData;
  UserAccountBean ub=(UserAccountBean)request.getSession().getAttribute(USER_BEAN_NAME);
  StudyBean currentStudy=(StudyBean)request.getSession().getAttribute("String_Node_Str");
  EventCRFBean ecb=(EventCRFBean)request.getAttribute(INPUT_EVENT_CRF);
  idb.setItemId(dib.getItem().getId());
  idb.setEventCRFId(ecb.getId());
  if (idb.getValue().equals("String_Node_Str")) {
    idb.setStatus(getBlankItemStatus());
  }
 else {
    idb.setStatus(getNonBlankItemStatus(request));
  }
  if (StringUtils.isBlank(dib.getEditFlag())) {
    if (!idb.isActive()) {
      idb.setOrdinal(ordinal);
      idb.setCreatedDate(new Date());
      idb.setOwner(ub);
      idb=(ItemDataBean)iddao.create(idb);
    }
 else {
      idb.setUpdater(ub);
      LOGGER.debug("String_Node_Str" + idb.getUpdater().getId());
      idb=(ItemDataBean)iddao.updateValue(idb);
    }
  }
 else {
    if ("String_Node_Str".equalsIgnoreCase(dib.getEditFlag())) {
      idb.setOrdinal(ordinal);
      idb.setCreatedDate(new Date());
      idb.setOwner(ub);
      LOGGER.debug("String_Node_Str" + idb.getItemId() + idb.getValue());
      idb.setUpdater(ub);
      idb=(ItemDataBean)iddao.upsert(idb);
    }
 else     if ("String_Node_Str".equalsIgnoreCase(dib.getEditFlag())) {
      idb.setUpdater(ub);
      LOGGER.debug("String_Node_Str" + idb.getUpdater().getId());
      if (idb.getId() != 0) {
        idb.setUpdatedDate(new Date());
        idb=(ItemDataBean)iddao.updateValue(idb);
      }
 else {
        idb.setCreatedDate(new Date());
        idb.setOrdinal(ordinal);
        idb.setOwner(ub);
        idb=(ItemDataBean)iddao.upsert(idb);
        LOGGER.debug("String_Node_Str" + idb.getId());
      }
    }
  }
  return idb.isActive();
}