/*
* This file is part of the WfMOpen project.
* Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: WrappedActivity.java 1607 2006-09-29 12:32:13Z drmlipp $
*
* $Log$
* Revision 1.1.1.1 2003/12/19 13:01:46 drmlipp
* Updated to 1.1rc1
*
* Revision 1.2 2003/10/28 14:06:13 huaiyang
* refactor it.
*
* Revision 1.1 2003/10/27 15:32:20 huaiyang
* initial.
*
*
*
*/
package common;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.rmi.RemoteException;
import de.danet.an.workflow.omgcore.CannotCompleteException;
import de.danet.an.workflow.omgcore.InvalidStateException;
import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
import de.danet.an.workflow.omgcore.WfActivity;
import de.danet.an.workflow.omgcore.WfProcess;
import de.danet.an.workflow.api.Activity;
/**
* Describe class <code>WrappedActivity</code> here.
*
* @author <a href="mailto:weidauer@danet.de">Christian Weidauer</a>
* @version 1.0
*/
public class WrappedActivity extends WrappedExecutionObject {
/**
* Creates a new <code>WrappedActivity</code> instance.
*
* @param wfa a <code>WfActivity</code> value
*/
public WrappedActivity(WfActivity wfa)
throws Exception {
super(wfa);
}
/**
* Sets the state of a Wfeoctivity object by calling
* complete().
* @exception RemoteException if an error occurs
* @exception CannotCompleteException if an error occurs
* @exception InvalidStateException if an error occurs
* @exception TransitionNotAllowedException if an error occurs
*/
protected void complete()
throws RemoteException, CannotCompleteException,
InvalidStateException, TransitionNotAllowedException {
while (true) {
try {
((WfActivity)wfeo).complete();
break;
} catch (RemoteException re) {
}
}
}
/**
* Returns the list of activities that may follow this activity,
* i.e. to which transitions exist.
* @return the list of {@link Activity <code>Activity</code>} objects.
* @throws RemoteException if a system-level error occurs.
*/
public List nextActivities () throws Exception {
List nextActivities = null;
while (true) {
try {
nextActivities
= (List)wrapActivities(((Activity)wfeo).nextActivities());
break;
} catch (RemoteException re) {
}
}
return nextActivities;
}
/**
* Returns all the <code>WfAssignment</code> associated with a
# * <code>WfActivity</code>.
* @return the collection of all the WfAssignment.
* @throws RemoteException if a system-level error occurs.
*/
public Collection assignments() {
while (true) {
try {
return ((WfActivity)wfeo).assignments();
} catch (RemoteException re) {
// try again
}
}
}
/**
* Returns the <code>WfProcess</code> that this activity is a part of.
* @return the process.
* @throws RemoteException if a system-level error occurs.
*/
public WrappedProcess container() throws Exception {
WrappedProcess proc = null;
while (true) {
try {
proc = new WrappedProcess(((WfActivity)wfeo).container());
break;
} catch (RemoteException re) {
}
}
return proc;
}
/**
* return the performers of this activity, i.e. processes.
*/
public Collection performers() throws Exception {
Collection performers = null;
while (true) {
try {
performers = ((WfActivity)wfeo).performers();
break;
} catch (RemoteException re) {
}
}
performers = wrapProcesses(performers);
return performers;
}
/**
* Describe <code>wrapProcesses</code> method here.
*
* @param activityCollection a <code>Collection</code> value
* @return a <code>Collection</code> value
*/
protected Collection wrapProcesses(Collection performerCollection)
throws Exception {
Collection newCollection = new ArrayList();
Iterator it = performerCollection.iterator();
while (it.hasNext()) {
WfProcess process = (WfProcess)it.next();
newCollection.add(new WrappedProcess(process));
}
return newCollection;
}
}