private Map<String, Object> checkRoadAudit(Student student) { log.debug("checkRoadAudit"); Map<String, Object> hm = null; if (student.getRoadTestCompletionDate() != null) { if (student.getRoadCompletionSchoolNumber() != null) { hm = new HashMap<String, Object>(); // if the school is is 1-499 or 6001-6500 its a dl employee. so won't have a score // but dont care cause its not going to be viewed by users. hm.put("studentFk", student.getStudentPk()); hm.put("completionDate", student.getRoadTestCompletionDate()); int fk = student.getRoadCompletionSchoolNumber().intValue(); // the values of dl employees if ((fk >= 1 && fk <= 499) || (fk >= 6001 && fk <= 6500)) { hm.put("schoolNumber", new Integer(0)); } else { hm.put("schoolNumber", student.getRoadCompletionSchoolNumber()); } if (student.getRoadTestScore() != null) { hm.put("roadScore", student.getRoadTestScore()); } if (student.getRoadTestInstructorFk() != null) { hm.put("roadInstructorFk", student.getRoadTestInstructorFk()); } } } return hm; }
public String mergeFileNumber() throws Exception { log.debug("******* mergeFileNumber " + getFileNumber() + " " + getStudentNumber()); QueryByDLResponseType wsResponse = getQueryByDl(); if (wsResponse != null) { if ("200".equals(wsResponse.getStatus())) { Student webStudent = parseQueryByDlResults(wsResponse, true); int i = getStudentService().fullUpdate(webStudent); setCurrentStudent(webStudent); setStudentPk(webStudent.getStudentPk()); } } return SUCCESS; }
private Map<String, Object> checkObservationAudit(Student student) { Map<String, Object> hm = null; if (student.getObservationCompletionDate() != null) { if (student.getObservationCompletionSchoolNumber() != null) { hm = new HashMap<String, Object>(); hm.put("studentFk", student.getStudentPk()); hm.put("schoolNumber", student.getObservationCompletionSchoolNumber()); hm.put("completionDate", student.getObservationCompletionDate()); hm.put("completionType", Constants.CompletionType_Observation); } } return hm; }
private Map<String, Object> checkClassroomAudit(Student student) { Map<String, Object> hm = null; if (student.getClassroomCompletionDate() != null) { if (student.getClassroomCompletionSchoolNumber() != null) { hm = new HashMap<String, Object>(); hm.put("studentFk", student.getStudentPk()); hm.put("schoolNumber", student.getClassroomCompletionSchoolNumber()); hm.put("completionDate", student.getClassroomCompletionDate()); hm.put("completionType", Constants.CompletionType_ClassroomTraining); } } return hm; }
private Map<String, Object> checkBtwAudit(Student student) { Map<String, Object> hm = null; if (student.getBehindWheelCompletionDate() != null) { if (student.getBtwCompletionSchoolNumber() != null) { hm = new HashMap<String, Object>(); hm.put("studentFk", student.getStudentPk()); hm.put("schoolNumber", student.getBtwCompletionSchoolNumber()); hm.put("completionDate", student.getBehindWheelCompletionDate()); hm.put("completionType", Constants.CompletionType_BehindTheWheel); } } return hm; }
public Map<String, Object> checkWrittenAudit(Student student) { Map<String, Object> hm = null; if (student.getWrittenTestCompletionDate() != null) { if (student.getWrittenCompletionSchoolNumber() != null) { hm = new HashMap<String, Object>(); hm.put("studentFk", student.getStudentPk()); hm.put("completionDate", student.getWrittenTestCompletionDate()); int fk = student.getWrittenCompletionSchoolNumber().intValue(); // the values of dl employees if ((fk >= 1 && fk <= 499) || (fk >= 6001 && fk <= 6500)) { hm.put("writtenScore", new Integer(101)); hm.put("schoolNumber", new Integer(0)); } else { if (student.getWrittenTestScore() != null) { hm.put("writtenScore", student.getWrittenTestScore()); } else { hm.put("writtenScore", new Integer(0)); } hm.put("schoolNumber", student.getWrittenCompletionSchoolNumber()); } } } return hm; }
private Student getDbStudent(Student st, Date webDob) throws Exception { Student retObj = null; List list = getStudentService().getStudentList(st); for (int i = 0; i < list.size(); i++) { Student dbStudent = (Student) list.get(i); log.debug("webdob = " + webDob + " dob = " + dbStudent.getDob()); if (webDob != null) { if (webDob.equals(dbStudent.getDob())) { retObj = dbStudent; break; } } } return retObj; }
public void webserviceUpdate() throws Exception { log.debug(">>> START webserviceUpdate..."); setFileNumber(getCurrentStudent().getFileNumber()); QueryByDLResponseType wsResponse = getQueryByDl(); Student student = parseQueryByDlResults(wsResponse); log.debug(""); if (student != null) { // redmine 28996 if (student.getStudentNumber() != null) { setStudentNumber(student.getStudentNumber()); } // fullUpdate sends nulls student.setAlmLog("No"); int i = getStudentService().fullUpdate(student); if (student.getStudentNumber() == null) { student.setStudentNumber(getStudentNumber()); } // AUDIT checkAuditDates(student); setCurrentStudent(student); setStudentPk(student.getStudentPk()); } else { log.debug("webserviceUpdate failed"); } }
private void setSchoolClassroom(List students) throws Exception { for (int i = 0; i < students.size(); i++) { Student student = (Student) students.get(i); HashMap hm = new HashMap(); hm.put("studentPk", student.getStudentPk()); List classroomList = getClassroomService().getSchoolInfoByStudent(hm); if (!classroomList.isEmpty()) { Classroom c = (Classroom) classroomList.get(0); student.setClassroomFk(c.getClassroomPk()); hm.put("studentFk", getCurrentStudent().getStudentPk()); hm.put("classroomPk", c.getClassroomPk()); Classroom school = getClassroomService().getSchoolInfo(hm); student.setSchoolName(school.getSchoolName()); } } }
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; }
public String dobSearch() throws Exception { log.debug("...Commercial dobSearch"); boolean studentExists = false; HashMap hm = new HashMap(); // Redmine 9505 commercial hm.put("firstName", "%" + getCurrentStudent().getFirstName() + "%"); hm.put("lastName", "%" + getCurrentStudent().getLastName() + "%"); hm.put("dob", getCurrentStudent().getDob()); if (getCurrentStudent().getSchoolFk() != null) { hm.put("schoolFk", getCurrentStudent().getSchoolFk()); List classroomList = getClassroomService().getClassroomList(hm); if (!classroomList.isEmpty()) { log.debug("...classroomlist size = " + classroomList.size()); for (int i = 0; i < classroomList.size(); i++) { Classroom c = (Classroom) classroomList.get(i); hm.put("classroomFk", c.getClassroomPk()); List studentList = getStudentService().getCommercialStudentList(hm); if (!studentList.isEmpty()) { Student s = (Student) studentList.get(0); studentExists = true; setCurrentStudent(s); setStudentPk(s.getStudentPk()); break; } } } } else { List list = getStudentService().getStudentList(hm); log.debug("...list size = " + list.size()); if (!list.isEmpty()) { studentExists = true; if (list.size() == 1) { setCurrentStudent((Student) list.get(0)); setStudentPk(getCurrentStudent().getStudentPk()); } else { // multiple result - redmine 9505 commercial // set school name and classroomFk in list setSchoolClassroom(list); setStudentListSearchResult(list); return "multipleResult"; } } } if (studentExists) { hm.put("studentPk", getStudentPk()); List classroomList = getClassroomService().getSchoolInfoByStudent(hm); if (!classroomList.isEmpty()) { Classroom c = (Classroom) classroomList.get(0); setClassroomPk(c.getClassroomPk()); } return SUCCESS; } else { addActionError("Student Not Found"); Collection errList = getActionErrors(); setCommercialAjaxMessages(errList); return "input"; } }
public String fileNumberSearch() throws Exception { log.debug("******* commercial fileNumberSearch " + getFileNumber()); boolean studentExists = false; boolean studentExistsInDl = false; boolean noErrors = true; Map hm = new HashMap(); hm.put("fileNumber", getFileNumber()); if (getSchoolPk() != null) { hm.put("schoolFk", getSchoolPk()); List classroomList = getClassroomService().getClassroomList(hm); if (!classroomList.isEmpty()) { log.debug("...classroomlist size = " + classroomList.size()); for (int i = 0; i < classroomList.size(); i++) { Classroom c = (Classroom) classroomList.get(i); hm.put("classroomFk", c.getClassroomPk()); List studentList = getStudentService().getCommercialStudentList(hm); if (!studentList.isEmpty()) { Student s = (Student) studentList.get(0); studentExists = true; break; } } } } if (studentExists) { QueryByDLResponseType wsResponse = getQueryByDl(); if (wsResponse != null) { Student student = parseQueryByDlResults(wsResponse); if ("200".equals(wsResponse.getStatus())) { studentExistsInDl = true; setCurrentStudent(student); setStudentPk(student.getStudentPk()); } } else { noErrors = false; addActionError("Web service response was empty."); log.debug("Webservice RESULTS EMPTY"); } } if (noErrors) { if (studentExistsInDl) { hm.put("studentPk", getStudentPk()); List classroomList = getClassroomService().getSchoolInfoByStudent(hm); if (!classroomList.isEmpty()) { Classroom c = (Classroom) classroomList.get(0); setClassroomPk(c.getClassroomPk()); } return SUCCESS; } else { addActionError("Student Not Found"); setCommercialAjaxMessages(getActionErrors()); return INPUT; } } else { Collection errList = getActionErrors(); setCommercialAjaxMessages(errList); return INPUT; } }
public String webSearch() throws Exception { log.debug("******* commercial webSearch " + getFileNumber()); boolean studentExists = false; int status = 0; boolean noErrors = true; Collection<String> col = new ArrayList<String>(); QueryByDLResponseType wsResponse = getQueryByDl(); if (wsResponse != null) { Student student = parseQueryByDlResults(wsResponse); if ("200".equals(wsResponse.getStatus())) { studentExists = true; if (student.getStudentPk() == null) { log.debug("Student Insert"); student.setStudentNumber(createStudentNumber(getClassroomPk())); int i = getStudentService().insert(student); student.setStudentPk(getSdcService().getLastInsertedId()); // AUDIT insertAuditDates(student); addRoster(student.getStudentPk(), getClassroomPk()); } else { // check if already on the roster boolean roster = checkRoster(student.getStudentPk(), getClassroomPk()); if (!roster) { addRoster(student.getStudentPk(), getClassroomPk()); if (student.getStudentNumber() == null) { log.debug("Student Number Insert"); student.setStudentNumber(createStudentNumber(getClassroomPk())); } } // fullUpdate sends nulls int i = getStudentService().fullUpdate(student); // AUDIT checkAuditDates(student); } setCurrentStudent(student); setStudentPk(student.getStudentPk()); } else { noErrors = false; if (status == 404) { col.add("File Number Not Found"); } } } else { noErrors = false; col.add("Web service response was empty."); log.debug("Webservice RESULTS EMPTY"); } if (noErrors) { if (studentExists) { return SUCCESS; } else { col = getActionErrors(); setCommercialAjaxMessages(col); return INPUT; } } else { if (col.isEmpty()) { col = getActionErrors(); } setCommercialAjaxMessages(col); return INPUT; } }
// This is a clone of the regular syncFileNumber that allows entry of // duplicate student records with the same fileNumber public String commercialSyncFileNumber() throws Exception { log.debug("******* commercialSyncFileNumber " + getFileNumber()); boolean noErrors = true; boolean studentMerged = false; boolean studentExists = false; boolean studentFound = false; int status = 0; Collection<String> col = new ArrayList<String>(); QueryByDLResponseType wsResponse = getQueryByDl(); if (wsResponse != null) { Student webStudent = parseQueryByDlResults(wsResponse); if ("200".equals(wsResponse.getStatus())) { studentExists = true; // This handles duplicate file numbers, By removing file number from existing record so that // it can be added if (webStudent.getFileNumber() != null) { log.debug("****** Existing FileNumber... preparing to remove"); Student a = new Student(); a.setFileNumber(webStudent.getFileNumber()); Student temp = getDbStudent(a); // Only remove if it is the same student otherwise this could be used to remove file // numbers from any existing record. if (temp != null) { log.debug("dbstudent " + temp.getDob() + " webstudent " + webStudent.getDob()); if (temp.getDob().equals(webStudent.getDob())) { log.debug( "dbstudent lastname " + temp.getLastName() + " webstudent " + webStudent.getLastName()); if (temp.getLastName().equalsIgnoreCase(webStudent.getLastName())) { temp.setFileNumber(null); int i = getStudentService().studentUpdateFileNumber(temp); if (i > 0) { log.debug("****** FileNumber removed from: " + temp.getStudentNumber()); } else { log.debug("****** FileNumber WAS NOT removed from: " + temp.getStudentNumber()); } } else { col.add( "Existing student using this filenumber: Last names do not match with DLD record."); noErrors = false; } } else { col.add( "Existing student using this filenumber: DOB does not match with DLD record."); noErrors = false; } } } if (noErrors) { log.debug("Student Insert"); if (getStudentNumber() != null) { Student a = new Student(); a.setStudentNumber(getStudentNumber()); // getDbStudent returns the sdc student with a matching dob. Student dbStudent = getDbStudent(a, webStudent.getDob()); if (dbStudent != null) { log.debug("dbstudent " + dbStudent.getDob() + " webstudent " + webStudent.getDob()); studentFound = true; log.debug( "db lastname " + dbStudent.getLastName() + " webstudent " + webStudent.getLastName()); if (dbStudent.getLastName().equals(webStudent.getLastName())) { log.debug( "db firstname " + dbStudent.getFirstName() + " webstudent " + webStudent.getFirstName()); if (dbStudent.getFirstName().equals(webStudent.getFirstName())) { studentMerged = true; // merge appropriate values webStudent.setStudentNumber(dbStudent.getStudentNumber()); webStudent.setStudentPk(dbStudent.getStudentPk()); webStudent.setSchoolFk(getSchoolPk()); // fullUpdate sends nulls int i = getStudentService().fullUpdate(webStudent); setCurrentStudent(webStudent); setStudentPk(webStudent.getStudentPk()); } else { col.add("First names do not match"); noErrors = false; } } else { col.add("Last names do not match"); noErrors = false; } if (!studentMerged) { List<String> web = new ArrayList<String>(); List<String> db = new ArrayList<String>(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); web.add(sdf.format(webStudent.getDob())); web.add(webStudent.getLastName()); web.add(webStudent.getFirstName()); setMergeWebStudent(web); db.add(sdf.format(dbStudent.getDob())); db.add(dbStudent.getLastName()); db.add(dbStudent.getFirstName()); setMergeDbStudent(db); } } else { // dob doesnt match. col.add("DOB does not match"); noErrors = false; } } } } else { col.add("Student Not Found in DLD(Webservice)"); noErrors = false; } if (!noErrors) { col.add("The File Number Entered Is Not Valid For This Student"); } } else { log.debug("Webservice RESULTS EMPTY"); noErrors = false; col.add("Web service response was empty."); } if (noErrors) { if (studentMerged) { return SUCCESS; } else if (studentFound) { return Constants.MERGE; } else { col = getActionErrors(); setCommercialAjaxMessages(col); // sendSyncErrorEmail((ArrayList) col, getStudentNumber(), getFileNumber()); return INPUT; } } else { if (col.isEmpty()) { col = getActionErrors(); } setCommercialAjaxMessages(col); return INPUT; } }
public String syncFileNumber() throws Exception { log.debug("******* syncFileNumber " + getFileNumber()); boolean studentMerged = false; boolean studentFound = false; QueryByDLResponseType wsResponse = getQueryByDl(); if (wsResponse != null) { Student webStudent = parseQueryByDlResults(wsResponse); if ("200".equals(wsResponse.getStatus())) { if (webStudent.getStudentPk() == null) { log.debug("Student Insert"); Student temp = new Student(); if (getStudentNumber() != null) { temp.setStudentNumber(getStudentNumber()); Student dbStudent = getStudentService().getStudent(temp); if (dbStudent.getDob().equals(webStudent.getDob())) { studentFound = true; if (dbStudent.getLastName().equals(webStudent.getLastName())) { if (dbStudent.getFirstName().equals(webStudent.getFirstName())) { studentMerged = true; // merge appropriate values webStudent.setStudentNumber(dbStudent.getStudentNumber()); webStudent.setStudentPk(dbStudent.getStudentPk()); webStudent.setSchoolFk(getSchoolPk()); // fullUpdate sends nulls int i = getStudentService().fullUpdate(webStudent); setCurrentStudent(webStudent); setStudentPk(webStudent.getStudentPk()); } } if (!studentMerged) { List<String> web = new ArrayList<String>(); List<String> db = new ArrayList<String>(); SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy"); web.add(sdf.format(webStudent.getDob())); web.add(webStudent.getLastName()); web.add(webStudent.getFirstName()); setMergeWebStudent(web); db.add(sdf.format(dbStudent.getDob())); db.add(dbStudent.getLastName()); db.add(dbStudent.getFirstName()); setMergeDbStudent(db); } } else { // dob doesnt match. addActionError("File Number cannot sync. Student dob does not match."); } } } else { // filenumber already in database. String note = null; if (webStudent.getStudentNumber() != null) { note = webStudent.getStudentNumber().toString(); } else { note = webStudent.getStudentFullName(); } addActionError( "File Number already associated with a student " + note + ", please contact SDC administration for assistance."); } } } else { addActionError("Web service response was empty."); log.debug("Webservice RESULTS EMPTY"); } if (studentMerged) { log.debug("SUCCESS"); return SUCCESS; } else if (studentFound) { log.debug("MERGE"); return Constants.MERGE; } else { log.debug("INPUT"); Collection list = getActionErrors(); setCommercialAjaxMessages(list); sendSyncErrorEmail((ArrayList) list, getStudentNumber(), getFileNumber()); return INPUT; } }
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; }