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: WrappedProcess.java,v 1.3 2007/03/27 21:59:44 mlipp Exp $
021: *
022: * $Log: WrappedProcess.java,v $
023: * Revision 1.3 2007/03/27 21:59:44 mlipp
024: * Fixed lots of checkstyle warnings.
025: *
026: * Revision 1.2 2006/09/29 12:32:08 drmlipp
027: * Consistently using WfMOpen as projct name now.
028: *
029: * Revision 1.1.1.1 2003/12/19 13:01:46 drmlipp
030: * Updated to 1.1rc1
031: *
032: * Revision 1.2 2003/10/28 14:06:13 huaiyang
033: * refactor it.
034: *
035: * Revision 1.1 2003/10/27 15:32:20 huaiyang
036: * initial.
037: *
038: *
039: *
040: */
041: package common;
042:
043: import java.util.Collection;
044:
045: import java.rmi.RemoteException;
046:
047: import de.danet.an.workflow.omgcore.AlreadyRunningException;
048: import de.danet.an.workflow.omgcore.CannotStartException;
049: import de.danet.an.workflow.omgcore.InvalidStateException;
050: import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
051: import de.danet.an.workflow.omgcore.WfProcess;
052:
053: /**
054: * Describe class <code>WrappedProcess</code> here.
055: *
056: * @author <a href="mailto:weidauer@danet.de">Christian Weidauer</a>
057: * @version 1.0
058: */
059: public class WrappedProcess extends WrappedExecutionObject {
060:
061: /**
062: * Creates a new <code>WrappedProcess</code> instance.
063: *
064: * @param wfp a <code>WfProcess</code> value
065: */
066: public WrappedProcess(WfProcess wfp) throws Exception {
067: super (wfp);
068: }
069:
070: /**
071: * Sets the state of a WfProcess object by calling
072: * start().
073: * @exception RemoteException if an error occurs
074: * @exception CannotStartException if an error occurs
075: * @exception AlreadyRunningException if an error occurs
076: * @exception InvalidStateException if an error occurs
077: * @exception TransitionNotAllowedException if an error occurs
078: */
079: public void start() throws RemoteException, CannotStartException,
080: AlreadyRunningException, InvalidStateException,
081: TransitionNotAllowedException {
082: while (true) {
083: try {
084: ((WfProcess) wfeo).start();
085: break;
086: } catch (RemoteException re) {
087: }
088: }
089: }
090:
091: /**
092: * Describe <code>activitiesInState</code> method here.
093: *
094: * @param state a <code>String</code> value
095: * @return a <code>Collection</code> value
096: * @exception Exception if an error occurs
097: */
098: public Collection activitiesInState(String state) throws Exception {
099: Collection activities = null;
100: while (true) {
101: try {
102: activities = ((WfProcess) wfeo)
103: .activitiesInState(state);
104: break;
105: } catch (RemoteException re) {
106: }
107: }
108: activities = wrapActivities(activities);
109: return activities;
110: }
111:
112: /**
113: * Describe <code>steps</code> method here.
114: *
115: * @return a <code>Collection</code> value
116: * @exception Exception if an error occurs
117: */
118: public Collection steps() throws Exception {
119: Collection steps = null;
120: while (true) {
121: try {
122: steps = ((WfProcess) wfeo).steps();
123: break;
124: } catch (RemoteException re) {
125: }
126: }
127: steps = wrapActivities(steps);
128: return steps;
129: }
130:
131: /**
132: * Describe <code>getWfProcess</code> method here.
133: *
134: * @return a <code>WfProcess</code> value
135: */
136: public WfProcess getWfProcess() {
137: return (WfProcess) wfeo;
138: }
139:
140: /**
141: * Check if the given proc is the same as the current one.
142: */
143: public boolean equals(Object wproc) {
144: try {
145: return this .getWfProcess().key().equals(
146: ((WrappedProcess) wproc).getWfProcess().key());
147: } catch (RemoteException e) {
148: throw new IllegalStateException();
149: }
150: }
151:
152: /**
153: * Return the hash code.<P>
154: * @return the result.
155: */
156: public int hashCode() {
157: try {
158: return this .getWfProcess().key().hashCode();
159: } catch (RemoteException e) {
160: throw new IllegalStateException();
161: }
162: }
163:
164: }
|