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());
      }
    }
  }
  public void setClassroomInfo() throws Exception {
    log.debug("setClassroomInfo");
    if (getCurrentStudent() != null) {
      Map<String, Object> hm = new HashMap<String, Object>();
      hm.put("studentFk", getCurrentStudent().getStudentPk());
      hm.put("classroomPk", getClassroomPk());
      Classroom school = getClassroomService().getSchoolInfo(hm);
      setSchoolName(school.getSchoolName());
      setHomeStudy(school.getHomeStudy());
      setSchoolPk(school.getSchoolFk());

      // setCompletionDate();
      setObservationCompletionDate(getCurrentStudent().getObservationCompletionDate());
      setBtwCompletionDate(getCurrentStudent().getBehindWheelCompletionDate());
      setTrainingCompletionDate(getCurrentStudent().getClassroomCompletionDate());
    } else {
      log.error("################# setClassroomInfo ERROR");
    }
  }
  public String studentNumberSearch() throws Exception {
    log.debug("...Commercial studentNumberSearch");
    boolean studentExists = false;
    boolean studentClassesExist = false;
    boolean noClassroom = true;
    Map<String, Object> hm = new HashMap<String, Object>();
    hm.put("studentNumber", getStudentNumber());

    List list = getStudentService().getStudentList(hm);
    if (!list.isEmpty()) {
      studentExists = true;
      setCurrentStudent((Student) list.get(0));
      setStudentPk(getCurrentStudent().getStudentPk());

      if (studentExists) {
        hm.put("studentPk", getStudentPk());
        List classroomList = getClassroomService().getSchoolInfoByStudent(hm);
        if (!classroomList.isEmpty()) {
          if (classroomList.size() > 1) {
            // means student is in multiple classrooms
            studentClassesExist = true;
          }
          noClassroom = false;
          Classroom c = (Classroom) classroomList.get(0);
          setClassroomPk(c.getClassroomPk());
          ArrayList<Object> multipleList = new ArrayList<Object>();
          for (int i = 0; i < classroomList.size(); i++) {
            Classroom temp = (Classroom) classroomList.get(i);
            multipleList.add(temp.getClassroomPk());
          }
          setMultipleClassroomList(multipleList);
        }

        if (noClassroom && !studentClassesExist) {
          // this would happen if a student was removed from a classroom;
          // 1.9.0 fix added here.  Ok to add student to classroom.
          log.debug("Student exists but is not associated with a classroom");
          if (getClassroomPk() != null && getClassroomPk().intValue() != 0) {
            hm.clear();
            hm.put("studentFk", getStudentPk());
            // log.debug("."+getClassroomPk()+".");
            hm.put("classroomFk", getClassroomPk());
            int retval = getClassroomService().addStudent(hm);
            if (retval > 0) {
              noClassroom = false;
            }
          }
        }
      }
    }

    if (studentClassesExist) {
      // Should be sent to a separate page which displays all classrooms
      // the student has been assigned to.
      return Constants.Forward_MultipleClasses;
    } else if (noClassroom && studentExists) {
      // should be sent to a separate page which finds all the
      // records regardless of classroom.
      return Constants.Forward_NoClassStudent;
    } else if (studentExists) {
      return SUCCESS;
    } else {
      addActionError("Student Not Found");
      Collection errList = getActionErrors();
      setCommercialAjaxMessages(errList);
      return "input";
    }
  }
  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;
    }
  }