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: DefaultParticipant.java,v 1.4 2007/05/03 21:58:18 mlipp Exp $
021: *
022: * $Log: DefaultParticipant.java,v $
023: * Revision 1.4 2007/05/03 21:58:18 mlipp
024: * Internal refactoring for making better use of local EJBs.
025: *
026: * Revision 1.3 2007/02/27 14:34:15 drmlipp
027: * Some refactoring to reduce cyclic dependencies.
028: *
029: * Revision 1.2 2006/09/29 12:32:08 drmlipp
030: * Consistently using WfMOpen as projct name now.
031: *
032: * Revision 1.1.1.1 2003/06/30 20:05:15 drmlipp
033: * Initial import
034: *
035: * Revision 1.16 2003/06/27 08:51:45 lipp
036: * Fixed copyright/license information.
037: *
038: * Revision 1.15 2003/04/25 20:12:22 lipp
039: * Removed old "constructor".
040: *
041: * Revision 1.14 2003/04/25 20:05:32 lipp
042: * Retrieving participants from SAX now.
043: *
044: * Revision 1.13 2003/04/24 20:50:13 lipp
045: * Fixed some warnings.
046: *
047: * Revision 1.12 2003/03/31 16:50:28 huaiyang
048: * Logging using common-logging.
049: *
050: * Revision 1.11 2003/03/28 12:44:08 lipp
051: * Moved XPDL related constants to XPDLUtil.
052: *
053: * Revision 1.10 2002/12/19 21:37:43 lipp
054: * Reorganized interfaces.
055: *
056: * Revision 1.9 2002/09/27 11:27:22 huaiyang
057: * Use fromString method to construct the object of participant type.
058: *
059: * Revision 1.8 2002/09/11 06:33:32 huaiyang
060: * Remove the variable of prefix.
061: *
062: * Revision 1.7 2002/09/02 12:24:03 huaiyang
063: * Use namespace in parsing.
064: *
065: * Revision 1.6 2002/08/30 07:58:19 huaiyang
066: * Separation of Domain class and persistent class more cleaner.
067: *
068: * Revision 1.5 2002/08/26 14:17:07 lipp
069: * JavaDoc fixes.
070: *
071: * Revision 1.4 2002/08/20 13:46:13 lipp
072: * Using xpath now to extract additional process information from xpdl.
073: *
074: * Revision 1.3 2002/07/24 08:04:42 huaiyang
075: * doccheck.
076: *
077: * Revision 1.2 2002/05/16 19:47:48 lipp
078: * Proper usage of constructingSAXHandler.
079: *
080: * Revision 1.1 2002/01/29 14:49:34 huaiyang
081: * Taken from the class Participant to seperate the the interface and specific
082: * usage.
083: *
084: *
085: */
086: package de.danet.an.workflow.domain;
087:
088: import org.xml.sax.Attributes;
089: import org.xml.sax.SAXException;
090:
091: import de.danet.an.util.sax.StackedHandler;
092: import de.danet.an.workflow.api.Participant;
093:
094: /**
095: * This class defines the handler for a participant.
096: */
097: public class DefaultParticipant implements Participant {
098:
099: private static final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory
100: .getLog(DefaultParticipant.class);
101:
102: // Identifier of the participant
103: private String id = null;
104:
105: // Name of the participant
106: private String name = null;
107:
108: // Type of the participant
109: private ParticipantType participantType = null;
110:
111: // Type of the participant
112: private Object resourceSelection = null;
113:
114: /**
115: * Construct a new <code>DefaultParticipant</code>.
116: * @param id identifier of the participant in String
117: * @param name name of the participant in String
118: * @param type type of the participant
119: * @param resSel an object that describes resource selection criteria.
120: * The paramter may be <code>null</code>.
121: */
122: public DefaultParticipant(String id, String name,
123: ParticipantType type, Object resSel) {
124: this .id = id;
125: this .name = name;
126: this .participantType = type;
127: this .resourceSelection = resSel;
128: }
129:
130: /**
131: * Get the id of the participant.
132: * @return a String representing the id value
133: */
134: public String getId() {
135: return id;
136: }
137:
138: /**
139: * Get the name of the participant.
140: * @return a String representing the name value
141: */
142: public String getName() {
143: return name;
144: }
145:
146: /**
147: * Get the type of the participant.
148: * @return a ParticipantType object representing the participant type value
149: */
150: public ParticipantType getParticipantType() {
151: return participantType;
152: }
153:
154: /**
155: * Get the additional resource selection information passed to the
156: * constructor.
157: * @return an Object representing the resource selection value
158: */
159: public Object getResourceSelection() {
160: return resourceSelection;
161: }
162:
163: /**
164: * Helper class for retrieving the applications from the process
165: * definition.
166: */
167: public static class SAXInitializer extends StackedHandler {
168:
169: private String id = null;
170: private String name = null;
171: private ParticipantType type = null;
172: private Object resSel = null;
173:
174: /**
175: * Receive notification of the beginning of an element.
176: *
177: * @param uri the Namespace URI, or the empty string if the
178: * element has no Namespace URI or if Namespace processing is not
179: * being performed.
180: * @param loc the local name (without prefix), or the empty string
181: * if Namespace processing is not being performed.
182: * @param raw the raw XML 1.0 name (with prefix), or the empty
183: * string if raw names are not available.
184: * @param a the attributes attached to the element. If there are
185: * no attributes, it shall be an empty Attributes object.
186: * @throws SAXException not thrown.
187: */
188: public void startElement(String uri, String loc, String raw,
189: Attributes a) throws SAXException {
190: if (loc.equals("Participant")) {
191: id = a.getValue("Id");
192: name = a.getValue("Name");
193: } else if (loc.equals("ParticipantType")) {
194: type = ParticipantType.fromString(a.getValue("Type"));
195: } else if (loc.equals("ExtendedAttribute")
196: && a.getValue("Name") != null
197: && a.getValue("Name").equals("resource-selection")) {
198: resSel = a.getValue("Value");
199: logger.debug("resource-selection: " + resSel);
200: }
201: }
202:
203: /**
204: * Receive notification of the end of an element.
205: *
206: * @param uri the Namespace URI, or the empty string if the
207: * element has no Namespace URI or if Namespace processing is not
208: * being performed.
209: * @param loc the local name (without prefix), or the empty string
210: * if Namespace processing is not being performed.
211: * @param raw the raw XML 1.0 name (with prefix), or the empty
212: * string if raw names are not available.
213: * @throws SAXException not thrown.
214: */
215: public void endElement(String uri, String loc, String raw)
216: throws SAXException {
217: if (loc.equals("Participant")) {
218: getStack().setContextData("Participant",
219: new DefaultParticipant(id, name, type, resSel));
220: }
221: }
222: }
223: }
|