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 // -------------------------------------------
27 if (operand != null && operand.getAuthor() != null) {
28 this.author = operand.getAuthor().equals(user); // user may be null
31 public StudyRights (Study study) {
32 // --------------------------------
33 this.user = study.getAuthor();
35 this.author = true; // In order to ignore the author in this context
38 // ==============================================================================================================================
39 // Public member functions
40 // ==============================================================================================================================
42 public boolean canAddScenario () {
43 // --------------------------------
44 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
45 return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
49 * Checks if the user has right to edit the description of the study.
50 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
52 * @return true if the user has right to edit the description.
54 public boolean canEditDescription () {
55 // ------------------------------------
56 return (operand.getAuthor().equals(user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(operand, user));
59 public boolean canEditProperties () {
60 // -----------------------------------
65 * Checks if the user has right to move the study from the Private to the Public area of the repository.
66 * Only the author of the study have such right.
68 * @return true if the user has right to edit the description.
70 public boolean canPublish () {
71 // ----------------------------
72 if (!author) return false;
73 return (!operand.isPublic());
76 public boolean canPurge () {
77 // --------------------------
78 if (!author) return false;
79 return operand.isVersioned();
82 public boolean canRemove () {
83 // ---------------------------
84 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
88 public boolean canVersion () {
89 // ----------------------------
90 if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
91 return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(operand, user);
94 // ==============================================================================================================================
96 // ==============================================================================================================================
98 public Study getOperand () {
99 // --------------------------