use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.
the class CourseDAO method listByStaffMember.
public List<Course> listByStaffMember(StaffMember staffMember) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Course> criteria = criteriaBuilder.createQuery(Course.class);
Root<CourseStaffMember> root = criteria.from(CourseStaffMember.class);
criteria.select(root.get(CourseStaffMember_.course));
criteria.where(criteriaBuilder.equal(root.get(CourseStaffMember_.staffMember), staffMember));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.
the class CourseDAO method listBySubject.
public List<Course> listBySubject(Subject subject) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Course> criteria = criteriaBuilder.createQuery(Course.class);
Root<Course> root = criteria.from(Course.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(Course_.archived), Boolean.FALSE), criteriaBuilder.equal(root.get(Course_.subject), subject)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.
the class CourseDAO method listByModule.
public List<Course> listByModule(Module module) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Course> criteria = criteriaBuilder.createQuery(Course.class);
Root<Course> root = criteria.from(Course.class);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(Course_.archived), Boolean.FALSE), criteriaBuilder.equal(root.get(Course_.module), module)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.
the class CourseDAO method listByCourseVariable.
public List<Course> listByCourseVariable(String key, String value) {
CourseBaseVariableKeyDAO variableKeyDAO = DAOFactory.getInstance().getCourseBaseVariableKeyDAO();
CourseBaseVariableKey courseBaseVariableKey = variableKeyDAO.findByVariableKey(key);
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Course> criteria = criteriaBuilder.createQuery(Course.class);
Root<CourseBaseVariable> variable = criteria.from(CourseBaseVariable.class);
Root<Course> course = criteria.from(Course.class);
criteria.select(course);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(course, variable.get(CourseBaseVariable_.courseBase)), criteriaBuilder.equal(course.get(Course_.archived), Boolean.FALSE), criteriaBuilder.equal(variable.get(CourseBaseVariable_.key), courseBaseVariableKey), criteriaBuilder.equal(variable.get(CourseBaseVariable_.value), value)));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.pyramus.domainmodel.courses.Course in project pyramus by otavanopisto.
the class CourseStudentDAO method listByModuleAndStudent.
public List<CourseStudent> listByModuleAndStudent(Module module, Student student) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<CourseStudent> criteria = criteriaBuilder.createQuery(CourseStudent.class);
Root<CourseStudent> root = criteria.from(CourseStudent.class);
Join<CourseStudent, Student> studentJoin = root.join(CourseStudent_.student);
Join<CourseStudent, Course> courseJoin = root.join(CourseStudent_.course);
criteria.select(root);
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(courseJoin.get(Course_.module), module), criteriaBuilder.equal(root.get(CourseStudent_.student), student), criteriaBuilder.equal(root.get(CourseStudent_.archived), Boolean.FALSE), criteriaBuilder.equal(courseJoin.get(Course_.archived), Boolean.FALSE), criteriaBuilder.equal(studentJoin.get(Student_.archived), Boolean.FALSE)));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations