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.kernel.User;
14 public class StudyRights {
17 private Study operand;
18 private boolean author = false; // For optimizing
20 // ==============================================================================================================================
22 // ==============================================================================================================================
24 public StudyRights (User user, Study study) {
25 // -------------------------------------------
28 this.author = operand.getAuthor().equals(user); // user may be null
30 public StudyRights (Study study) {
31 // --------------------------------
32 this.user = study.getAuthor();
34 this.author = true; // In order to ignore the author in this context
37 // ==============================================================================================================================
38 // Public member functions
39 // ==============================================================================================================================
41 public boolean canAddScenario () {
42 // --------------------------------
43 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
44 return operand.isStaffedBy(user);
48 * Checks if the user has right to edit the description of the study.
49 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
51 * @return true if the user has right to edit the description.
53 public boolean canEditDescription () {
54 // ------------------------------------
55 return (operand.getAuthor().equals(user) || operand.hasActor(user));
58 public boolean canEditProperties () {
59 // -----------------------------------
64 * Checks if the user has right to move the study from the Private to the Public area of the repository.
65 * Only the author of the study have such right.
67 * @return true if the user has right to edit the description.
69 public boolean canPublish () {
70 // ----------------------------
71 if (!author) return false;
72 return (!operand.isPublic());
75 public boolean canPurge () {
76 // --------------------------
77 if (!author) return false;
78 return operand.isVersioned();
81 public boolean canRemove () {
82 // ---------------------------
83 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
87 public boolean canVersion () {
88 // ----------------------------
89 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
90 return operand.isStaffedBy(user);
93 // ==============================================================================================================================
95 // ==============================================================================================================================
97 public Study getOperand () {
98 // --------------------------