001: /*
002: * This file is part of the WfMOpen project.
003: * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
004: * All rights reserved.
005: *
006: * This program is free software; you can redistribute it and/or modify
007: * it under the terms of the GNU General Public License as published by
008: * the Free Software Foundation; either version 2 of the License, or
009: * (at your option) any later version.
010: *
011: * This program is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014: * GNU General Public License for more details.
015: *
016: * You should have received a copy of the GNU General Public License
017: * along with this program; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: * $Id: Participant.java,v 1.4 2007/03/27 21:59:44 mlipp Exp $
021: *
022: * $Log: Participant.java,v $
023: * Revision 1.4 2007/03/27 21:59:44 mlipp
024: * Fixed lots of checkstyle warnings.
025: *
026: * Revision 1.3 2007/02/27 14:34:21 drmlipp
027: * Some refactoring to reduce cyclic dependencies.
028: *
029: * Revision 1.2 2006/09/29 12:32:07 drmlipp
030: * Consistently using WfMOpen as projct name now.
031: *
032: * Revision 1.1.1.1 2003/08/26 13:20:50 drmlipp
033: * Update to 1.0rc2
034: *
035: * Revision 1.1 2003/07/04 08:08:45 lipp
036: * Started variable performer.
037: *
038: */
039: package de.danet.an.workflow.api;
040:
041: import java.io.Serializable;
042: import java.util.HashMap;
043: import java.util.Map;
044:
045: /**
046: * This interface identifies the data type "workflow participant" in a
047: * {@link de.danet.an.workflow.omgcore.ProcessDataInfo
048: * <code>ProcessDataInfo</code>} object.
049: *
050: * @author <a href="mailto:lipp@danet.de">Michael Lipp</a>
051: * @version $Revision: 1.4 $
052: */
053: public interface Participant {
054:
055: /**
056: * This class defines the participant type for a participant.
057: */
058: public static final class ParticipantType implements Serializable {
059: private String type = null;
060: /**
061: * RESOURCE_SET ParticipantType.
062: */
063: public static final ParticipantType RESOURCE_SET = new ParticipantType(
064: "RESOURCE_SET");
065: /**
066: * RESOURCE ParticipantType.
067: */
068: public static final ParticipantType RESOURCE = new ParticipantType(
069: "RESOURCE");
070: /**
071: * ROLE ParticipantType.
072: */
073: public static final ParticipantType ROLE = new ParticipantType(
074: "ROLE");
075:
076: /**
077: * ORGANIZATIONAL_UNIT ParticipantType.
078: */
079: public static final ParticipantType ORGANIZATIONAL_UNIT = new ParticipantType(
080: "ORGANIZATIONAL_UNIT");
081: /**
082: * HUMAN ParticipantType.
083: */
084: public static final ParticipantType HUMAN = new ParticipantType(
085: "HUMAN");
086: /**
087: * SYSTEM ParticipantType.
088: */
089: public static final ParticipantType SYSTEM = new ParticipantType(
090: "SYSTEM");
091:
092: private static Map participantTypeMap = new HashMap();
093:
094: static {
095: participantTypeMap.put(RESOURCE_SET.toString(),
096: RESOURCE_SET);
097: participantTypeMap.put(RESOURCE.toString(), RESOURCE);
098: participantTypeMap.put(ROLE.toString(), ROLE);
099: participantTypeMap.put(ORGANIZATIONAL_UNIT.toString(),
100: ORGANIZATIONAL_UNIT);
101: participantTypeMap.put(HUMAN.toString(), HUMAN);
102: participantTypeMap.put(SYSTEM.toString(), SYSTEM);
103: }
104:
105: /**
106: * Default constructor.
107: * @param text textual representation of the type.
108: */
109: private ParticipantType(String text) {
110: type = text;
111: }
112:
113: /**
114: * Get a participant type by name.
115: * @param text participant type name to search
116: * @return participant type object
117: * @throws IllegalArgumentException if <code>text</code> is not a valid
118: * participant type name.
119: */
120: public static ParticipantType fromString(String text)
121: throws IllegalArgumentException {
122: if (text == null) {
123: throw new IllegalArgumentException(text);
124: }
125: ParticipantType participant = (ParticipantType) participantTypeMap
126: .get(text);
127: if (participant == null) {
128: throw new IllegalArgumentException(text);
129: }
130: return participant;
131: }
132:
133: /**
134: * Returns the type as text.
135: * @return type as text
136: */
137: public final String toString() {
138: return type;
139: }
140:
141: /**
142: * Checks if the type is "RESOURCE_SET".
143: * @return <code>true</code> if the type is "RESOURCE_SET".
144: */
145: public final boolean isResourceSet() {
146: return type.equals("RESOURCE_SET");
147: }
148:
149: /**
150: * Checks if the type is "RESOURCE".
151: * @return <code>true</code> if the type is "RESOURCE".
152: */
153: public final boolean isResource() {
154: return type.equals("RESOURCE");
155: }
156:
157: /**
158: * Checks if the type is "ROLE".
159: * @return <code>true</code> if the type is "ROLE".
160: */
161: public final boolean isRole() {
162: return type.equals("ROLE");
163: }
164:
165: /**
166: * Checks if the type is "ORGANIZATIONAL_UNIT".
167: * @return <code>true</code> if the type is "ORGANIZATIONAL_UNIT".
168: */
169: public final boolean isOrganizationUnit() {
170: return type.equals("ORGANIZATIONAL_UNIT");
171: }
172:
173: /**
174: * Checks if the type is "HUMAN".
175: * @return <code>true</code> if the type is "HUMAN".
176: */
177: public final boolean isHuman() {
178: return type.equals("HUMAN");
179: }
180:
181: /**
182: * Checks if the type is "SYSTEM".
183: * @return <code>true</code> if the type is "SYSTEM".
184: */
185: public final boolean isSystem() {
186: return type.equals("SYSTEM");
187: }
188:
189: /**
190: * Perform instance substitution during serialization.
191: */
192: private Object readResolve() {
193: try {
194: return fromString(type);
195: } catch (IllegalArgumentException iae) {
196: throw new IllegalArgumentException(
197: "Unexpected error in serialization");
198: }
199: }
200: }
201:
202: /**
203: * Get the id of the participant.
204: * @return a String representing the id value
205: */
206: public String getId();
207:
208: /**
209: * Get the name of the participant.
210: * @return a String representing the name value
211: */
212: public String getName();
213:
214: /**
215: * Get the type of the participant.
216: * @return a ParticipantType object representing the participant type value
217: */
218: public ParticipantType getParticipantType();
219:
220: /**
221: * Get the additional resource selection information passed to the
222: * constructor.
223: * @return an Object representing the resource selection value
224: */
225: public Object getResourceSelection();
226: }
|