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