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: WrappedActivity.java,v 1.2 2006/09/29 12:32:08 drmlipp Exp $
021: *
022: * $Log: WrappedActivity.java,v $
023: * Revision 1.2 2006/09/29 12:32:08 drmlipp
024: * Consistently using WfMOpen as projct name now.
025: *
026: * Revision 1.1.1.1 2003/12/19 13:01:46 drmlipp
027: * Updated to 1.1rc1
028: *
029: * Revision 1.2 2003/10/28 14:06:13 huaiyang
030: * refactor it.
031: *
032: * Revision 1.1 2003/10/27 15:32:20 huaiyang
033: * initial.
034: *
035: *
036: *
037: */
038:
039: package common;
040:
041: import java.util.ArrayList;
042: import java.util.Collection;
043: import java.util.Iterator;
044: import java.util.List;
045:
046: import java.rmi.RemoteException;
047:
048: import de.danet.an.workflow.omgcore.CannotCompleteException;
049: import de.danet.an.workflow.omgcore.InvalidStateException;
050: import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
051: import de.danet.an.workflow.omgcore.WfActivity;
052: import de.danet.an.workflow.omgcore.WfProcess;
053:
054: import de.danet.an.workflow.api.Activity;
055:
056: /**
057: * Describe class <code>WrappedActivity</code> here.
058: *
059: * @author <a href="mailto:weidauer@danet.de">Christian Weidauer</a>
060: * @version 1.0
061: */
062: public class WrappedActivity extends WrappedExecutionObject {
063: /**
064: * Creates a new <code>WrappedActivity</code> instance.
065: *
066: * @param wfa a <code>WfActivity</code> value
067: */
068: public WrappedActivity(WfActivity wfa) throws Exception {
069: super (wfa);
070: }
071:
072: /**
073: * Sets the state of a Wfeoctivity object by calling
074: * complete().
075: * @exception RemoteException if an error occurs
076: * @exception CannotCompleteException if an error occurs
077: * @exception InvalidStateException if an error occurs
078: * @exception TransitionNotAllowedException if an error occurs
079: */
080: protected void complete() throws RemoteException,
081: CannotCompleteException, InvalidStateException,
082: TransitionNotAllowedException {
083: while (true) {
084: try {
085: ((WfActivity) wfeo).complete();
086: break;
087: } catch (RemoteException re) {
088: }
089: }
090: }
091:
092: /**
093: * Returns the list of activities that may follow this activity,
094: * i.e. to which transitions exist.
095: * @return the list of {@link Activity <code>Activity</code>} objects.
096: * @throws RemoteException if a system-level error occurs.
097: */
098: public List nextActivities() throws Exception {
099: List nextActivities = null;
100: while (true) {
101: try {
102: nextActivities = (List) wrapActivities(((Activity) wfeo)
103: .nextActivities());
104: break;
105: } catch (RemoteException re) {
106: }
107: }
108: return nextActivities;
109: }
110:
111: /**
112: * Returns all the <code>WfAssignment</code> associated with a
113: # * <code>WfActivity</code>.
114: * @return the collection of all the WfAssignment.
115: * @throws RemoteException if a system-level error occurs.
116: */
117: public Collection assignments() {
118: while (true) {
119: try {
120: return ((WfActivity) wfeo).assignments();
121: } catch (RemoteException re) {
122: // try again
123: }
124: }
125: }
126:
127: /**
128: * Returns the <code>WfProcess</code> that this activity is a part of.
129: * @return the process.
130: * @throws RemoteException if a system-level error occurs.
131: */
132: public WrappedProcess container() throws Exception {
133: WrappedProcess proc = null;
134: while (true) {
135: try {
136: proc = new WrappedProcess(((WfActivity) wfeo)
137: .container());
138: break;
139: } catch (RemoteException re) {
140: }
141: }
142: return proc;
143: }
144:
145: /**
146: * return the performers of this activity, i.e. processes.
147: */
148: public Collection performers() throws Exception {
149: Collection performers = null;
150: while (true) {
151: try {
152: performers = ((WfActivity) wfeo).performers();
153: break;
154: } catch (RemoteException re) {
155: }
156: }
157: performers = wrapProcesses(performers);
158: return performers;
159: }
160:
161: /**
162: * Describe <code>wrapProcesses</code> method here.
163: *
164: * @param activityCollection a <code>Collection</code> value
165: * @return a <code>Collection</code> value
166: */
167: protected Collection wrapProcesses(Collection performerCollection)
168: throws Exception {
169: Collection newCollection = new ArrayList();
170: Iterator it = performerCollection.iterator();
171: while (it.hasNext()) {
172: WfProcess process = (WfProcess) it.next();
173: newCollection.add(new WrappedProcess(process));
174: }
175: return newCollection;
176: }
177: }
|