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();
}
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();
}
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();
}
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();
}
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");
}
Aggregations