Program: 189336
Project: 189336
Buggy source:
/** 
 * The first screen of the submission process which allows the student to supply their identity, affiliation, and contact information. We default the data displayed to information from the submitter's person object if available. After successfully completing this step a new submission is persisted in the database and the user is sent on to the license step.
 * @param subId The id of the submission being edited. This may be null for this step, all other steps this id is required.
 */
@Security(RoleType.STUDENT) public static void personalInfo(Long subId){
  if (params.get("String_Node_Str") != null)   Application.index();
  Person submitter=context.getPerson();
  Submission sub;
  if (subId == null) {
    SubmissionStatus subStatus=new SubmissionStatus();
    if (!subStatus.getAllowMultiple() && subStatus.getHasSubmissions()) {
      error("String_Node_Str");
    }
    sub=subRepo.createSubmission(submitter);
    if (isFieldEnabled(STUDENT_FIRST_NAME))     sub.setStudentFirstName(submitter.getFirstName());
    if (isFieldEnabled(STUDENT_MIDDLE_NAME))     sub.setStudentMiddleName(submitter.getMiddleName());
    if (isFieldEnabled(STUDENT_LAST_NAME))     sub.setStudentLastName(submitter.getLastName());
    if (isFieldEnabled(STUDENT_BIRTH_YEAR))     sub.setStudentBirthYear(submitter.getBirthYear());
    if (isFieldEnabled(PROGRAM))     sub.setProgram(submitter.getCurrentProgram());
    if (isFieldEnabled(COLLEGE))     sub.setCollege(submitter.getCurrentCollege());
    if (isFieldEnabled(DEPARTMENT))     sub.setDepartment(submitter.getCurrentDepartment());
    if (isFieldEnabled(DEGREE))     sub.setDegree(submitter.getCurrentDegree());
    if (isFieldEnabled(MAJOR))     sub.setMajor(submitter.getCurrentMajor());
    if (isFieldEnabled(STUDENT_ORCID))     sub.setOrcid(submitter.getOrcid());
    sub.save();
    subId=sub.getId();
    Logger.info("String_Node_Str",submitter.getFormattedName(NameFormat.FIRST_LAST),submitter.getId(),submitter.getEmail(),sub.getId());
    Map<String,Object> routeArgs=new HashMap<String,Object>();
    routeArgs.put("String_Node_Str",sub.getId());
    ActionDefinition newSub=Router.reverse("String_Node_Str",routeArgs);
    redirect(newSub.url);
  }
 else {
    sub=getSubmission();
  }
  String firstName=params.get("String_Node_Str");
  String middleName=params.get("String_Node_Str");
  String lastName=params.get("String_Node_Str");
  String orcid=params.get("String_Node_Str");
  String birthYear=params.get("String_Node_Str");
  String program=params.get("String_Node_Str");
  String college=params.get("String_Node_Str");
  String department=params.get("String_Node_Str");
  String degree=params.get("String_Node_Str");
  String major=params.get("String_Node_Str");
  String permPhone=params.get("String_Node_Str");
  String permAddress=params.get("String_Node_Str");
  String permEmail=params.get("String_Node_Str");
  String currentPhone=params.get("String_Node_Str");
  String currentAddress=params.get("String_Node_Str");
  List<String> disabledFields=new ArrayList<String>();
  if (isFieldGroupLocked("String_Node_Str")) {
    if (submitter.getFirstName() != null) {
      disabledFields.add("String_Node_Str");
      firstName=submitter.getFirstName();
    }
    if (submitter.getMiddleName() != null) {
      disabledFields.add("String_Node_Str");
      middleName=submitter.getMiddleName();
    }
    if (submitter.getLastName() != null) {
      disabledFields.add("String_Node_Str");
      lastName=submitter.getLastName();
    }
    if (sub.getOrcid() != null) {
      disabledFields.add("String_Node_Str");
      orcid=sub.getOrcid();
    }
    if (submitter.getBirthYear() != null) {
      if (submitter.getBirthYear() == null)       birthYear="String_Node_Str";
 else       birthYear=String.valueOf(submitter.getBirthYear());
      disabledFields.add("String_Node_Str");
    }
  }
  if (isFieldGroupLocked("String_Node_Str")) {
    if (isValidProgram(submitter.getCurrentProgram())) {
      disabledFields.add("String_Node_Str");
      program=submitter.getCurrentProgram();
    }
    if (isValidCollege(submitter.getCurrentCollege())) {
      disabledFields.add("String_Node_Str");
      college=submitter.getCurrentCollege();
    }
    if (isValidDepartment(submitter.getCurrentDepartment())) {
      disabledFields.add("String_Node_Str");
      department=submitter.getCurrentDepartment();
    }
    if (isValidDegree(submitter.getCurrentDegree())) {
      disabledFields.add("String_Node_Str");
      degree=submitter.getCurrentDegree();
    }
    if (isValidMajor(submitter.getCurrentMajor())) {
      disabledFields.add("String_Node_Str");
      major=submitter.getCurrentMajor();
    }
  }
  if (isFieldGroupLocked("String_Node_Str")) {
    if (submitter.getPermanentPhoneNumber() != null) {
      disabledFields.add("String_Node_Str");
      permPhone=submitter.getPermanentPhoneNumber();
    }
    if (submitter.getPermanentPostalAddress() != null) {
      disabledFields.add("String_Node_Str");
      permAddress=submitter.getPermanentEmailAddress();
    }
    if (submitter.getPermanentEmailAddress() != null) {
      try {
        new InternetAddress(submitter.getPermanentEmailAddress()).validate();
        disabledFields.add("String_Node_Str");
        permEmail=submitter.getPermanentEmailAddress();
      }
 catch (      AddressException ae) {
      }
    }
    if (submitter.getCurrentPhoneNumber() != null) {
      disabledFields.add("String_Node_Str");
      currentPhone=submitter.getCurrentPhoneNumber();
    }
    if (submitter.getCurrentPostalAddress() != null) {
      disabledFields.add("String_Node_Str");
      currentAddress=submitter.getCurrentPostalAddress();
    }
  }
  if ("String_Node_Str".equals(params.get("String_Node_Str"))) {
    if (isFieldEnabled(STUDENT_FIRST_NAME))     sub.setStudentFirstName(firstName);
    if (isFieldEnabled(STUDENT_MIDDLE_NAME))     sub.setStudentMiddleName(middleName);
    if (isFieldEnabled(STUDENT_LAST_NAME))     sub.setStudentLastName(lastName);
    if (isFieldEnabled(STUDENT_ORCID))     sub.setOrcid(orcid);
    if (isFieldEnabled(STUDENT_BIRTH_YEAR)) {
      if (birthYear != null && birthYear.trim().length() > 0) {
        try {
          sub.setStudentBirthYear(Integer.valueOf(birthYear));
        }
 catch (        NumberFormatException ex) {
          sub.setStudentBirthYear(null);
        }
      }
 else {
        sub.setStudentBirthYear(null);
      }
    }
    if (isFieldEnabled(PROGRAM)) {
      if (program != null && program.trim().length() == 0)       sub.setProgram(null);
 else       sub.setProgram(program);
    }
    if (isFieldEnabled(COLLEGE)) {
      if (college != null && college.trim().length() == 0)       sub.setCollege(null);
 else       sub.setCollege(college);
    }
    if (isFieldEnabled(DEPARTMENT)) {
      if (department != null && department.trim().length() == 0)       sub.setDepartment(null);
 else       sub.setDepartment(department);
    }
    if (isFieldEnabled(DEGREE)) {
      if (degree != null && degree.trim().length() == 0)       sub.setDegree(null);
 else       sub.setDegree(degree);
      if (settingRepo.findDegreeByName(degree) != null)       sub.setDegreeLevel(settingRepo.findDegreeByName(degree).getLevel());
    }
    if (isFieldEnabled(MAJOR)) {
      if (major != null && major.trim().length() == 0)       sub.setMajor(null);
 else       sub.setMajor(major);
    }
    if (isFieldEnabled(PERMANENT_PHONE_NUMBER))     submitter.setPermanentPhoneNumber(permPhone);
    if (isFieldEnabled(PERMANENT_POSTAL_ADDRESS))     submitter.setPermanentPostalAddress(permAddress);
    if (isFieldEnabled(PERMANENT_EMAIL_ADDRESS))     submitter.setPermanentEmailAddress(permEmail);
    if (isFieldEnabled(CURRENT_PHONE_NUMBER))     submitter.setCurrentPhoneNumber(currentPhone);
    if (isFieldEnabled(CURRENT_POSTAL_ADDRESS))     submitter.setCurrentPostalAddress(currentAddress);
    try {
      sub.save();
      submitter.save();
    }
 catch (    RuntimeException re) {
      validation.addError("String_Node_Str",re.getMessage());
    }
  }
  if ("String_Node_Str".equals(params.get("String_Node_Str")) || "String_Node_Str".equals(flash.get("String_Node_Str"))) {
    verify(sub);
  }
  if (params.get("String_Node_Str") != null && !validation.hasErrors()) {
    License.license(sub.getId());
  }
  if (params.get("String_Node_Str") == null) {
    firstName=sub.getStudentFirstName();
    middleName=sub.getStudentMiddleName();
    lastName=sub.getStudentLastName();
    orcid=sub.getOrcid();
    birthYear=sub.getStudentBirthYear() != null ? String.valueOf(sub.getStudentBirthYear()) : null;
    program=sub.getProgram();
    college=sub.getCollege();
    department=sub.getDepartment();
    degree=sub.getDegree();
    major=sub.getMajor();
    permPhone=submitter.getPermanentPhoneNumber();
    permAddress=submitter.getPermanentPostalAddress();
    permEmail=submitter.getPermanentEmailAddress();
    currentPhone=submitter.getCurrentPhoneNumber();
    currentAddress=submitter.getCurrentPostalAddress();
    orcid=submitter.getOrcid();
  }
  List<String> stickies=new ArrayList<String>();
  String stickiesRaw=settingRepo.getConfigValue(SUBMIT_PERSONAL_INFO_STICKIES);
  if (stickiesRaw != null && !"String_Node_Str".equals(stickiesRaw)) {
    try {
      CSVReader reader=new CSVReader(new StringReader(stickiesRaw));
      stickies=Arrays.asList(reader.readNext());
      reader.close();
    }
 catch (    IOException ioe) {
      throw new RuntimeException(ioe);
    }
  }
  String grantor=settingRepo.getConfigValue(AppConfig.GRANTOR,"String_Node_Str");
  List<Submission> submissions=subRepo.findSubmission(submitter);
class DegMaj {
    public String degree;
    public String major;
    @Override public boolean equals(    Object obj){
      if (obj instanceof DegMaj) {
        DegMaj myObj=(DegMaj)obj;
        if (this.degree != null && this.degree.equals(myObj.degree) && this.major != null && this.major.equals(myObj.major)) {
          return true;
        }
 else         if (this.degree == myObj.degree && this.major == myObj.major) {
          return true;
        }
      }
      return false;
    }
  }
  List<DegMaj> disabledDegMaj=new ArrayList<DegMaj>();
  for (  Submission submission : submissions) {
    DegMaj temp=new DegMaj();
    temp.degree=submission.getDegree();
    temp.major=submission.getMajor();
    if (!disabledDegMaj.contains(temp) && (sub.getDegree() != null && sub.getMajor() != null) && !(sub.getDegree().equals(temp.degree) && sub.getMajor().equals(temp.major))) {
      disabledDegMaj.add(temp);
    }
 else     if (!disabledDegMaj.contains(temp) && (sub.getDegree() == null || sub.getMajor() == null)) {
      disabledDegMaj.add(temp);
    }
  }
  renderTemplate("String_Node_Str",submitter,subId,disabledFields,stickies,disabledDegMaj,firstName,middleName,lastName,orcid,birthYear,grantor,program,college,department,degree,major,permPhone,permAddress,permEmail,currentPhone,currentAddress);
}

Fixed version (ground truth):
/** 
 * The first screen of the submission process which allows the student to supply their identity, affiliation, and contact information. We default the data displayed to information from the submitter's person object if available. After successfully completing this step a new submission is persisted in the database and the user is sent on to the license step.
 * @param subId The id of the submission being edited. This may be null for this step, all other steps this id is required.
 */
@Security(RoleType.STUDENT) public static void personalInfo(Long subId){
  if (params.get("String_Node_Str") != null)   Application.index();
  Person submitter=context.getPerson();
  Submission sub;
  if (subId == null) {
    SubmissionStatus subStatus=new SubmissionStatus();
    if (!subStatus.getAllowMultiple() && subStatus.getHasSubmissions()) {
      error("String_Node_Str");
    }
    sub=subRepo.createSubmission(submitter);
    if (isFieldEnabled(STUDENT_FIRST_NAME))     sub.setStudentFirstName(submitter.getFirstName());
    if (isFieldEnabled(STUDENT_MIDDLE_NAME))     sub.setStudentMiddleName(submitter.getMiddleName());
    if (isFieldEnabled(STUDENT_LAST_NAME))     sub.setStudentLastName(submitter.getLastName());
    if (isFieldEnabled(STUDENT_BIRTH_YEAR))     sub.setStudentBirthYear(submitter.getBirthYear());
    if (isFieldEnabled(PROGRAM))     sub.setProgram(submitter.getCurrentProgram());
    if (isFieldEnabled(COLLEGE))     sub.setCollege(submitter.getCurrentCollege());
    if (isFieldEnabled(DEPARTMENT))     sub.setDepartment(submitter.getCurrentDepartment());
    if (isFieldEnabled(DEGREE))     sub.setDegree(submitter.getCurrentDegree());
    if (isFieldEnabled(MAJOR))     sub.setMajor(submitter.getCurrentMajor());
    if (isFieldEnabled(STUDENT_ORCID))     sub.setOrcid(submitter.getOrcid());
    sub.save();
    subId=sub.getId();
    Logger.info("String_Node_Str",submitter.getFormattedName(NameFormat.FIRST_LAST),submitter.getId(),submitter.getEmail(),sub.getId());
    Map<String,Object> routeArgs=new HashMap<String,Object>();
    routeArgs.put("String_Node_Str",sub.getId());
    ActionDefinition newSub=Router.reverse("String_Node_Str",routeArgs);
    redirect(newSub.url);
  }
 else {
    sub=getSubmission();
  }
  String firstName=params.get("String_Node_Str");
  String middleName=params.get("String_Node_Str");
  String lastName=params.get("String_Node_Str");
  String orcid=params.get("String_Node_Str");
  String birthYear=params.get("String_Node_Str");
  String program=params.get("String_Node_Str");
  String college=params.get("String_Node_Str");
  String department=params.get("String_Node_Str");
  String degree=params.get("String_Node_Str");
  String major=params.get("String_Node_Str");
  String permPhone=params.get("String_Node_Str");
  String permAddress=params.get("String_Node_Str");
  String permEmail=params.get("String_Node_Str");
  String currentPhone=params.get("String_Node_Str");
  String currentAddress=params.get("String_Node_Str");
  List<String> disabledFields=new ArrayList<String>();
  if (isFieldGroupLocked("String_Node_Str")) {
    if (submitter.getFirstName() != null) {
      disabledFields.add("String_Node_Str");
      firstName=submitter.getFirstName();
    }
    if (submitter.getMiddleName() != null) {
      disabledFields.add("String_Node_Str");
      middleName=submitter.getMiddleName();
    }
    if (submitter.getLastName() != null) {
      disabledFields.add("String_Node_Str");
      lastName=submitter.getLastName();
    }
    if (sub.getOrcid() != null || submitter.getOrcid() != null) {
      disabledFields.add("String_Node_Str");
      orcid=(sub.getOrcid() != null ? sub.getOrcid() : submitter.getOrcid());
    }
    if (submitter.getBirthYear() != null) {
      if (submitter.getBirthYear() == null)       birthYear="String_Node_Str";
 else       birthYear=String.valueOf(submitter.getBirthYear());
      disabledFields.add("String_Node_Str");
    }
  }
  if (isFieldGroupLocked("String_Node_Str")) {
    if (isValidProgram(submitter.getCurrentProgram())) {
      disabledFields.add("String_Node_Str");
      program=submitter.getCurrentProgram();
    }
    if (isValidCollege(submitter.getCurrentCollege())) {
      disabledFields.add("String_Node_Str");
      college=submitter.getCurrentCollege();
    }
    if (isValidDepartment(submitter.getCurrentDepartment())) {
      disabledFields.add("String_Node_Str");
      department=submitter.getCurrentDepartment();
    }
    if (isValidDegree(submitter.getCurrentDegree())) {
      disabledFields.add("String_Node_Str");
      degree=submitter.getCurrentDegree();
    }
    if (isValidMajor(submitter.getCurrentMajor())) {
      disabledFields.add("String_Node_Str");
      major=submitter.getCurrentMajor();
    }
  }
  if (isFieldGroupLocked("String_Node_Str")) {
    if (submitter.getPermanentPhoneNumber() != null) {
      disabledFields.add("String_Node_Str");
      permPhone=submitter.getPermanentPhoneNumber();
    }
    if (submitter.getPermanentPostalAddress() != null) {
      disabledFields.add("String_Node_Str");
      permAddress=submitter.getPermanentEmailAddress();
    }
    if (submitter.getPermanentEmailAddress() != null) {
      try {
        new InternetAddress(submitter.getPermanentEmailAddress()).validate();
        disabledFields.add("String_Node_Str");
        permEmail=submitter.getPermanentEmailAddress();
      }
 catch (      AddressException ae) {
      }
    }
    if (submitter.getCurrentPhoneNumber() != null) {
      disabledFields.add("String_Node_Str");
      currentPhone=submitter.getCurrentPhoneNumber();
    }
    if (submitter.getCurrentPostalAddress() != null) {
      disabledFields.add("String_Node_Str");
      currentAddress=submitter.getCurrentPostalAddress();
    }
  }
  if ("String_Node_Str".equals(params.get("String_Node_Str"))) {
    if (isFieldEnabled(STUDENT_FIRST_NAME))     sub.setStudentFirstName(firstName);
    if (isFieldEnabled(STUDENT_MIDDLE_NAME))     sub.setStudentMiddleName(middleName);
    if (isFieldEnabled(STUDENT_LAST_NAME))     sub.setStudentLastName(lastName);
    if (isFieldEnabled(STUDENT_ORCID)) {
      boolean orcidVerify=true;
      if (settingRepo.getConfigBoolean(AppConfig.ORCID_VALIDATION)) {
        if (settingRepo.getConfigBoolean(AppConfig.ORCID_AUTHENTICATION))         orcidVerify=Utilities.verifyOrcid(orcid,sub.getStudentFirstName(),sub.getStudentLastName());
 else         orcidVerify=Utilities.verifyOrcid(orcid);
      }
      if (!orcidVerify) {
        validation.addError("String_Node_Str","String_Node_Str");
      }
 else {
        sub.setOrcid(orcid);
        submitter.setOrcid(orcid);
      }
    }
    if (isFieldEnabled(STUDENT_BIRTH_YEAR)) {
      if (birthYear != null && birthYear.trim().length() > 0) {
        try {
          sub.setStudentBirthYear(Integer.valueOf(birthYear));
        }
 catch (        NumberFormatException ex) {
          sub.setStudentBirthYear(null);
        }
      }
 else {
        sub.setStudentBirthYear(null);
      }
    }
    if (isFieldEnabled(PROGRAM)) {
      if (program != null && program.trim().length() == 0)       sub.setProgram(null);
 else       sub.setProgram(program);
    }
    if (isFieldEnabled(COLLEGE)) {
      if (college != null && college.trim().length() == 0)       sub.setCollege(null);
 else       sub.setCollege(college);
    }
    if (isFieldEnabled(DEPARTMENT)) {
      if (department != null && department.trim().length() == 0)       sub.setDepartment(null);
 else       sub.setDepartment(department);
    }
    if (isFieldEnabled(DEGREE)) {
      if (degree != null && degree.trim().length() == 0)       sub.setDegree(null);
 else       sub.setDegree(degree);
      if (settingRepo.findDegreeByName(degree) != null)       sub.setDegreeLevel(settingRepo.findDegreeByName(degree).getLevel());
    }
    if (isFieldEnabled(MAJOR)) {
      if (major != null && major.trim().length() == 0)       sub.setMajor(null);
 else       sub.setMajor(major);
    }
    if (isFieldEnabled(PERMANENT_PHONE_NUMBER))     submitter.setPermanentPhoneNumber(permPhone);
    if (isFieldEnabled(PERMANENT_POSTAL_ADDRESS))     submitter.setPermanentPostalAddress(permAddress);
    if (isFieldEnabled(PERMANENT_EMAIL_ADDRESS))     submitter.setPermanentEmailAddress(permEmail);
    if (isFieldEnabled(CURRENT_PHONE_NUMBER))     submitter.setCurrentPhoneNumber(currentPhone);
    if (isFieldEnabled(CURRENT_POSTAL_ADDRESS))     submitter.setCurrentPostalAddress(currentAddress);
    try {
      sub.save();
      submitter.save();
    }
 catch (    RuntimeException re) {
      validation.addError("String_Node_Str",re.getMessage());
    }
  }
  if ("String_Node_Str".equals(params.get("String_Node_Str")) || "String_Node_Str".equals(flash.get("String_Node_Str"))) {
    verify(sub);
  }
  if (params.get("String_Node_Str") != null && !validation.hasErrors()) {
    License.license(sub.getId());
  }
  if (params.get("String_Node_Str") == null) {
    firstName=sub.getStudentFirstName();
    middleName=sub.getStudentMiddleName();
    lastName=sub.getStudentLastName();
    orcid=sub.getOrcid();
    birthYear=sub.getStudentBirthYear() != null ? String.valueOf(sub.getStudentBirthYear()) : null;
    program=sub.getProgram();
    college=sub.getCollege();
    department=sub.getDepartment();
    degree=sub.getDegree();
    major=sub.getMajor();
    permPhone=submitter.getPermanentPhoneNumber();
    permAddress=submitter.getPermanentPostalAddress();
    permEmail=submitter.getPermanentEmailAddress();
    currentPhone=submitter.getCurrentPhoneNumber();
    currentAddress=submitter.getCurrentPostalAddress();
    orcid=submitter.getOrcid();
  }
  List<String> stickies=new ArrayList<String>();
  String stickiesRaw=settingRepo.getConfigValue(SUBMIT_PERSONAL_INFO_STICKIES);
  if (stickiesRaw != null && !"String_Node_Str".equals(stickiesRaw)) {
    try {
      CSVReader reader=new CSVReader(new StringReader(stickiesRaw));
      stickies=Arrays.asList(reader.readNext());
      reader.close();
    }
 catch (    IOException ioe) {
      throw new RuntimeException(ioe);
    }
  }
  String grantor=settingRepo.getConfigValue(AppConfig.GRANTOR,"String_Node_Str");
  List<Submission> submissions=subRepo.findSubmission(submitter);
class DegMaj {
    public String degree;
    public String major;
    @Override public boolean equals(    Object obj){
      if (obj instanceof DegMaj) {
        DegMaj myObj=(DegMaj)obj;
        if (this.degree != null && this.degree.equals(myObj.degree) && this.major != null && this.major.equals(myObj.major)) {
          return true;
        }
 else         if (this.degree == myObj.degree && this.major == myObj.major) {
          return true;
        }
      }
      return false;
    }
  }
  List<DegMaj> disabledDegMaj=new ArrayList<DegMaj>();
  for (  Submission submission : submissions) {
    DegMaj temp=new DegMaj();
    temp.degree=submission.getDegree();
    temp.major=submission.getMajor();
    if (!disabledDegMaj.contains(temp) && (sub.getDegree() != null && sub.getMajor() != null) && !(sub.getDegree().equals(temp.degree) && sub.getMajor().equals(temp.major))) {
      disabledDegMaj.add(temp);
    }
 else     if (!disabledDegMaj.contains(temp) && (sub.getDegree() == null || sub.getMajor() == null)) {
      disabledDegMaj.add(temp);
    }
  }
  renderTemplate("String_Node_Str",submitter,subId,disabledFields,stickies,disabledDegMaj,firstName,middleName,lastName,orcid,birthYear,grantor,program,college,department,degree,major,permPhone,permAddress,permEmail,currentPhone,currentAddress);
}