Search in sources :

Example 96 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class UserUtils method getHighestPersonRole.

public static Role getHighestPersonRole(Person person) {
    List<StaffMember> staffMembers = person.getStaffMembers();
    Role role = Role.EVERYONE;
    for (StaffMember staffMember : staffMembers) {
        if (isHigherOrEqualRole(staffMember.getRole(), role))
            role = staffMember.getRole();
    }
    return role;
}
Also used : Role(fi.otavanopisto.pyramus.domainmodel.users.Role) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember)

Example 97 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class StaffMemberDAO method listByUserVariable.

public List<StaffMember> listByUserVariable(String key, String value) {
    UserVariableKeyDAO variableKeyDAO = DAOFactory.getInstance().getUserVariableKeyDAO();
    UserVariableKey userVariableKey = variableKeyDAO.findByVariableKey(key);
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<StaffMember> criteria = criteriaBuilder.createQuery(StaffMember.class);
    Root<UserVariable> uvRoot = criteria.from(UserVariable.class);
    Root<StaffMember> smRoot = criteria.from(StaffMember.class);
    Join<UserVariable, User> userJoin = uvRoot.join(UserVariable_.user);
    criteria.select(smRoot);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(uvRoot.get(UserVariable_.user), smRoot), criteriaBuilder.equal(uvRoot.get(UserVariable_.key), userVariableKey), criteriaBuilder.equal(uvRoot.get(UserVariable_.value), value), criteriaBuilder.equal(userJoin.get(User_.archived), Boolean.FALSE)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) User(fi.otavanopisto.pyramus.domainmodel.users.User) UserVariableKey(fi.otavanopisto.pyramus.domainmodel.users.UserVariableKey) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember) UserVariable(fi.otavanopisto.pyramus.domainmodel.users.UserVariable)

Example 98 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class StaffMemberDAO method listByProperty.

public List<StaffMember> listByProperty(String key, String value) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<StaffMember> criteria = criteriaBuilder.createQuery(StaffMember.class);
    Root<StaffMember> root = criteria.from(StaffMember.class);
    MapJoin<StaffMember, String, String> props = root.join(StaffMember_.properties);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(StaffMember_.archived), Boolean.FALSE), criteriaBuilder.equal(props.key(), key), criteriaBuilder.equal(props.value(), value)));
    return entityManager.createQuery(criteria).getResultList();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember)

Example 99 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class StaffMemberDAO method findByPerson.

public StaffMember findByPerson(Person person) {
    EntityManager entityManager = getEntityManager();
    CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
    CriteriaQuery<StaffMember> criteria = criteriaBuilder.createQuery(StaffMember.class);
    Root<StaffMember> root = criteria.from(StaffMember.class);
    criteria.select(root);
    criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(StaffMember_.person), person), criteriaBuilder.equal(root.get(StaffMember_.archived), Boolean.FALSE)));
    return getSingleResult(entityManager.createQuery(criteria));
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) FullTextEntityManager(org.hibernate.search.jpa.FullTextEntityManager) EntityManager(javax.persistence.EntityManager) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember)

Example 100 with StaffMember

use of fi.otavanopisto.pyramus.domainmodel.users.StaffMember in project pyramus by otavanopisto.

the class Person method getStaffMembers.

public List<StaffMember> getStaffMembers() {
    List<User> users = getUsers();
    List<StaffMember> staffMembers = new ArrayList<>();
    for (User user : users) {
        if (user instanceof StaffMember)
            staffMembers.add((StaffMember) user);
    }
    return staffMembers;
}
Also used : User(fi.otavanopisto.pyramus.domainmodel.users.User) ArrayList(java.util.ArrayList) StaffMember(fi.otavanopisto.pyramus.domainmodel.users.StaffMember)

Aggregations

StaffMember (fi.otavanopisto.pyramus.domainmodel.users.StaffMember)128 StaffMemberDAO (fi.otavanopisto.pyramus.dao.users.StaffMemberDAO)83 Student (fi.otavanopisto.pyramus.domainmodel.students.Student)38 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)26 Path (javax.ws.rs.Path)26 User (fi.otavanopisto.pyramus.domainmodel.users.User)25 Date (java.util.Date)24 StudentDAO (fi.otavanopisto.pyramus.dao.students.StudentDAO)23 Organization (fi.otavanopisto.pyramus.domainmodel.base.Organization)23 SmvcRuntimeException (fi.internetix.smvc.SmvcRuntimeException)22 CourseStudent (fi.otavanopisto.pyramus.domainmodel.courses.CourseStudent)20 Tag (fi.otavanopisto.pyramus.domainmodel.base.Tag)18 OrganizationDAO (fi.otavanopisto.pyramus.dao.base.OrganizationDAO)16 Course (fi.otavanopisto.pyramus.domainmodel.courses.Course)16 StudentGroup (fi.otavanopisto.pyramus.domainmodel.students.StudentGroup)16 ApplicationDAO (fi.otavanopisto.pyramus.dao.application.ApplicationDAO)14 Person (fi.otavanopisto.pyramus.domainmodel.base.Person)14 HashMap (java.util.HashMap)14 HashSet (java.util.HashSet)14 Curriculum (fi.otavanopisto.pyramus.domainmodel.base.Curriculum)13