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: *
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.misc.project;
018:
019: import java.util.Date;
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.misc.concreteactivity.ConcreteActivity;
027: import wilos.model.misc.wilosuser.Participant;
028: import wilos.model.misc.wilosuser.ProjectDirector;
029: import wilos.model.spem2.process.Process;
030:
031: /**
032: * This class represents a project.
033: *
034: */
035: public class Project extends ConcreteActivity implements Cloneable {
036:
037: private String description;
038:
039: private Date creationDate;
040:
041: private Date launchingDate;
042:
043: private Boolean isFinished;
044:
045: private Process process;
046:
047: private Set<Participant> participants;
048:
049: private Participant projectManager;
050:
051: private ProjectDirector projectDirector;
052:
053: private boolean considerWorkProductAndTaskLinks;
054:
055: /**
056: * Class constructor
057: */
058: public Project() {
059: this .creationDate = new Date();
060: this .launchingDate = new Date();
061: this .participants = new HashSet<Participant>();
062: this .isFinished = false;
063: this .considerWorkProductAndTaskLinks = false;
064: }
065:
066: /**
067: * Returns the Date of the Project creation
068: *
069: * @return the creationDate
070: */
071: public Date getCreationDate() {
072: return creationDate;
073: }
074:
075: /**
076: * Adds a relation between the Project and the Process
077: *
078: * @param _process
079: * the process to be linked to
080: */
081: public void addProcess(Process _process) {
082: this .process = _process;
083: _process.getProjects().add(this );
084: }
085:
086: /**
087: * * Removes the relation between the Project and the Process
088: *
089: * @param _process
090: * the process to be unlinked to
091: */
092: public void removeProcess(Process _process) {
093: this .process = null;
094: _process.getProjects().remove(this );
095: }
096:
097: /**
098: * Sets the Project creation Date
099: *
100: * @param creationDate
101: * the creationDate to set
102: */
103: public void setCreationDate(Date creationDate) {
104: this .creationDate = creationDate;
105: }
106:
107: /**
108: * Returns the description for the Project
109: *
110: * @return the description
111: */
112: public String getDescription() {
113: return description;
114: }
115:
116: /**
117: * Sets the description for the Project
118: *
119: * @param description
120: * the description to set
121: */
122: public void setDescription(String description) {
123: this .description = description;
124: }
125:
126: /**
127: * Returns the launching Date for the Project
128: *
129: * @return the launchingDate
130: */
131: public Date getLaunchingDate() {
132: return launchingDate;
133: }
134:
135: /**
136: * Sets the launching Date for the Project
137: *
138: * @param launchingDate
139: * the launchingDate to set
140: */
141: public void setLaunchingDate(Date launchingDate) {
142: this .launchingDate = launchingDate;
143: }
144:
145: /**
146: * Returns a copy of the current instance of Project
147: *
148: * @return a copy of the Project
149: * @throws CloneNotSupportedException
150: */
151: public Project clone() throws CloneNotSupportedException {
152: Project project = new Project();
153: project.copy(this );
154: return project;
155: }
156:
157: /**
158: * Copy the values of the specified Project into the current instance of the
159: * class.
160: *
161: * @param _project
162: * the Project to copy
163: */
164: protected void copy(final Project _project) {
165: this .description = _project.description;
166: this .creationDate = _project.creationDate;
167: this .launchingDate = _project.launchingDate;
168: this .considerWorkProductAndTaskLinks = _project.considerWorkProductAndTaskLinks;
169: }
170:
171: /**
172: * Returns a hash code value for the object. This method is supported for
173: * the benefit of hash tables.
174: *
175: * @return the hash code of the current instance of Project
176: */
177: public int hashCode() {
178: return new HashCodeBuilder(17, 37)
179: .appendSuper(super .hashCode()).append(this .description)
180: .append(this .creationDate).append(this .launchingDate)
181: .append(this .isFinished).append(this .process).append(
182: this .projectManager).append(
183: this .considerWorkProductAndTaskLinks)
184: .toHashCode();
185: }
186:
187: /**
188: * Defines if the specified Object is the same or has the same values as the
189: * current instance of the class.
190: *
191: * @param obj
192: * the Object to be compare to the Project
193: * @return true if the specified Object is the same, false otherwise
194: */
195: public boolean equals(Object _obj) {
196: if (_obj instanceof Project == false) {
197: return false;
198: }
199: if (this == _obj) {
200: return true;
201: }
202: Project project = (Project) _obj;
203: return new EqualsBuilder().appendSuper(super .equals(project))
204: .append(this .description, project.description).append(
205: this .creationDate, project.creationDate)
206: .append(this .launchingDate, project.launchingDate)
207: .append(this .isFinished, project.isFinished).append(
208: this .process, project.process).append(
209: this .participants, project.participants)
210: .append(this .projectManager, project.projectManager)
211: .append(this .considerWorkProductAndTaskLinks,
212: project.considerWorkProductAndTaskLinks)
213: .isEquals();
214:
215: }
216:
217: /**
218: * Getter of process.
219: *
220: * @return the process.
221: */
222: public Process getProcess() {
223: return this .process;
224: }
225:
226: /**
227: * Setter of process.
228: *
229: * @param _process
230: * The process to set.
231: */
232: public void setProcess(Process _process) {
233: this .process = _process;
234: }
235:
236: /**
237: * Getter of participants.
238: *
239: * @return the participants.
240: */
241: public Set<Participant> getParticipants() {
242: return this .participants;
243: }
244:
245: /**
246: * Setter of participants.
247: *
248: * @param _participants
249: * The participants to set.
250: */
251: public void setParticipants(Set<Participant> _participants) {
252: this .participants = _participants;
253: }
254:
255: /**
256: * Getter of the project manager.
257: *
258: * @return the project manager.
259: */
260: public Participant getProjectManager() {
261: return projectManager;
262: }
263:
264: /**
265: * Setter of the project manager.
266: *
267: * @param projectManager
268: * The project manager to set.
269: */
270: public void setProjectManager(Participant projectManager) {
271: this .projectManager = projectManager;
272: }
273:
274: /**
275: * add participant to this project
276: *
277: * @param participant
278: * the participant to add
279: */
280: public void addParticipant(Participant participant) {
281: this .participants.add(participant);
282: participant.getAffectedProjectList().add(this );
283: }
284:
285: /**
286: * remove a project from a participant
287: *
288: * @param participant
289: * the participant to remove from
290: */
291: public void removeParticipant(Participant participant) {
292: this .participants.remove(participant);
293: }
294:
295: /**
296: * remove the project from all the participants
297: *
298: */
299: public void removeAllParticipants() {
300: for (Participant participant : this .participants) {
301: participant.removeAffectedProject(this );
302: }
303: this .participants.clear();
304: }
305:
306: /**
307: * Getter of isFinished.
308: *
309: * @return the isFinished.
310: */
311: public Boolean getIsFinished() {
312: return this .isFinished;
313: }
314:
315: /**
316: * Setter of isFinished.
317: *
318: * @param _isFinished
319: * The isFinished to set.
320: */
321: public void setIsFinished(Boolean _isFinished) {
322: this .isFinished = _isFinished;
323: }
324:
325: /**
326: * Adds a relation between the current instance of Project and a specified
327: * Participant (project manager).
328: *
329: * @param projectManager
330: */
331: public void addProjectManager(Participant projectManager) {
332: this .projectManager = projectManager;
333: projectManager.getManagedProjects().add(this );
334: }
335:
336: /**
337: * Removes the relation between the current instance of Project and a
338: * specified Participant (project manager).
339: *
340: * @param projectManager
341: */
342: public void removeProjectManager(Participant projectManager) {
343: this .projectManager = null;
344: }
345:
346: /**
347: * Getter of projectDirector.
348: *
349: * @return the projectDirector.
350: */
351: public ProjectDirector getProjectDirector() {
352: return this .projectDirector;
353: }
354:
355: /**
356: * Setter of projectDirector.
357: *
358: * @param _projectDirector
359: * The projectDirector to set.
360: */
361: public void setProjectDirector(ProjectDirector _projectDirector) {
362: this .projectDirector = _projectDirector;
363: }
364:
365: /**
366: *
367: * Add a project director
368: *
369: * @param project
370: */
371: public void addProjectDirector(ProjectDirector _projectDirector) {
372: this .projectDirector = _projectDirector;
373: _projectDirector.getProjectMonitored().add(this );
374: }
375:
376: /**
377: *
378: * Remove a project director
379: *
380: * @param project
381: */
382: public void removeProjectDirector(ProjectDirector _projectDirector) {
383: this .projectDirector = null;
384: }
385:
386: /**
387: * @return the considerWorkProductAndTaskLinks
388: */
389: public boolean getConsiderWorkProductAndTaskLinks() {
390: return this .considerWorkProductAndTaskLinks;
391: }
392:
393: /**
394: * @param _considerWorkProductAndTaskLinks
395: * the considerWorkProductAndTaskLinks to set
396: */
397: public void setConsiderWorkProductAndTaskLinks(
398: boolean _considerWorkProductAndTaskLinks) {
399: this.considerWorkProductAndTaskLinks = _considerWorkProductAndTaskLinks;
400: }
401:
402: }
|