Managing Runtime Activities Using the GP API
Use
Once you instantiate a Guided Procedures (GP) process, you can access and modify it at runtime, adding flexibility and complexity to the workflow. Using the GP runtime API, you can:
- Retrieve the input and output context of process, block and action instances
The context is the structure of all current attribute values assigned to the parameters defined for the activity instance. You can use context information for display purposes, troubleshooting or logic control.
- Dynamically assign or change task processors
If you cannot determine the task processor at design time, or you have changed your decision at runtime, you can dynamically assign a different user to a specific process role or task.
Prerequisites
To be able to manage and modify runtime activities, you must have access to a running process started previously.
More information: Starting and Terminating Processes Within a Composite
Procedure
Retrieving Input and Output Activity Context
- Instantiate the IGPRuntimeManager if you have not done so already.
- Retrieve one or more process instances using the methods available in the GP API.
The example shows you how to access all process instances belonging to the current user. From all available running instances, you have to retrieve the ones for which the user is assigned to the Owner process role.
- Retrieve the context of the process instance or the context of its blocks and actions.
Assigning and Changing Users Dynamically
If required, you can dynamically assign users for specific tasks at runtime.
- You can do this with the methods of the IGPRuntimeManager.
- You can also construct a callable object for background execution and overwrite its onExecute() method. In the implementation, you can retrieve the current process role instance from the GP context and assign a user to it.
To change task processors dynamically, use the following method:
You can provide a null value for the current user argument as long as only one processor has been assigned to this task previously. Otherwise, the method call results in a GPInvocationException.