Search in sources :

Example 41 with StudyProgramme

use of fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme in project pyramus by otavanopisto.

the class ChangeStudentStudyProgrammeJSONRequestController method process.

public void process(JSONRequestContext requestContext) {
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
    StaffMember loggedUser = staffMemberDAO.findById(requestContext.getLoggedUserId());
    Long studentId = requestContext.getLong("studentId");
    Long studyProgrammeId = requestContext.getLong("studyProgrammeId");
    Student student = studentDAO.findById(studentId);
    StudyProgramme studyProgramme = studyProgrammeDAO.findById(studyProgrammeId);
    if (!(UserUtils.canAccessOrganization(loggedUser, student.getOrganization()) && UserUtils.canAccessOrganization(loggedUser, studyProgramme.getOrganization()))) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNAUTHORIZED, "Invalid studyprogramme.");
    }
    Long oldStudyProgrammeId = student.getStudyProgramme() != null ? student.getStudyProgramme().getId() : null;
    logger.info(String.format("Changing study programme for student %d from %d to %d.", studentId, oldStudyProgrammeId, studyProgrammeId));
    KoskiClient client = CDI.current().select(KoskiClient.class).get();
    try {
        client.invalidateAllStudentOIDs(student);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, String.format("Invalidation of study permits for student %d failed", studentId), ex);
    }
    studentDAO.updateStudyProgramme(student, studyProgramme);
}
Also used : StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) KoskiClient(fi.otavanopisto.pyramus.koski.KoskiClient) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) StudyProgramme(fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StudyProgrammeDAO(fi.otavanopisto.pyramus.dao.base.StudyProgrammeDAO) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException)

Example 42 with StudyProgramme

use of fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme in project pyramus by otavanopisto.

the class StudyProgrammeCopyPopupViewController method process.

/**
 * Processes the page request.
 */
public void process(PageRequestContext pageRequestContext) {
    TransferCreditDAO transferCreditDAO = DAOFactory.getInstance().getTransferCreditDAO();
    CourseAssessmentDAO courseAssessmentDAO = DAOFactory.getInstance().getCourseAssessmentDAO();
    CreditLinkDAO creditLinkDAO = DAOFactory.getInstance().getCreditLinkDAO();
    StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    Long studentId = pageRequestContext.getLong("student");
    Student student = studentDAO.findById(studentId);
    StaffMember loggedUser = staffMemberDAO.findById(pageRequestContext.getLoggedUserId());
    List<StudyProgramme> studyProgrammes = UserUtils.canAccessAllOrganizations(loggedUser) ? studyProgrammeDAO.listUnarchived() : studyProgrammeDAO.listByOrganization(loggedUser.getOrganization(), Archived.UNARCHIVED);
    Collections.sort(studyProgrammes, new StringAttributeComparator("getName"));
    Long courseAssessmentCount = courseAssessmentDAO.countByStudent(student);
    Long transferCreditCount = transferCreditDAO.countByStudent(student);
    Long creditLinkCount = creditLinkDAO.countByStudent(student);
    pageRequestContext.getRequest().setAttribute("courseAssessmentCount", courseAssessmentCount);
    pageRequestContext.getRequest().setAttribute("transferCreditCount", transferCreditCount);
    pageRequestContext.getRequest().setAttribute("creditLinkCount", creditLinkCount);
    pageRequestContext.getRequest().setAttribute("studyProgrammes", studyProgrammes);
    pageRequestContext.setIncludeJSP("/templates/students/studyprogrammecopypopup.jsp");
}
Also used : StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) TransferCreditDAO(fi.otavanopisto.pyramus.dao.grading.TransferCreditDAO) StudyProgramme(fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme) CourseAssessmentDAO(fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO) StringAttributeComparator(fi.otavanopisto.pyramus.util.StringAttributeComparator) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) CreditLinkDAO(fi.otavanopisto.pyramus.dao.grading.CreditLinkDAO) StudyProgrammeDAO(fi.otavanopisto.pyramus.dao.base.StudyProgrammeDAO)

Example 43 with StudyProgramme

use of fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme in project pyramus by otavanopisto.

the class ChangeStudentStudyProgammeDialogViewController method process.

public void process(PageRequestContext requestContext) {
    StaffMemberDAO staffMemberDAO = DAOFactory.getInstance().getStaffMemberDAO();
    StudyProgrammeDAO studyProgrammeDAO = DAOFactory.getInstance().getStudyProgrammeDAO();
    StudentDAO studentDAO = DAOFactory.getInstance().getStudentDAO();
    Long studentId = requestContext.getLong("studentId");
    if (studentId == null) {
        logger.log(Level.WARNING, "Unable to load dialog with missing studentId.");
        try {
            requestContext.getResponse().sendError(HttpServletResponse.SC_BAD_REQUEST);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Error sending response", e);
        }
        return;
    }
    StaffMember loggedUser = staffMemberDAO.findById(requestContext.getLoggedUserId());
    Student student = studentDAO.findById(studentId);
    if (!UserUtils.canAccessOrganization(loggedUser, student.getOrganization())) {
        try {
            requestContext.getResponse().sendError(HttpServletResponse.SC_FORBIDDEN);
        } catch (Exception e) {
            logger.log(Level.SEVERE, "Error sending response", e);
        }
        return;
    }
    List<StudyProgramme> studyProgrammes = UserUtils.canAccessAllOrganizations(loggedUser) ? studyProgrammeDAO.listUnarchived() : studyProgrammeDAO.listByOrganization(loggedUser.getOrganization(), Archived.UNARCHIVED);
    Collections.sort(studyProgrammes, new StringAttributeComparator("getName"));
    requestContext.getRequest().setAttribute("student", student);
    requestContext.getRequest().setAttribute("studyProgrammes", studyProgrammes);
    requestContext.setIncludeJSP("/templates/students/changestudentstudyprogrammedialog.jsp");
}
Also used : StudentDAO(fi.otavanopisto.pyramus.dao.students.StudentDAO) StaffMemberDAO(fi.otavanopisto.pyramus.dao.users.StaffMemberDAO) StudyProgramme(fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme) StringAttributeComparator(fi.otavanopisto.pyramus.util.StringAttributeComparator) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) StudyProgrammeDAO(fi.otavanopisto.pyramus.dao.base.StudyProgrammeDAO)

Aggregations

StudyProgramme (fi.otavanopisto.pyramus.domainmodel.base.StudyProgramme)43 StudyProgrammeDAO (fi.otavanopisto.pyramus.dao.base.StudyProgrammeDAO)26 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)21 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)15 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)14 Person (fi.otavanopisto.pyramus.domainmodel.base.Person)14 Language (fi.otavanopisto.pyramus.domainmodel.base.Language)13 Municipality (fi.otavanopisto.pyramus.domainmodel.base.Municipality)13 Nationality (fi.otavanopisto.pyramus.domainmodel.base.Nationality)13 School (fi.otavanopisto.pyramus.domainmodel.base.School)12 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)12 PersonDAO (fi.otavanopisto.pyramus.dao.base.PersonDAO)10 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)9 StudentActivityType (fi.otavanopisto.pyramus.domainmodel.students.StudentActivityType)9 StudentEducationalLevel (fi.otavanopisto.pyramus.domainmodel.students.StudentEducationalLevel)9 StudentExaminationType (fi.otavanopisto.pyramus.domainmodel.students.StudentExaminationType)9 StudentStudyEndReason (fi.otavanopisto.pyramus.domainmodel.students.StudentStudyEndReason)9 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)8 Path (javax.ws.rs.Path)8 ContactType (fi.otavanopisto.pyramus.domainmodel.base.ContactType)7