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.kernel.User;
13 public class StepRights {
18 // ==============================================================================================================================
20 // ==============================================================================================================================
22 public StepRights (User user, Step step) {
23 // ----------------------------------------
27 public StepRights (Step step) {
28 // -----------------------------
29 this.user = step.getOwner().getAuthor();
33 // ==============================================================================================================================
34 // Public member functions
35 // ==============================================================================================================================
38 * Checks if the user has right to add a comment attached to the selected step.
39 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
41 * @return true if the user has right to add a comment.
43 public boolean canAddComment () {
44 // -------------------------------
45 Study owner = operand.getOwnerStudy();
46 return (owner.getAuthor().equals(user) || owner.hasActor(user));
50 * Checks if the user has right to create or import a document into the selected step.
51 * Only the author and contributors have such right, providing that the study step is enabled for writing.
53 * @return true if the user has right to create or import a document.
55 public boolean canCreateDocument () {
56 // -----------------------------------
57 if (!isEnabled()) return false;
58 return operand.getOwnerStudy().isStaffedBy(user);
62 * Checks if the user has right to enter a knowledge into the selected step.
63 * Only the author and contributors have such right.
65 * @return true if the user has right to enter a knowledge.
67 public boolean canCreateKnowledge () {
68 // ------------------------------------
69 return operand.getOwnerStudy().isStaffedBy(user);
73 * Checks if the user has right to edit the simulation contexts attached to the selected step.
74 * All actors of the study have such right, including the author, contributors, reviewers and approvers.
76 * @return true if the user has right to edit the simulation contexts.
78 public boolean canEditSimulationContext () {
79 // ------------------------------------------
80 Study owner = operand.getOwnerStudy();
81 return (owner.getAuthor().equals(user) || owner.hasActor(user));
85 * Checks if the selected step is enabled for writing.
86 * A step may be disabled for writing, or locked, following a check-out of the owner scenario.
88 * @return true if the step is enabled for writing.
90 public boolean isEnabled () {
91 // ---------------------------
92 ProjectElement owner = operand.getOwner();
94 if (owner instanceof Scenario) {
95 Scenario scene = (Scenario)owner;
96 if (scene.isCheckedout()) return false;
101 // ==============================================================================================================================
103 // ==============================================================================================================================
105 public Step getOperand () {
106 // -------------------------