Package com.mendix.workflows
Interface Workflow
public interface Workflow
Provides an interface for managing workflow instances.
-
Method Summary
Modifier and TypeMethodDescriptionvoidAborts this workflow with the specified reason.booleanReturns whether this workflow can be continued.booleancanJump()Returns whether this workflow allows a jump-to option to be applied.booleanReturns whether this workflow can be restarted.Collection<? extends WorkflowActivity> Returns the current activities for this workflow instance.Returns the list of possible workflow activities the workflow can jump to.getKey()Returns the key that uniquely identifies the workflow instance.Returns the Mendix object for this workflow instance.List<? extends WorkflowActivityRecord> Returns the workflow activity records for the activities that have been executed or are executing for this workflow instance.Returns the Mendix object for the context parameter of this workflow instance.voidlockDefinition(boolean pauseAllWorkflows) Locks the definition of this workflow instance.voidContinues this workflow.voidopenPage()Opens the Admin Page for this workflow instance.voidpause()Pauses this workflow instance.voidrestart()Restarts this workflow.voidretry()Retries this workflow.voidsetWorkflowContext(IMendixObject contextObject) Sets the context parameter of this workflow instance to the specified Mendix object.state()Returns the current state of this workflow instance.voidunlockDefinition(boolean resumeAllPausedWorkflows) Unlocks the definition of this workflow instance.voidunpause()Unpauses this workflow instance.
-
Method Details
-
getMendixObject
IMendixObject getMendixObject()Returns the Mendix object for this workflow instance.- Returns:
- the Mendix object
-
getWorkflowContext
IMendixObject getWorkflowContext()Returns the Mendix object for the context parameter of this workflow instance.- Returns:
- the context object
-
getWorkflowActivityRecords
List<? extends WorkflowActivityRecord> getWorkflowActivityRecords()Returns the workflow activity records for the activities that have been executed or are executing for this workflow instance.- Returns:
- the list of workflow activity records
-
setWorkflowContext
Sets the context parameter of this workflow instance to the specified Mendix object.- Parameters:
contextObject- the context object to set
-
pause
void pause()Pauses this workflow instance.- Throws:
MendixRuntimeException- when this workflow cannot be paused in its current state
-
unpause
void unpause()Unpauses this workflow instance.- Throws:
MendixRuntimeException- when this workflow is not paused
-
restart
void restart()Restarts this workflow.Note that
canRestart()must return true for this workflow to be restartable.- Throws:
MendixRuntimeException- when this workflow cannot be restarted
-
retry
void retry()Retries this workflow.Note that it has to be failed for retry to be applicable.
- Throws:
MendixRuntimeException- when this workflow cannot be retried
-
abort
Aborts this workflow with the specified reason.- Parameters:
reason- the reason for aborting the workflow- Throws:
MendixRuntimeException- when this workflow cannot be aborted
-
markAsResolved
void markAsResolved()Continues this workflow.Note that it must be Incompatible and that
canContinue()must return true.- Throws:
MendixRuntimeException- when this workflow cannot be continued
-
openPage
void openPage()Opens the Admin Page for this workflow instance. -
lockDefinition
void lockDefinition(boolean pauseAllWorkflows) Locks the definition of this workflow instance.- Parameters:
pauseAllWorkflows- indicates whether to pause all active workflow instances with the same definition- Throws:
UserException- if the workflow definition has already been locked
-
unlockDefinition
void unlockDefinition(boolean resumeAllPausedWorkflows) Unlocks the definition of this workflow instance.- Parameters:
resumeAllPausedWorkflows- indicates whether to resume all paused workflow instances with the same definition- Throws:
UserException- if the workflow definition is not locked
-
canRestart
boolean canRestart()Returns whether this workflow can be restarted.- Returns:
- true if this workflow is restartable, otherwise return false
-
canContinue
boolean canContinue()Returns whether this workflow can be continued.- Returns:
- true if this workflow can be continued, otherwise return false
-
canJump
boolean canJump()Returns whether this workflow allows a jump-to option to be applied.- Returns:
- true if this workflow can jump, otherwise return false
-
state
WorkflowState state()Returns the current state of this workflow instance.- Returns:
- the state
WorkflowState
-
getCurrentActivities
Collection<? extends WorkflowActivity> getCurrentActivities()Returns the current activities for this workflow instance.- Returns:
- the list of current activities
-
getJumpToOptions
JumpToOptions getJumpToOptions()Returns the list of possible workflow activities the workflow can jump to.Sample usage as follows:
Workflow workflow = Core.workflows().getWorkflow(context, workflowObject); JumpToOptions jumpToOptions = workflow.getJumpToOptions(); JumpableWorkflowActivity sourceActivity = jumpToOptions.getCurrentActivities() .stream() .filter(a -> a.getDetails().getCaption().equals("MyUserTask1")) .findFirst() .get(); WorkflowActivityDetails targetActivity = sourceActivity.getApplicableTargets() .stream() .filter(a -> a.getCaption().equals("MyUserTask2")) .findFirst() .get(); Workflow updatedWorkflow = jumpToOptions.prepareJumpTo() .jumpActivityTo(sourceActivity, targetActivity) .applyJumpTo();- Returns:
- the interface for jump-to operations
-
getKey
String getKey()Returns the key that uniquely identifies the workflow instance. The value is the same asWorkflowRecord.getWorkflowKey().The value cannot and should not be used for retrieving workflows from the database.
- Returns:
- the workflow key
-