0001: /*
0002: * This file is part of the WfMOpen project.
0003: * Copyright (C) 2001-2003 Danet GmbH (www.danet.de), GS-AN.
0004: * All rights reserved.
0005: *
0006: * This program is free software; you can redistribute it and/or modify
0007: * it under the terms of the GNU General Public License as published by
0008: * the Free Software Foundation; either version 2 of the License, or
0009: * (at your option) any later version.
0010: *
0011: * This program is distributed in the hope that it will be useful,
0012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0014: * GNU General Public License for more details.
0015: *
0016: * You should have received a copy of the GNU General Public License
0017: * along with this program; if not, write to the Free Software
0018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
0019: *
0020: * $Id: Activity.java,v 1.10 2007/02/27 14:34:21 drmlipp Exp $
0021: *
0022: * $Log: Activity.java,v $
0023: * Revision 1.10 2007/02/27 14:34:21 drmlipp
0024: * Some refactoring to reduce cyclic dependencies.
0025: *
0026: * Revision 1.9 2006/12/04 14:17:20 drmlipp
0027: * Added support for retrieving invoked subprocess.
0028: *
0029: * Revision 1.8 2006/09/29 12:32:07 drmlipp
0030: * Consistently using WfMOpen as projct name now.
0031: *
0032: * Revision 1.7 2006/09/14 08:03:46 drmlipp
0033: * Removed activity attribute and method from Activity.Info for improved
0034: * serializability and long term storage. Anyone calling activityInfo()
0035: * should already have the activity anyway.
0036: *
0037: * Revision 1.6 2005/10/15 21:19:38 mlipp
0038: * Added support for providing WfAssignment
0039: * implementations based purely on methods of Activity.
0040: *
0041: * Revision 1.5 2005/08/19 14:32:42 drmlipp
0042: * Synchronized with wfmopen-1.3.1p4.
0043: *
0044: * Revision 1.3.2.3 2005/08/19 13:13:21 drmlipp
0045: * Using dbdoclet for DocBook style JavaDoc generation now.
0046: *
0047: * Revision 1.4 2005/02/04 14:25:24 drmlipp
0048: * Synchronized with 1.3rc2.
0049: *
0050: * Revision 1.3.2.2 2005/02/01 16:08:37 drmlipp
0051: * Implemented deferred choice.
0052: *
0053: * Revision 1.3.2.1 2005/01/31 15:41:15 drmlipp
0054: * Started implementation of deferred choice.
0055: *
0056: * Revision 1.3 2005/01/09 21:32:41 mlipp
0057: * Added support for debugging exceptions and deadlines.
0058: *
0059: * Revision 1.2 2005/01/05 21:29:21 mlipp
0060: * Added method to retrieve handled exceptions.
0061: *
0062: * Revision 1.1.1.3 2004/08/18 15:17:36 drmlipp
0063: * Update to 1.2
0064: *
0065: * Revision 1.30 2004/06/14 19:37:19 lipp
0066: * Fixed assignment functions and cleaned up assignment related
0067: * interfaces.
0068: *
0069: * Revision 1.29 2004/03/29 11:41:01 lipp
0070: * Extended documentation.
0071: *
0072: * Revision 1.28 2004/03/26 12:18:44 lipp
0073: * Updated documentation.
0074: *
0075: * Revision 1.27 2004/03/21 20:34:41 lipp
0076: * Added "abandon" to Activity.
0077: *
0078: * Revision 1.26 2003/09/23 14:27:37 lipp
0079: * Moved definition of closed.completed substates to activity (only used
0080: * there).
0081: *
0082: * Revision 1.25 2003/09/22 12:32:57 lipp
0083: * Implemented deadline creation for block activities.
0084: *
0085: * Revision 1.24 2003/06/27 08:51:46 lipp
0086: * Fixed copyright/license information.
0087: *
0088: * Revision 1.23 2003/05/15 11:31:07 lipp
0089: * Refactored executor() method.
0090: *
0091: * Revision 1.22 2003/04/25 14:50:59 lipp
0092: * Fixed javadoc errors and warnings.
0093: *
0094: * Revision 1.21 2003/02/04 12:38:10 lipp
0095: * Added interface for subflow implementation.
0096: *
0097: * Revision 1.20 2002/11/26 11:23:30 lipp
0098: * Modified RemoteException comment.
0099: *
0100: * Revision 1.19 2002/11/12 17:12:52 lipp
0101: * Added fromString for JoinSplitMode.
0102: *
0103: * Revision 1.18 2002/10/09 14:26:53 lipp
0104: * Renamed ActivityMode to StartFinishMode and moved to interface
0105: * Activity.
0106: *
0107: * Revision 1.17 2002/10/02 10:58:13 lipp
0108: * Modifications for tool invocation.
0109: *
0110: * Revision 1.16 2002/09/26 09:53:00 huaiyang
0111: * In readresolve method use text representation to compare.
0112: *
0113: * Revision 1.15 2002/09/23 20:31:28 lipp
0114: * Implemented async/sync invocation.
0115: *
0116: * Revision 1.14 2002/09/23 15:12:39 lipp
0117: * Extended tool implementation definition and usage.
0118: *
0119: * Revision 1.13 2002/09/18 09:47:01 huaiyang
0120: * Use readResolve method to make enumerations typesafe.
0121: *
0122: * Revision 1.12 2002/08/26 20:23:13 lipp
0123: * Lots of method renames.
0124: *
0125: * Revision 1.11 2002/06/17 20:10:12 lipp
0126: * Added last change date.
0127: *
0128: * Revision 1.10 2002/06/17 15:04:30 lipp
0129: * Added priority to info and display.
0130: *
0131: * Revision 1.9 2002/06/17 14:42:35 lipp
0132: * Introducing activity info.
0133: *
0134: * Revision 1.8 2002/05/22 13:54:59 lipp
0135: * Return type of getTools changed from Collection to List.
0136: *
0137: * Revision 1.7 2002/05/21 13:26:19 huaiyang
0138: * New method of executor.
0139: *
0140: * Revision 1.6 2002/02/04 12:34:23 lipp
0141: * Moved ActivityFinderAndKey to its proper scope.
0142: *
0143: * Revision 1.5 2002/01/31 15:40:10 huaiyang
0144: * Add the method of getTools.
0145: *
0146: * Revision 1.4 2002/01/22 10:59:15 huaiyang
0147: * Take the resoure selection out of the database.
0148: *
0149: * Revision 1.3 2002/01/18 09:52:37 huaiyang
0150: * Add performer() method
0151: *
0152: * Revision 1.2 2002/01/17 16:42:14 lipp
0153: * Fixed comment
0154: *
0155: * Revision 1.1 2002/01/15 14:25:01 robert
0156: * replace from workflow/domain to workflow/api
0157: *
0158: * Revision 1.44 2002/01/10 15:36:53 lipp
0159: * Cleaned up definition of Priority.
0160: *
0161: * Revision 1.43 2001/12/20 22:22:50 lipp
0162: * Resource release implemented.
0163: *
0164: * Revision 1.42 2001/12/19 21:07:50 lipp
0165: * Added resource selection object.
0166: *
0167: * Revision 1.41 2001/12/18 22:16:53 lipp
0168: * Restructured DOM generation, implemented "assignments" method from ras.
0169: *
0170: * Revision 1.40 2001/12/17 09:15:50 lipp
0171: * Javadoc fixes.
0172: *
0173: * Revision 1.39 2001/12/15 12:47:07 lipp
0174: * Getting an ActivityFinder implemented.
0175: *
0176: * Revision 1.38 2001/11/30 15:39:37 lipp
0177: * Evolving resource assignment.
0178: *
0179: * Revision 1.37 2001/11/27 18:26:42 lipp
0180: * Resource handling redesigned.
0181: *
0182: * Revision 1.36 2001/11/19 16:12:50 lipp
0183: * Handling resource assignments, 2nd design try.
0184: *
0185: * Revision 1.35 2001/10/25 17:15:50 lipp
0186: * Renamed getTransitionsRefs() to getNextActivities() (more appropriate
0187: * name) and added TransitionRefs to DOM representatiosn.
0188: *
0189: * Revision 1.34 2001/10/09 16:00:33 lipp
0190: * Additional imports for javadoc.
0191: *
0192: * Revision 1.33 2001/10/09 13:48:27 montag
0193: * doccheck
0194: *
0195: * Revision 1.32 2001/10/06 09:45:51 lipp
0196: * Seperated interface and implementation of domain classes.
0197: *
0198: * Revision 1.31 2001/10/04 08:01:21 montag
0199: * correction changeState for aborted process
0200: * and aborting activity.
0201: *
0202: * Revision 1.30 2001/10/02 13:15:34 montag
0203: * allow state change only if process is not closed.
0204: *
0205: * Revision 1.29 2001/10/01 10:29:52 montag
0206: * rewriting of transition manager (fourth part):
0207: * XOR splits now works.
0208: * TO DO: if a process is finished now depends not
0209: * on that all activities closed.
0210: *
0211: * Revision 1.28 2001/09/27 14:38:16 montag
0212: * rewriting of transition manager (second part):
0213: * now the old behaviour is available
0214: *
0215: * Revision 1.27 2001/09/27 12:09:50 montag
0216: * rewriting of transition manager (first part)
0217: *
0218: * Revision 1.26 2001/09/26 13:06:16 montag
0219: * db scheme now supports join and splits
0220: * for activities.
0221: * Two new process types for join and split tests
0222: * intoduced.
0223: *
0224: * Revision 1.25 2001/09/26 11:39:15 montag
0225: * db scheme now supports join and splits
0226: * for activities.
0227: * Two new process types for join and split tests
0228: * intoduced.
0229: *
0230: * Revision 1.24 2001/09/25 13:55:43 montag
0231: * start- and finish-mode now private
0232: *
0233: * Revision 1.23 2001/09/24 12:46:46 montag
0234: * ActivityAttributes removed.
0235: *
0236: * Revision 1.22 2001/09/21 16:43:08 montag
0237: * "Faule Bits" solved
0238: *
0239: * Revision 1.21 2001/09/11 12:30:05 montag
0240: * clean up refresh/dispose due to new db scheme
0241: *
0242: * Revision 1.20 2001/09/11 11:43:55 montag
0243: * removed obsolete columns from the db. next step:
0244: * clean up refresh/dispose due to new db scheme
0245: *
0246: * Revision 1.19 2001/09/11 07:19:07 montag
0247: * usage of bean resources, second part
0248: * load of transitions corrected
0249: *
0250: * Revision 1.18 2001/09/10 15:51:53 montag
0251: * usage of bean resources, first part
0252: *
0253: * Revision 1.17 2001/09/09 14:21:08 montag
0254: * notify process not in setInternalState()
0255: *
0256: * Revision 1.16 2001/09/09 13:39:19 montag
0257: * automatic finish mode: set activity to closed.completed
0258: * and notify process
0259: *
0260: * Revision 1.15 2001/09/07 12:19:00 lipp
0261: * Reflect manual and automatic finish mode in validStates
0262: *
0263: * Revision 1.14 2001/09/04 12:43:03 montag
0264: * lazy initialization of modes
0265: *
0266: * Revision 1.13 2001/08/23 14:13:16 lipp
0267: * Status handling now conformant to "Workflow Management Application
0268: * Programming Interface (Interface 2&3)", Appendix G.
0269: *
0270: * Revision 1.12 2001/08/21 15:48:05 lipp
0271: * Return types of state querying functions converted to
0272: * String as required by OMG (some minor bugs still left)
0273: *
0274: * Revision 1.11 2001/08/19 14:12:32 montag
0275: * no start of activity if process is not started
0276: *
0277: * Revision 1.10 2001/08/15 07:46:37 montag
0278: * new interface for client calls
0279: *
0280: * Revision 1.9 2001/08/14 16:30:47 montag
0281: * internal mode
0282: *
0283: * Revision 1.8 2001/08/14 09:11:21 montag
0284: * check closed state of process activities
0285: *
0286: * Revision 1.7 2001/08/11 13:16:30 montag
0287: * State and Priority now inner classes of interface WfExecutionObject
0288: *
0289: * Revision 1.6 2001/08/08 12:23:21 montag
0290: * javadoc corrected
0291: *
0292: * Revision 1.5 2001/08/02 09:35:54 montag
0293: * priority and domain classes
0294: *
0295: * Revision 1.4 2001/08/01 14:00:57 montag
0296: * References to the omg modell.
0297: *
0298: * Revision 1.3 2001/08/01 13:28:40 montag
0299: * make modell easier
0300: *
0301: * Revision 1.2 2001/08/01 08:16:26 montag
0302: * modelling according to the xpdl description
0303: *
0304: * Revision 1.1 2001/07/31 16:20:17 montag
0305: * more base classes
0306: *
0307: *
0308: */
0309: package de.danet.an.workflow.api;
0310:
0311: import java.io.Serializable;
0312:
0313: import java.util.Date;
0314: import java.util.List;
0315:
0316: import java.rmi.RemoteException;
0317:
0318: import de.danet.an.workflow.omgcore.InvalidResourceException;
0319: import de.danet.an.workflow.omgcore.NotAssignedException;
0320: import de.danet.an.workflow.omgcore.TransitionNotAllowedException;
0321: import de.danet.an.workflow.omgcore.WfAssignment;
0322: import de.danet.an.workflow.omgcore.WfResource;
0323:
0324: /**
0325: * Interface <code>Activity</code> adds some functions to the
0326: * {@link de.danet.an.workflow.omgcore.WfActivity OMG activity}.
0327: */
0328: public interface Activity extends ExecutionObject,
0329: de.danet.an.workflow.omgcore.WfActivity {
0330:
0331: /**
0332: * This class defines the sub-states of ClosedState.COMPLETED of a
0333: * {@link de.danet.an.workflow.omgcore.WfExecutionObject
0334: * <code>WfExecutionObject</code>}. These substates are an
0335: * extention of the predefined omg states.
0336: */
0337: public static class ClosedCompletedState extends ClosedState
0338: implements Serializable {
0339: /**
0340: * Provides a state indicating that the activity was completed
0341: * normally.
0342: */
0343: public static final ClosedCompletedState NORMAL = new ClosedCompletedState(
0344: "normal");
0345: /**
0346: * Provides a state indicating that the activity was completed
0347: * by an exception.
0348: */
0349: public static final ClosedCompletedState ABANDONED = new ClosedCompletedState(
0350: "abandoned");
0351: static {
0352: registerState(NORMAL);
0353: registerState(ABANDONED);
0354: }
0355:
0356: /**
0357: * Default constructor.
0358: * @param text Textual representation of the state
0359: */
0360: protected ClosedCompletedState(String text) {
0361: super (text);
0362: }
0363:
0364: /**
0365: * Returns the parent in the state hierachy if all states
0366: * defined in this class or <code>null</code>, if this states
0367: * are at the top level of the hierachy.
0368: * @return parent in the state hierachy
0369: */
0370: public State getParent() {
0371: return ClosedState.COMPLETED;
0372: }
0373:
0374: /**
0375: * Returns the workflow state, i.e. the grandparent.
0376: * @return the workflow state.
0377: */
0378: public State workflowState() {
0379: return getParent().getParent();
0380: }
0381:
0382: /**
0383: * Returns the workflow substate for open execution objects.
0384: * @return the open state.
0385: */
0386: public State whileOpenState() {
0387: throw new IllegalStateException();
0388: }
0389:
0390: /**
0391: * Returns the workflow substate for open, not running
0392: * execution objects.
0393: * @return the why not running state.
0394: */
0395: public State whyNotRunningState() {
0396: throw new IllegalStateException();
0397: }
0398:
0399: /**
0400: * Returns the workflow substate for closed
0401: * execution objects.
0402: * @return the closed state.
0403: */
0404: public State howClosedState() {
0405: return getParent();
0406: }
0407:
0408: /**
0409: * Perform instance substitution during serialization.
0410: */
0411: private Object readResolve() {
0412: String repr = textRepresentation();
0413: if (repr == null) {
0414: throw new IllegalArgumentException(
0415: "Unexpected error in deserialization");
0416: }
0417: if (repr.equals(NORMAL.textRepresentation())) {
0418: return NORMAL;
0419: }
0420: if (repr.equals(ABANDONED.textRepresentation())) {
0421: return ABANDONED;
0422: }
0423: throw new IllegalArgumentException(
0424: "Unexpected error in serialization");
0425: }
0426: }
0427:
0428: /**
0429: * This class defines the values for start and finish mode for an
0430: * {@link Activity <code>Activity</code>}.
0431: */
0432: public static class StartFinishMode implements Serializable {
0433: /**
0434: ** Triggered implicitly by the system.
0435: */
0436: public static final StartFinishMode AUTOMATIC = new StartFinishMode(
0437: "Automatic");
0438: /**
0439: * Triggered explicitly by the user.
0440: */
0441: public static final StartFinishMode MANUAL = new StartFinishMode(
0442: "Manual");
0443:
0444: /**
0445: * Default constructor.
0446: * @param text textual representation of the activity mode.
0447: */
0448: protected StartFinishMode(String text) {
0449: mode = text;
0450: }
0451:
0452: private String mode;
0453:
0454: /**
0455: * Returns the mode as text.
0456: * @return mode as text
0457: */
0458: public String toString() {
0459: return mode;
0460: }
0461:
0462: /**
0463: * Convert a string to a <code>StartFinishMode</code>.
0464: * @param mode the mode to convert.
0465: * @return the result.
0466: */
0467: public static StartFinishMode fromString(String mode) {
0468: if (mode.equals(AUTOMATIC.toString())) {
0469: return AUTOMATIC;
0470: }
0471: if (mode.equals(MANUAL.toString())) {
0472: return MANUAL;
0473: }
0474: throw new IllegalArgumentException(
0475: "Not a start/finish mode: " + mode);
0476: }
0477:
0478: /**
0479: * Perform instance substitution during serialization.
0480: */
0481: private Object readResolve() {
0482: return fromString(mode);
0483: }
0484: }
0485:
0486: /**
0487: * This class defines the join and split modes for an activity.
0488: */
0489: public static class JoinAndSplitMode implements Serializable {
0490: private String mode;
0491: /**
0492: * XOR join or split.
0493: */
0494: public static final JoinAndSplitMode XOR = new JoinAndSplitMode(
0495: "XOR");
0496: /**
0497: * AND join or split.
0498: */
0499: public static final JoinAndSplitMode AND = new JoinAndSplitMode(
0500: "AND");
0501:
0502: /**
0503: * Default constructor.
0504: * @param text textual representation of the mode.
0505: */
0506: protected JoinAndSplitMode(String text) {
0507: mode = text;
0508: }
0509:
0510: /**
0511: * Returns the mode as text.
0512: * @return mode as text
0513: */
0514: public final String toString() {
0515: return mode;
0516: }
0517:
0518: /**
0519: * Get the join/split mode by name.
0520: * @param text mode name.
0521: * @return mode object
0522: * @throws IllegalArgumentException if <code>text</code> is not a valid
0523: * mode name.
0524: */
0525: public static JoinAndSplitMode fromString(String text)
0526: throws IllegalArgumentException {
0527: if (text.equals(AND.toString())) {
0528: return AND;
0529: } else if (text.equals(XOR.toString())) {
0530: return XOR;
0531: } else {
0532: throw new IllegalArgumentException(
0533: "Not a valid join or split mode: " + text);
0534: }
0535: }
0536:
0537: /**
0538: * Checks if the mode is "XOR".
0539: * @return <code>true</code> if the mode is "XOR".
0540: */
0541: public final boolean isXOR() {
0542: return mode.equals("XOR");
0543: }
0544:
0545: /**
0546: * Checks if the mode is "AND".
0547: * @return <code>true</code> if the mode is "AND".
0548: */
0549: public final boolean isAND() {
0550: return mode.equals("AND");
0551: }
0552:
0553: /**
0554: * Perform instance substitution during serialization.
0555: */
0556: private Object readResolve() {
0557: return fromString(mode);
0558: }
0559: }
0560:
0561: /**
0562: * The super interface of possible activity implementation
0563: * descriptions.
0564: */
0565: public interface Implementation extends Serializable {
0566: }
0567:
0568: /**
0569: * This interface describes the implementation of an
0570: * activity by a tool.
0571: */
0572: public interface ToolImplementation extends Implementation {
0573:
0574: /**
0575: * Return the tool id. The id can be mapped to a tool
0576: * definition by {@link ProcessDefinition#applicationById
0577: * <code>ProcessDefinition.applicationById</code>}.
0578: * @return value of id.
0579: */
0580: String id();
0581:
0582: /**
0583: * Return the implementation description.
0584: * @return value of description.
0585: */
0586: String description();
0587: }
0588:
0589: /**
0590: * This interface describes the implementation of an
0591: * activity by a sub flow.
0592: */
0593: public interface SubFlowImplementation extends Implementation {
0594:
0595: /**
0596: * Denotes asynchronous execution of subflow.
0597: */
0598: static final int ASYNCHR = 1;
0599:
0600: /**
0601: * Denotes synchronous execution of subflow.
0602: */
0603: static final int SYNCHR = 2;
0604:
0605: /**
0606: * Return the package id of the subflow. Can be used together
0607: * with the {@link #processId <code>processId</code>} to
0608: * lookup the process definition using {@link
0609: * de.danet.an.workflow.api.ProcessDefinitionDirectory#lookupProcessDefinition
0610: * <code>ProcessDefinitionDirectory.lookupProcessDefinition</code>}.
0611: * @return value of package id.
0612: */
0613: String packageId();
0614:
0615: /**
0616: * Return the process id of the subflow. Can be used together
0617: * with the {@link #packageId <code>packageId</code>} to
0618: * lookup the process definition using {@link
0619: * de.danet.an.workflow.api.ProcessDefinitionDirectory#lookupProcessDefinition
0620: * <code>ProcessDefinitionDirectory.lookupProcessDefinition</code>}.
0621: * @return value of process id.
0622: */
0623: String processId();
0624:
0625: /**
0626: * Return the key of the invoked process if it has been started.
0627: * @return the key or <code>null</code> if no process is running.
0628: */
0629: String processKey();
0630:
0631: /**
0632: * Return the execution mode.
0633: * @return either {@link #ASYNCHR <code>ASYNCHR</code>} or
0634: * {@link #SYNCHR <code>SYNCHR</code>}.
0635: */
0636: int execution();
0637: }
0638:
0639: /**
0640: * Return a unique key for the activity. (Note that the OMG
0641: * interface defines the key returned by the {@link
0642: * de.danet.an.workflow.omgcore.WfExecutionObject#key
0643: * <code>key()</code>} method as unique within the scope of the
0644: * containing process only.)
0645: * @return value of uniqueKey
0646: * @throws RemoteException if a system-level error occurs
0647: */
0648: ActivityUniqueKey uniqueKey() throws RemoteException;
0649:
0650: /**
0651: * Returns the implementation of the activity as {@link
0652: * de.danet.an.workflow.api.Activity.Implementation
0653: * <code>Implementation</code>}s.
0654: *
0655: * @return an array of <code>Implementation</code>}s or
0656: * <code>null</code> if no implementation is defined
0657: * @throws RemoteException if a system-level error occurs
0658: */
0659: Implementation[] implementation() throws RemoteException;
0660:
0661: /**
0662: * Returns the performer as string.
0663: * @return performer as string
0664: * @throws RemoteException if a system-level error occurs
0665: */
0666: String performer() throws RemoteException;
0667:
0668: /**
0669: * Returns the current executor.
0670: *
0671: * @return current executor or <code>null</code> if no executor
0672: * running
0673: * @throws RemoteException if a system-level error occurs
0674: */
0675: Implementation executor() throws RemoteException;
0676:
0677: /**
0678: * Returns the join mode.
0679: * @return join mode
0680: * @throws RemoteException if a system-level error occurs
0681: */
0682: JoinAndSplitMode joinMode() throws RemoteException;
0683:
0684: /**
0685: * Returns the split mode.
0686: * @return split mode
0687: * @throws RemoteException if a system-level error occurs
0688: */
0689: JoinAndSplitMode splitMode() throws RemoteException;
0690:
0691: /**
0692: * Returns the list of activities that may follow this activity,
0693: * i.e. to which transitions exist.
0694: * @return the list of {@link Activity <code>Activity</code>} objects.
0695: * @throws RemoteException if a system-level error occurs
0696: */
0697: List nextActivities() throws RemoteException;
0698:
0699: /**
0700: * Returns the names of the exceptions handled by this activity.
0701: * @return handled exceptions
0702: * @throws RemoteException if a system-level error occurs
0703: */
0704: String[] handledExceptions() throws RemoteException;
0705:
0706: /**
0707: * Class <code>DeadlineInfo</code> describes all properties of a
0708: * deadline.
0709: */
0710: public class DeadlineInfo implements Serializable {
0711:
0712: /** Denotes asynchronous execution of the deadline. */
0713: public static final int ASYNCHR = 1;
0714:
0715: /** Denotes synchronous execution of the deadline. */
0716: public static final int SYNCHR = 2;
0717:
0718: /** Deadline is in initial state. */
0719: public static final int STATE_INITIAL = 0;
0720:
0721: /** Deadline has been reached. */
0722: public static final int STATE_REACHED = 1;
0723:
0724: /** Deadline is running. */
0725: public static final int STATE_ACTIVE = 2;
0726:
0727: /** Deadline has been canceled. */
0728: public static final int STATE_CANCELED = 3;
0729:
0730: private int executionMode;
0731: private String exceptionName;
0732: private String condition;
0733: private int state;
0734:
0735: /**
0736: * Creates a new <code>DeadlineInfo</code> instance with the given
0737: * values.
0738: *
0739: * @param executionMode the execution mode
0740: * @param exceptionName the exception to be thrown
0741: * @param condition the condition
0742: * @param state the current state
0743: */
0744: public DeadlineInfo(int executionMode, String exceptionName,
0745: String condition, int state) {
0746: this .executionMode = executionMode;
0747: this .exceptionName = exceptionName;
0748: this .condition = condition;
0749: this .state = state;
0750: }
0751:
0752: /**
0753: * Get the value of execution, one of <code>ASYNCHR</code>
0754: * or <code>SYNCHR</code>.
0755: * @return value of execution.
0756: */
0757: public int getExecutionMode() {
0758: return executionMode;
0759: }
0760:
0761: /**
0762: * Get the value of ExceptionName.
0763: * @return value of ExceptionName.
0764: */
0765: public String getExceptionName() {
0766: return exceptionName;
0767: }
0768:
0769: /**
0770: * Get the value of Condition.
0771: * @return value of Condition.
0772: */
0773: public String getCondition() {
0774: return condition;
0775: }
0776:
0777: /**
0778: * Get the value of state, one of <code>STATE_INITIAL</code>,
0779: * <code>STATE_REACHED</code> or <code>STATE_CANCELED</code>.
0780: * @return value of state.
0781: */
0782: public int getState() {
0783: return state;
0784: }
0785: }
0786:
0787: /**
0788: * Returns the deadlines defined for this activity.
0789: *
0790: * @return the deadlines
0791: * @throws RemoteException if a system-level error occurs
0792: */
0793: DeadlineInfo[] deadlines() throws RemoteException;
0794:
0795: /**
0796: * Class <code>Info</code> combines various informational
0797: * attributes about an activity in a single structure for
0798: * efficient retrieval.
0799: */
0800: public class Info implements Serializable {
0801:
0802: private ActivityUniqueKey uniqueKey;
0803: private String activityName;
0804: private String activityDescription;
0805: private int activityPriority;
0806: private Date lastStateTime;
0807: private String processName;
0808: private String processDescription;
0809:
0810: /**
0811: * Creates a new <code>Info</code> instance with the given values.
0812: *
0813: * @param key the unique key.
0814: * @param actName the activity name.
0815: * @param actDesc the activity description.
0816: * @param actPrio the priority of the activity.
0817: * @param actLastTime the date of the last state change.
0818: * @param procName the name of the containing process.
0819: * @param procDesc the description of the containing process.
0820: */
0821: public Info(ActivityUniqueKey key, String actName,
0822: String actDesc, int actPrio, Date actLastTime,
0823: String procName, String procDesc) {
0824: uniqueKey = key;
0825: activityName = actName;
0826: activityDescription = actDesc;
0827: activityPriority = actPrio;
0828: lastStateTime = actLastTime;
0829: processName = procName;
0830: processDescription = procDesc;
0831: }
0832:
0833: /**
0834: * Get the value of uniqueKey.
0835: * @return value of uniqueKey.
0836: */
0837: public ActivityUniqueKey uniqueKey() {
0838: return uniqueKey;
0839: }
0840:
0841: /**
0842: * Get the value of activityName.
0843: * @return value of activityName.
0844: */
0845: public String name() {
0846: return activityName;
0847: }
0848:
0849: /**
0850: * Get the value of activityDescription.
0851: * @return value of activityDescription.
0852: */
0853: public String description() {
0854: return activityDescription;
0855: }
0856:
0857: /**
0858: * Get the value of activityPriority.
0859: * @return value of activityPriority.
0860: */
0861: public int priority() {
0862: return activityPriority;
0863: }
0864:
0865: /**
0866: * Get the value of lastStateTime.
0867: * @return value of lastStateTime.
0868: */
0869: public Date lastStateTime() {
0870: return lastStateTime;
0871: }
0872:
0873: /**
0874: * Get the value of processName.
0875: * @return value of processName.
0876: */
0877: public String processName() {
0878: return processName;
0879: }
0880:
0881: /**
0882: * Get the value of processDescription.
0883: * @return value of processDescription.
0884: */
0885: public String processDescription() {
0886: return processDescription;
0887: }
0888: }
0889:
0890: /**
0891: * This method returns all available information about the
0892: * activity in a single operation.
0893: *
0894: * @return the resulting <code>Activity.Info</code> value
0895: * @throws RemoteException if a system-level error occurs
0896: */
0897: Activity.Info activityInfo() throws RemoteException;
0898:
0899: /**
0900: * Returns the key of the "parent" block activity. All activities
0901: * implicitly created by a block activity share the same block
0902: * activity key.<P>
0903: *
0904: * Note that there need not be an activity with the returned key,
0905: * as an activity set is actually a template describing how to
0906: * implement block activities. The information obtained can mainly
0907: * be used to group all activities that have been instantiated as
0908: * part of an activity set.<P>
0909: *
0910: * @return an identification of the block activity that caused
0911: * this activity to be instantiated or <code>null</code> if this
0912: * activity was not instantiated as part of an activity set
0913: * @throws RemoteException if a system-level error occurs
0914: */
0915: String blockActivity() throws RemoteException;
0916:
0917: /**
0918: * Force the completion of this activity, leaving it in state
0919: * "closed.completed.abandoned". Does nothing if the activity is
0920: * in state "closed" already or has not been started
0921: * ("open.not_running.not_started").<P>
0922: *
0923: * An abandoned activity is considered to be completed under
0924: * exceptional circumstances. Therefore only transitions with
0925: * conditions of type <code>EXCEPTION</code> or
0926: * <code>DEFAULTEXCEPTION</code> are considered when evaluating
0927: * the set of subsequent activities. The argument is the name of
0928: * the exception which may be used to distinguish different
0929: * exceptions in transition evaluation (see XPDL).<P>
0930: *
0931: * This method should be used with care. In general, exceptions
0932: * have a different level of abstraction in a workflow process
0933: * description than in Java programming. The author of a workflow
0934: * process should not have to know about e.g. a
0935: * "SAXException". But he may know what to do in case of a
0936: * "ResultInvalid" exception (though this kind of problem should
0937: * only arise during development anyway).<P>
0938: *
0939: * This method may only be called during tool execution. Note that
0940: * calling this method does not terminate tool execution, i.e. the
0941: * method will return. A tool agent should, however, not try to do
0942: * anything with the activity any more after calling this method.
0943: *
0944: * @param exceptionName the name of the exception
0945: * @throws RemoteException if a system-level error occurs
0946: * @throws TransitionNotAllowedException if the activity is not
0947: * executing a tool
0948: */
0949: void abandon(String exceptionName) throws RemoteException,
0950: TransitionNotAllowedException;
0951:
0952: /**
0953: * Get the resource associated with an Assignment. The method calls
0954: * the corresponding method of the resource assignment service.
0955: *
0956: * This method is intended to be used by resource assignment
0957: * systems for implementing {@link
0958: * de.danet.an.workflow.omgcore.WfAssignment#assignee
0959: * <code>WfAssignment.assignee</code>}.<P>
0960: *
0961: * Clients should not use this method but rather call {@link
0962: * de.danet.an.workflow.omgcore.WfAssignment#assignee
0963: * <code>WfAssignment.assignee</code>}.
0964: *
0965: * @param asnmnt the assignment
0966: * @return the resource
0967: * @throws RemoteException if a system-level error occurs.
0968: * @since 1.3.4
0969: */
0970: WfResource getResource(WfAssignment asnmnt) throws RemoteException;
0971:
0972: /**
0973: * Change an assignment for enacting the activity. This method calls
0974: * the corresponding method of the resource assignment service and
0975: * creates the appropriate audit event.<P>
0976: *
0977: * This method is intended to be used by resource assignment
0978: * systems for implementing {@link
0979: * de.danet.an.workflow.omgcore.WfAssignment#setAssignee
0980: * <code>WfAssignment.setAssignee</code>}. Resource assignment
0981: * systems are responsible for implementing
0982: * <code>WfAssignment</code> and could therefore perform the
0983: * reassignment directly; this would, however, leave the
0984: * generation of notifications unexecuted. <P>
0985: *
0986: * Clients should not use this method but rather call {@link
0987: * de.danet.an.workflow.omgcore.WfAssignment#setAssignee
0988: * <code>WfAssignment.setAssignee</code>}.
0989: *
0990: * @param oldResource the resource that has its assignment removed
0991: * @param newResource the resource to be assigned
0992: * @throws RemoteException if a system-level error occurs
0993: * @throws InvalidResourceException if the resource is invalid.
0994: * As the environment is a concurrent multi user environment,
0995: * <code>WfResource</code> objects may become invalid.
0996: * @throws AlreadyAssignedException if the assignment already
0997: * exists
0998: * @throws NotAssignedException if there is no assignment to the
0999: * old resource
1000: */
1001: void changeAssignment(WfResource oldResource, WfResource newResource)
1002: throws RemoteException, InvalidResourceException,
1003: AlreadyAssignedException, NotAssignedException;
1004:
1005: /**
1006: * Removes an assignment for enacting the activity. This method calls
1007: * the corresponding method of the resource assignment service and
1008: * creates the appropriate audit event.<P>
1009: *
1010: * This method is intended to be used by resource management
1011: * systems for implementing {@link WfResource#release
1012: * <code>WfResource.release</code>}. <P>
1013: *
1014: * Clients should not use this
1015: * method but rather call {@link WfResource#release
1016: * <code>WfResource.release</code>}.
1017: *
1018: * @param resource the resource whose assignment is to be canceled
1019: * @throws RemoteException if a system-level error occurs
1020: * @throws InvalidResourceException if the resource is invalid.
1021: * As the environment is a concurrent multi user environment,
1022: * <code>WfResource</code> objects may become invalid.
1023: * @throws NotAssignedException if there is no such assignment
1024: */
1025: void removeAssignment(WfResource resource) throws RemoteException,
1026: InvalidResourceException, NotAssignedException;
1027:
1028: /**
1029: * Makes this activity the chosen one in a set of activities
1030: * started by an AND split with the "deferred choice" option
1031: * set. All other activities in the set are reset to their initial
1032: * state.
1033: *
1034: * <P>If the activity does not participate in a deferred choice,
1035: * this method does nothing and returns <code>true</code>.
1036: *
1037: * @return <code>true</code> if the activity could be made the
1038: * effectively chosen one
1039: * @throws RemoteException if a system-level error occurs
1040: * @throws TransitionNotAllowedException if the activity is
1041: * neither running nor suspended
1042: */
1043: boolean choose() throws RemoteException,
1044: TransitionNotAllowedException;
1045: }
|