Ejemplo n.º 1
0
  // 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;
    }
  }
Ejemplo n.º 2
0
  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;
    }
  }