Search in sources :

Example 21 with CourseStudent

use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.

the class CourseAssessmentRequestDAO method listByCourse.

public List<CourseAssessmentRequest> listByCourse(Course course) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseAssessmentRequest> criteria = criteriaBuilder.createQuery(CourseAssessmentRequest.class);
    Root<CourseAssessmentRequest> root = criteria.from(CourseAssessmentRequest.class);
    Join<CourseAssessmentRequest, CourseStudent> courseStudent = root.join(CourseAssessmentRequest_.courseStudent);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(courseStudent.get(CourseStudent_.course), course), criteriaBuilder.equal(courseStudent.get(CourseStudent_.archived), Boolean.FALSE), criteriaBuilder.equal(root.get(CourseAssessmentRequest_.archived), Boolean.FALSE)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)

Example 22 with CourseStudent

use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.

the class CourseAssessmentRequestDAO method listByCourseAndStudent.

/**
 * Lists all student's course assessments excluding archived ones
 *
 * @return list of all students course assessments
 */
public List<CourseAssessmentRequest> listByCourseAndStudent(Course course, Student student) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseAssessmentRequest> criteria = criteriaBuilder.createQuery(CourseAssessmentRequest.class);
    Root<CourseAssessmentRequest> root = criteria.from(CourseAssessmentRequest.class);
    Join<CourseAssessmentRequest, CourseStudent> courseStudentJoin = root.join(CourseAssessmentRequest_.courseStudent);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(courseStudentJoin.get(CourseStudent_.course), course), criteriaBuilder.equal(courseStudentJoin.get(CourseStudent_.student), student), criteriaBuilder.equal(root.get(CourseAssessmentRequest_.archived), Boolean.FALSE)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)

Example 23 with CourseStudent

use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.

the class CourseAssessmentRequestDAO method listByCourseAndHandled.

public List<CourseAssessmentRequest> listByCourseAndHandled(Course course, Boolean handled) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseAssessmentRequest> criteria = criteriaBuilder.createQuery(CourseAssessmentRequest.class);
    Root<CourseAssessmentRequest> root = criteria.from(CourseAssessmentRequest.class);
    Join<CourseAssessmentRequest, CourseStudent> courseStudent = root.join(CourseAssessmentRequest_.courseStudent);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(courseStudent.get(CourseStudent_.course), course), criteriaBuilder.equal(courseStudent.get(CourseStudent_.archived), Boolean.FALSE), criteriaBuilder.equal(root.get(CourseAssessmentRequest_.archived), Boolean.FALSE), criteriaBuilder.equal(root.get(CourseAssessmentRequest_.handled), handled)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)

Example 24 with CourseStudent

use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.

the class CourseAssessmentRequestDAO method listByStudent.

public List<CourseAssessmentRequest> listByStudent(Student student) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<CourseAssessmentRequest> criteria = criteriaBuilder.createQuery(CourseAssessmentRequest.class);
    Root<CourseAssessmentRequest> root = criteria.from(CourseAssessmentRequest.class);
    Join<CourseAssessmentRequest, CourseStudent> courseStudent = root.join(CourseAssessmentRequest_.courseStudent);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(courseStudent.get(CourseStudent_.student), student), criteriaBuilder.equal(root.get(CourseAssessmentRequest_.archived), Boolean.FALSE)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) CourseAssessmentRequest(fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)

Example 25 with CourseStudent

use of fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent in project pyramus by otavanopisto.

the class CourseStudentDetailsDialogViewController method process.

public void process(PageRequestContext pageRequestContext) {
    CourseStudentDAO courseStudentDAO = DAOFactory.getInstance().getCourseStudentDAO();
    RoomTypeDAO roomTypeDAO = DAOFactory.getInstance().getRoomTypeDAO();
    RoomDAO roomDAO = DAOFactory.getInstance().getRoomDAO();
    Long courseStudentId = pageRequestContext.getLong("courseStudentId");
    if (courseStudentId == null) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Missing courseStudentId parameter");
    }
    CourseStudent courseStudent = courseStudentDAO.findById(courseStudentId);
    if (courseStudent == null) {
        throw new SmvcRuntimeException(PyramusStatusCode.UNDEFINED, "Invalid courseStudentId parameter");
    }
    Map<RoomType, List<Room>> rooms = new TreeMap<>(new Comparator<RoomType>() {

        @Override
        public int compare(RoomType o1, RoomType o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    List<RoomType> roomTypes = roomTypeDAO.listAll();
    for (RoomType roomType : roomTypes) {
        List<Room> typeRooms = roomDAO.listByType(roomType);
        rooms.put(roomType, typeRooms);
    }
    // Support other currencies
    List<Currency> currencies = Arrays.asList(Currency.getInstance("EUR"));
    List<BillingDetails> existingBillingDetails = getExistingBillingDetails(courseStudent);
    pageRequestContext.getRequest().setAttribute("courseStudent", courseStudent);
    pageRequestContext.getRequest().setAttribute("rooms", rooms);
    pageRequestContext.getRequest().setAttribute("currencies", currencies);
    pageRequestContext.getRequest().setAttribute("existingBillingDetails", existingBillingDetails);
    pageRequestContext.setIncludeJSP("/templates/courses/studentdetailsdialog.jsp");
}
Also used : RoomDAO(fi.otavanopisto.pyramus.dao.accommodation.RoomDAO) CourseStudentDAO(fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO) SmvcRuntimeException(fi.internetix.smvc.SmvcRuntimeException) TreeMap(java.util.TreeMap) BillingDetails(fi.otavanopisto.pyramus.domainmodel.base.BillingDetails) RoomType(fi.otavanopisto.pyramus.domainmodel.accommodation.RoomType) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Currency(java.util.Currency) RoomTypeDAO(fi.otavanopisto.pyramus.dao.accommodation.RoomTypeDAO) ArrayList(java.util.ArrayList) List(java.util.List) Room(fi.otavanopisto.pyramus.domainmodel.accommodation.Room)

Aggregations

CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)75 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)39 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)33 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)29 EntityManager (javax.persistence.EntityManager)26 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)25 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)22 CourseAssessmentRequest (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)13 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)12 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)12 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)12 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)12 Path (javax.ws.rs.Path)12 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)11 Date (java.util.Date)10 CourseAssessmentDAO (fi.otavanopisto.pyramus.dao.grading.CourseAssessmentDAO)8 Grade (fi.otavanopisto.pyramus.domainmodel.grading.Grade)8 StudentGroupStudent (fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent)8 ArrayList (java.util.ArrayList)8 Currency (java.util.Currency)8