001: /*
002: * Created on 29 oct. 2004
003: */
004: package org.objectweb.speedo.pobjects.cap;
005:
006: import java.util.Collection;
007:
008: /**
009: * @author mhoudu
010: */
011: public class JDORole {
012:
013: /** the role identifier */
014: private int id;
015:
016: /** the role label */
017: private String label;
018:
019: /** the role scopes */
020: private Collection scopes;
021:
022: /** the role actions type JDORoleHasAction*/
023: private Collection actions;
024:
025: /**
026: * Default constructor.
027: * @param id The role identifier.
028: * @param label The role label.
029: * @param scopes The role scopes.
030: * @param actions The role actions.
031: */
032: public JDORole(int id, String label, Collection scopes,
033: Collection actions) {
034: this .id = id;
035: this .label = label;
036: this .scopes = scopes;
037: this .actions = actions;
038: }
039:
040: /**
041: * Adds an action to the role.
042: * @param action The action to add.
043: * @param isDisplayedInMenu The flag which indicates if the action has to be displayed in the menu or not.
044: * @param displayOrder The isplay order.
045: */
046: public void addAction(JDOAction action, boolean isDisplayedInMenu,
047: int displayOrder) {
048: JDORoleHasAction action4role = new JDORoleHasAction(this ,
049: action, isDisplayedInMenu, displayOrder);
050: actions.add(action4role);
051: }
052:
053: /**
054: * Tells if this role has the specified scope.
055: * @param scope the scope to check.
056: * @return <tt>true</tt> if this role has the specified scope,
057: * <tt>false</tt> otherwise.
058: */
059: public boolean hasScope(JDOScope scope) {
060: return scopes.contains(scope);
061: }
062:
063: /**
064: * Tells if this role has the specified action.
065: * @param action the action to check.
066: * @return <tt>true</tt> if this role has the specified action,
067: * <tt>false</tt> otherwise.
068: */
069: public boolean hasAction(JDOAction action) {
070: return actions.contains(action);
071: }
072:
073: /**
074: * Gets the id.
075: * @return Returns the id.
076: */
077: public int getId() {
078: return id;
079: }
080:
081: /**
082: * Sets the id.
083: * @param id The id to set.
084: */
085: public void setId(int id) {
086: this .id = id;
087: }
088:
089: /**
090: * Gets the label.
091: * @return Returns the label.
092: */
093: public String getLabel() {
094: return label;
095: }
096:
097: /**
098: * Sets the label.
099: * @param label The label to set.
100: */
101: public void setLabel(String label) {
102: this .label = label;
103: }
104:
105: /**
106: * Gets the scopes.
107: * @return Returns the scopes.
108: */
109: public Collection getScopes() {
110: return scopes;
111: }
112:
113: /**
114: * Sets the scopes.
115: * @param scopes The scope to set.
116: */
117: public void setScopes(Collection scopes) {
118: this .scopes = scopes;
119: }
120:
121: /**
122: * Gets the actions.
123: * @return Returns the actions.
124: */
125: public Collection getActions() {
126: return actions;
127: }
128:
129: /**
130: * Sets the actions.
131: * @param actions The actions to set.
132: */
133: public void setActions(Collection actions) {
134: this.actions = actions;
135: }
136:
137: }
|