001: /*
002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004: * Copyright (C) 2007 Mathieu BENOIT <mathieu-benoit@hotmail.fr>
005: * Copyright (C) 2007-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
006: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
007: * General Public License as published by the Free Software Foundation; either version 2 of the License,
008: * or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
011: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License along with this program; if not,
015: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
016: */
017:
018: package wilos.model.spem2.role;
019:
020: import java.util.HashSet;
021: import java.util.Set;
022:
023: import org.apache.commons.lang.builder.EqualsBuilder;
024: import org.apache.commons.lang.builder.HashCodeBuilder;
025:
026: import wilos.model.spem2.element.Element;
027: import wilos.model.spem2.guide.Guidance;
028:
029: /**
030: *
031: * A RoleDefinition is an {@link Element} that defines a set of related skills,
032: * competencies, and responsibilities. Roles are used by Tasks to define who
033: * performs them as well as define a set of work products they are responsible
034: * for.
035: * <p />
036: * It's an element of the SPEM2 specification of the OMG organization
037: * (http://www.omg.org/).
038: *
039: */
040: public class RoleDefinition extends Element implements Cloneable {
041:
042: /**
043: * Collection of TaskDescriptor
044: */
045: private Set<RoleDescriptor> roleDescriptors;
046:
047: private Set<Guidance> guidances;
048:
049: private String assignmentApproaches;
050:
051: private String skills;
052:
053: private String synonyms;
054:
055: /**
056: * Class constructor.
057: *
058: */
059: public RoleDefinition() {
060: super ();
061: this .roleDescriptors = new HashSet<RoleDescriptor>();
062: this .guidances = new HashSet<Guidance>();
063: this .assignmentApproaches = "";
064: this .skills = "";
065: this .synonyms = "";
066: }
067:
068: /**
069: * Defines if the specified Object is the same or has the same values as the
070: * current instance of the RoleDefinition.
071: *
072: * @param obj
073: * the Object to be compare to the RoleDefinition
074: * @return true if the specified Object is the same, false otherwise
075: */
076: public boolean equals(Object obj) {
077: if (obj instanceof RoleDefinition == false) {
078: return false;
079: }
080: if (this == obj) {
081: return true;
082: }
083: RoleDefinition role = (RoleDefinition) obj;
084: return new EqualsBuilder().appendSuper(super .equals(role))
085: .append(this .roleDescriptors, role.roleDescriptors)
086: .append(this .guidances, role.guidances).append(
087: this .assignmentApproaches,
088: role.assignmentApproaches).append(this .skills,
089: role.skills).append(this .synonyms,
090: role.synonyms).isEquals();
091: }
092:
093: /**
094: * Returns a hash code value for the object. This method is supported for
095: * the benefit of hash tables.
096: *
097: * @return the hash code of the current instance of RoleDefinition
098: */
099: public int hashCode() {
100: return new HashCodeBuilder(17, 37)
101: .appendSuper(super .hashCode()).append(
102: this .assignmentApproaches).append(this .skills)
103: .append(this .synonyms).toHashCode();
104: }
105:
106: /**
107: * Returns a copy of the current instance of RoleDefinition
108: *
109: * @return a copy of the RoleDefinition
110: * @throws CloneNotSupportedException
111: */
112: @Override
113: public RoleDefinition clone() throws CloneNotSupportedException {
114: RoleDefinition roleDefinition = new RoleDefinition();
115: roleDefinition.copy(this );
116: return roleDefinition;
117: }
118:
119: /**
120: * Copy the values of the specified RoleDefinition into the current instance
121: * of the class.
122: *
123: * @param _roleDefinition
124: * The RoleDefinition to copy.
125: */
126: protected void copy(final RoleDefinition _roleDefinition) {
127: super .copy(_roleDefinition);
128: this .roleDescriptors.addAll(_roleDefinition
129: .getRoleDescriptors());
130: this .guidances.addAll(_roleDefinition.getGuidances());
131: this .assignmentApproaches = _roleDefinition
132: .getAssignmentApproaches();
133: this .skills = _roleDefinition.getSkills();
134: this .synonyms = _roleDefinition.getSynonyms();
135: }
136:
137: /*
138: * relation between RoleDefinition and RoleDescriptor
139: */
140:
141: /**
142: * Adds a RoleDescriptor to the Set of the RoleDefinition
143: *
144: * @param _role
145: */
146: public void addRoleDescriptor(RoleDescriptor _role) {
147: this .roleDescriptors.add(_role);
148: _role.setRoleDefinition(this );
149: }
150:
151: /**
152: * Removes a RoleDescriptor from the RoleDefinition
153: *
154: * @param _role
155: */
156: public void removeRoleDescriptor(RoleDescriptor _role) {
157: _role.setRoleDefinition(null);
158: this .roleDescriptors.remove(_role);
159:
160: }
161:
162: /**
163: * Removes from a RoleDefinition all its RoleDescriptor
164: *
165: */
166: public void removeAllRoleDescriptors() {
167: for (RoleDescriptor _role : this .roleDescriptors) {
168: _role.setRoleDefinition(null);
169: }
170: this .roleDescriptors.clear();
171: }
172:
173: /**
174: * Adds a RoleDescriptor collection to the RoleDescriptor collection of an
175: * RoleDefinition
176: *
177: * @param _role
178: */
179: public void addAllRoleDescriptors(Set<RoleDescriptor> _role) {
180: for (RoleDescriptor _role1 : _role) {
181: _role1.addRoleDefinition(this );
182: }
183: }
184:
185: /*
186: * connection to guidances
187: */
188:
189: /**
190: * Removes the relation between the RoleDefinition and the specified
191: * Guidance
192: *
193: * @param _guidance
194: * the Guidance to be unlinked to
195: */
196: public void removeGuidance(Guidance _guidance) {
197: _guidance.getRoleDefinitions().remove(this );
198: this .guidances.remove(_guidance);
199: }
200:
201: /**
202: * Adds a relation between the RoleDefinition and the specified Guidance
203: *
204: * @param _guidance
205: * the Guidance to be link to the RoleDefinition
206: */
207: public void addGuidance(Guidance _guidance) {
208: this .guidances.add(_guidance);
209: _guidance.getRoleDefinitions().add(this );
210: }
211:
212: /**
213: * Removes all the Guidance related to the RoleDefinition
214: */
215: public void removeAllGuidances() {
216: for (Guidance guidance : this .guidances) {
217: guidance.getRoleDefinitions().remove(this );
218: }
219: this .guidances.clear();
220: }
221:
222: /**
223: * Adds all the Guidance of the Collection in parameter to the
224: * RoleDefinition
225: *
226: * @param _guidances
227: * to be related to the RoleDefinition
228: */
229: public void addAllGuidances(Set<Guidance> _guidances) {
230: for (Guidance _guid1 : _guidances) {
231: this .addGuidance(_guid1);
232: }
233: }
234:
235: /**
236: * Getter of roleDescriptors.
237: *
238: * @return the roleDescriptors.
239: */
240: public Set<RoleDescriptor> getRoleDescriptors() {
241: return this .roleDescriptors;
242: }
243:
244: /**
245: * Setter of roleDescriptors.
246: *
247: * @param _roleDescriptors
248: * The roleDescriptors to set.
249: */
250: @SuppressWarnings("unused")
251: public void setRoleDescriptors(Set<RoleDescriptor> _roleDescriptors) {
252: this .roleDescriptors = _roleDescriptors;
253: }
254:
255: /**
256: * Returns the Guidance related to the RoleDefinition
257: *
258: * @return a Set of Guidance
259: */
260: public Set<Guidance> getGuidances() {
261: return guidances;
262: }
263:
264: /**
265: * Sets the Collection of Guidance to the RoleDefinition
266: *
267: * @param guidances
268: * the Collection of Guidance to assigned to the RoleDefinition
269: */
270: public void setGuidances(Set<Guidance> guidances) {
271: this .guidances = guidances;
272: }
273:
274: /**
275: * Returns the assignment approaches of the RoleDefinition
276: *
277: * @return the string that symbolizes the assignment approaches
278: */
279: public String getAssignmentApproaches() {
280: return assignmentApproaches;
281: }
282:
283: /**
284: * Sets the assignment approaches of the RoleDefinition
285: *
286: * @param _assignmentApproaches
287: * the assignment approaches to be set
288: */
289: public void setAssignmentApproaches(String _assignmentApproaches) {
290: this .assignmentApproaches = _assignmentApproaches;
291: }
292:
293: /**
294: * Returns the skills for the RoleDefinition
295: *
296: * @return the skills for the RoleDefinition
297: */
298: public String getSkills() {
299: return skills;
300: }
301:
302: /**
303: * Sets the skills for the RoleDefinition
304: *
305: * @param _skills
306: * the string to set the skills
307: */
308: public void setSkills(String _skills) {
309: this .skills = _skills;
310: }
311:
312: /**
313: * Returns the synonyms for the RoleDefinition
314: *
315: * @return the synonyms for the RoleDefinition
316: */
317: public String getSynonyms() {
318: return synonyms;
319: }
320:
321: /**
322: * Sets the synonyms for the RoleDefinition
323: *
324: * @param _synonyms
325: * the String to st the synonyms of the RoleDefinition
326: */
327: public void setSynonyms(String _synonyms) {
328: this.synonyms = _synonyms;
329: }
330: }
|