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;
16 public class StudyRights {
19 private Study operand;
20 private boolean author = false; // For optimizing
22 // ==============================================================================================================================
24 // ==============================================================================================================================
26 public StudyRights (User user, Study study) {
27 // -------------------------------------------
30 this.author = operand.getAuthor().equals(user); // user may be null
32 public StudyRights (Study study) {
33 // --------------------------------
34 this.user = study.getAuthor();
36 this.author = true; // In order to ignore the author in this context
39 // ==============================================================================================================================
40 // Public member functions
41 // ==============================================================================================================================
43 public boolean canAddScenario () {
44 // --------------------------------
45 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
46 return operand.isStaffedBy(user);
50 * Checks if the user has right to edit the description of the study.
51 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
53 * @return true if the user has right to edit the description.
55 public boolean canEditDescription () {
56 // ------------------------------------
57 return (operand.getAuthor().equals(user) || operand.hasActor(user));
60 public boolean canEditProperties () {
61 // -----------------------------------
66 * Checks if the user has right to move the study from the Private to the Public area of the repository.
67 * Only the author of the study have such right.
69 * @return true if the user has right to edit the description.
71 public boolean canPublish () {
72 // ----------------------------
73 if (!author) return false;
74 return (!operand.isPublic());
77 public boolean canPurge () {
78 // --------------------------
79 if (!author) return false;
80 return operand.isVersioned();
83 public boolean canRemove () {
84 // ---------------------------
85 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
89 public boolean canVersion () {
90 // ----------------------------
91 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
92 return operand.isStaffedBy(user);
95 // ==============================================================================================================================
97 // ==============================================================================================================================
99 public Study getOperand () {
100 // --------------------------