package net.sourceforge.fenixedu.predicates; import net.sourceforge.fenixedu.domain.Person; import net.sourceforge.fenixedu.domain.person.RoleType; import net.sourceforge.fenixedu.injectionCode.AccessControl; import net.sourceforge.fenixedu.injectionCode.AccessControlPredicate; public class RolePredicates { public static final AccessControlPredicate ACADEMIC_ADMINISTRATIVE_OFFICE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.ACADEMIC_ADMINISTRATIVE_OFFICE); }; }; public static final AccessControlPredicate BOLONHA_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.BOLONHA_MANAGER); }; }; public static final AccessControlPredicate COORDINATOR_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.COORDINATOR); }; }; public static final AccessControlPredicate CREDITS_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.CREDITS_MANAGER); }; }; public static final AccessControlPredicate DEGREE_ADMINISTRATIVE_OFFICE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.DEGREE_ADMINISTRATIVE_OFFICE); }; }; public static final AccessControlPredicate DEGREE_ADMINISTRATIVE_OFFICE_SUPER_USER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.DEGREE_ADMINISTRATIVE_OFFICE_SUPER_USER); }; }; public static final AccessControlPredicate DELEGATE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.DELEGATE); }; }; public static final AccessControlPredicate DEPARTMENT_ADMINISTRATIVE_OFFICE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.DEPARTMENT_ADMINISTRATIVE_OFFICE); }; }; public static final AccessControlPredicate DEPARTMENT_CREDITS_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.DEPARTMENT_CREDITS_MANAGER); }; }; public static final AccessControlPredicate DEPARTMENT_MEMBER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.DEPARTMENT_MEMBER); }; }; public static final AccessControlPredicate DIRECTIVE_COUNCIL_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object object) { return hasRole(RoleType.DIRECTIVE_COUNCIL); }; }; public static final AccessControlPredicate EMPLOYEE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.EMPLOYEE); }; }; public static final AccessControlPredicate GEP_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.GEP); }; }; public static final AccessControlPredicate GRANT_OWNER_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.GRANT_OWNER_MANAGER); }; }; public static final AccessControlPredicate LIBRARY_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.LIBRARY); }; }; public static final AccessControlPredicate MANAGER_OR_ACADEMIC_ADMINISTRATIVE_OFFICE_OR_GRANT_OWNER_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return MANAGER_PREDICATE.evaluate(domainObject) || ACADEMIC_ADMINISTRATIVE_OFFICE_PREDICATE.evaluate(domainObject) || GRANT_OWNER_MANAGER_PREDICATE.evaluate(domainObject); }; }; public static final AccessControlPredicate MANAGER_OR_ACADEMIC_ADMINISTRATIVE_OFFICE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return MANAGER_PREDICATE.evaluate(domainObject) || ACADEMIC_ADMINISTRATIVE_OFFICE_PREDICATE.evaluate(domainObject); }; }; public static final AccessControlPredicate MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.MANAGER); }; }; public static final AccessControlPredicate MASTER_DEGREE_ADMINISTRATIVE_OFFICE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.MASTER_DEGREE_ADMINISTRATIVE_OFFICE); }; }; public static final AccessControlPredicate MASTER_DEGREE_CANDIDATE_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.MASTER_DEGREE_CANDIDATE); }; }; public static final AccessControlPredicate OPERATOR_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.OPERATOR); }; }; public static final AccessControlPredicate PARKING_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.PARKING_MANAGER); }; }; public static final AccessControlPredicate PEDAGOGICAL_COUNCIL_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.PEDAGOGICAL_COUNCIL); }; }; public static final AccessControlPredicate PERSON_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.PERSON); }; }; public static final AccessControlPredicate PERSONNEL_SECTION_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.PERSONNEL_SECTION); }; }; public static final AccessControlPredicate RESEARCHER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.RESEARCHER); }; }; public static final AccessControlPredicate RESOURCE_ALLOCATION_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.RESOURCE_ALLOCATION_MANAGER); }; }; public static final AccessControlPredicate RESOURCE_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.RESOURCE_MANAGER); }; }; public static final AccessControlPredicate SCIENTIFIC_COUNCIL_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.SCIENTIFIC_COUNCIL); }; }; public static final AccessControlPredicate SEMINARIES_COORDINATOR_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.SEMINARIES_COORDINATOR); }; }; public static final AccessControlPredicate SPACE_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.SPACE_MANAGER); }; }; public static final AccessControlPredicate STUDENT_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.STUDENT); }; }; public static final AccessControlPredicate TEACHER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.TEACHER); }; }; public static final AccessControlPredicate STUDENT_AND_TEACHER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.TEACHER) || hasRole(RoleType.STUDENT); }; }; public static final AccessControlPredicate TREASURY_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.TREASURY); }; }; public static final AccessControlPredicate WEBSITE_MANAGER_PREDICATE = new AccessControlPredicate() { public boolean evaluate(Object domainObject) { return hasRole(RoleType.WEBSITE_MANAGER); }; }; private static boolean hasRole(final RoleType roleType) { final Person person = AccessControl.getPerson(); return person != null && person.hasRole(roleType); } }