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: *
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.process;
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.misc.project.Project;
027: import wilos.model.misc.wilosuser.ProcessManager;
028: import wilos.model.spem2.activity.Activity;
029:
030: /**
031: *
032: * A Process is a special {@link Activity} that describes a structure for
033: * particular types of development projects. To perform such a development
034: * project a Processes would be 'instantiated' and adapted for the specific
035: * situation. Process is an abstract class and this meta-model defines different
036: * special types of Processes for different process management applications and
037: * different situations of process reuse.
038: * <p />
039: * It's an element of the SPEM2 specification of the OMG organization
040: * (http://www.omg.org/).
041: *
042: */
043: public class Process extends Activity implements Cloneable {
044:
045: // The Project of Process
046: private Set<Project> projects;
047:
048: private ProcessManager processManager;
049:
050: private String folderPath;
051:
052: /**
053: * Default constructor
054: *
055: */
056: public Process() {
057: super ();
058: this .projects = new HashSet<Project>();
059: }
060:
061: /**
062: * Returns a copy of the current instance of Process
063: *
064: * @return a copy of the Process
065: * @throws CloneNotSupportedException
066: */
067: @Override
068: public Process clone() throws CloneNotSupportedException {
069: Process process = new Process();
070: process.copy(this );
071: return process;
072: }
073:
074: /**
075: * Copy the values of the specified Process into the current instance of the
076: * class.
077: *
078: * @param _process
079: * The Process to copy.
080: */
081: protected void copy(final Process _process) {
082: super .copy(_process);
083: this .processManager = _process.getProcessManager();
084: this .projects.addAll(_process.getProjects());
085: }
086:
087: /**
088: * Defines if the specified Object is the same or has the same values as the
089: * current instance of the Process.
090: *
091: * @param obj
092: * the Object to be compare to the Process
093: * @return true if the specified Object is the same, false otherwise
094: */
095: public boolean equals(Object obj) {
096: if (obj instanceof Process == false) {
097: return false;
098: }
099: if (this == obj) {
100: return true;
101: }
102: Process process = (Process) obj;
103: return new EqualsBuilder().appendSuper(super .equals(process))
104: .append(this .projects, process.projects).append(
105: this .processManager, process.processManager)
106: .isEquals();
107: }
108:
109: /**
110: * Returns a hash code value for the object. This method is supported for
111: * the benefit of hash tables.
112: *
113: * @return the hash code of the current instance of Process
114: */
115: public int hashCode() {
116: return new HashCodeBuilder(17, 37)
117: .appendSuper(super .hashCode()).append(
118: this .processManager).toHashCode();
119: }
120:
121: /**
122: * Removes a Project from the Process
123: *
124: * @param _project
125: */
126: public void removeProject(Project _project) {
127: _project.setProcess(null);
128: this .projects.remove(_project);
129: }
130:
131: /**
132: * Adds a Project to the Process
133: *
134: * @param _project
135: */
136: public void addProject(Project _project) {
137: this .projects.add(_project);
138: _project.setProcess(this );
139: }
140:
141: /**
142: * Removes all the Project related to the Process
143: */
144: public void removeAllProjects() {
145: for (Project project : this .projects) {
146: project.setProcess(null);
147: }
148: this .projects.clear();
149: }
150:
151: /**
152: * Add a Project Set to the Project Collection of a Process
153: *
154: * @param _project
155: * the Set of Project to add to the Process
156: */
157: public void addAllProjects(Set<Project> _project) {
158: for (Project _proj1 : _project) {
159: _proj1.addProcess(this );
160: }
161: }
162:
163: /**
164: * Returns the Collection of Project related to the Process
165: *
166: * @return a Set of Project
167: */
168: public Set<Project> getProjects() {
169: return projects;
170: }
171:
172: /**
173: * Sets the Collection of Project related to the Process
174: *
175: * @param project
176: * the Set of Project to be set
177: */
178: public void setProjects(Set<Project> project) {
179: this .projects = project;
180: }
181:
182: /*
183: * relation between Process et Project Manager
184: */
185:
186: /**
187: * Adds a relation between the specified ProcessManager and the Process
188: *
189: * @param _processManager
190: * the ProcessManager to be linked to
191: */
192: public void addProcessManager(ProcessManager _processManager) {
193: this .processManager = _processManager;
194: _processManager.getProcessesManaged().add(this );
195: }
196:
197: /**
198: * Removes the relation between the specified ProcessManager and the Process
199: *
200: * @param _processManager
201: * the ProcessManager to be unlinked to
202: */
203: public void removeProcessManager(ProcessManager _processManager) {
204: _processManager.getProcessesManaged().remove(this );
205: this .processManager = null;
206:
207: }
208:
209: /**
210: * Returns the ProcessManager assigned to the Process
211: *
212: * @return the Process ProcessManager
213: */
214: public ProcessManager getProcessManager() {
215: return processManager;
216: }
217:
218: /**
219: * Sets the ProcessManager assigned to the Process
220: *
221: * @param processManager
222: * the ProcessManager to set to the Process
223: */
224: public void setProcessManager(ProcessManager processManager) {
225: this .processManager = processManager;
226: }
227:
228: /**
229: * Returns the folder path to the Process
230: *
231: * @return the String of the folder path
232: */
233: public String getFolderPath() {
234: return folderPath;
235: }
236:
237: /**
238: * Sets the folder path of the Process
239: *
240: * @param folderPath
241: * the folder path
242: */
243: public void setFolderPath(String folderPath) {
244: this.folderPath = folderPath;
245: }
246:
247: }
|