Program: 115007
Project: 115007
Buggy source:
/** 
 * <P> createStepOne, per the 'Detailed use case for administer system document v1.0rc1' document. We insert the study in this method, and then update the same study in the next three steps. <P> The next three steps, by the way, can then be used to update studies as well.
 * @param sb Study bean about to be created.
 * @return same study bean with a primary key in the ID field.
 */
public StudyBean createStepOne(StudyBean sb){
  HashMap variables=new HashMap();
  HashMap nullVars=new HashMap();
  sb.setId(this.findNextKey());
  variables.put(new Integer(1),new Integer(sb.getId()));
  if (sb.getParentStudyId() == 0) {
    nullVars.put(new Integer(2),new Integer(Types.INTEGER));
    variables.put(new Integer(2),null);
  }
 else {
    variables.put(new Integer(2),new Integer(sb.getParentStudyId()));
  }
  variables.put(new Integer(3),sb.getName());
  variables.put(new Integer(4),sb.getOfficialTitle());
  variables.put(new Integer(5),sb.getIdentifier());
  variables.put(new Integer(6),sb.getSecondaryIdentifier());
  variables.put(new Integer(7),sb.getSummary());
  variables.put(new Integer(8),sb.getPrincipalInvestigator());
  if (sb.getDatePlannedStart() == null) {
    nullVars.put(new Integer(9),new Integer(Types.DATE));
    variables.put(new Integer(9),null);
  }
 else {
    variables.put(new Integer(9),sb.getDatePlannedStart());
  }
  if (sb.getDatePlannedEnd() == null) {
    nullVars.put(new Integer(10),new Integer(Types.DATE));
    variables.put(new Integer(10),null);
  }
 else {
    variables.put(new Integer(10),sb.getDatePlannedEnd());
  }
  variables.put(new Integer(11),sb.getFacilityName());
  variables.put(new Integer(12),sb.getFacilityCity());
  variables.put(new Integer(13),sb.getFacilityState());
  variables.put(new Integer(14),sb.getFacilityZip());
  variables.put(new Integer(15),sb.getFacilityCountry());
  variables.put(new Integer(16),sb.getFacilityRecruitmentStatusKey());
  variables.put(new Integer(17),sb.getFacilityContactName());
  variables.put(new Integer(18),sb.getFacilityContactDegree());
  variables.put(new Integer(19),sb.getFacilityContactPhone());
  variables.put(new Integer(20),sb.getFacilityContactEmail());
  variables.put(new Integer(21),new Integer(sb.getStatus().getId()));
  variables.put(new Integer(22),new java.util.Date());
  variables.put(new Integer(23),new Integer(sb.getOwnerId()));
  variables.put(new Integer(24),getValidOid(sb));
  this.execute(digester.getQuery("String_Node_Str"),variables,nullVars);
  return sb;
}

Fixed version (ground truth):
/** 
 * <P> createStepOne, per the 'Detailed use case for administer system document v1.0rc1' document. We insert the study in this method, and then update the same study in the next three steps. <P> The next three steps, by the way, can then be used to update studies as well.
 * @param sb Study bean about to be created.
 * @return same study bean with a primary key in the ID field.
 */
public StudyBean createStepOne(StudyBean sb){
  HashMap variables=new HashMap();
  HashMap nullVars=new HashMap();
  sb.setId(this.findNextKey());
  variables.put(new Integer(1),new Integer(sb.getId()));
  if (sb.getParentStudyId() == 0) {
    nullVars.put(new Integer(2),new Integer(Types.INTEGER));
    variables.put(new Integer(2),null);
  }
 else {
    variables.put(new Integer(2),new Integer(sb.getParentStudyId()));
  }
  variables.put(new Integer(3),sb.getName());
  variables.put(new Integer(4),sb.getOfficialTitle());
  variables.put(new Integer(5),sb.getIdentifier());
  variables.put(new Integer(6),sb.getSecondaryIdentifier());
  variables.put(new Integer(7),sb.getSummary());
  variables.put(new Integer(8),sb.getPrincipalInvestigator());
  if (sb.getDatePlannedStart() == null) {
    nullVars.put(new Integer(9),new Integer(Types.DATE));
    variables.put(new Integer(9),null);
  }
 else {
    variables.put(new Integer(9),sb.getDatePlannedStart());
  }
  if (sb.getDatePlannedEnd() == null) {
    nullVars.put(new Integer(10),new Integer(Types.DATE));
    variables.put(new Integer(10),null);
  }
 else {
    variables.put(new Integer(10),sb.getDatePlannedEnd());
  }
  variables.put(new Integer(11),sb.getFacilityName());
  variables.put(new Integer(12),sb.getFacilityCity());
  variables.put(new Integer(13),sb.getFacilityState());
  variables.put(new Integer(14),sb.getFacilityZip());
  variables.put(new Integer(15),sb.getFacilityCountry());
  variables.put(new Integer(16),sb.getFacilityRecruitmentStatusKey());
  variables.put(new Integer(17),sb.getFacilityContactName());
  variables.put(new Integer(18),sb.getFacilityContactDegree());
  variables.put(new Integer(19),sb.getFacilityContactPhone());
  variables.put(new Integer(20),sb.getFacilityContactEmail());
  variables.put(new Integer(21),new Integer(sb.getStatus().getId()));
  variables.put(new Integer(22),new java.util.Date());
  variables.put(new Integer(23),new Integer(sb.getOwnerId()));
  variables.put(new Integer(24),getValidOid(sb));
  variables.put(new Integer(25),sb.getEnvType().toString());
  this.execute(digester.getQuery("String_Node_Str"),variables,nullVars);
  return sb;
}