public class TaskController extends ProcessController
TaskController provides simplified access to find a task within a recursive process tree, and it provides simplified execution of such task once found.
Example:
TaskController session = TaskController.initialize(currentServiceContext, processId); TaskDetails taskDetails = session.expect("MyNode*"); if (taskDetails != null) { session.execute(new ActivityClassParameter[] {new ActivityClassParameter( "myparam", AppianTypeLong.STRING, "Hello")}); } session.expect("Order Number *"); if (taskDetails != null) { session.execute(new ActivityClassParameter[] {new ActivityClassParameter( "otherparam", AppianTypeLong.STRING, "Goodbye")}); }
Call session.getLog() to get log of actions taken; use session.setLogLevel() to tune
the amount of information.
Call session.getPerformanceSummary() for a textual description of performance timings.
As this extends ProcessController and Controller, all ProcessController and Controller capabilities are available.
Controller.ControllerException, Controller.LogElement, Controller.LogLevel
targetProcessId
defaultDuration, defaultTimeUnit, log, LOG, logLevel, logToLogger, performance, sc
Modifier and Type | Method and Description |
---|---|
TaskDetails |
execute(TaskProperties taskProperties,
ActivityClassParameter... inputs)
Executes a given task
Accepts the current task.
|
TaskDetails |
execute(TaskProperties taskProperties,
long duration,
java.util.concurrent.TimeUnit timeUnit,
ActivityClassParameter... inputs)
Executes a given task
Accepts the current task.
|
TaskSummary[] |
expect(java.lang.String taskNameRegEx)
Examine tasks to find a task name that matches taskNameRegEx.
|
TaskSummary[] |
expect(java.lang.String taskNameRegEx,
java.lang.Integer... requiredStatus)
Examine tasks to find a task name that matches taskNameRegEx.
|
TaskSummary[] |
expect(java.lang.String taskNameRegEx,
long duration,
java.util.concurrent.TimeUnit timeUnit,
java.lang.Integer... requiredStatus)
Examine tasks to find a task name that matches taskNameRegEx.
|
static TaskController |
initialize(ServiceContext sc,
java.lang.Long targetProcessId)
Generate a TaskController from the given targetProcessId and its recursive children.
|
static TaskController |
initialize(ServiceContext sc,
java.lang.Long targetProcessId,
java.lang.Long[] excludeProcessIds,
boolean recursive)
Generate a TaskController from the given targetProcessId, and its recursive children if
requested, excluding the excludeProcessId if set.
|
concludeProcess, concludeProcess, startProcess
clearLog, enableLogToLogger, enablePerformanceLogging, getLog, getPerformanceSummary, log, setLogLevel, setTimeout, yield
public static TaskController initialize(ServiceContext sc, java.lang.Long targetProcessId) throws InvalidProcessException, PrivilegeException
sc
- ServiceContext under which this will executetargetProcessId
- in which to find the taskInvalidProcessException
- if targetProcessId is invalidPrivilegeException
- if access to targetProcessId is not allowedpublic static TaskController initialize(ServiceContext sc, java.lang.Long targetProcessId, java.lang.Long[] excludeProcessIds, boolean recursive) throws InvalidProcessException, PrivilegeException
sc
- ServiceContext under which this will executetargetProcessId
- in which to find the taskexcludeProcessIds
- will not find the task in the given excluded process ids,
useful for recursive to exclude self or other specific process idsrecursive
- if true will search subprocesses recursively for matching taskInvalidProcessException
- if targetProcessId is invalidPrivilegeException
- if access to targetProcessId is not allowedpublic TaskSummary[] expect(java.lang.String taskNameRegEx) throws InvalidProcessException, PrivilegeException, java.util.concurrent.TimeoutException
taskNameRegEx
- regex to match. Use Pattern.quote(taskNameRegEx) for an exact
match, Pattern.quote(taskNameRegEx)+"*" for startsWith.InvalidProcessException
PrivilegeException
java.util.concurrent.TimeoutException
- if timeout occurspublic TaskSummary[] expect(java.lang.String taskNameRegEx, java.lang.Integer... requiredStatus) throws InvalidProcessException, PrivilegeException, java.util.concurrent.TimeoutException
taskNameRegEx
- regex to match. Use Pattern.quote(taskNameRegEx) for an exact
match, Pattern.quote(taskNameRegEx)+"*" for startsWith.requiredStatus
- will only return TaskSummary for tasks that have one of
these requiredStatus; null allows any status including null; empty allows
TASK_STATUS_ASSIGNED or TASK_STATUS_ACCEPTED, the two states under which
an attended task may be executed.InvalidProcessException
PrivilegeException
java.util.concurrent.TimeoutException
- if timeout occurspublic TaskSummary[] expect(java.lang.String taskNameRegEx, long duration, java.util.concurrent.TimeUnit timeUnit, java.lang.Integer... requiredStatus) throws InvalidProcessException, PrivilegeException, java.util.concurrent.TimeoutException
taskNameRegEx
- regex to match. Use Pattern.quote(taskNameRegEx) for an exact
match, Pattern.quote(taskNameRegEx)+"*" for startsWith.duration
- 0 is no timeout, >0 is time in timeUnit it will fail with Timeout for no task matches.timeUnit
- unit for durationrequiredStatus
- will only return TaskSummary for tasks that have one of
these requiredStatus; null allows any status including null; empty allows
TASK_STATUS_ASSIGNED or TASK_STATUS_ACCEPTED, the two states under which
an attended task may be executed.InvalidProcessException
PrivilegeException
java.util.concurrent.TimeoutException
- if timeout occurspublic TaskDetails execute(TaskProperties taskProperties, ActivityClassParameter... inputs) throws InvalidActivityException, PrivilegeException, InvalidUserException, InvalidStateException, InvalidOperationException, InvalidProcessException, ArchivedProcessException, InvalidActivityClassParameterException, InvalidProcessModelException, InvalidPriorityException, StorageLimitException, InvalidExpressionException, TaskNavigationException, Controller.ControllerException, java.lang.IllegalArgumentException, java.util.concurrent.TimeoutException
The default Controller duration and timeUnit will be used; it will fail with TimeoutException if it cannot accept and execute the task in the given time.
TaskProperties
- (note, TaskSummary as returned by expect extends TaskProperties and will typically be the TaskProperties passed here)inputs
- If the task matches a subprocess task, these are the subprocess
parameters. If the task matches any other task, then the names are mapped
to the names in task's parameters.PrivilegeException
InvalidActivityException
InvalidOperationException
InvalidStateException
InvalidUserException
InvalidActivityClassParameterException
java.lang.IllegalArgumentException
TaskNavigationException
InvalidExpressionException
StorageLimitException
InvalidPriorityException
InvalidProcessModelException
ArchivedProcessException
InvalidProcessException
java.util.concurrent.TimeoutException
ControllerException
java.lang.IllegalStateException
- if activityId was not set by expectController.ControllerException
public TaskDetails execute(TaskProperties taskProperties, long duration, java.util.concurrent.TimeUnit timeUnit, ActivityClassParameter... inputs) throws InvalidActivityException, PrivilegeException, InvalidUserException, InvalidStateException, InvalidOperationException, InvalidProcessException, ArchivedProcessException, Controller.ControllerException, java.util.concurrent.TimeoutException, InvalidActivityClassParameterException, InvalidProcessModelException, InvalidPriorityException, StorageLimitException, InvalidExpressionException, TaskNavigationException, java.lang.IllegalArgumentException
TaskProperties
- (note, TaskSummary as returned by expect extends TaskProperties and will typically be the TaskProperties passed here)inputs
- If the task matches a subprocess task, these are the subprocess
parameters. If the task matches any other task, then the names are mapped
to the names in task's parameters.duration
- 0 is no timeout, >0 is time in timeUnit; it will fail with TimeoutException if it cannot accept and execute the task in the given time.timeUnit
- unit for durationPrivilegeException
InvalidActivityException
InvalidOperationException
InvalidStateException
InvalidUserException
InvalidActivityClassParameterException
java.lang.IllegalArgumentException
TaskNavigationException
InvalidExpressionException
StorageLimitException
InvalidPriorityException
InvalidProcessModelException
ArchivedProcessException
InvalidProcessException
java.util.concurrent.TimeoutException
ControllerException
java.lang.IllegalStateException
- if activityId was not set by expectController.ControllerException
Copyright © 2003-2024 Appian Corporation. All Rights Reserved.