001: /*
002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003: * Copyright (C) 2007-2008 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004: *
005: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
006: * General Public License as published by the Free Software Foundation; either version 2 of the License,
007: * or (at your option) any later version.
008: *
009: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
010: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011: * GNU General Public License for more details.
012: *
013: * You should have received a copy of the GNU General Public License along with this program; if not,
014: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
015: */
016:
017: package wilos.model.spem2.workproduct;
018:
019: import java.util.HashSet;
020: import java.util.Set;
021:
022: import org.apache.commons.lang.builder.EqualsBuilder;
023: import org.apache.commons.lang.builder.HashCodeBuilder;
024:
025: import wilos.model.spem2.activity.Activity;
026: import wilos.model.misc.concreteworkproduct.ConcreteWorkProductDescriptor;
027: import wilos.model.spem2.role.RoleDescriptor;
028: import wilos.model.spem2.task.TaskDescriptor;
029: import wilos.model.spem2.breakdownelement.BreakdownElement;
030:
031: /**
032: * A Work Product Descriptor represents a {@link WorkProductDefinition} in the
033: * context of one specific Activity. Every breakdown structure can define
034: * different relationships of {@link WorkProductDefinition} Descriptors to
035: * {@link TaskDefinition} Descriptors and Role Descriptors. Therefore one
036: * {@link WorkProductDefinition} can be represented by many Work Product
037: * Descriptors each within the context of an {@link Activity} with its own set
038: * of relationships. *
039: * <p />
040: * It's an element of the SPEM2 specification of the OMG organization
041: * (http://www.omg.org/).
042: *
043: */
044: public class WorkProductDescriptor extends BreakdownElement implements
045: Cloneable {
046:
047: /**
048: * the attached WorkProductDefinition
049: */
050: private WorkProductDefinition workProductDefinition;
051:
052: /**
053: * Associated ConcreteWorkProductDescriptor.
054: */
055: private Set<ConcreteWorkProductDescriptor> concreteWorkProductDescriptors;
056:
057: private boolean isDeliverable;
058:
059: private RoleDescriptor responsibleRoleDescriptor;
060:
061: private String activityEntryState = "";
062:
063: private String activityExitState = "";
064:
065: private Set<Activity> userActivities;
066:
067: private Set<Activity> producerActivities;
068:
069: private Set<TaskDescriptor> producerTasks;
070:
071: private Set<TaskDescriptor> optionalUserTasks;
072:
073: private Set<TaskDescriptor> mandatoryUserTasks;
074:
075: private boolean isOutOfProcess;
076:
077: public WorkProductDescriptor() {
078: super ();
079: this .concreteWorkProductDescriptors = new HashSet<ConcreteWorkProductDescriptor>();
080: this .userActivities = new HashSet<Activity>();
081: this .producerActivities = new HashSet<Activity>();
082: this .producerTasks = new HashSet<TaskDescriptor>();
083: this .optionalUserTasks = new HashSet<TaskDescriptor>();
084: this .mandatoryUserTasks = new HashSet<TaskDescriptor>();
085: this .isOutOfProcess = false;
086: }
087:
088: /*
089: * (non-Javadoc)
090: *
091: * @see java.lang.Object#clone()
092: */
093: @Override
094: public WorkProductDescriptor clone()
095: throws CloneNotSupportedException {
096: WorkProductDescriptor workProductDescriptor = new WorkProductDescriptor();
097: workProductDescriptor.copy(this );
098: return workProductDescriptor;
099: }
100:
101: /**
102: * Copy the object.
103: *
104: * @param _workProductDescriptor
105: * The RoleDescriptor to copy.
106: */
107: protected void copy(
108: final WorkProductDescriptor _workProductDescriptor) {
109: super .copy(_workProductDescriptor);
110: this .workProductDefinition = _workProductDescriptor
111: .getWorkProductDefinition();
112: this .concreteWorkProductDescriptors
113: .addAll(_workProductDescriptor
114: .getConcreteWorkProductDescriptors());
115: this .responsibleRoleDescriptor = _workProductDescriptor
116: .getResponsibleRoleDescriptor();
117: this .isDeliverable = _workProductDescriptor.isDeliverable();
118: this .activityEntryState = _workProductDescriptor
119: .getActivityEntryState();
120: this .activityExitState = _workProductDescriptor
121: .getActivityExitState();
122:
123: this .producerTasks.addAll(_workProductDescriptor
124: .getProducerTasks());
125: this .optionalUserTasks.addAll(_workProductDescriptor
126: .getOptionalUserTasks());
127: this .mandatoryUserTasks.addAll(_workProductDescriptor
128: .getMandatoryUserTasks());
129: this .isOutOfProcess = _workProductDescriptor
130: .getIsOutOfProcess();
131: }
132:
133: /*
134: * (non-Javadoc)
135: *
136: * @see wilos.model.spem2.breakdownelement.BreakdownElement#equals(java.lang.Object)
137: */
138: public boolean equals(Object obj) {
139: if (obj instanceof WorkProductDescriptor == false) {
140: return false;
141: }
142: if (this == obj) {
143: return true;
144: }
145:
146: WorkProductDescriptor workProductDescriptor = (WorkProductDescriptor) obj;
147: return new EqualsBuilder()
148: .appendSuper(super .equals(workProductDescriptor))
149: .append(this .workProductDefinition,
150: workProductDescriptor.workProductDefinition)
151: .append(
152: this .concreteWorkProductDescriptors,
153: workProductDescriptor.concreteWorkProductDescriptors)
154: .append(this .isDeliverable,
155: workProductDescriptor.isDeliverable)
156: .append(this .activityEntryState,
157: workProductDescriptor.activityEntryState)
158: .append(this .activityExitState,
159: workProductDescriptor.activityExitState)
160: .append(this .producerActivities,
161: workProductDescriptor.producerActivities)
162: .append(this .userActivities,
163: workProductDescriptor.userActivities)
164: .append(this .responsibleRoleDescriptor,
165: workProductDescriptor.responsibleRoleDescriptor)
166: .append(this .producerTasks,
167: workProductDescriptor.producerTasks).append(
168: this .optionalUserTasks,
169: workProductDescriptor.optionalUserTasks)
170: .append(this .mandatoryUserTasks,
171: workProductDescriptor.mandatoryUserTasks)
172: .append(this .isOutOfProcess,
173: workProductDescriptor.isOutOfProcess)
174: .isEquals();
175: }
176:
177: /*
178: * (non-Javadoc)
179: *
180: * @see wilos.model.spem2.breakdownelement.BreakdownElement#hashCode()
181: */
182: public int hashCode() {
183: return new HashCodeBuilder(17, 37)
184: .appendSuper(super .hashCode()).append(
185: this .workProductDefinition).toHashCode();
186: }
187:
188: /*
189: * relation between WOrkProductDescriptor and ConcreteWorkProductDescriptor.
190: *
191: */
192:
193: /**
194: * @param _workProductDescriptor
195: */
196: public void addConcreteWorkProductDescriptor(
197: ConcreteWorkProductDescriptor _concreteWorkProductDescriptor) {
198: this .concreteWorkProductDescriptors
199: .add(_concreteWorkProductDescriptor);
200: _concreteWorkProductDescriptor.addWorkProductDescriptor(this );
201: }
202:
203: /**
204: * @param _workProductDescriptor
205: */
206: public void removeConcreteWorkProductDescriptor(
207: ConcreteWorkProductDescriptor _concreteWorkProductDescriptor) {
208: _concreteWorkProductDescriptor
209: .removeWorkProductDescriptor(this );
210: this .concreteWorkProductDescriptors
211: .remove(_concreteWorkProductDescriptor);
212: }
213:
214: public void addAllConcreteWorkProductDescriptors(
215: Set<ConcreteWorkProductDescriptor> _concreteWorkProductDescriptors) {
216: for (ConcreteWorkProductDescriptor cwpd : _concreteWorkProductDescriptors) {
217: cwpd.addWorkProductDescriptor(this );
218: }
219: }
220:
221: public void removeAllConcreteWorkProductDescriptors() {
222: for (ConcreteWorkProductDescriptor cwpd : this
223: .getConcreteWorkProductDescriptors())
224: cwpd.setWorkProductDescriptor(null);
225: this .getConcreteWorkProductDescriptors().clear();
226: }
227:
228: /*
229: * relation between WorkProductDescriptor and WorkProductDefinition
230: */
231:
232: /**
233: * Add a WorkProductDefinition to the Set
234: *
235: * @param _workProduct
236: */
237: public void addWorkProductDefinition(
238: WorkProductDefinition _workProduct) {
239: this .workProductDefinition = _workProduct;
240: _workProduct.getWorkProductDescriptors().add(this );
241: }
242:
243: /**
244: * remove a WorkProductDefinition
245: *
246: * @param _workProduct
247: */
248: public void removeWorkProductDefinition(
249: WorkProductDefinition _workProduct) {
250: _workProduct.getWorkProductDescriptors().remove(this );
251: this .workProductDefinition = null;
252: }
253:
254: /*
255: * Getter and Setter.
256: */
257:
258: /**
259: * Getter of workProductDefinition.
260: *
261: * @return the workProductDefinition.
262: */
263: public WorkProductDefinition getWorkProductDefinition() {
264: return this .workProductDefinition;
265: }
266:
267: /**
268: * Setter of workProductDefinition.
269: *
270: * @param _workProductDefinition
271: * The workProductDefinition to set.
272: */
273: public void setWorkProductDefinition(
274: WorkProductDefinition _workProductDefinition) {
275: this .workProductDefinition = _workProductDefinition;
276: }
277:
278: public Set<ConcreteWorkProductDescriptor> getConcreteWorkProductDescriptors() {
279: return concreteWorkProductDescriptors;
280: }
281:
282: public void setConcreteWorkProductDescriptors(
283: Set<ConcreteWorkProductDescriptor> concreteWorkProductDescriptors) {
284: this .concreteWorkProductDescriptors = concreteWorkProductDescriptors;
285: }
286:
287: /**
288: * @return the isDeliverable
289: */
290: public boolean isDeliverable() {
291: return this .isDeliverable;
292: }
293:
294: /**
295: * @param _isDeliverable
296: * the isDeliverable to set
297: */
298: public void setDeliverable(boolean _isDeliverable) {
299: this .isDeliverable = _isDeliverable;
300: }
301:
302: /**
303: * @return the activityEntryState
304: */
305: public String getActivityEntryState() {
306: return this .activityEntryState;
307: }
308:
309: /**
310: * @param _activityEntryState
311: * the activityEntryState to set
312: */
313: public void setActivityEntryState(String _activityEntryState) {
314: this .activityEntryState = _activityEntryState;
315: }
316:
317: /**
318: * @return the activityExitState
319: */
320: public String getActivityExitState() {
321: return this .activityExitState;
322: }
323:
324: /**
325: * @param _activityExitState
326: * the activityExitState to set
327: */
328: public void setActivityExitState(String _activityExitState) {
329: this .activityExitState = _activityExitState;
330: }
331:
332: /**
333: * @return the userActivities
334: */
335: public Set<Activity> getUserActivities() {
336: return userActivities;
337: }
338:
339: /**
340: * @return the producerActivities
341: */
342: public Set<Activity> getProducerActivities() {
343: return producerActivities;
344: }
345:
346: /**
347: * @param _userActivities
348: * the userActivities to set
349: */
350: public void setUserActivities(Set<Activity> _userActivities) {
351: userActivities = _userActivities;
352: }
353:
354: /**
355: * @param _producerActivities
356: * the producerActivities to set
357: */
358: public void setProducerActivities(Set<Activity> _producerActivities) {
359: producerActivities = _producerActivities;
360: }
361:
362: /**
363: * @return the responsibleRoleDescriptor
364: */
365: public RoleDescriptor getResponsibleRoleDescriptor() {
366: return this .responsibleRoleDescriptor;
367: }
368:
369: /**
370: * @param _responsibleRoleDescriptor
371: * the responsibleRoleDescriptor to set
372: */
373: public void setResponsibleRoleDescriptor(
374: RoleDescriptor _responsibleRoleDescriptor) {
375: this .responsibleRoleDescriptor = _responsibleRoleDescriptor;
376: }
377:
378: /**
379: * Attach a workProductDescriptor to a roleDescriptor
380: *
381: * @param _roleDescriptor
382: */
383: public void addResponsibleRole(RoleDescriptor _roleDescriptor) {
384: this .responsibleRoleDescriptor = _roleDescriptor;
385: _roleDescriptor.getResponsibleFor().add(this );
386: }
387:
388: /**
389: * @return the producerTasks i.e. return a list of tasks which produce this
390: * workproduct
391: */
392: public Set<TaskDescriptor> getProducerTasks() {
393: return this .producerTasks;
394: }
395:
396: /**
397: * @param _producerTasks
398: * the producerTasks to set
399: */
400: public void setProducerTasks(Set<TaskDescriptor> _producerTasks) {
401: this .producerTasks = _producerTasks;
402: }
403:
404: /**
405: * @return the optionalUserTasks
406: */
407: public Set<TaskDescriptor> getOptionalUserTasks() {
408: return this .optionalUserTasks;
409: }
410:
411: /**
412: * @param _optionalUserTasks
413: * the optionalUserTasks to set
414: */
415: public void setOptionalUserTasks(
416: Set<TaskDescriptor> _optionalUserTasks) {
417: this .optionalUserTasks = _optionalUserTasks;
418: }
419:
420: /**
421: * @return the mandatoryUserTasks
422: */
423: public Set<TaskDescriptor> getMandatoryUserTasks() {
424: return this .mandatoryUserTasks;
425: }
426:
427: /**
428: * @param _mandatoryUserTasks
429: * the mandatoryUserTasks to set
430: */
431: public void setMandatoryUserTasks(
432: Set<TaskDescriptor> _mandatoryUserTasks) {
433: this .mandatoryUserTasks = _mandatoryUserTasks;
434: }
435:
436: /**
437: * @param _taskDescriptor
438: */
439: public void addProducerTask(TaskDescriptor _taskDescriptor) {
440: this .producerTasks.add(_taskDescriptor);
441: _taskDescriptor.getOutputWorkProductDescriptors().add(this );
442:
443: }
444:
445: /**
446: * @param _taskDescriptor
447: */
448: public void addOptionalUser(TaskDescriptor _taskDescriptor) {
449: this .optionalUserTasks.add(_taskDescriptor);
450: _taskDescriptor.getOptionalInputWorkProductDescriptors().add(
451: this );
452:
453: }
454:
455: /**
456: * @param _taskDescriptor
457: */
458: public void addMandatoryUser(TaskDescriptor _taskDescriptor) {
459: this .mandatoryUserTasks.add(_taskDescriptor);
460: _taskDescriptor.getMandatoryInputWorkProductDescriptors().add(
461: this );
462:
463: }
464:
465: /**
466: * @param _producerTasks
467: */
468: public void addAllProducerTasks(Set<TaskDescriptor> _producerTasks) {
469: for (TaskDescriptor task : _producerTasks) {
470: task.addOutputWorkProduct(this );
471: }
472:
473: }
474:
475: /**
476: * @param _optionalUserTasks
477: */
478: public void addAllOptionalUserTasks(
479: Set<TaskDescriptor> _optionalUserTasks) {
480: for (TaskDescriptor task : _optionalUserTasks) {
481: task.addOptionalInputWorkProduct(this );
482: }
483:
484: }
485:
486: /**
487: * @param _mandatoryUserTasks
488: */
489: public void addAllMandatoryUserTasks(
490: Set<TaskDescriptor> _mandatoryUserTasks) {
491: for (TaskDescriptor task : _mandatoryUserTasks) {
492: task.addMandatoryInputWorkProduct(this );
493: }
494:
495: }
496:
497: /**
498: * @return the isOutOfProcess
499: */
500: public boolean getIsOutOfProcess() {
501: return this .isOutOfProcess;
502: }
503:
504: /**
505: * @param _isOutOfProcess the isOutOfProcess to set
506: */
507: public void setIsOutOfProcess(boolean _isOutOfProcess) {
508: this.isOutOfProcess = _isOutOfProcess;
509: }
510: }
|