3 * Class defining the default rights related to operations on study steps.
5 * @author Daniel Brunier-Coulin
6 * @copyright OPEN CASCADE 2012
8 //TODO: Review this rights according to the state of the owner study.
10 import org.splat.dal.bo.kernel.User;
11 import org.splat.dal.bo.som.ProjectElement;
12 import org.splat.dal.bo.som.Scenario;
13 import org.splat.dal.bo.som.Study;
16 public class StepRights {
21 // ==============================================================================================================================
23 // ==============================================================================================================================
25 public StepRights (User user, Step step) {
26 // ----------------------------------------
30 public StepRights (Step step) {
31 // -----------------------------
32 this.user = step.getOwner().getAuthor();
36 // ==============================================================================================================================
37 // Public member functions
38 // ==============================================================================================================================
41 * Checks if the user has right to add a comment attached to the selected step.
42 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
44 * @return true if the user has right to add a comment.
46 public boolean canAddComment () {
47 // -------------------------------
48 Study owner = operand.getOwnerStudy();
49 return (owner.getAuthor().equals(user) || owner.hasActor(user));
53 * Checks if the user has right to create or import a document into the selected step.
54 * Only the author and contributors have such right, providing that the study step is enabled for writing.
56 * @return true if the user has right to create or import a document.
58 public boolean canCreateDocument () {
59 // -----------------------------------
60 if (!isEnabled()) return false;
61 return operand.getOwnerStudy().isStaffedBy(user);
65 * Checks if the user has right to enter a knowledge into the selected step.
66 * Only the author and contributors have such right.
68 * @return true if the user has right to enter a knowledge.
70 public boolean canCreateKnowledge () {
71 // ------------------------------------
72 return operand.getOwnerStudy().isStaffedBy(user);
76 * Checks if the user has right to edit the simulation contexts attached to the selected step.
77 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
79 * @return true if the user has right to edit the simulation contexts.
81 public boolean canEditSimulationContext () {
82 // ------------------------------------------
83 Study owner = operand.getOwnerStudy();
84 return (owner.getAuthor().equals(user) || owner.hasActor(user));
88 * Checks if the selected step is enabled for writing.
89 * A step may be disabled for writing, or locked, following a check-out of the owner scenario.
91 * @return true if the step is enabled for writing.
93 public boolean isEnabled () {
94 // ---------------------------
95 ProjectElement owner = operand.getOwner();
97 if (owner instanceof Scenario) {
98 Scenario scene = (Scenario)owner;
99 if (scene.isCheckedout()) return false;
104 // ==============================================================================================================================
106 // ==============================================================================================================================
108 public Step getOperand () {
109 // -------------------------