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: ActivityUniqueKey.java,v 1.2 2006/09/29 12:32:07 drmlipp Exp $
021: *
022: * $Log: ActivityUniqueKey.java,v $
023: * Revision 1.2 2006/09/29 12:32:07 drmlipp
024: * Consistently using WfMOpen as projct name now.
025: *
026: * Revision 1.1.1.1 2003/06/30 20:05:13 drmlipp
027: * Initial import
028: *
029: * Revision 1.6 2003/06/27 08:51:46 lipp
030: * Fixed copyright/license information.
031: *
032: * Revision 1.5 2002/11/26 11:23:30 lipp
033: * Modified RemoteException comment.
034: *
035: * Revision 1.4 2002/10/02 10:58:13 lipp
036: * Modifications for tool invocation.
037: *
038: * Revision 1.3 2002/07/05 20:35:12 lipp
039: * Redefined ActivityUniqueKey constructor parameter sequence.
040: *
041: * Revision 1.2 2002/06/26 21:45:43 lipp
042: * Added equals and hash.
043: *
044: * Revision 1.1 2002/06/15 19:02:02 lipp
045: * New utility type.
046: *
047: */
048: package de.danet.an.workflow.api;
049:
050: import java.io.Serializable;
051:
052: import java.rmi.RemoteException;
053:
054: import de.danet.an.workflow.omgcore.WfActivity;
055: import de.danet.an.workflow.omgcore.WfProcess;
056:
057: /**
058: * This class implements a unique activity key. The OMG interface defines
059: * the key returned by the
060: * {@link de.danet.an.workflow.omgcore.WfExecutionObject#key
061: * <code>key()</code>} method as unique within the scope of the containing
062: * process only. The key of a process in turn is unique only among the
063: * processes with a common process manager.<P>
064: *
065: * This class therefore combines the activity key, the process key and
066: * the process manager name to a unique activity key.
067: *
068: * @author <a href="mailto:mnl@mnl.de">Michael N. Lipp</a>
069: * @version $Revision: 1.2 $
070: */
071:
072: public class ActivityUniqueKey implements Serializable {
073:
074: private String mgrName;
075: private String procKey;
076: private String actKey;
077:
078: /**
079: * Creates an instance of <code>ActivityUniqueKey</code>
080: * for the given activity.
081: *
082: * @param activity the <code>WfActivity</code>.
083: * @throws RemoteException if a system-level error occurs.
084: */
085: public ActivityUniqueKey(WfActivity activity)
086: throws RemoteException {
087: actKey = activity.key();
088: WfProcess proc = activity.container();
089: procKey = proc.key();
090: String mgrName = proc.manager().name();
091: }
092:
093: /**
094: * Creates an instance of <code>ActivityUniqueKey</code>
095: * from the given partial keys.
096: *
097: * @param managerName the process manager name.
098: * @param processKey the process key.
099: * @param activityKey the activity key.
100: */
101: public ActivityUniqueKey(String managerName, String processKey,
102: String activityKey) {
103: if (activityKey == null || processKey == null
104: || managerName == null) {
105: throw new IllegalArgumentException();
106: }
107: mgrName = managerName;
108: procKey = processKey;
109: actKey = activityKey;
110: }
111:
112: /**
113: * Two <code>ActivityUniqueKey</code>s are equal, if all
114: * attributes are equal.
115: *
116: * @param other a <code>ActivityUniqueKey</code> value
117: * @return <code>true</code> if objects are equal.
118: */
119: public boolean equals(Object other) {
120: ActivityUniqueKey o = (ActivityUniqueKey) other;
121: return actKey.equals(o.actKey) && procKey.equals(o.procKey)
122: && mgrName.equals(o.mgrName);
123: }
124:
125: /**
126: * Calculate a hash code for a <code>ActivityUniqueKey</code>
127: * object.
128: *
129: * @return the hash code.
130: */
131: public int hashCode() {
132: return actKey.hashCode() ^ procKey.hashCode()
133: ^ mgrName.hashCode();
134: }
135:
136: /**
137: * Return the activity key.
138: *
139: * @return the activity key.
140: */
141: public String activityKey() {
142: return actKey;
143: }
144:
145: /**
146: * Return the process key.
147: *
148: * @return the process key.
149: */
150: public String processKey() {
151: return procKey;
152: }
153:
154: /**
155: * Return the process manager name.
156: *
157: * @return the process manager name.
158: */
159: public String managerName() {
160: return mgrName;
161: }
162:
163: /**
164: * Generate a string representation for debugging purposes.
165: * @return a string representation.
166: */
167: public String toString() {
168: return "Activity[" + mgrName + "/" + procKey + "/" + actKey
169: + "]";
170: }
171: }
|