3 * Class defining the default rights related to operations on studies.
4 * On the contrary of documents, a study cannot directly be reviewed or approved. It is reviewed or approved through
7 * @author Daniel Brunier-Coulin
8 * @copyright OPEN CASCADE 2012
11 import org.splat.dal.bo.kernel.User;
12 import org.splat.dal.bo.som.ProgressState;
13 import org.splat.dal.bo.som.Study;
14 import org.splat.service.ServiceLocatorImpl;
17 public class StudyRights {
20 private Study operand;
21 private boolean author = false; // For optimizing
22 public StudyRights (User user, Study study) {
23 // -------------------------------------------
26 this.author = operand.getAuthor().equals(user); // user may be null
28 public StudyRights (Study study) {
29 // --------------------------------
30 this.user = study.getAuthor();
32 this.author = true; // In order to ignore the author in this context
35 // ==============================================================================================================================
36 // Public member functions
37 // ==============================================================================================================================
39 public boolean canAddScenario () {
40 // --------------------------------
41 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
42 return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
46 * Checks if the user has right to edit the description of the study.
47 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
49 * @return true if the user has right to edit the description.
51 public boolean canEditDescription () {
52 // ------------------------------------
53 return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
56 public boolean canEditProperties () {
57 // -----------------------------------
62 * Checks if the user has right to move the study from the Private to the Public area of the repository.
63 * Only the author of the study have such right.
65 * @return true if the user has right to edit the description.
67 public boolean canPublish () {
68 // ----------------------------
69 if (!author) return false;
70 return (!operand.isPublic());
73 public boolean canPurge () {
74 // --------------------------
75 if (!author) return false;
76 return operand.isVersioned();
79 public boolean canRemove () {
80 // ---------------------------
81 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
85 public boolean canVersion () {
86 // ----------------------------
87 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
88 return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
91 // ==============================================================================================================================
93 // ==============================================================================================================================
95 public Study getOperand () {
96 // --------------------------