public final class WorkflowEngine extends Object
Modifier and Type | Method and Description |
---|---|
void |
allocateWorkItem(WorkItemKey aKey,
UserReference aUser)
Allocates the specified work item to the specified user.
|
void |
allocateWorkItemToMyself(WorkItemKey aWorkItemKey)
Allocates a work item to the current user.
|
void |
cleanHistory(Date aDate)
Deletes the data in history for workflows terminated from a given date.
|
void |
cleanHistory(ProcessInstanceKey processInstanceKey)
Deletes the data in history for workflows terminated for a given
ProcessInstanceKey . |
SessionInteraction |
createOrOpenInteraction(WorkItemKey aWorkItemKey)
Creates or opens the interaction associated with the specified work item.
|
void |
deallocateWorkItem(WorkItemKey aKey)
Deallocates the specified work item.
|
void |
forceTerminationWithoutCleaning(ProcessInstanceKey aKey)
Terminates the specified process instance without deleting it.
|
List<UserTask.WorkItem> |
getAllWorkItems()
Returns all the work items.
|
static WorkflowEngine |
getFromProcedureContext(ProcedureContext aContext) |
static WorkflowEngine |
getFromRepository(Repository aRepository,
Session aSession)
Creates a workflow engine from a repository and, optionally, a session.
|
static WorkflowEngine |
getFromServiceContext(ServiceContext aContext)
Deprecated.
|
static WorkflowEngine |
getFromUserServiceContext(UserServiceRequest aContext)
Creates a workflow engine from a user service context.
|
SessionInteraction.Specification |
getInteractionSpecification(WorkItemKey aWorkItemKey)
Returns the specification of a session interaction.
|
ProcessInstance |
getProcessInstance(ProcessInstanceKey aProcessInstanceKey)
Returns information about the specified workflow.
|
List<ProcessInstanceComment> |
getProcessInstanceComments(ProcessInstanceKey aProcessInstanceKey)
Returns the comments of the specified workflow.
|
ProcessInstanceHistory |
getProcessInstanceHistory(ProcessInstanceKey aProcessInstanceKey)
Returns the history of the specified workflow.
|
List<ProcessInstanceKey> |
getProcessInstanceKeys(PublishedProcessKey aKey)
Returns a list containing all existing process instance keys for the specified
publication key.
|
List<ProcessInstanceKey> |
getProcessInstanceKeys(String aLaunchingPublicationName)
Returns a list containing all existing workflow keys for the
specified launching publication name.
|
List<ProcessInstanceKey> |
getProcessInstanceKeysForDataContextVariable(PublishedProcessKey publishedProcessKey,
String varName,
String varValue)
This method selects process instances which:
are associated with the specified published process key,
have in their current data context the specified variable and equal to the specified value.
|
List<ProcessInstanceKey> |
getProcessInstanceKeysFromHistory(PublishedProcessKey aKey)
Returns a list containing all the process instance keys for the specified
publication key, including deleted processes.
|
List<ProcessInstanceKey> |
getProcessInstanceKeysFromHistory(String aLaucnhingPublicationName)
Returns a list containing all existing workflow keys for the
specified launching publication name, including deleted workflows.
|
ProcessLauncher |
getProcessLauncher(PublishedProcessKey aKey)
Returns a launcher to create workflows from the
specified publication.
|
List<PublishedProcessKey> |
getPublishedKeys()
Returns the enabled publication keys.
|
List<PublishedProcessKey> |
getPublishedKeys(boolean onlyEnabled)
Returns the publication keys.
|
PublishedProcess |
getPublishedProcess(PublishedProcessKey aPublishProcessKey)
Returns information about the specified workflow publication.
|
UserTask.WorkItem |
getWorkItem(WorkItemKey aWorkItemKey)
Returns information about the specified work item.
|
List<UserTask.WorkItem> |
getWorkItemsAllocatedToUser(UserReference aUser)
Returns all the work items allocated to a user.
|
List<UserTask.WorkItem> |
getWorkItemsOfferedToRole(Role aRole)
Returns all the work items offered to a role.
|
List<UserTask.WorkItem> |
getWorkItemsOfferedToSession(Session aSession)
Returns all the work items offered to a Session.
|
List<UserTask.WorkItem> |
getWorkItemsOfferedToUser(UserReference aUser)
Returns all the work items offered to a user.
|
boolean |
isProcessInstanceRunning(ProcessInstanceKey aKey)
Returns
true if the specified process instance is running, else false . |
boolean |
isUserInRoleAdmin(PublishedProcessKey aKey)
Returns
true if the user of the current session
is the administrator of the process definition associated with
the specified publication key. |
void |
reallocateWorkItem(WorkItemKey aKey,
UserReference aUser)
Reallocates the specified work item.
|
void |
replayCurrentStep(ProcessInstanceKey aKey)
Replays the current step of the specified workflow.
|
WaitTaskResumeResult |
resumeWaitTask(WaitTaskResumeMessage aMessage)
Resumes a wait task.
|
void |
terminateProcessInstance(ProcessInstanceKey aKey)
Terminates and cleans the specified process instance.
|
public static WorkflowEngine getFromRepository(Repository aRepository, Session aSession)
aRepository
- repository in which the workflow is running.aSession
- optional user session, must only be defined in order to invoke methods that
require information about the current user:
isUserInRoleAdmin
,
allocateWorkItem(WorkItemKey, UserReference)
,
deallocateWorkItem(WorkItemKey)
,
reallocateWorkItem(WorkItemKey, UserReference)
and terminateProcessInstance
.public static WorkflowEngine getFromProcedureContext(ProcedureContext aContext)
public static WorkflowEngine getFromServiceContext(ServiceContext aContext)
public static WorkflowEngine getFromUserServiceContext(UserServiceRequest aContext)
public boolean isUserInRoleAdmin(PublishedProcessKey aKey)
true
if the user of the current session
is the administrator of the process definition associated with
the specified publication key.IllegalStateException
- if the session of the workflow engine is null
.public ProcessLauncher getProcessLauncher(PublishedProcessKey aKey)
IllegalStateException
- if the session of the workflow engine is null
.public void forceTerminationWithoutCleaning(ProcessInstanceKey aKey)
terminateProcessInstance(ProcessInstanceKey)
,
this method does not delete the process instance. It only deletes the objects
associated with the current process instance (work items, interactions, sub-workflows).
The current user must have the permission to perform the administration action 'Force termination' (unless this method is called from a procedure with all privileges).
This method can only be used in order to force termination of sub-workflows in order to wake up the parent, or to force the termination of a process instance if an error has occurred during normal completion.
terminateProcessInstance(ProcessInstanceKey)
public void terminateProcessInstance(ProcessInstanceKey aKey)
The current user must have the permissions for the administration action 'Terminate and clean' (unless this method is called from a procedure with all privileges).
IllegalStateException
- if the session of the workflow engine is null
IllegalArgumentException
- if the process instance to clean is a sub-workflow.forceTerminationWithoutCleaning(ProcessInstanceKey)
public void replayCurrentStep(ProcessInstanceKey aKey) throws OperationException
This action removes all objects linked to the current step (current work items, interaction, sub-workflows) and restarts it. If an action has already been performed by a user, no rollback is done (for example in the record creation case).
aKey
- the workflow identifierIllegalStateException
- if the session of the workflow engine is null
IllegalArgumentException
- if the specified workflow key is null
.OperationException
- if one of the following occurs:
public WaitTaskResumeResult resumeWaitTask(WaitTaskResumeMessage aMessage) throws OperationException
The resume identifier is required to resume a wait task by a WaitTaskResumeMessage
.
The resumption can fail if:
In these cases, no exception is thrown, but the WaitTaskResumeResult
contains the reason of the resumption failure.
WaitTaskResumeResult
to indicate if the resumption has failed, and in this case the error reason.OperationException
- If an unexpected error occurs during the wait task resumption.IllegalStateException
- If the session of the workflow engine is null
.IllegalArgumentException
- If the user is not allowed to resume the wait task (if the user does not
belong to the expected profile).public void allocateWorkItem(WorkItemKey aKey, UserReference aUser)
The work item must be in the 'Offered' state, and the current user must have the permission to perform the administration action 'Allocate' (unless this method is called from a procedure with all privileges).
After this method is called, the work item is in the 'Allocated' state.
aUser
- the new owner of the work item. Even if an offered role is defined
for the work item, the workflow engine does not check that the new
owner of the work item belongs to the offered role.IllegalStateException
- if the session of the workflow engine is null
.IllegalArgumentException
- if the work item is not in the 'Offered' state.allocateWorkItemToMyself(WorkItemKey)
public void deallocateWorkItem(WorkItemKey aKey)
The work item must be in the 'Allocated' or 'Started' state, and users must be available for allocation. The current user must have the permission to perform the administration action 'Deallocate' (unless this method is called from a procedure with all privileges).
After this method is called, the work item is in the 'Offered' state.
IllegalStateException
- if the session of the workflow engine is null
.IllegalArgumentException
- if one of the following occurs:
public void reallocateWorkItem(WorkItemKey aKey, UserReference aUser)
The work item must be in the 'Allocated' or 'Started' state, and the current user must have the permission to perform the administration action 'Reallocate' (unless this method is called from a procedure with all privileges).
After this method is called, the work item is in the 'Allocated' state.
aUser
- the new owner of the work item. No verification is performed on the user.
If an offered role is specified, it is not enforced.IllegalStateException
- if one of the following occurs:
if the session of the workflow engine is null
.IllegalArgumentException
- if one of the following occurs:
public void allocateWorkItemToMyself(WorkItemKey aWorkItemKey) throws OperationException
The work item must be in the offered state, and offered to the current user. After calling this method, the work item will be in the allocated state.
IllegalStateException
- if the session of the workflow engine is null
.OperationException
- if one of the following occurs:
allocateWorkItem(WorkItemKey, UserReference)
public SessionInteraction createOrOpenInteraction(WorkItemKey aWorkItemKey) throws OperationException
The work item must be allocated to the current user, and either
in the allocated or in the started
state.
If the work item is in the offered state, first call the
allocateWorkItemToMyself(WorkItemKey)
method (see the
work item
state diagram).
This method does the following:
SessionInteraction
life cycle.
A custom user service is considered
as auto-complete if it has been declared as auto-complete (see
WebComponentDeclarationContext.setAvailableAsWorkflowUserTask(boolean, boolean)
.
The following built-in services (or extensions of these services) can be considered
as auto-complete too:
ServiceKey.DEFAULT_SERVICE
if its input
parameter disableAutoComplete
is not equal to
false
,
ServiceKey.SELECT_DATASPACE
,
ServiceKey.MERGE_VIEW
,
ServiceKey.VALIDATION
,
ServiceKey.COMPARE
.
IllegalStateException
- if:
the session of the workflow engine is null
.OperationException
- if one of the following occurs:
public SessionInteraction.Specification getInteractionSpecification(WorkItemKey aWorkItemKey)
Returns null
if the work item has not been found.
IllegalArgumentException
- if the work item key is null
.SessionInteraction.getSpecification()
public List<PublishedProcessKey> getPublishedKeys()
List
of PublishedProcessKey
.getPublishedKeys(boolean)
public List<PublishedProcessKey> getPublishedKeys(boolean onlyEnabled)
onlyEnabled
- if true
returns only the keys of enabled
publications, else returns all keys regardless of the publication state.List
of PublishedProcessKey
.public PublishedProcess getPublishedProcess(PublishedProcessKey aPublishProcessKey)
public List<ProcessInstanceKey> getProcessInstanceKeys(PublishedProcessKey aKey)
This method returns only execution data. As a consequence, it does not return deleted processes.
public List<ProcessInstanceKey> getProcessInstanceKeys(String aLaunchingPublicationName)
This method returns all workflows which have been launched with the specified publication name (initial or current publication name), including workflows associated with a disabled publication.
This method returns only execution data. As a consequence, it does not return deleted processes.
aLaunchingPublicationName
- publication name with which workflows have been launched.IllegalArgumentException
- if the publication is not defined.getProcessInstanceKeysFromHistory(String)
public List<ProcessInstanceKey> getProcessInstanceKeysFromHistory(PublishedProcessKey aKey)
Unlike getProcessInstance(ProcessInstanceKey)
,
this method will query directly the workflow history.
aKey
- a specified PublishedProcessKeyIllegalArgumentException
- if the specified PublishedProcessKey
is null
.getProcessInstanceKeys(PublishedProcessKey)
public List<ProcessInstanceKey> getProcessInstanceKeysFromHistory(String aLaucnhingPublicationName) throws IllegalArgumentException, OperationException
This method returns all workflows from history which have been launched with the specified publication name (initial or current publication name), including workflows associated with a disabled publication.
This method will query directly the workflow history.
aLaucnhingPublicationName
- publication name with which workflows have been launched.IllegalArgumentException
- if the publication is not defined.OperationException
getProcessInstanceKeys(String)
public ProcessInstance getProcessInstance(ProcessInstanceKey aProcessInstanceKey)
public ProcessInstanceHistory getProcessInstanceHistory(ProcessInstanceKey aProcessInstanceKey) throws OperationException
aProcessInstanceKey
- the key of a workflow, which can represent a completed workflow.OperationException
public List<ProcessInstanceComment> getProcessInstanceComments(ProcessInstanceKey aProcessInstanceKey)
The result includes comments of the sub-workflows of the specified workflow in a recursive way. The list of comments is sorted by descending date.
If the associated workflow has not been found, returns an empty list.
IllegalArgumentException
- if the process instance key is null
.public UserTask.WorkItem getWorkItem(WorkItemKey aWorkItemKey)
public List<UserTask.WorkItem> getWorkItemsOfferedToRole(Role aRole)
Only returns work items in the 'Offered' state.
List
of UserTask.WorkItem
.public List<UserTask.WorkItem> getWorkItemsAllocatedToUser(UserReference aUser)
The returned work items can be in the following states:
List
of UserTask.WorkItem
.public List<UserTask.WorkItem> getWorkItemsOfferedToUser(UserReference aUser)
It only returns the work items in the 'Offered' state.
This method returns an empty list for the system user.
List
of UserTask.WorkItem
.IllegalArgumentException
- if the user is null.Session.isSystemUser()
public List<UserTask.WorkItem> getWorkItemsOfferedToSession(Session aSession)
It only returns the work items in the 'Offered' state.
List
of UserTask.WorkItem
.public List<UserTask.WorkItem> getAllWorkItems()
All the current work items are returned whatever their state: they can be offered, allocated, started, completed or in error.
List
of UserTask.WorkItem
.public List<ProcessInstanceKey> getProcessInstanceKeysForDataContextVariable(PublishedProcessKey publishedProcessKey, String varName, String varValue)
public boolean isProcessInstanceRunning(ProcessInstanceKey aKey)
true
if the specified process instance is running, else false
.public void cleanHistory(ProcessInstanceKey processInstanceKey) throws OperationException
ProcessInstanceKey
.
The method will also remove recursively all history data related to the associated sub-workflows.
processInstanceKey
- a specified ProcessInstanceKeyIllegalArgumentException
- if the specified ProcessInstanceKey
is null.OperationException
- if one of the following occurs:
ProcessInstanceKey
has been
found,ProcessInstanceKey
is not a main
workflow,ProcessInstanceKey
has not been
removed from execution.terminateProcessInstance(ProcessInstanceKey)
,
cleanHistory(Date)
public void cleanHistory(Date aDate) throws OperationException
This method deletes only workflows which meet the following criteria:
The workflows which does not meet these criteria are ignored.
The method will also remove recursively all history data related to the associated sub-workflows.
Warning: it may take a long time to complete and as a result, all workflow executions might also be affected.
For a more targeted clean, please consider using cleanHistory(ProcessInstanceKey)
.
aDate
- the date to compare at the termination date of workflows. Only workflows with a terminated date
lower than or equal to the specified date will be deleted.IllegalArgumentException
- if the specified date is null.OperationException
cleanHistory(ProcessInstanceKey)
,
terminateProcessInstance(ProcessInstanceKey)