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 {
19 private final transient User _user;
20 private final transient Study _operand;
21 private transient boolean _author = false; // For optimizing
22 public StudyRights (final User user, final Study study) {
23 // -------------------------------------------
25 this._operand = study;
27 if (_operand != null && _operand.getAuthor() != null) {
28 this._author = _operand.getAuthor().equals(user); // user may be null
31 public StudyRights (final Study study) {
32 // --------------------------------
33 this._user = study.getAuthor();
34 this._operand = study;
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) {
47 return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
51 * Checks if the user has right to edit the description of the study.
52 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
54 * @return true if the user has right to edit the description.
56 public boolean canEditDescription () {
57 // ------------------------------------
58 return (_operand.getAuthor().equals(_user) || ServiceLocatorImpl.getInstance().getStudyService().hasActor(_operand, _user));
61 public boolean canEditProperties () {
62 // -----------------------------------
67 * Checks if the user has right to move the study from the Private to the Public area of the repository.
68 * Only the author of the study have such right.
70 * @return true if the user has right to edit the description.
72 public boolean canPublish () {
73 // ----------------------------
77 return (!_operand.isPublic());
80 public boolean canPurge () {
81 // --------------------------
85 return _operand.isVersioned();
88 public boolean canRemove () {
89 // ---------------------------
90 if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
96 public boolean canVersion () {
97 // ----------------------------
98 if (_operand.getProgressState() != ProgressState.inWORK && _operand.getProgressState() != ProgressState.inDRAFT) {
101 return ServiceLocatorImpl.getInstance().getStudyService().isStaffedBy(_operand, _user);
104 // ==============================================================================================================================
106 // ==============================================================================================================================
108 public Study getOperand () {
109 // --------------------------