コード例 #1
0
  /**
   * Returns the Attendance Dash board information list.
   *
   * @param model - ModelMap.
   * @param attendanceDashboardDto - AttendanceDashboardDto.
   * @param request - an instance of HttpServletRequest contains the parameters of the request.
   * @param flag - flag.
   * @return BestStudentAttendance list.
   * @throws AkuraAppException - The exception details that occurred when processing.
   */
  private List<BestStudentAttendanceTemplate> getBestAttendanceInfoWithPagination(
      ModelMap model,
      HttpServletRequest request,
      AttendanceDashboardDto attendanceDashboardDto,
      boolean flag)
      throws AkuraAppException {

    try {
      LOG.debug(AttendanceDashboardController.class);

      // minimum number of the item to be published on the page.
      int minNo = 0;

      String pagination = (String) request.getParameter(PAGINATE);
      String minNumber = (String) request.getParameter(ITEM_NO);

      if (minNumber != AkuraWebConstant.EMPTY_STRING && minNumber != null) {
        minNo = Integer.parseInt(minNumber);
      }

      if (pagination != null && pagination != AkuraWebConstant.EMPTY_STRING) {
        if (pagination.equals(new ErrorMsgLoader().getErrorMessage(PAGINATION_NEXT))) {

          minNo = minNo + PAGINATION_NO;

          model.addAttribute(PAGE_MIN_NO, minNo);
          model.addAttribute(PAGE_MAX_NO, PAGINATION_NO + minNo);

          flag = true;

        } else {
          minNo = minNo - PAGINATION_NO;

          if (minNo < 0) {
            minNo = 0;
          }
          model.addAttribute(PAGE_MIN_NO, minNo);
        }
      } else {
        model.addAttribute(PAGE_MIN_NO, minNo);
        model.addAttribute(PAGE_MAX_NO, PAGINATION_NO);
      }

      attendanceDashboardDto.setMinNo(minNo);
      attendanceDashboardDto.setFlag(flag);

      return dailyAttendanceService.getTopAttendanceList(attendanceDashboardDto);

    } catch (AkuraAppException e) {
      throw e;
    }
  }
コード例 #2
0
  /**
   * Returns the attendance dash board information with pagination.
   *
   * @param modelMap - a model map contains the data.
   * @param request - request scope data.
   * @param response - response scope data.
   * @param attendanceDashboardDto - AttendanceDashboardDto
   * @return - the name of the view to be redirected.
   * @throws AkuraAppException - The exception details that occurred when processing.
   */
  @RequestMapping(value = ATTENDANCE_PAGINATION, method = RequestMethod.POST)
  public ModelAndView getPagination(
      HttpServletRequest request,
      HttpServletResponse response,
      @ModelAttribute(MODEL_ATT_TEMPLATE) AttendanceDashboardDto attendanceDashboardDto,
      ModelMap modelMap)
      throws AkuraAppException {

    boolean flag = false;
    modelMap.addAttribute(STATUS, Boolean.FALSE);

    String selectedClass = request.getParameter(SELECT_CLASSES);

    if (selectedClass != null) {
      ClassGrade classGradeObj = commonService.findClassGrade(Integer.parseInt(selectedClass));

      if (classGradeObj != null) {
        attendanceDashboardDto.setClassDescription(classGradeObj.getDescription());
      }
    }

    setMonthAndClass(request, attendanceDashboardDto);
    attendanceDashboardDto.setAcademicDays(getAcademicDays(attendanceDashboardDto));
    setSelectedValues(attendanceDashboardDto, modelMap);
    List<BestStudentAttendanceTemplate> bestStudentAttendanceList =
        getBestAttendanceInfoWithPagination(modelMap, request, attendanceDashboardDto, flag);

    if (bestStudentAttendanceList == null) {

      int minNo = attendanceDashboardDto.getMinNo() - PAGINATION_NO;
      attendanceDashboardDto.setMinNo(minNo);
      bestStudentAttendanceList =
          dailyAttendanceService.getTopAttendanceList(attendanceDashboardDto);
      modelMap.addAttribute(STATUS, Boolean.TRUE);
      modelMap.addAttribute(PAGE_MIN_NO, minNo);
    }

    if (bestStudentAttendanceList != null) {
      if (attendanceDashboardDto.isFlag()) {

        modelMap.addAttribute(PAGE_MAX_NO, bestStudentAttendanceList.size() + PAGINATION_NO);
      } else {
        modelMap.addAttribute(PAGE_MAX_NO, bestStudentAttendanceList.size());
      }
    }

    modelMap.addAttribute(BEST_STUDENT_ATTENDANCE_LIST, bestStudentAttendanceList);

    return new ModelAndView(VIEW_ATTENDANCE_DASHBOARD, modelMap);
  }