/*
* 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: Assignment.java 2548 2007-10-22 14:00:52Z $
*
* $Log$
* Revision 1.3 2006/09/29 12:32:12 drmlipp
* Consistently using WfMOpen as projct name now.
*
* Revision 1.2 2005/10/15 21:19:38 mlipp
* Added support for providing WfAssignment
* implementations based purely on methods of Activity.
*
* Revision 1.1.1.2 2004/08/18 15:17:36 drmlipp
* Update to 1.2
*
* Revision 1.6 2004/06/14 19:37:19 lipp
* Fixed assignment functions and cleaned up assignment related
* interfaces.
*
* Revision 1.5 2004/03/03 17:23:13 lipp
* Implemented setAssignee and cleaned up code a bit.
*
* Revision 1.4 2003/06/27 08:51:46 lipp
* Fixed copyright/license information.
*
* Revision 1.3 2003/04/26 16:11:15 lipp
* Moved some classes to reduce package dependencies.
*
* Revision 1.2 2001/12/18 15:35:11 lipp
* Implemented workItems and isMemberOfWorkItem.
*
* Revision 1.1 2001/12/17 21:38:17 lipp
* New class.
*
*/
package de.danet.an.workflow.assignment;
import java.io.Serializable;
import java.rmi.RemoteException;
import de.danet.an.workflow.omgcore.InvalidResourceException;
import de.danet.an.workflow.omgcore.NotAssignedException;
import de.danet.an.workflow.omgcore.WfActivity;
import de.danet.an.workflow.omgcore.WfAssignment;
import de.danet.an.workflow.omgcore.WfResource;
import de.danet.an.workflow.api.Activity;
import de.danet.an.workflow.api.AlreadyAssignedException;
import de.danet.an.workflow.api.NoSuchResourceException;
/**
* This class provides the implementation of a resource
* {@link de.danet.an.workflow.omgcore.WfAssignment <code>assignment</code>}
* as used by {@link de.danet.an.workflow.assignment the standard
* assignment package}.
*/
public class Assignment implements WfAssignment, Serializable {
private long key;
private WfActivity activity;
/**
* Create a new Assignment.
*
* @param key the assignment key
* @param act the associated <code>WfActivity</code>
* @param svc the assignment service.
*/
public Assignment (long key, WfActivity act) {
this.key = key;
activity = act;
}
/**
* Return the id of this assignment.
* @return the finder index
*/
public long key () {
return key;
}
/* Comment copied from interface */
public WfActivity activity() throws RemoteException {
return activity;
}
/* Comment copied from interface */
public WfResource assignee() throws RemoteException {
return ((Activity)activity).getResource (this);
}
/* Comment copied from interface */
public void setAssignee (WfResource newValue)
throws RemoteException, InvalidResourceException {
if (newValue == null) {
throw new InvalidResourceException ();
}
try {
((Activity)activity).changeAssignment(assignee(), newValue);
} catch (NotAssignedException e) {
throw (InvalidResourceException)
(new InvalidResourceException ()).initCause (e);
} catch (AlreadyAssignedException e) {
throw (InvalidResourceException)
(new InvalidResourceException ()).initCause (e);
}
}
}