List<Department> departments = (List<Department>) ServiceUtils.executeService(userView,
Collection<Department> departments = (Collection<Department>) ServiceUtils.executeService(userView,
    public ActionForward viewCreditsReport(ActionMapping mapping, ActionForm form,            HttpServletRequest request, HttpServletResponse response) throws FenixFilterException,            FenixServiceException, InvalidPeriodException {        IUserView userView = SessionUtils.getUserView(request);        DynaActionForm dynaForm = (DynaActionForm) form;        Integer fromExecutionPeriodID = Integer.parseInt(dynaForm.getString("fromExecutionPeriodID"));        Integer untilExecutionPeriodID = Integer.parseInt(dynaForm.getString("untilExecutionPeriodID"));        request.setAttribute("fromExecutionPeriodID", fromExecutionPeriodID);        request.setAttribute("untilExecutionPeriodID", untilExecutionPeriodID);        ExecutionPeriod fromExecutionPeriod = (ExecutionPeriod) ServiceUtils.executeService(userView,                "ReadDomainObject", new Object[] { ExecutionPeriod.class, fromExecutionPeriodID });        ExecutionPeriod untilExecutionPeriod = (ExecutionPeriod) ServiceUtils.executeService(userView,                "ReadDomainObject", new Object[] { ExecutionPeriod.class, untilExecutionPeriodID });        if(!validExecutionPeriodsChoice(fromExecutionPeriod,untilExecutionPeriod)){            throw new InvalidPeriodException();        }        List<TeacherCreditsReportDTO> teacherCreditsReportList = new ArrayList<TeacherCreditsReportDTO>();        Integer departmentID = (Integer) dynaForm.get("departmentID");        Map<Department, List<TeacherCreditsReportDTO>> teachersCreditsByDepartment = new HashMap<Department, List<TeacherCreditsReportDTO>>();        if (departmentID == 0) {            List<Department> departments = (List<Department>) ServiceUtils.executeService(userView,                    "ReadAllDomainObjects", new Object[] { Department.class });            for (Department department : departments) {                Unit unit = department.getDepartmentUnit();                teacherCreditsReportList = (List<TeacherCreditsReportDTO>) ServiceUtils.executeService(                        userView, "ReadTeachersCreditsResumeByPeriodAndUnit", new Object[] { unit,                                fromExecutionPeriod, untilExecutionPeriod });                teachersCreditsByDepartment.put(department, teacherCreditsReportList);            }            request.setAttribute("departmentID", 0);            request.setAttribute("unitID", 0);        } else {            Integer unitID = (Integer) dynaForm.get("unitID");            Unit unit = null;            Department department = (Department) ServiceUtils.executeService(userView,                    "ReadDomainObject", new Object[] { Department.class, departmentID });                        if (unitID == null || unitID == 0) {                unit = department.getDepartmentUnit();            } else {                unit = (Unit) ServiceUtils.executeService(userView, "ReadDomainObject", new Object[] {                        Unit.class, unitID });            }            teacherCreditsReportList = (List<TeacherCreditsReportDTO>) ServiceUtils.executeService(                    userView, "ReadTeachersCreditsResumeByPeriodAndUnit", new Object[] { unit,                            fromExecutionPeriod, untilExecutionPeriod });            teachersCreditsByDepartment.put(department, teacherCreditsReportList);            request.setAttribute("department", department);            request.setAttribute("departmentID", department.getIdInternal());            request.setAttribute("unitID", unit.getIdInternal());        }        if (teachersCreditsByDepartment != null && !teachersCreditsByDepartment.isEmpty()) {            Map<Department, Map<Unit, List>> teachersCreditsDisplayMap = new TreeMap<Department, Map<Unit, List>>(                    new BeanComparator("name"));            for (Department department : teachersCreditsByDepartment.keySet()) {                Map<Unit, List> teachersCreditsByUnit = new TreeMap<Unit,List>(new BeanComparator("name"));                List<TeacherCreditsReportDTO> list = teachersCreditsByDepartment.get(department);                for (TeacherCreditsReportDTO creditsReportDTO : list) {                    List mapLineList = teachersCreditsByUnit.get(creditsReportDTO.getUnit());                    if (mapLineList == null) {                        mapLineList = new ArrayList<TeacherCreditsReportDTO>();                        mapLineList.add(creditsReportDTO);                        teachersCreditsByUnit.put(creditsReportDTO.getUnit(), mapLineList);                    } else {                        mapLineList.add(creditsReportDTO);                    }                }                for (List teachersCreditMapLine : teachersCreditsByUnit.values()) {                    Collections.sort(teachersCreditMapLine, new BeanComparator("teacher.teacherNumber"));                }                teachersCreditsDisplayMap.put(department, teachersCreditsByUnit);            }            if (!teacherCreditsReportList.isEmpty()) {            	request.setAttribute("executionPeriodHeader", teacherCreditsReportList.iterator().next()            			.getCreditsByExecutionPeriod());            }            request.setAttribute("teachersCreditsDisplayMap", teachersCreditsDisplayMap);        }        return mapping.findForward("showCreditsReport");    }