package net.sourceforge.fenixedu.predicates; import net.sourceforge.fenixedu.applicationTier.IUserView; import net.sourceforge.fenixedu.domain.person.RoleType; import net.sourceforge.fenixedu.domain.research.result.ResearchResult; import net.sourceforge.fenixedu.domain.research.result.ResearchResultDocumentFile; import net.sourceforge.fenixedu.domain.research.result.ResultParticipation; import net.sourceforge.fenixedu.domain.research.result.ResultUnitAssociation; import net.sourceforge.fenixedu.injectionCode.AccessControl; import net.sourceforge.fenixedu.injectionCode.AccessControlPredicate; public class ResultPredicates { /** * Predicates to access Result objects. */ public static final AccessControlPredicate createPredicate = new AccessControlPredicate() { public boolean evaluate(ResearchResult result) { final IUserView userView = AccessControl.getUserView(); if (userView != null && (userView.hasRoleType(RoleType.SCIENTIFIC_COUNCIL) || (userView.hasRoleType(RoleType.RESEARCHER) && !result .hasAnyResultParticipations()))) { return true; } return false; } }; public static final AccessControlPredicate writePredicate = new AccessControlPredicate() { public boolean evaluate(ResearchResult result) { return result.isEditableByCurrentUser(); } }; /** * Predicates to access ResultUnitAssociation objects. */ public static final AccessControlPredicate unitWritePredicate = new AccessControlPredicate() { public boolean evaluate(ResultUnitAssociation association) { return writePredicate.evaluate(association.getResult()); } }; /** * Predicates to access ResultParticipation objects. */ public static final AccessControlPredicate participationWritePredicate = new AccessControlPredicate() { public boolean evaluate(ResultParticipation participation) { return writePredicate.evaluate(participation.getResult()); } }; /** * Predicates to access ResultDocumentFile objects. */ public static final AccessControlPredicate documentFileWritePredicate = new AccessControlPredicate() { public boolean evaluate(ResearchResultDocumentFile documentFile) { return writePredicate.evaluate(documentFile.getResult()); } }; }