Search in sources :

Example 96 with Course

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) CourseStaffMember(fi.otavanopisto.pyramus.domainmodel.courses.CourseStaffMember) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Example 97 with Course

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Example 98 with Course

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Example 99 with Course

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) CourseBaseVariableKey(fi.otavanopisto.pyramus.domainmodel.base.CourseBaseVariableKey) CourseBaseVariable(fi.otavanopisto.pyramus.domainmodel.base.CourseBaseVariable) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) CourseBaseVariableKeyDAO(fi.otavanopisto.pyramus.dao.base.CourseBaseVariableKeyDAO) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Example 100 with Course

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Student(fi.otavanopisto.pyramus.domainmodel.students.Student) CourseStudent(fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent) Course(fi.otavanopisto.pyramus.domainmodel.courses.Course)

Aggregations

Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)111 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)50 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)44 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)44 Path (javax.ws.rs.Path)44 CourseDAO (fi.otavanopisto.pyramus.dao.courses.CourseDAO)34 CourseAssessment (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessment)25 GET (javax.ws.rs.GET)23 Subject (fi.otavanopisto.pyramus.domainmodel.base.Subject)20 Date (java.util.Date)20 CourseStudentDAO (fi.otavanopisto.pyramus.dao.courses.CourseStudentDAO)18 StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)18 HashMap (java.util.HashMap)18 ArrayList (java.util.ArrayList)17 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)16 EducationalTimeUnit (fi.otavanopisto.pyramus.domainmodel.base.EducationalTimeUnit)14 EntityManager (javax.persistence.EntityManager)14 CourseParticipationType (fi.otavanopisto.pyramus.domainmodel.courses.CourseParticipationType)13 CourseAssessmentRequest (fi.otavanopisto.pyramus.domainmodel.grading.CourseAssessmentRequest)13 StudentGroupStudent (fi.otavanopisto.pyramus.domainmodel.students.StudentGroupStudent)13