KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > Workflow


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow;
6
7 import com.opensymphony.module.propertyset.PropertySet;
8
9 import com.opensymphony.workflow.config.Configuration;
10 import com.opensymphony.workflow.loader.WorkflowDescriptor;
11 import com.opensymphony.workflow.query.WorkflowExpressionQuery;
12 import com.opensymphony.workflow.query.WorkflowQuery;
13
14 import java.util.List JavaDoc;
15 import java.util.Map JavaDoc;
16
17
18 /**
19  * The core workflow interface.
20  *
21  * @author <a HREF="mailto:plightbo@hotmail.com">Patrick Lightbody</a>
22  */

23 public interface Workflow {
24     //~ Instance fields ////////////////////////////////////////////////////////
25

26     String JavaDoc BSF_COL = "col";
27     String JavaDoc BSF_LANGUAGE = "language";
28     String JavaDoc BSF_ROW = "row";
29     String JavaDoc BSF_SCRIPT = "script";
30     String JavaDoc BSF_SOURCE = "source";
31     String JavaDoc BSH_SCRIPT = "script";
32
33     // statics
34
String JavaDoc CLASS_NAME = "class.name";
35     String JavaDoc EJB_LOCATION = "ejb.location";
36     String JavaDoc JNDI_LOCATION = "jndi.location";
37
38     //~ Methods ////////////////////////////////////////////////////////////////
39

40     /**
41      * @deprecated use {@link #getAvailableActions(long, Map)} with an empty Map instead.
42      */

43     public int[] getAvailableActions(long id);
44
45     /**
46      * Returns a Collection of Step objects that are the current steps of the specified workflow instance.
47      *
48      * @param id The workflow instance id.
49      * @return The steps that the workflow instance is currently in.
50      */

51     public List JavaDoc getCurrentSteps(long id);
52
53     /**
54      * Return the state of the specified workflow instance id.
55      * @param id The workflow instance id.
56      * @return int The state id of the specified workflow
57      */

58     public int getEntryState(long id);
59
60     /**
61      * Returns a list of all steps that are completed for the given workflow instance id.
62      *
63      * @param id The workflow instance id.
64      * @return a List of Steps
65      * @see com.opensymphony.workflow.spi.Step
66      */

67     public List JavaDoc getHistorySteps(long id);
68
69     /**
70      * Get the PropertySet for the specified workflow instance id.
71      * @param id The workflow instance id.
72      */

73     public PropertySet getPropertySet(long id);
74
75     /**
76      * Get a collection (Strings) of currently defined permissions for the specified workflow instance.
77      * @param id the workflow instance id.
78      * @return A List of permissions specified currently (a permission is a string name).
79      */

80     public List JavaDoc getSecurityPermissions(long id);
81
82     /**
83      * Get the workflow descriptor for the specified workflow name.
84      * @param workflowName The workflow name.
85      */

86     public WorkflowDescriptor getWorkflowDescriptor(String JavaDoc workflowName);
87
88     /**
89      * Get the name of the specified workflow instance.
90      * @param id the workflow instance id.
91      */

92     public String JavaDoc getWorkflowName(long id);
93
94     /**
95      * Check if the calling user has enough permissions to initialise the specified workflow.
96      * @param workflowName The name of the workflow to check.
97      * @param initialStep The id of the initial state to check.
98      * @return true if the user can successfully call initialize, false otherwise.
99      */

100     public boolean canInitialize(String JavaDoc workflowName, int initialStep);
101
102     /**
103     * Check if the state of the specified workflow instance can be changed to the new specified one.
104     * @param id The workflow instance id.
105     * @param newState The new state id.
106     * @return true if the state of the workflow can be modified, false otherwise.
107     */

108     public boolean canModifyEntryState(long id, int newState);
109
110     /**
111      * Modify the state of the specified workflow instance.
112      * @param id The workflow instance id.
113      * @param newState the new state to change the workflow instance to.
114      * If the new state is {@link com.opensymphony.workflow.spi.WorkflowEntry.KILLED}
115      * or {@link com.opensymphony.workflow.spi.WorkflowEntry.COMPLETED}
116      * then all current steps are moved to history steps. If the new state is
117      */

118     public void changeEntryState(long id, int newState) throws WorkflowException;
119
120     /**
121      * Perform an action on the specified workflow instance.
122      * @param id The workflow instance id.
123      * @param actionId The action id to perform (action id's are listed in the workflow descriptor).
124      * @param inputs The inputs to the workflow instance.
125      * @throws InvalidInputException if a validator is specified and an input is invalid.
126      * @throws InvalidActionException if the action is invalid for the specified workflow
127      * instance's current state.
128      */

129     public void doAction(long id, int actionId, Map JavaDoc inputs) throws InvalidInputException, WorkflowException;
130
131     /**
132      * Executes a special trigger-function using the context of the given workflow instance id.
133      *
134      * @param id The workflow instance id
135      * @param triggerId The id of the speciail trigger-function
136      */

137     public void executeTriggerFunction(long id, int triggerId) throws WorkflowException;
138
139     /**
140     * Initializes a workflow so that it can begin processing. A workflow must be initialized before it can
141     * begin any sort of activity. It can only be initialized once.
142     *
143     * @param workflowName The workflow name to create and initialize an instance for
144     * @param initialAction The initial step to start the workflow
145     * @param inputs The inputs entered by the end-user
146     * @throws InvalidRoleException if the user can't start this function
147     * @throws InvalidInputException if a validator is specified and an input is invalid.
148     * @throws InvalidActionException if the specified initial action is invalid for the specified workflow.
149     */

150     public long initialize(String JavaDoc workflowName, int initialAction, Map JavaDoc inputs) throws InvalidRoleException, InvalidInputException, WorkflowException, InvalidEntryStateException, InvalidActionException;
151
152     /**
153      * Query the workflow store for matching instances
154      * @deprecated use {@link Workflow#query(WorkflowExpressionQuery)} instead.
155      */

156     public List JavaDoc query(WorkflowQuery query) throws WorkflowException;
157
158     /**
159      * Query the workflow store for matching instances
160      */

161     public List JavaDoc query(WorkflowExpressionQuery query) throws WorkflowException;
162
163     /**
164      * Get the available actions for the specified workflow instance.
165      * @ejb.interface-method
166      * @param id The workflow instance id.
167      * @param inputs The inputs map to pass on to conditions
168      * @return An array of action id's that can be performed on the specified entry
169      * @throws IllegalArgumentException if the specified id does not exist, or if its workflow
170      * descriptor is no longer available or has become invalid.
171      */

172     int[] getAvailableActions(long id, Map JavaDoc inputs);
173
174     /**
175      * Set the configuration for this workflow.
176      * If not set, then the workflow will use the default configuration static instance.
177      * @param configuration a workflow configuration
178      */

179     void setConfiguration(Configuration configuration);
180
181     /**
182      * Get all available workflow names.
183      */

184     String JavaDoc[] getWorkflowNames();
185
186     /**
187      * Determine if a particular workflow can be initialized.
188      * @param workflowName The workflow name to check.
189      * @param initialAction The potential initial action.
190      * @param inputs The inputs to check.
191      * @return true if the workflow can be initialized, false otherwise.
192      */

193     boolean canInitialize(String JavaDoc workflowName, int initialAction, Map JavaDoc inputs);
194
195     /**
196      * Remove the specified workflow descriptor.
197      * @param workflowName The workflow name of the workflow to remove.
198      * @return true if the workflow was removed, false otherwise.
199      * @throws FactoryException If the underlying workflow factory has an error removing the workflow,
200      * or if it does not support the removal of workflows.
201      */

202     boolean removeWorkflowDescriptor(String JavaDoc workflowName) throws FactoryException;
203
204     /**
205      * Add a new workflow descriptor
206      * @param workflowName The workflow name of the workflow to add
207      * @param descriptor The workflow descriptor to add
208      * @param replace true, if an existing descriptor should be overwritten
209      * @return true if the workflow was added, fales otherwise
210      * @throws FactoryException If the underlying workflow factory has an error adding the workflow,
211      * or if it does not support adding workflows.
212      */

213     boolean saveWorkflowDescriptor(String JavaDoc workflowName, WorkflowDescriptor descriptor, boolean replace) throws FactoryException;
214 }
215
Popular Tags