]> SALOME platform Git repositories - tools/siman.git/blob - Workspace/SPlat/src/org/splat/som/StudyRights.java
Salome HOME
XML comment is fixed
[tools/siman.git] / Workspace / SPlat / src / org / splat / som / StudyRights.java
1 package org.splat.som;
2 /**
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
5  * its final report.
6  * 
7  * @author    Daniel Brunier-Coulin
8  * @copyright OPEN CASCADE 2012
9  */
10
11 import org.splat.kernel.User;
12
13
14 public class StudyRights {
15
16     private User     user;
17     private Study    operand;
18     private boolean  author = false;                    // For optimizing 
19
20 //  ==============================================================================================================================
21 //  Construction
22 //  ==============================================================================================================================
23
24     public StudyRights (User user, Study study) {
25 //  -------------------------------------------
26       this.user    = user;
27       this.operand = study;
28       this.author  = operand.getAuthor().equals(user);  // user may be null
29     }
30     public StudyRights (Study study) {
31 //  --------------------------------
32       this.user    = study.getAuthor();
33       this.operand = study;
34       this.author  = true;                              // In order to ignore the author in this context
35     }
36
37 //  ==============================================================================================================================
38 //  Public member functions
39 //  ==============================================================================================================================
40
41     public boolean canAddScenario () {
42 //  --------------------------------
43       if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
44       return operand.isStaffedBy(user);
45     }
46
47 /**
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.
50  * 
51  * @return true if the user has right to edit the description.
52  */
53     public boolean canEditDescription () {
54 //  ------------------------------------
55       return (operand.getAuthor().equals(user) || operand.hasActor(user));
56     }
57
58     public boolean canEditProperties () {
59 //  -----------------------------------
60       return author;
61     }
62
63 /**
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.
66  * 
67  * @return true if the user has right to edit the description.
68  */
69     public boolean canPublish () {
70 //  ----------------------------
71       if (!author) return false;
72       return (!operand.isPublic());
73     }
74
75     public boolean canPurge () {
76 //  --------------------------
77       if (!author) return false;
78       return operand.isVersioned();
79     }
80
81     public boolean canRemove () {
82 //  ---------------------------
83       if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
84       return author;
85     }
86
87     public boolean canVersion () {
88 //  ----------------------------
89       if (operand.getProgressState() != ProgressState.inWORK && operand.getProgressState() != ProgressState.inDRAFT) return false;
90       return operand.isStaffedBy(user);
91     }
92
93 //  ==============================================================================================================================
94 //  Getter
95 //  ==============================================================================================================================
96
97     public Study getOperand () {
98 //  --------------------------
99       return operand;
100     }
101 }