Search in sources :

Example 31 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class EditCourseViewController method process.

/**
 * Processes the page request by including the corresponding JSP page to the response.
 *
 * @param pageRequestContext Page request context
 */
public void process(PageRequestContext pageRequestContext) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    CourseDescriptionCategoryDAO descriptionCategoryDAO = DAOFactory.getInstance().getCourseDescriptionCategoryDAO();
    CourseDescriptionDAO descriptionDAO = DAOFactory.getInstance().getCourseDescriptionDAO();
    CourseParticipationTypeDAO participationTypeDAO = DAOFactory.getInstance().getCourseParticipationTypeDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    CourseStateDAO courseStateDAO = DAOFactory.getInstance().getCourseStateDAO();
    CourseTypeDAO courseTypeDAO = DAOFactory.getInstance().getCourseTypeDAO();
    CourseStaffMemberDAO courseStaffMemberDAO = DAOFactory.getInstance().getCourseStaffMemberDAO();
    CourseStaffMemberRoleDAO courseStaffMemberRoleDAO = DAOFactory.getInstance().getCourseStaffMemberRoleDAO();
    CourseComponentDAO courseComponentDAO = DAOFactory.getInstance().getCourseComponentDAO();
    CourseEnrolmentTypeDAO enrolmentTypeDAO = DAOFactory.getInstance().getCourseEnrolmentTypeDAO();
    SubjectDAO subjectDAO = DAOFactory.getInstance().getSubjectDAO();
    EducationTypeDAO educationTypeDAO = DAOFactory.getInstance().getEducationTypeDAO();
    EducationalTimeUnitDAO educationalTimeUnitDAO = DAOFactory.getInstance().getEducationalTimeUnitDAO();
    EducationSubtypeDAO educationSubtypeDAO = DAOFactory.getInstance().getEducationSubtypeDAO();
    CurriculumDAO curriculumDAO = DAOFactory.getInstance().getCurriculumDAO();
    OrganizationDAO organizationDAO = DAOFactory.getInstance().getOrganizationDAO();
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    // The course to be edited
    Course course = courseDAO.findById(NumberUtils.createLong(pageRequestContext.getRequest().getParameter("course")));
    pageRequestContext.getRequest().setAttribute("course", course);
    // Create a hashmap of the education types and education subtypes selected in the course
    List<EducationType> educationTypes = educationTypeDAO.listUnarchived();
    Collections.sort(educationTypes, new StringAttributeComparator("getName"));
    pageRequestContext.getRequest().setAttribute("educationTypes", educationTypes);
    Map<String, Boolean> enabledEducationTypes = new HashMap<>();
    for (CourseEducationType courseEducationType : course.getCourseEducationTypes()) {
        for (CourseEducationSubtype courseEducationSubtype : courseEducationType.getCourseEducationSubtypes()) {
            enabledEducationTypes.put(courseEducationType.getEducationType().getId() + "." + courseEducationSubtype.getEducationSubtype().getId(), Boolean.TRUE);
        }
    }
    pageRequestContext.getRequest().setAttribute("enabledEducationTypes", enabledEducationTypes);
    // Various lists of base entities from module, course, and resource DAOs
    List<CourseStudent> courseStudents = courseStudentDAO.listByCourse(course);
    Collections.sort(courseStudents, new Comparator<CourseStudent>() {

        @Override
        public int compare(CourseStudent o1, CourseStudent o2) {
            int cmp = o1.getStudent().getLastName().compareToIgnoreCase(o2.getStudent().getLastName());
            if (cmp == 0)
                cmp = o1.getStudent().getFirstName().compareToIgnoreCase(o2.getStudent().getFirstName());
            return cmp;
        }
    });
    List<CourseStaffMember> courseUsers = courseStaffMemberDAO.listByCourse(course);
    Collections.sort(courseUsers, new Comparator<CourseStaffMember>() {

        @Override
        public int compare(CourseStaffMember o1, CourseStaffMember o2) {
            int cmp = o1.getStaffMember().getLastName().compareToIgnoreCase(o2.getStaffMember().getLastName());
            if (cmp == 0)
                cmp = o1.getStaffMember().getFirstName().compareToIgnoreCase(o2.getStaffMember().getFirstName());
            return cmp;
        }
    });
    StringBuilder tagsBuilder = new StringBuilder();
    Iterator<Tag> tagIterator = course.getTags().iterator();
    while (tagIterator.hasNext()) {
        Tag tag = tagIterator.next();
        tagsBuilder.append(tag.getText());
        if (tagIterator.hasNext())
            tagsBuilder.append(' ');
    }
    List<CourseComponent> courseComponents = courseComponentDAO.listByCourse(course);
    // course students students
    Map<Long, List<Student>> courseStudentsStudents = new HashMap<>();
    for (CourseStudent courseStudent : courseStudents) {
        courseStudentsStudents.put(courseStudent.getId(), studentDAO.listByPerson(courseStudent.getStudent().getPerson()));
    }
    // Subjects
    Map<Long, List<Subject>> subjectsByEducationType = new HashMap<>();
    List<Subject> subjectsByNoEducationType = subjectDAO.listByEducationType(null);
    Collections.sort(subjectsByNoEducationType, new StringAttributeComparator("getName"));
    for (EducationType educationType : educationTypes) {
        List<Subject> subjectsOfType = subjectDAO.listByEducationType(educationType);
        if (subjectsOfType != null && !subjectsOfType.isEmpty()) {
            Collections.sort(subjectsOfType, new StringAttributeComparator("getName"));
            subjectsByEducationType.put(educationType.getId(), subjectsOfType);
        }
    }
    List<EducationalTimeUnit> educationalTimeUnits = educationalTimeUnitDAO.listUnarchived();
    Collections.sort(educationalTimeUnits, new StringAttributeComparator("getName"));
    List<CourseParticipationType> courseParticipationTypes = participationTypeDAO.listUnarchived();
    Collections.sort(courseParticipationTypes, new Comparator<CourseParticipationType>() {

        public int compare(CourseParticipationType o1, CourseParticipationType o2) {
            return o1.getIndexColumn() == null ? -1 : o2.getIndexColumn() == null ? 1 : o1.getIndexColumn().compareTo(o2.getIndexColumn());
        }
    });
    Map<Long, List<EducationSubtype>> educationSubtypes = new HashMap<>();
    for (EducationType educationType : educationTypes) {
        List<EducationSubtype> subtypes = educationSubtypeDAO.listByEducationType(educationType);
        Collections.sort(subtypes, new StringAttributeComparator("getName"));
        educationSubtypes.put(educationType.getId(), subtypes);
    }
    // TODO: Support other currencies
    List<Currency> currencies = Arrays.asList(Currency.getInstance("EUR"));
    List<Curriculum> curriculums = curriculumDAO.listUnarchived();
    Collections.sort(curriculums, new StringAttributeComparator("getName"));
    // Organizations
    Long loggedUserId = pageRequestContext.getLoggedUserId();
    StaffMember user = staffMemberDAO.findById(loggedUserId);
    List<Organization> organizations;
    if (UserUtils.canAccessAllOrganizations(user)) {
        organizations = organizationDAO.listUnarchived();
    } else {
        organizations = Arrays.asList(user.getOrganization());
    }
    Collections.sort(organizations, new StringAttributeComparator("getName"));
    pageRequestContext.getRequest().setAttribute("organizations", organizations);
    pageRequestContext.getRequest().setAttribute("educationSubtypes", educationSubtypes);
    pageRequestContext.getRequest().setAttribute("tags", tagsBuilder.toString());
    pageRequestContext.getRequest().setAttribute("states", courseStateDAO.listUnarchived());
    pageRequestContext.getRequest().setAttribute("types", courseTypeDAO.listUnarchived());
    pageRequestContext.getRequest().setAttribute("roles", courseStaffMemberRoleDAO.listAll());
    pageRequestContext.getRequest().setAttribute("subjectsByNoEducationType", subjectsByNoEducationType);
    pageRequestContext.getRequest().setAttribute("subjectsByEducationType", subjectsByEducationType);
    pageRequestContext.getRequest().setAttribute("courseParticipationTypes", courseParticipationTypes);
    pageRequestContext.getRequest().setAttribute("courseEnrolmentTypes", enrolmentTypeDAO.listAll());
    pageRequestContext.getRequest().setAttribute("courseStudents", courseStudents);
    pageRequestContext.getRequest().setAttribute("courseUsers", courseUsers);
    pageRequestContext.getRequest().setAttribute("courseLengthTimeUnits", educationalTimeUnits);
    pageRequestContext.getRequest().setAttribute("courseComponents", courseComponents);
    pageRequestContext.getRequest().setAttribute("courseStudentsStudents", courseStudentsStudents);
    pageRequestContext.getRequest().setAttribute("courseDescriptions", descriptionDAO.listByCourseBase(course));
    pageRequestContext.getRequest().setAttribute("courseDescriptionCategories", descriptionCategoryDAO.listUnarchived());
    pageRequestContext.getRequest().setAttribute("currencies", currencies);
    pageRequestContext.getRequest().setAttribute("curriculums", curriculums);
    pageRequestContext.setIncludeJSP("/templates/courses/editcourse.jsp");
}
Also used : HashMap(java.util.HashMap) CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseDescriptionDAO(fi.otavanopisto.pyramus.dao.courses.CourseDescriptionDAO) CourseStaffMember(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Currency(java.util.Currency) List(java.util.List) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) OrganizationDAO(fi.otavanopisto.pyramus.dao.base.OrganizationDAO) EducationalTimeUnit(fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit) CourseEducationType(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationType) CourseParticipationTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO) CourseComponentDAO(fi.otavanopisto.pyramus.dao.courses.CourseComponentDAO) EducationalTimeUnitDAO(fi.otavanopisto.pyramus.dao.base.EducationalTimeUnitDAO) CourseEducationSubtype(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationSubtype) EducationSubtype(fi.otavanopisto.pyramus.domainmodel.base.EducationSubtype) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseEducationSubtype(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationSubtype) CourseStaffMemberRoleDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberRoleDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) CourseEnrolmentTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseEnrolmentTypeDAO) EducationTypeDAO(fi.otavanopisto.pyramus.dao.base.EducationTypeDAO) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) CourseTypeDAO(fi.otavanopisto.pyramus.dao.courses.CourseTypeDAO) Organization(fi.otavanopisto.pyramus.domainmodel.base.Organization) CourseEducationType(fi.otavanopisto.pyramus.domainmodel.base.CourseEducationType) EducationType(fi.otavanopisto.pyramus.domainmodel.base.EducationType) SubjectDAO(fi.otavanopisto.pyramus.dao.base.SubjectDAO) StringAttributeComparator(fi.otavanopisto.pyramus.util.StringAttributeComparator) CourseDescriptionCategoryDAO(fi.otavanopisto.pyramus.dao.courses.CourseDescriptionCategoryDAO) CourseComponent(fi.otavanopisto.pyramus.domainmodel.courses.CourseComponent) CourseStateDAO(fi.otavanopisto.pyramus.dao.courses.CourseStateDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) CourseStaffMemberDAO(fi.otavanopisto.pyramus.dao.courses.CourseStaffMemberDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType) CurriculumDAO(fi.otavanopisto.pyramus.dao.base.CurriculumDAO) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) EducationSubtypeDAO(fi.otavanopisto.pyramus.dao.base.EducationSubtypeDAO) CourseStaffMember(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember) Curriculum(fi.otavanopisto.pyramus.domainmodel.base.Curriculum) Tag(fi.otavanopisto.pyramus.domainmodel.base.Tag)

Example 32 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class SearchStudentProjectModuleCoursesDialogViewController method process.

/**
 * Processes the page request by including the corresponding JSP page to the response.
 *
 * @param pageRequestContext Page request context
 */
@SuppressWarnings("unchecked")
public void process(PageRequestContext pageRequestContext) {
    CourseDAO courseDAO = DAOFactory.getInstance().getCourseDAO();
    ModuleDAO moduleDAO = DAOFactory.getInstance().getModuleDAO();
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    AcademicTermDAO academicTermDAO = DAOFactory.getInstance().getAcademicTermDAO();
    Long moduleId = pageRequestContext.getLong("moduleId");
    Long academicTermId = pageRequestContext.getLong("academicTermId");
    Long studentId = pageRequestContext.getLong("studentId");
    Module module = moduleDAO.findById(moduleId);
    AcademicTerm academicTerm = null;
    if (academicTermId != null && academicTermId >= 0)
        academicTerm = academicTermDAO.findById(academicTermId);
    Student student = studentDAO.findById(studentId);
    List<Course> courses = courseDAO.listByModule(module);
    Collections.sort(courses, new ReverseComparator(new Comparator<Course>() {

        @Override
        public int compare(Course o1, Course o2) {
            int result = compareDates(o1.getBeginDate(), o2.getBeginDate());
            if (result == 0) {
                result = compareDates(o1.getEndDate(), o2.getEndDate());
            }
            return result;
        }

        private int compareDates(Date d1, Date d2) {
            if (d1 == d2) {
                return 0;
            } else {
                if (d1 == null)
                    return 1;
                else if (d2 == null)
                    return -1;
                else {
                    return d1.compareTo(d2);
                }
            }
        }
    }));
    List<StudentProjectModuleCourseBean> studentProjectModuleCourses = new ArrayList<>();
    int coursesInTimeFrame = 0;
    for (Course course : courses) {
        boolean withinTimeFrame = false;
        if ((academicTerm != null) && (academicTerm.getStartDate() != null) && (academicTerm.getEndDate() != null) && (course.getBeginDate() != null) && (course.getEndDate() != null)) {
            withinTimeFrame = isWithinTimeFrame(academicTerm.getStartDate(), academicTerm.getEndDate(), course.getBeginDate(), course.getEndDate());
            if (withinTimeFrame)
                coursesInTimeFrame++;
        }
        CourseParticipationType courseParticipationType = null;
        CourseStudent courseStudent = courseStudentDAO.findByCourseAndStudent(course, student);
        if (courseStudent != null)
            courseParticipationType = courseStudent.getParticipationType();
        Long courseStudentCount = courseStudentDAO.countByCourse(course);
        Long maxCourseStudentCount = course.getMaxParticipantCount();
        StudentProjectModuleCourseBean studentProjectModuleCourseBean = new StudentProjectModuleCourseBean(course, courseParticipationType, withinTimeFrame, courseStudentCount, maxCourseStudentCount);
        studentProjectModuleCourses.add(studentProjectModuleCourseBean);
    }
    String message;
    if (!courses.isEmpty()) {
        message = Messages.getInstance().getText(pageRequestContext.getRequest().getLocale(), "projects.searchStudentProjectModuleCoursesDialog.coursesFound", new Object[] { courses.size(), coursesInTimeFrame });
    } else {
        message = Messages.getInstance().getText(pageRequestContext.getRequest().getLocale(), "projects.searchStudentProjectModuleCoursesDialog.noCoursesFound");
    }
    pageRequestContext.getRequest().setAttribute("message", message);
    pageRequestContext.getRequest().setAttribute("studentProjectModuleCourses", studentProjectModuleCourses);
    pageRequestContext.setIncludeJSP("/templates/projects/searchstudentprojectmodulecoursesdialog.jsp");
}
Also used : CourseDAO(fi.otavanopisto.pyramus.dao.courses.CourseDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) ModuleDAO(fi.otavanopisto.pyramus.dao.modules.ModuleDAO) ArrayList(java.util.ArrayList) ReverseComparator(org.apache.commons.collections.comparators.ReverseComparator) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Date(java.util.Date) ReverseComparator(org.apache.commons.collections.comparators.ReverseComparator) Comparator(java.util.Comparator) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) AcademicTerm(fi.otavanopisto.pyramus.domainmodel.base.AcademicTerm) AcademicTermDAO(fi.otavanopisto.pyramus.dao.base.AcademicTermDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Module(fi.otavanopisto.pyramus.domainmodel.modules.Module) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) CourseParticipationType(fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)

Example 33 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class ViewStudentViewController method process.

/**
 * Processes the page request.
 *
 * In parameters
 * - student
 * - person
 *
 * Page parameters
 * - student - Student object
 * - nationalities - List of Nationality objects
 * - municipalities - List of Municipality objects
 * - languages - List of Language objects
 * - studentCourses - List of CourseStudent objects
 * - studentContactEntries - List of StudentContactLogEntry objects
 *
 * @param pageRequestContext pageRequestContext
 */
public void process(PageRequestContext pageRequestContext) {
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    PersonDAO personDAO = DAOFactory.getInstance().getPersonDAO();
    StudentImageDAO imageDAO = DAOFactory.getInstance().getStudentImageDAO();
    StudentContactLogEntryDAO logEntryDAO = DAOFactory.getInstance().getStudentContactLogEntryDAO();
    StudentContactLogEntryCommentDAO entryCommentDAO = DAOFactory.getInstance().getStudentContactLogEntryCommentDAO();
    StudentGroupDAO studentGroupDAO = DAOFactory.getInstance().getStudentGroupDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    StudentProjectDAO studentProjectDAO = DAOFactory.getInstance().getStudentProjectDAO();
    CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
    TransferCreditDAO transferCreditDAO = DAOFactory.getInstance().getTransferCreditDAO();
    ProjectAssessmentDAO projectAssessmentDAO = DAOFactory.getInstance().getProjectAssessmentDAO();
    CreditLinkDAO creditLinkDAO = DAOFactory.getInstance().getCreditLinkDAO();
    StudentFileDAO studentFileDAO = DAOFactory.getInstance().getStudentFileDAO();
    ReportDAO reportDAO = DAOFactory.getInstance().getReportDAO();
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    CurriculumDAO curriculumDAO = DAOFactory.getInstance().getCurriculumDAO();
    UserVariableDAO userVariableDAO = DAOFactory.getInstance().getUserVariableDAO();
    StudentLodgingPeriodDAO studentLodgingPeriodDAO = DAOFactory.getInstance().getStudentLodgingPeriodDAO();
    PersonVariableDAO personVariableDAO = DAOFactory.getInstance().getPersonVariableDAO();
    PersonVariableKeyDAO personVariableKeyDAO = DAOFactory.getInstance().getPersonVariableKeyDAO();
    StudentStudyPeriodDAO studentStudyPeriodDAO = DAOFactory.getInstance().getStudentStudyPeriodDAO();
    MatriculationExamEnrollmentDAO matriculationExamEnrollmentDAO = DAOFactory.getInstance().getMatriculationExamEnrollmentDAO();
    Long loggedUserId = pageRequestContext.getLoggedUserId();
    StaffMember loggedUser = staffMemberDAO.findById(loggedUserId);
    Long personId = pageRequestContext.getLong("person");
    Person person = personDAO.findById(personId);
    pageRequestContext.getRequest().setAttribute("person", person);
    StaffMember staffMember = staffMemberDAO.findByPerson(person);
    pageRequestContext.getRequest().setAttribute("staffMember", staffMember);
    List<Student> students = UserUtils.canAccessAllOrganizations(loggedUser) ? studentDAO.listByPerson(person) : studentDAO.listByPersonAndOrganization(person, loggedUser.getOrganization());
    Collections.sort(students, new Comparator<Student>() {

        @Override
        public int compare(Student o1, Student o2) {
            /**
             * Ordering study programmes as follows
             *  1. studies that have start date but no end date (ongoing)
             *  2. studies that have no start nor end date
             *  3. studies that have ended
             *  4. studies that are archived
             *  5. other
             */
            int o1class = (o1.getArchived()) ? 4 : (o1.getStudyStartDate() != null && o1.getStudyEndDate() == null) ? 1 : (o1.getStudyStartDate() == null && o1.getStudyEndDate() == null) ? 2 : (o1.getStudyEndDate() != null) ? 3 : 5;
            int o2class = (o2.getArchived()) ? 4 : (o2.getStudyStartDate() != null && o2.getStudyEndDate() == null) ? 1 : (o2.getStudyStartDate() == null && o2.getStudyEndDate() == null) ? 2 : (o2.getStudyEndDate() != null) ? 3 : 5;
            if (o1class == o2class) {
                // classes are the same, we try to do last comparison from the start dates
                return ((o1.getStudyStartDate() != null) && (o2.getStudyStartDate() != null)) ? o2.getStudyStartDate().compareTo(o1.getStudyStartDate()) : 0;
            } else
                return o1class < o2class ? -1 : o1class == o2class ? 0 : 1;
        }
    });
    Map<Long, Boolean> studentHasImage = new HashMap<>();
    Map<Long, List<CourseStudent>> courseStudents = new HashMap<>();
    Map<Long, List<StudentContactLogEntry>> contactEntries = new HashMap<>();
    Map<Long, List<TransferCredit>> transferCredits = new HashMap<>();
    Map<Long, List<CourseAssessment>> courseAssessments = new HashMap<>();
    Map<Long, CourseAssessmentRequest> courseAssessmentRequests = new HashMap<>();
    Map<Long, List<StudentGroup>> studentGroups = new HashMap<>();
    Map<Long, List<StudentProjectBean>> studentProjects = new HashMap<>();
    Map<Long, CourseAssessment> courseAssessmentsByCourseStudent = new HashMap<>();
    // StudentProject.id -> List of module beans
    Map<Long, List<StudentProjectModuleBean>> studentProjectModules = new HashMap<>();
    final Map<Long, List<StudentContactLogEntryComment>> contactEntryComments = new HashMap<>();
    Map<Long, List<StudentLodgingPeriod>> studentLodgingPeriods = new HashMap<>();
    Map<Long, List<StudentStudyPeriod>> studentStudyPeriods = new HashMap<>();
    Map<Long, StudentTOR> subjectCredits = new HashMap<>();
    Map<Long, List<MatriculationExamEnrollment>> studentMatriculationEnrollments = new HashMap<>();
    JSONObject linkedCourseAssessments = new JSONObject();
    JSONObject linkedTransferCredits = new JSONObject();
    JSONObject studentFiles = new JSONObject();
    JSONObject studentVariablesJSON = new JSONObject();
    JSONArray studentReportsJSON = new JSONArray();
    JSONArray curriculumsJSON = new JSONArray();
    JSONObject studentAssessmentsJSON = new JSONObject();
    List<Report> studentReports = reportDAO.listByContextType(ReportContextType.Student);
    Collections.sort(studentReports, new StringAttributeComparator("getName"));
    for (Report report : studentReports) {
        JSONObject obj = new JSONObject();
        obj.put("id", report.getId().toString());
        obj.put("name", report.getName());
        studentReportsJSON.add(obj);
    }
    /* PersonVariables */
    List<PersonVariableKey> personVariableKeys = personVariableKeyDAO.listUserEditablePersonVariableKeys();
    Collections.sort(personVariableKeys, new StringAttributeComparator("getVariableName"));
    JSONArray personVariablesJSON = new JSONArray();
    for (PersonVariableKey personVariableKey : personVariableKeys) {
        PersonVariable personVariable = personVariableDAO.findByPersonAndVariableKey(person, personVariableKey);
        JSONObject personVariableJSON = new JSONObject();
        personVariableJSON.put("type", personVariableKey.getVariableType());
        personVariableJSON.put("name", personVariableKey.getVariableName());
        personVariableJSON.put("key", personVariableKey.getVariableKey());
        personVariableJSON.put("value", personVariable != null ? personVariable.getValue() : "");
        personVariablesJSON.add(personVariableJSON);
    }
    setJsDataVariable(pageRequestContext, "personVariables", personVariablesJSON.toString());
    /* Curriculums */
    List<Curriculum> curriculums = curriculumDAO.listUnarchived();
    for (Curriculum curriculum : curriculums) {
        JSONObject obj = new JSONObject();
        obj.put("id", curriculum.getId().toString());
        obj.put("name", curriculum.getName());
        curriculumsJSON.add(obj);
    }
    for (Student student : students) {
        /**
         * Fetch courses this student is part of and sort the courses by course name
         */
        List<CourseStudent> courseStudentsByStudent = courseStudentDAO.listByStudent(student);
        Collections.sort(courseStudentsByStudent, new Comparator<CourseStudent>() {

            private String getCourseAssessmentCompareStr(CourseStudent courseStudent) {
                String result = "";
                if (courseStudent != null)
                    if (courseStudent.getCourse() != null)
                        result = courseStudent.getCourse().getName();
                return result;
            }

            @Override
            public int compare(CourseStudent o1, CourseStudent o2) {
                String s1 = getCourseAssessmentCompareStr(o1);
                String s2 = getCourseAssessmentCompareStr(o2);
                return s1.compareToIgnoreCase(s2);
            }
        });
        for (CourseStudent courseStudent : courseStudentsByStudent) {
            List<CourseAssessmentRequest> courseAssessmentRequestsByCourseStudent = courseAssessmentRequestDAO.listByCourseStudent(courseStudent);
            Collections.sort(courseAssessmentRequestsByCourseStudent, new Comparator<CourseAssessmentRequest>() {

                @Override
                public int compare(CourseAssessmentRequest o1, CourseAssessmentRequest o2) {
                    return o2.getCreated().compareTo(o1.getCreated());
                }
            });
            if (!courseAssessmentRequestsByCourseStudent.isEmpty()) {
                courseAssessmentRequests.put(courseStudent.getId(), courseAssessmentRequestsByCourseStudent.get(0));
            }
        }
        /**
         * Contact log entries
         */
        List<StudentContactLogEntry> listStudentContactEntries = logEntryDAO.listByStudent(student);
        for (int j = 0; j < listStudentContactEntries.size(); j++) {
            StudentContactLogEntry entry = listStudentContactEntries.get(j);
            List<StudentContactLogEntryComment> listComments = entryCommentDAO.listByEntry(entry);
            Collections.sort(listComments, new Comparator<StudentContactLogEntryComment>() {

                public int compare(StudentContactLogEntryComment o1, StudentContactLogEntryComment o2) {
                    Date d1 = o1.getCommentDate();
                    Date d2 = o2.getCommentDate();
                    int val = d1 == null ? d2 == null ? 0 : 1 : d2 == null ? -1 : d1.compareTo(d2);
                    if (val == 0)
                        return o1.getId().compareTo(o2.getId());
                    else
                        return val;
                }
            });
            contactEntryComments.put(entry.getId(), listComments);
        }
        // And then sort the entries by latest date of entry or its comments
        Collections.sort(listStudentContactEntries, new Comparator<StudentContactLogEntry>() {

            private Date getDateForEntry(StudentContactLogEntry entry) {
                Date d = entry.getEntryDate();
                List<StudentContactLogEntryComment> comments = contactEntryComments.get(entry.getId());
                for (int i = 0; i < comments.size(); i++) {
                    StudentContactLogEntryComment comment = comments.get(i);
                    if (d == null) {
                        d = comment.getCommentDate();
                    } else {
                        if (d.before(comment.getCommentDate()))
                            d = comment.getCommentDate();
                    }
                }
                return d;
            }

            public int compare(StudentContactLogEntry o1, StudentContactLogEntry o2) {
                Date d1 = getDateForEntry(o1);
                Date d2 = getDateForEntry(o2);
                int val = d1 == null ? d2 == null ? 0 : 1 : d2 == null ? -1 : d2.compareTo(d1);
                if (val == 0)
                    return o2.getId().compareTo(o1.getId());
                else
                    return val;
            }
        });
        /**
         * Students Course Assessments, sorted by course name
         */
        List<CourseAssessment> courseAssessmentsByStudent = courseAssessmentDAO.listByStudent(student);
        for (CourseAssessment courseAssessment : courseAssessmentsByStudent) {
            Long courseStudentId = courseAssessment.getCourseStudent().getId();
            courseAssessmentsByCourseStudent.put(courseStudentId, courseAssessment);
        }
        Collections.sort(courseAssessmentsByStudent, new Comparator<CourseAssessment>() {

            private String getCourseAssessmentCompareStr(CourseAssessment courseAssessment) {
                String result = "";
                if (courseAssessment != null)
                    if (courseAssessment.getCourseStudent() != null)
                        if (courseAssessment.getCourseStudent().getCourse() != null)
                            result = courseAssessment.getCourseStudent().getCourse().getName();
                return result;
            }

            @Override
            public int compare(CourseAssessment o1, CourseAssessment o2) {
                String s1 = getCourseAssessmentCompareStr(o1);
                String s2 = getCourseAssessmentCompareStr(o2);
                return s1.compareToIgnoreCase(s2);
            }
        });
        JSONArray jsonCourseStudentAssessments = new JSONArray();
        for (CourseStudent courseStudent : courseStudentsByStudent) {
            List<CourseAssessment> courseAssessmentList = courseAssessmentsByStudent.stream().filter(courseAssessment -> Objects.equals(courseStudent.getId(), courseAssessment.getCourseStudent().getId())).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(courseAssessmentList) && courseStudent.getCourse() != null) {
                Course course = courseStudent.getCourse();
                JSONObject obj = new JSONObject();
                obj.put("courseStudentId", courseStudent.getId());
                obj.put("courseName", course.getName());
                obj.put("subjectName", getSubjectText(course.getSubject(), pageRequestContext.getRequest().getLocale()));
                JSONArray jsonCurriculums = new JSONArray();
                for (Curriculum curriculum : course.getCurriculums()) {
                    JSONObject curobj = new JSONObject();
                    curobj.put("name", curriculum.getName());
                    jsonCurriculums.add(curobj);
                }
                obj.put("curriculums", jsonCurriculums);
                if (course.getCourseLength() != null) {
                    EducationalLength courseLength = course.getCourseLength();
                    obj.put("courseLength", courseLength.getUnits().toString());
                    if (courseLength.getUnit() != null) {
                        obj.put("courseLengthUnitName", courseLength.getUnit().getName());
                    }
                }
                JSONArray jsonCourseAssessments = new JSONArray();
                for (CourseAssessment ass : courseAssessmentList) {
                    JSONObject assobj = new JSONObject();
                    assobj.put("timestamp", ass.getDate() != null ? ass.getDate().getTime() : null);
                    assobj.put("gradeName", ass.getGrade() != null ? ass.getGrade().getName() : null);
                    assobj.put("gradingScaleName", (ass.getGrade() != null && ass.getGrade().getGradingScale() != null) ? ass.getGrade().getGradingScale().getName() : null);
                    assobj.put("assessorName", ass.getAssessor() != null ? ass.getAssessor().getFullName() : null);
                    jsonCourseAssessments.add(assobj);
                }
                obj.put("assessments", jsonCourseAssessments);
                jsonCourseStudentAssessments.add(obj);
            }
        }
        studentAssessmentsJSON.put(student.getId(), jsonCourseStudentAssessments);
        /**
         * Fetching and sorting of Transfer Credits
         */
        List<TransferCredit> transferCreditsByStudent = transferCreditDAO.listByStudent(student);
        Collections.sort(transferCreditsByStudent, new Comparator<TransferCredit>() {

            private String getCourseAssessmentCompareStr(TransferCredit tCredit) {
                String result = "";
                if (tCredit != null)
                    result = tCredit.getCourseName();
                return result;
            }

            @Override
            public int compare(TransferCredit o1, TransferCredit o2) {
                String s1 = getCourseAssessmentCompareStr(o1);
                String s2 = getCourseAssessmentCompareStr(o2);
                return s1.compareToIgnoreCase(s2);
            }
        });
        /**
         * Linked CourseAssessments
         */
        List<CreditLink> linkedCourseAssessmentByStudent = creditLinkDAO.listByStudentAndType(student, CreditType.CourseAssessment);
        Collections.sort(linkedCourseAssessmentByStudent, new Comparator<CreditLink>() {

            private String getCourseAssessmentCompareStr(CourseAssessment courseAssessment) {
                String result = "";
                if (courseAssessment != null)
                    if (courseAssessment.getCourseStudent() != null)
                        if (courseAssessment.getCourseStudent().getCourse() != null)
                            result = courseAssessment.getCourseStudent().getCourse().getName();
                return result;
            }

            @Override
            public int compare(CreditLink o1, CreditLink o2) {
                String s1 = getCourseAssessmentCompareStr((CourseAssessment) o1.getCredit());
                String s2 = getCourseAssessmentCompareStr((CourseAssessment) o2.getCredit());
                return s1.compareToIgnoreCase(s2);
            }
        });
        JSONArray arr = new JSONArray();
        for (CreditLink linkedCourseAssessment : linkedCourseAssessmentByStudent) {
            CourseAssessment courseAssessment = (CourseAssessment) linkedCourseAssessment.getCredit();
            String subjectName = getSubjectText(courseAssessment.getCourseStudent().getCourse().getSubject(), pageRequestContext.getRequest().getLocale());
            JSONObject obj = new JSONObject();
            obj.put("creditLinkId", linkedCourseAssessment.getId().toString());
            obj.put("courseStudentId", courseAssessment.getCourseStudent().getId().toString());
            obj.put("courseName", courseAssessment.getCourseStudent().getCourse().getName());
            obj.put("subjectName", subjectName);
            obj.put("creditDate", courseAssessment.getDate().getTime());
            obj.put("courseLength", courseAssessment.getCourseStudent().getCourse().getCourseLength().getUnits().toString());
            obj.put("courseLengthUnitName", courseAssessment.getCourseStudent().getCourse().getCourseLength().getUnit().getName());
            obj.put("gradeName", courseAssessment.getGrade() != null ? courseAssessment.getGrade().getName() : null);
            obj.put("gradingScaleName", courseAssessment.getGrade() != null ? courseAssessment.getGrade().getGradingScale().getName() : null);
            obj.put("assessingUserName", courseAssessment.getAssessor().getFullName());
            JSONArray courseCurriculums = new JSONArray();
            if (CollectionUtils.isNotEmpty(courseAssessment.getCourseStudent().getCourse().getCurriculums())) {
                for (Curriculum curriculum : courseAssessment.getCourseStudent().getCourse().getCurriculums()) {
                    JSONObject courseCurriculum = new JSONObject();
                    courseCurriculum.put("curriculumId", curriculum.getId());
                    courseCurriculum.put("curriculumName", curriculum.getName());
                    courseCurriculums.add(courseCurriculum);
                }
            }
            obj.put("curriculums", courseCurriculums);
            arr.add(obj);
        }
        if (!arr.isEmpty())
            linkedCourseAssessments.put(student.getId(), arr);
        /**
         * Linked TransferCredits
         */
        List<CreditLink> linkedTransferCreditsByStudent = creditLinkDAO.listByStudentAndType(student, CreditType.TransferCredit);
        Collections.sort(linkedTransferCreditsByStudent, new Comparator<CreditLink>() {

            private String getCourseAssessmentCompareStr(TransferCredit tCredit) {
                String result = "";
                if (tCredit != null)
                    result = tCredit.getCourseName();
                return result;
            }

            @Override
            public int compare(CreditLink o1, CreditLink o2) {
                String s1 = getCourseAssessmentCompareStr((TransferCredit) o1.getCredit());
                String s2 = getCourseAssessmentCompareStr((TransferCredit) o2.getCredit());
                return s1.compareToIgnoreCase(s2);
            }
        });
        arr = new JSONArray();
        for (CreditLink linkedTransferCredit : linkedTransferCreditsByStudent) {
            TransferCredit transferCredit = (TransferCredit) linkedTransferCredit.getCredit();
            String subjectName = getSubjectText(transferCredit.getSubject(), pageRequestContext.getRequest().getLocale());
            JSONObject obj = new JSONObject();
            obj.put("creditLinkId", linkedTransferCredit.getId().toString());
            obj.put("transferCreditId", transferCredit.getId().toString());
            obj.put("courseName", transferCredit.getCourseName());
            obj.put("subjectName", subjectName);
            obj.put("creditDate", transferCredit.getDate().getTime());
            obj.put("courseLength", transferCredit.getCourseLength().getUnits().toString());
            obj.put("courseLengthUnitName", transferCredit.getCourseLength().getUnit().getName());
            obj.put("gradeName", transferCredit.getGrade() != null ? transferCredit.getGrade().getName() : null);
            obj.put("gradingScaleName", transferCredit.getGrade() != null ? transferCredit.getGrade().getGradingScale().getName() : null);
            obj.put("assessingUserName", transferCredit.getAssessor().getFullName());
            if (transferCredit.getCurriculum() != null) {
                Curriculum curriculum = transferCredit.getCurriculum();
                obj.put("curriculumId", curriculum.getId());
                obj.put("curriculumName", curriculum.getName());
            }
            arr.add(obj);
        }
        if (!arr.isEmpty())
            linkedTransferCredits.put(student.getId(), arr);
        /**
         * Project beans setup
         */
        List<StudentProject> studentsStudentProjects = studentProjectDAO.listByStudent(student);
        List<StudentProjectBean> studentProjectBeans = new ArrayList<>();
        for (StudentProject studentProject : studentsStudentProjects) {
            int mandatoryModuleCount = 0;
            int optionalModuleCount = 0;
            int passedMandatoryModuleCount = 0;
            int passedOptionalModuleCount = 0;
            List<StudentProjectModuleBean> studentProjectModuleBeans = new ArrayList<>();
            /**
             * Go through project modules to
             *  a) count mandatory/optional modules
             *  b) count mandatory/optional modules that have passing grade on them
             *  c) create beans to be passed to jsp
             */
            List<CourseAssessment> allStudentCourseAssessments = courseAssessmentDAO.listByStudent(student);
            List<TransferCredit> allStudentTransferCredits = transferCreditDAO.listByStudent(student);
            List<CreditLink> allStudentCreditLinks = creditLinkDAO.listByStudent(student);
            for (CreditLink creditLink : allStudentCreditLinks) {
                switch(creditLink.getCredit().getCreditType()) {
                    case CourseAssessment:
                        allStudentCourseAssessments.add(((CourseAssessment) creditLink.getCredit()));
                        break;
                    case TransferCredit:
                        allStudentTransferCredits.add(((TransferCredit) creditLink.getCredit()));
                        break;
                    case ProjectAssessment:
                        break;
                }
            }
            for (StudentProjectModule studentProjectModule : studentProject.getStudentProjectModules()) {
                boolean hasPassingGrade = false;
                List<CourseStudent> projectCourseCourseStudentList = new ArrayList<>();
                List<TransferCredit> projectCourseTransferCreditList = new ArrayList<>();
                for (CourseAssessment assessment : allStudentCourseAssessments) {
                    if (assessment.getCourseStudent().getCourse().getModule().getId().equals(studentProjectModule.getModule().getId())) {
                        projectCourseCourseStudentList.add(assessment.getCourseStudent());
                        if (assessment.getGrade() != null && assessment.getGrade().getPassingGrade())
                            hasPassingGrade = true;
                    }
                }
                if ((studentProjectModule.getModule().getCourseNumber() != null) && (studentProjectModule.getModule().getCourseNumber() != -1) && (studentProjectModule.getModule().getSubject() != null)) {
                    for (TransferCredit tc : allStudentTransferCredits) {
                        if ((tc.getCourseNumber() != null) && (tc.getCourseNumber() != -1) && (tc.getSubject() != null)) {
                            if (tc.getCourseNumber().equals(studentProjectModule.getModule().getCourseNumber()) && tc.getSubject().equals(studentProjectModule.getModule().getSubject())) {
                                projectCourseTransferCreditList.add(tc);
                                if (tc.getGrade() != null && tc.getGrade().getPassingGrade())
                                    hasPassingGrade = true;
                            }
                        }
                    }
                }
                if (studentProjectModule.getOptionality() == CourseOptionality.MANDATORY) {
                    mandatoryModuleCount++;
                    if (hasPassingGrade)
                        passedMandatoryModuleCount++;
                } else if (studentProjectModule.getOptionality() == CourseOptionality.OPTIONAL) {
                    optionalModuleCount++;
                    if (hasPassingGrade)
                        passedOptionalModuleCount++;
                }
                StudentProjectModuleBean moduleBean = new StudentProjectModuleBean(studentProjectModule, hasPassingGrade, projectCourseCourseStudentList, projectCourseTransferCreditList);
                studentProjectModuleBeans.add(moduleBean);
            }
            // Add ModuleBeans to response
            studentProjectModules.put(studentProject.getId(), studentProjectModuleBeans);
            List<ProjectAssessment> projectAssessments = projectAssessmentDAO.listByProjectAndArchived(studentProject, Boolean.FALSE);
            Collections.sort(projectAssessments, new Comparator<ProjectAssessment>() {

                @Override
                public int compare(ProjectAssessment o1, ProjectAssessment o2) {
                    return o2.getDate().compareTo(o1.getDate());
                }
            });
            StudentProjectBean bean = new StudentProjectBean(studentProject, mandatoryModuleCount, optionalModuleCount, passedMandatoryModuleCount, passedOptionalModuleCount, projectAssessments);
            studentProjectBeans.add(bean);
        }
        List<StudentFile> files = studentFileDAO.listByStudent(student);
        Collections.sort(files, new StringAttributeComparator("getName", true));
        arr = new JSONArray();
        for (StudentFile file : files) {
            JSONObject obj = new JSONObject();
            obj.put("id", file.getId());
            obj.put("name", file.getName());
            obj.put("fileTypeName", file.getFileType() != null ? file.getFileType().getName() : "");
            obj.put("created", file.getCreated().getTime());
            obj.put("lastModified", file.getLastModified().getTime());
            arr.add(obj);
        }
        if (!arr.isEmpty())
            studentFiles.put(student.getId(), arr);
        JSONArray variables = new JSONArray();
        for (UserVariable userVariable : userVariableDAO.listByUserAndUserEditable(student, true)) {
            JSONObject variable = new JSONObject();
            variable.put("type", userVariable.getKey().getVariableType());
            variable.put("name", userVariable.getKey().getVariableName());
            variable.put("key", userVariable.getKey().getVariableKey());
            variable.put("value", userVariable.getValue() != null ? userVariable.getValue() : "");
            variables.add(variable);
        }
        if (!variables.isEmpty())
            studentVariablesJSON.put(student.getId(), variables);
        // Student Image
        studentHasImage.put(student.getId(), imageDAO.findStudentHasImage(student));
        List<StudentLodgingPeriod> studentLodgingPeriodEntities = studentLodgingPeriodDAO.listByStudent(student);
        studentLodgingPeriodEntities.sort(Comparator.comparing(StudentLodgingPeriod::getBegin, Comparator.nullsLast(Comparator.naturalOrder())));
        List<StudentStudyPeriod> studentStudyPeriodEntities = studentStudyPeriodDAO.listByStudent(student);
        studentStudyPeriodEntities.sort(Comparator.comparing(StudentStudyPeriod::getBegin, Comparator.nullsLast(Comparator.naturalOrder())));
        courseStudents.put(student.getId(), courseStudentsByStudent);
        courseAssessments.put(student.getId(), courseAssessmentsByStudent);
        contactEntries.put(student.getId(), listStudentContactEntries);
        transferCredits.put(student.getId(), transferCreditsByStudent);
        studentGroups.put(student.getId(), studentGroupDAO.listByStudent(student, null, null, false));
        studentProjects.put(student.getId(), studentProjectBeans);
        studentLodgingPeriods.put(student.getId(), studentLodgingPeriodEntities);
        studentStudyPeriods.put(student.getId(), studentStudyPeriodEntities);
        studentMatriculationEnrollments.put(student.getId(), matriculationExamEnrollmentDAO.listByStudent(student));
        try {
            StudentTOR tor = StudentTORController.constructStudentTOR(student);
            subjectCredits.put(student.getId(), tor);
        } catch (Exception ex) {
            logger.log(Level.SEVERE, String.format("Failed to construct TOR for student %d", student.getId()), ex);
        }
    }
    ObjectMapper mapper = new ObjectMapper();
    StringWriter writer = new StringWriter();
    mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
    try {
        mapper.writeValue(writer, subjectCredits);
        String requestStr = writer.toString();
        setJsDataVariable(pageRequestContext, "subjectCredits", requestStr);
    } catch (JsonGenerationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (JsonMappingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    setJsDataVariable(pageRequestContext, "studentAssessments", studentAssessmentsJSON.toString());
    setJsDataVariable(pageRequestContext, "linkedCourseAssessments", linkedCourseAssessments.toString());
    setJsDataVariable(pageRequestContext, "linkedTransferCredits", linkedTransferCredits.toString());
    setJsDataVariable(pageRequestContext, "studentFiles", studentFiles.toString());
    setJsDataVariable(pageRequestContext, "studentReports", studentReportsJSON.toString());
    setJsDataVariable(pageRequestContext, "curriculums", curriculumsJSON.toString());
    setJsDataVariable(pageRequestContext, "studentVariables", studentVariablesJSON.toString());
    pageRequestContext.getRequest().setAttribute("students", students);
    pageRequestContext.getRequest().setAttribute("courses", courseStudents);
    pageRequestContext.getRequest().setAttribute("contactEntries", contactEntries);
    pageRequestContext.getRequest().setAttribute("contactEntryComments", contactEntryComments);
    pageRequestContext.getRequest().setAttribute("transferCredits", transferCredits);
    pageRequestContext.getRequest().setAttribute("courseAssessments", courseAssessments);
    pageRequestContext.getRequest().setAttribute("studentGroups", studentGroups);
    pageRequestContext.getRequest().setAttribute("studentProjects", studentProjects);
    pageRequestContext.getRequest().setAttribute("studentProjectModules", studentProjectModules);
    pageRequestContext.getRequest().setAttribute("courseAssessmentsByCourseStudent", courseAssessmentsByCourseStudent);
    pageRequestContext.getRequest().setAttribute("studentHasImage", studentHasImage);
    pageRequestContext.getRequest().setAttribute("courseAssessmentRequests", courseAssessmentRequests);
    pageRequestContext.getRequest().setAttribute("studentLodgingPeriods", studentLodgingPeriods);
    pageRequestContext.getRequest().setAttribute("studentStudyPeriods", studentStudyPeriods);
    pageRequestContext.getRequest().setAttribute("studentMatriculationEnrollments", studentMatriculationEnrollments);
    pageRequestContext.getRequest().setAttribute("hasPersonVariables", CollectionUtils.isNotEmpty(personVariableKeys));
    pageRequestContext.setIncludeJSP("/templates/students/viewstudent.jsp");
}
Also used : StudentTORController(fi.otavanopisto.pyramus.tor.StudentTORController) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) ProjectAssessment(fi.otavanopisto.pyramus.domainmodel.grading.ProjectAssessment) UserUtils(fi.otavanopisto.pyramus.framework.UserUtils) Date(java.util.Date) CreditType(fi.otavanopisto.pyramus.domainmodel.grading.CreditType) StringUtils(org.apache.commons.lang3.StringUtils) StudentLodgingPeriod(fi.otavanopisto.pyramus.domainmodel.students.StudentLodgingPeriod) StudentContactLogEntryComment(fi.otavanopisto.pyramus.domainmodel.students.StudentContactLogEntryComment) StudentStudyPeriod(fi.otavanopisto.pyramus.domainmodel.students.StudentStudyPeriod) Locale(java.util.Locale) StudentProjectDAO(fi.otavanopisto.pyramus.dao.projects.StudentProjectDAO) StudentStudyPeriodDAO(fi.otavanopisto.pyramus.dao.students.StudentStudyPeriodDAO) Map(java.util.Map) CourseOptionality(fi.otavanopisto.pyramus.domainmodel.base.CourseOptionality) CreditLinkDAO(fi.otavanopisto.pyramus.dao.grading.CreditLinkDAO) PyramusViewPermissions(fi.otavanopisto.pyramus.views.PyramusViewPermissions) StringAttributeComparator(fi.otavanopisto.pyramus.util.StringAttributeComparator) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentGroupDAO(fi.otavanopisto.pyramus.dao.students.StudentGroupDAO) RequestContext(fi.internetix.smvc.controllers.RequestContext) EducationalLength(fi.otavanopisto.pyramus.domainmodel.base.EducationalLength) Messages(fi.otavanopisto.pyramus.I18N.Messages) StudentProjectModule(fi.otavanopisto.pyramus.domainmodel.projects.StudentProjectModule) Breadcrumbable(fi.otavanopisto.pyramus.breadcrumbs.Breadcrumbable) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) PersonVariable(fi.otavanopisto.pyramus.domainmodel.users.PersonVariable) Objects(java.util.Objects) List(java.util.List) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO) Report(fi.otavanopisto.pyramus.domainmodel.reports.Report) PersonVariableKey(fi.otavanopisto.pyramus.domainmodel.users.PersonVariableKey) JSONObject(net.sf.json.JSONObject) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) CurriculumDAO(fi.otavanopisto.pyramus.dao.base.CurriculumDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) ProjectAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.ProjectAssessmentDAO) PyramusViewController2(fi.otavanopisto.pyramus.framework.PyramusViewController2) ReportDAO(fi.otavanopisto.pyramus.dao.reports.ReportDAO) PersonVariableDAO(fi.otavanopisto.pyramus.dao.users.PersonVariableDAO) ReportContextType(fi.otavanopisto.pyramus.domainmodel.reports.ReportContextType) SimpleDateFormat(java.text.SimpleDateFormat) HashMap(java.util.HashMap) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) UserVariable(fi.otavanopisto.pyramus.domainmodel.users.UserVariable) CreditLink(fi.otavanopisto.pyramus.domainmodel.grading.CreditLink) UserDAO(fi.otavanopisto.pyramus.dao.users.UserDAO) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) StudentImageDAO(fi.otavanopisto.pyramus.dao.students.StudentImageDAO) PyramusRequestControllerAccess(fi.otavanopisto.pyramus.framework.PyramusRequestControllerAccess) Curriculum(fi.otavanopisto.pyramus.domainmodel.base.Curriculum) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) User(fi.otavanopisto.pyramus.domainmodel.users.User) CollectionUtils(org.apache.commons.collections.CollectionUtils) StudentContactLogEntryCommentDAO(fi.otavanopisto.pyramus.dao.students.StudentContactLogEntryCommentDAO) MatriculationExamEnrollmentDAO(fi.otavanopisto.pyramus.dao.matriculation.MatriculationExamEnrollmentDAO) MatriculationExamEnrollment(fi.otavanopisto.pyramus.domainmodel.matriculation.MatriculationExamEnrollment) StudentProject(fi.otavanopisto.pyramus.domainmodel.projects.StudentProject) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) Permissions(fi.otavanopisto.pyramus.security.impl.Permissions) StudentFile(fi.otavanopisto.pyramus.domainmodel.file.StudentFile) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit) Person(fi.otavanopisto.pyramus.domainmodel.base.Person) StudentContactLogEntryDAO(fi.otavanopisto.pyramus.dao.students.StudentContactLogEntryDAO) StringWriter(java.io.StringWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest) StudentFileDAO(fi.otavanopisto.pyramus.dao.file.StudentFileDAO) IOException(java.io.IOException) TransferCreditDAO(fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO) UserVariableDAO(fi.otavanopisto.pyramus.dao.users.UserVariableDAO) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO) PersonVariableKeyDAO(fi.otavanopisto.pyramus.dao.users.PersonVariableKeyDAO) PageRequestContext(fi.internetix.smvc.controllers.PageRequestContext) PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) StudentLodgingPeriodDAO(fi.otavanopisto.pyramus.dao.students.StudentLodgingPeriodDAO) StudentGroup(fi.otavanopisto.pyramus.domainmodel.students.StudentGroup) JSONArray(net.sf.json.JSONArray) Subject(fi.otavanopisto.pyramus.domainmodel.base.Subject) StudentContactLogEntry(fi.otavanopisto.pyramus.domainmodel.students.StudentContactLogEntry) Comparator(java.util.Comparator) Collections(java.util.Collections) DAOFactory(fi.otavanopisto.pyramus.dao.DAOFactory) StudentTOR(fi.otavanopisto.pyramus.tor.StudentTOR) ArrayList(java.util.ArrayList) UserVariable(fi.otavanopisto.pyramus.domainmodel.users.UserVariable) StudentProjectDAO(fi.otavanopisto.pyramus.dao.projects.StudentProjectDAO) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) StudentImageDAO(fi.otavanopisto.pyramus.dao.students.StudentImageDAO) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) JSONObject(net.sf.json.JSONObject) StudentProjectModule(fi.otavanopisto.pyramus.domainmodel.projects.StudentProjectModule) Person(fi.otavanopisto.pyramus.domainmodel.base.Person) MatriculationExamEnrollmentDAO(fi.otavanopisto.pyramus.dao.matriculation.MatriculationExamEnrollmentDAO) StudentContactLogEntryCommentDAO(fi.otavanopisto.pyramus.dao.students.StudentContactLogEntryCommentDAO) TransferCreditDAO(fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO) StringWriter(java.io.StringWriter) PersonVariableKeyDAO(fi.otavanopisto.pyramus.dao.users.PersonVariableKeyDAO) CurriculumDAO(fi.otavanopisto.pyramus.dao.base.CurriculumDAO) PersonVariable(fi.otavanopisto.pyramus.domainmodel.users.PersonVariable) IOException(java.io.IOException) CourseAssessment(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment) StudentGroupDAO(fi.otavanopisto.pyramus.dao.students.StudentGroupDAO) StudentTOR(fi.otavanopisto.pyramus.tor.StudentTOR) Curriculum(fi.otavanopisto.pyramus.domainmodel.base.Curriculum) StudentStudyPeriod(fi.otavanopisto.pyramus.domainmodel.students.StudentStudyPeriod) StudentProject(fi.otavanopisto.pyramus.domainmodel.projects.StudentProject) StudentFile(fi.otavanopisto.pyramus.domainmodel.file.StudentFile) HashMap(java.util.HashMap) StudentContactLogEntryDAO(fi.otavanopisto.pyramus.dao.students.StudentContactLogEntryDAO) StudentContactLogEntry(fi.otavanopisto.pyramus.domainmodel.students.StudentContactLogEntry) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) StudentLodgingPeriodDAO(fi.otavanopisto.pyramus.dao.students.StudentLodgingPeriodDAO) PersonDAO(fi.otavanopisto.pyramus.dao.base.PersonDAO) CreditLink(fi.otavanopisto.pyramus.domainmodel.grading.CreditLink) List(java.util.List) ArrayList(java.util.ArrayList) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course) EducationalLength(fi.otavanopisto.pyramus.domainmodel.base.EducationalLength) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) StudentFileDAO(fi.otavanopisto.pyramus.dao.file.StudentFileDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO) StudentContactLogEntryComment(fi.otavanopisto.pyramus.domainmodel.students.StudentContactLogEntryComment) ProjectAssessment(fi.otavanopisto.pyramus.domainmodel.grading.ProjectAssessment) ProjectAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.ProjectAssessmentDAO) PersonVariableKey(fi.otavanopisto.pyramus.domainmodel.users.PersonVariableKey) StringAttributeComparator(fi.otavanopisto.pyramus.util.StringAttributeComparator) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) UserVariableDAO(fi.otavanopisto.pyramus.dao.users.UserVariableDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) StudentStudyPeriodDAO(fi.otavanopisto.pyramus.dao.students.StudentStudyPeriodDAO) Report(fi.otavanopisto.pyramus.domainmodel.reports.Report) JSONArray(net.sf.json.JSONArray) CreditLinkDAO(fi.otavanopisto.pyramus.dao.grading.CreditLinkDAO) Date(java.util.Date) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) IOException(java.io.IOException) StudentLodgingPeriod(fi.otavanopisto.pyramus.domainmodel.students.StudentLodgingPeriod) PersonVariableDAO(fi.otavanopisto.pyramus.dao.users.PersonVariableDAO) TransferCredit(fi.otavanopisto.pyramus.domainmodel.grading.TransferCredit) ReportDAO(fi.otavanopisto.pyramus.dao.reports.ReportDAO) JsonGenerationException(com.fasterxml.jackson.core.JsonGenerationException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 34 with CourseStudentDAO

use of fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO in project pyramus by otavanopisto.

the class StudentCourseAssessmentRequestsPopupViewController method process.

public void process(PageRequestContext pageRequestContext) {
    CourseAssessmentRequestDAO courseAssessmentRequestDAO = DAOFactory.getInstance().getCourseAssessmentRequestDAO();
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    Long courseStudentId = pageRequestContext.getLong("courseStudent");
    CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
    List<CourseAssessmentRequest> courseAssessmentRequests = courseAssessmentRequestDAO.listByCourseStudent(courseStudent);
    Collections.sort(courseAssessmentRequests, new Comparator<CourseAssessmentRequest>() {

        @Override
        public int compare(CourseAssessmentRequest o1, CourseAssessmentRequest o2) {
            return o2.getCreated().compareTo(o1.getCreated());
        }
    });
    pageRequestContext.getRequest().setAttribute("courseStudent", courseStudent);
    pageRequestContext.getRequest().setAttribute("courseAssessmentRequests", courseAssessmentRequests);
    pageRequestContext.setIncludeJSP("/templates/students/studentcourseassessmentrequestspopup.jsp");
}
Also used : CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequestDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentRequestDAO) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)

Aggregations

CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)34 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)30 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)16 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)16 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)14 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)14 CourseAssessmentDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)9 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)9 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)9 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)8 Currency (java.util.Currency)8 HashMap (java.util.HashMap)8 CourseParticipationTypeDAO (fi.otavanopisto.pyramus.dao.courses.CourseParticipationTypeDAO)7 Room (fi.otavanopisto.pyramus.domainmodel.accommodation.Room)7 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)7 Date (java.util.Date)7 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)6 CourseOptionality (fi.otavanopisto.pyramus.domainmodel.base.CourseOptionality)6 BigDecimal (java.math.BigDecimal)6 Locale (java.util.Locale)6