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: Assignment.java,v 1.4 2007/02/27 14:34:18 drmlipp Exp $
021: *
022: * $Log: Assignment.java,v $
023: * Revision 1.4 2007/02/27 14:34:18 drmlipp
024: * Some refactoring to reduce cyclic dependencies.
025: *
026: * Revision 1.3 2006/09/29 12:32:12 drmlipp
027: * Consistently using WfMOpen as projct name now.
028: *
029: * Revision 1.2 2005/10/15 21:19:38 mlipp
030: * Added support for providing WfAssignment
031: * implementations based purely on methods of Activity.
032: *
033: * Revision 1.1.1.2 2004/08/18 15:17:36 drmlipp
034: * Update to 1.2
035: *
036: * Revision 1.6 2004/06/14 19:37:19 lipp
037: * Fixed assignment functions and cleaned up assignment related
038: * interfaces.
039: *
040: * Revision 1.5 2004/03/03 17:23:13 lipp
041: * Implemented setAssignee and cleaned up code a bit.
042: *
043: * Revision 1.4 2003/06/27 08:51:46 lipp
044: * Fixed copyright/license information.
045: *
046: * Revision 1.3 2003/04/26 16:11:15 lipp
047: * Moved some classes to reduce package dependencies.
048: *
049: * Revision 1.2 2001/12/18 15:35:11 lipp
050: * Implemented workItems and isMemberOfWorkItem.
051: *
052: * Revision 1.1 2001/12/17 21:38:17 lipp
053: * New class.
054: *
055: */
056: package de.danet.an.workflow.assignment;
057:
058: import java.io.Serializable;
059:
060: import java.rmi.RemoteException;
061:
062: import de.danet.an.workflow.omgcore.InvalidResourceException;
063: import de.danet.an.workflow.omgcore.NotAssignedException;
064: import de.danet.an.workflow.omgcore.WfActivity;
065: import de.danet.an.workflow.omgcore.WfAssignment;
066: import de.danet.an.workflow.omgcore.WfResource;
067:
068: import de.danet.an.workflow.api.Activity;
069: import de.danet.an.workflow.api.AlreadyAssignedException;
070: import de.danet.an.workflow.api.NoSuchResourceException;
071:
072: /**
073: * This class provides the implementation of a resource
074: * {@link de.danet.an.workflow.omgcore.WfAssignment <code>assignment</code>}
075: * as used by {@link de.danet.an.workflow.assignment the standard
076: * assignment package}.
077: */
078: public class Assignment implements WfAssignment, Serializable {
079:
080: private long key;
081: private WfActivity activity;
082:
083: /**
084: * Create a new Assignment.
085: *
086: * @param key the assignment key
087: * @param act the associated <code>WfActivity</code>
088: * @param svc the assignment service.
089: */
090: public Assignment(long key, WfActivity act) {
091: this .key = key;
092: activity = act;
093: }
094:
095: /**
096: * Return the id of this assignment.
097: * @return the finder index
098: */
099: public long key() {
100: return key;
101: }
102:
103: /* Comment copied from interface */
104: public WfActivity activity() throws RemoteException {
105: return activity;
106: }
107:
108: /* Comment copied from interface */
109: public WfResource assignee() throws RemoteException {
110: return ((Activity) activity).getResource(this );
111: }
112:
113: /* Comment copied from interface */
114: public void setAssignee(WfResource newValue)
115: throws RemoteException, InvalidResourceException {
116: if (newValue == null) {
117: throw new InvalidResourceException();
118: }
119: try {
120: ((Activity) activity)
121: .changeAssignment(assignee(), newValue);
122: } catch (NotAssignedException e) {
123: throw (InvalidResourceException) (new InvalidResourceException())
124: .initCause(e);
125: } catch (AlreadyAssignedException e) {
126: throw (InvalidResourceException) (new InvalidResourceException())
127: .initCause(e);
128: }
129: }
130: }
|