Program: 39081
Project: 39081
Buggy source:
@Override protected Collection<ECRFStatusEntryVO> handleSignVerifiedEcrfs(AuthenticationVO auth,Long trialId,Long probandListEntryId,boolean signAll) throws Exception {
  if (trialId != null) {
    CheckIDUtil.checkTrialId(trialId,this.getTrialDao(),LockMode.PESSIMISTIC_WRITE);
  }
  if (probandListEntryId != null) {
    CheckIDUtil.checkProbandListEntryId(probandListEntryId,this.getProbandListEntryDao(),LockMode.PESSIMISTIC_WRITE);
  }
  Timestamp now=new Timestamp(System.currentTimeMillis());
  User user=CoreUtil.getUser();
  ArrayList<ECRFStatusEntryVO> results=new ArrayList<ECRFStatusEntryVO>();
  Iterator<ECRFStatusEntry> statusEntryIt=this.getECRFStatusEntryDao().findByTrialListEntryDoneValidatedReviewVerified(trialId,probandListEntryId,null,null,null,null,null).iterator();
  while (statusEntryIt.hasNext()) {
    ECRFStatusEntry statusEntry=statusEntryIt.next();
    Iterator<ECRFStatusType> it=statusEntry.getStatus().getTransitions().iterator();
    ECRFStatusType newStatus=null;
    while (it.hasNext()) {
      ECRFStatusType status=it.next();
      if ((signAll || !statusEntry.getStatus().equals(status)) && hasEcrfStatusAction(status,org.phoenixctms.ctsms.enumeration.ECRFStatusAction.SIGN_ECRF)) {
        newStatus=status;
        break;
      }
    }
    if (newStatus != null) {
      checkTeamMemberSign(statusEntry.getListEntry().getTrial(),user);
      ECRFStatusEntryVO result=updateEcrfStatusEntry(statusEntry,statusEntry.getEcrf(),statusEntry.getListEntry(),newStatus,statusEntry.getVersion(),null,now,user);
      results.add(result);
    }
  }
  return results;
}

Fixed version (ground truth):
@Override protected Collection<ECRFStatusEntryVO> handleSignVerifiedEcrfs(AuthenticationVO auth,Long trialId,Long probandListEntryId,boolean signAll) throws Exception {
  if (trialId != null) {
    CheckIDUtil.checkTrialId(trialId,this.getTrialDao(),LockMode.PESSIMISTIC_WRITE);
  }
  if (probandListEntryId != null) {
    CheckIDUtil.checkProbandListEntryId(probandListEntryId,this.getProbandListEntryDao(),LockMode.PESSIMISTIC_WRITE);
  }
  Timestamp now=new Timestamp(System.currentTimeMillis());
  User user=CoreUtil.getUser();
  ArrayList<ECRFStatusEntryVO> results=new ArrayList<ECRFStatusEntryVO>();
  Iterator<ECRFStatusEntry> statusEntryIt=this.getECRFStatusEntryDao().findByTrialListEntryDoneValidatedReviewVerified(trialId,probandListEntryId,null,null,null,signAll ? null : true,null).iterator();
  while (statusEntryIt.hasNext()) {
    ECRFStatusEntry statusEntry=statusEntryIt.next();
    Iterator<ECRFStatusType> it=statusEntry.getStatus().getTransitions().iterator();
    ECRFStatusType newStatus=null;
    while (it.hasNext()) {
      ECRFStatusType status=it.next();
      if ((signAll || !statusEntry.getStatus().equals(status)) && hasEcrfStatusAction(status,org.phoenixctms.ctsms.enumeration.ECRFStatusAction.SIGN_ECRF)) {
        newStatus=status;
        break;
      }
    }
    if (newStatus != null) {
      checkTeamMemberSign(statusEntry.getListEntry().getTrial(),user);
      ECRFStatusEntryVO result=updateEcrfStatusEntry(statusEntry,statusEntry.getEcrf(),statusEntry.getListEntry(),newStatus,statusEntry.getVersion(),null,now,user);
      results.add(result);
    }
  }
  return results;
}