Exemplo n.º 1
0
 private Student setAllSchoolNumbers(Student student) throws DaoException {
   if (student.getSchoolFk() != null) {
     String number = getSchoolNumber(student.getSchoolFk());
     Integer schoolNumber = Integer.valueOf(number);
     log.debug("allSchoolNumbers schoolNumber is " + schoolNumber);
     if (student.getBtwCompletionSchoolNumber() == null) {
       student.setBtwCompletionSchoolNumber(schoolNumber);
     }
     if (student.getClassroomCompletionSchoolNumber() == null) {
       student.setClassroomCompletionSchoolNumber(schoolNumber);
     }
     if (student.getObservationCompletionSchoolNumber() == null) {
       student.setObservationCompletionSchoolNumber(schoolNumber);
     }
     if (student.getRoadCompletionSchoolNumber() == null) {
       student.setRoadCompletionSchoolNumber(schoolNumber);
     }
     if (student.getWrittenCompletionSchoolNumber() == null) {
       student.setWrittenCompletionSchoolNumber(schoolNumber);
     }
   }
   return student;
 }
  private Student parseQueryByDlResults(
      QueryByDLResponseType wsResponse, boolean lookupByStudentNumber) throws Exception {
    log.debug("LOOKUP BY STUDENT NUMBER " + lookupByStudentNumber);
    boolean studentInsert = false;
    Student temp = new Student();
    if (lookupByStudentNumber) {
      temp.setStudentNumber(getStudentNumber());
    } else if (getFileNumber() != null && getFileNumber().length() > 1) {
      temp.setFileNumber(getFileNumber());
    } else {
      temp.setStudentPk(getStudentPk()); // required for multiple student records
    }

    if ("200".equals(wsResponse.getStatus())) {
      try {
        log.debug("Status 200");
        Student student = getStudentService().getStudent(temp);

        if (student.getStudentPk() == null) {
          studentInsert = true;
        }

        student.setDob(wsResponse.getSubject().getBirthDate());
        student.setFirstName(wsResponse.getSubject().getGivenName());
        student.setMiddleName(wsResponse.getSubject().getMiddleName());
        student.setLastName(wsResponse.getSubject().getSurName());

        if (wsResponse.getStudentDriverCertificate() != null) {
          if (wsResponse.getStudentDriverCertificate().getClassroomCompletionDate() != null) {
            student.setClassroomCompletionDate(
                wsResponse.getStudentDriverCertificate().getClassroomCompletionDate());
          }
          if (wsResponse.getStudentDriverCertificate().getClassroomSchoolId() != null) {
            student.setClassroomCompletionSchoolNumber(
                blankInteger(wsResponse.getStudentDriverCertificate().getClassroomSchoolId()));
          }

          if (wsResponse.getStudentDriverCertificate().getObservationCompletionDate() != null) {
            student.setObservationCompletionDate(
                wsResponse.getStudentDriverCertificate().getObservationCompletionDate());
          }
          if (wsResponse.getStudentDriverCertificate().getObservationSchoolId() != null) {
            student.setObservationCompletionSchoolNumber(
                blankInteger(wsResponse.getStudentDriverCertificate().getObservationSchoolId()));
          }

          if (wsResponse.getStudentDriverCertificate().getWheelCompletionDate() != null) {
            student.setBehindWheelCompletionDate(
                wsResponse.getStudentDriverCertificate().getWheelCompletionDate());
          }
          if (wsResponse.getStudentDriverCertificate().getWheelSchoolId() != null) {
            student.setBtwCompletionSchoolNumber(
                blankInteger(wsResponse.getStudentDriverCertificate().getWheelSchoolId()));
          }

          if (wsResponse.getStudentDriverCertificate().getWrittenExamCompletionDateTime() != null) {
            student.setWrittenTestCompletionDate(
                wsResponse
                    .getStudentDriverCertificate()
                    .getWrittenExamCompletionDateTime()
                    .getTime());
          }
          if (wsResponse.getStudentDriverCertificate().getWrittenExamSchoolId() != null) {
            student.setWrittenCompletionSchoolNumber(
                blankInteger(
                    wsResponse.getStudentDriverCertificate().getWrittenExamSchoolId().trim()));
          }

          if (wsResponse.getStudentDriverCertificate().getRoadTestCompletionDateTime() != null) {
            student.setRoadTestCompletionDate(
                wsResponse.getStudentDriverCertificate().getRoadTestCompletionDateTime().getTime());
          }
          if (wsResponse.getStudentDriverCertificate().getRoadTestSchoolId() != null) {
            student.setRoadCompletionSchoolNumber(
                blankInteger(wsResponse.getStudentDriverCertificate().getRoadTestSchoolId()));
          }

          if (wsResponse.getStudentDriverCertificate().getEligibilityDate() != null) {
            student.setEligibilityDate(
                wsResponse.getStudentDriverCertificate().getEligibilityDate());
          }

          if (wsResponse.getDriverLicense().getLicenseCategoryCode() != null) {
            student.setLicenseType(
                wsResponse.getDriverLicense().getLicenseCategoryCode().getValue());
          }

          student.setFileNumber(getFileNumber());
          Person loggedInPerson = (Person) getSession().get(Constants.USER_KEY);
          student.setUpdatedBy(loggedInPerson.getEmail());
        }

        log.debug("#################### returning student");
        return student;
      } catch (DaoException de) {
        log.error("DAO ", de);
        throw new Exception(de);
      }
    } else {
      addActionError("Status " + wsResponse.getStatus() + " " + wsResponse.getStatusDescription());
    }

    log.debug("#################### returning blank student");
    return null;
  }