public class Process extends BaseClass implements HasFinishedHandlers, HasTraceElementHandlers
state
across the different tasks that are executed. This allows you to maintain context as you
walk a user through a multi-step business process in your application, which may involve
multiple operations on multiple entities. Each Task that executes can use the Process state
as inputs, and can output a result which is stored in the Process state - see
TaskIO
.
A Process can have multiple branches, choosing the next Task to execute based on
Criteria
- see DecisionTask
and MultiDecisionTask
.
Because a Process may return to a previous Task in various situations, the data model of a
Process is strictly speaking a graph (a set of nodes connected by arbitary
interlinks). However, most processes have sequences of several tasks in a row, and the
definition format allows these to be represented as simple Arrays called "sequences",
specified via sequences
. This reduces the need to
manually specify IDs and
interlinks for Tasks that simply proceed to the next task in a sequence.
Processes follow all the standard rules for encoding as ComponentXML
, however,
note that the <Process> tag allows any kind of ProcessElement
(tasks,
decisions
and sequences) to appear as a direct subelement of the <Process> tag without the need
for an intervening <elements> or <sequences> tag. The example below
demonstrates this shorthand format.
<Process ID="processId"> <ServiceTask ID="serviceTaskId" nextElement="sequenceId" ..> <inputFieldList> <value>order.countryName</value> </inputFieldList> <outputFieldList> <value>order.countryName</value> <value>order.continent</value> <outputFieldList> </ServiceTask> <sequence ID="sequenceId" > <StateTask ../> <StateTask ../> <StateTask ../> <StateTask nextElement="userTaskId" ../> </sequence> <UserTask ID="userTaskId" ../> ... </Process>NOTE: you must load the standard DataBinding module before you can use
Process
.config, configOnly, factoryCreated, factoryProperties, id, scClassName
Constructor and Description |
---|
Process() |
Process(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addFinishedHandler(FinishedHandler handler)
Add a finished handler.
|
com.google.gwt.event.shared.HandlerRegistration |
addTraceElementHandler(TraceElementHandler handler)
Add a traceElement handler.
|
com.google.gwt.core.client.JavaScriptObject |
create() |
java.lang.String |
getContainerId()
Identifier of canvas where UI elements created by using
inline view property should be added using addMember. |
ProcessElement |
getElement(java.lang.String ID)
Retrieve a
ProcessElement by it's ID |
ProcessElement[] |
getElements()
Elements involved in this Process.
|
com.google.gwt.core.client.JavaScriptObject |
getJsObj() |
java.lang.Object |
getLastTaskOutput()
Returns the task output of the last task executed.
|
java.lang.Object |
getLastTaskOutput(java.lang.String taskType)
Returns the task output of the last task executed.
|
java.lang.Boolean |
getMockMode()
Enable mock mode on the workflow? By default, this setting does nothing but is available for individual tasks to trigger
special action.
|
com.google.gwt.core.client.JavaScriptObject |
getOrCreateJsObj() |
static Process |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
static Process |
getProcess(java.lang.String processId)
Get a Process instance by it's ID.
|
ProcessElement[] |
getProcessElements(java.lang.String attribute) |
java.lang.String |
getRuleScope()
Canvas.ID of the component that manages "rule context" for which this
process participates. |
ProcessSequence[] |
getSequences()
Sequences of ProcessElements.
|
java.lang.String |
getStartElement()
|
Record |
getState()
Current state of a process.
|
java.lang.Object |
getStateVariable(java.lang.String stateVariablePath)
Returns a variable value from the
process state . |
java.util.Map |
getTraceContext()
Context object to be passed to
Process.traceElement() during process execution. |
java.lang.Boolean |
getWizard()
If wizard is set then current workflow will be handled as wizard.
|
boolean |
isCreated() |
static void |
loadProcess(java.lang.String processId,
ProcessCallback callback) |
protected void |
onInit() |
void |
passThruTaskOutput(ProcessElement task)
|
void |
reset()
Reset process to it's initial state, so process can be started again.
|
void |
reset(Record state)
Reset process to it's initial state, so process can be started again.
|
Process |
setAttribute(java.lang.String attribute,
ProcessElement[] value,
boolean allowPostCreate) |
void |
setConfig(com.google.gwt.core.client.JavaScriptObject jsObj) |
Process |
setContainerId(java.lang.String containerId)
Identifier of canvas where UI elements created by using
inline view property should be added using addMember. |
Process |
setElements(ProcessElement... elements)
Elements involved in this Process.
|
void |
setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj) |
Process |
setMockMode(java.lang.Boolean mockMode)
Enable mock mode on the workflow? By default, this setting does nothing but is available for individual tasks to trigger
special action.
|
void |
setNextElement()
Sets the task ID of the next task to execute after the current task finishes.
|
void |
setNextElement(java.lang.String nextElement)
Sets the task ID of the next task to execute after the current task finishes.
|
Process |
setRuleScope(java.lang.String ruleScope)
Canvas.ID of the component that manages "rule context" for which this
process participates. |
Process |
setSequences(ProcessSequence... sequences)
Sequences of ProcessElements.
|
void |
setStartElement(ProcessElement startElement) |
Process |
setStartElement(java.lang.String startElement)
|
Process |
setState(Record state)
Current state of a process.
|
void |
setStateVariable(java.lang.String stateVariablePath,
java.lang.Object value)
Sets a
process state variable for later reference with getStateVariable() or more commonly with a TaskInputExpression property. |
void |
setTaskOutput(ProcessElement task,
java.lang.Object value)
Sets the task output of
task in the process state so it can be used
by later tasks with getLastTaskOutput() or more
commonly with a TaskInputExpression property. |
Process |
setTraceContext(java.util.Map traceContext)
Context object to be passed to
Process.traceElement() during process execution. |
Process |
setWizard(java.lang.Boolean wizard)
If wizard is set then current workflow will be handled as wizard.
|
void |
start()
Starts this task by executing the
startElement . |
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setScClassName
public Process()
public Process(com.google.gwt.core.client.JavaScriptObject jsObj)
public static Process getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
setJavaScriptObject
in class BaseClass
public com.google.gwt.core.client.JavaScriptObject create()
public com.google.gwt.core.client.JavaScriptObject getJsObj()
public com.google.gwt.core.client.JavaScriptObject getOrCreateJsObj()
getOrCreateJsObj
in class BaseClass
public Process setContainerId(java.lang.String containerId)
inline view
property should be added using addMember.public java.lang.String getContainerId()
inline view
property should be added using addMember.GlobalId
public Process setElements(ProcessElement... elements) throws java.lang.IllegalStateException
sequences
to reduce the need to explicitly define IDs for
elements and interlink them.elements
- New elements value. Default value is nullProcess
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic Process setMockMode(java.lang.Boolean mockMode)
mockMode can also be enabled or disabled for an individual task with ProcessElement.mockMode
.
mockMode
- New mockMode value. Default value is nullProcess
instance, for chaining setter callspublic java.lang.Boolean getMockMode()
mockMode can also be enabled or disabled for an individual task with ProcessElement.mockMode
.
public Process setRuleScope(java.lang.String ruleScope) throws java.lang.IllegalStateException
Canvas.ID
of the component that manages "rule context" for which this
process participates. The rule context can be used in taskInputExpression
.setRuleScope
in class BaseClass
ruleScope
- New ruleScope value. Default value is nullProcess
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdCanvas.setRuleScope(java.lang.String)
public java.lang.String getRuleScope()
Canvas.ID
of the component that manages "rule context" for which this
process participates. The rule context can be used in taskInputExpression
.getRuleScope
in class BaseClass
Canvas.getRuleScope()
public Process setSequences(ProcessSequence... sequences) throws java.lang.IllegalStateException
ProcessElement.nextElement
implicit.
Example of using sequences:
Process process = new Process(); process.setStartElement("firstSequence"); ProcessSequence innerSequence = new ProcessSequence(incTask, add2Task, incTask); process.setSequences( new ProcessSequence("firstSequence", serviceTask, multiDecisionTask), new ProcessSequence("errorFlow", failureTask, userNotifyTask) ); // standalone process elements not part of sequences process.setElements(new ServiceTask(){...}); Record state = new Record(); state.setAttribute("someField", "someValue"); process.setState(state); process.start();
sequences
- New sequences value. Default value is nullProcess
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic ProcessSequence[] getSequences()
ProcessElement.nextElement
implicit.
Example of using sequences:
Process process = new Process(); process.setStartElement("firstSequence"); ProcessSequence innerSequence = new ProcessSequence(incTask, add2Task, incTask); process.setSequences( new ProcessSequence("firstSequence", serviceTask, multiDecisionTask), new ProcessSequence("errorFlow", failureTask, userNotifyTask) ); // standalone process elements not part of sequences process.setElements(new ServiceTask(){...}); Record state = new Record(); state.setAttribute("someField", "someValue"); process.setState(state); process.start();
public Process setStartElement(java.lang.String startElement) throws java.lang.IllegalStateException
sequence
or an element
which should be the starting point of the process. If
not specified, the first sequence is chosen, or if there are no sequences, the first element. - log a warning and do
nothing if there are neither sequences or elementsstartElement
- New startElement value. Default value is nullProcess
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.String getStartElement()
sequence
or an element
which should be the starting point of the process. If
not specified, the first sequence is chosen, or if there are no sequences, the first element. - log a warning and do
nothing if there are neither sequences or elementspublic Process setState(Record state)
taskInputExpressions
.
state
- the new process state. Default value is nullProcess
instance, for chaining setter callspublic Record getState()
taskInputExpressions
.public Process setTraceContext(java.util.Map traceContext)
Process.traceElement()
during process execution.
Note : This is an advanced setting
traceContext
- New traceContext value. Default value is nullProcess
instance, for chaining setter callspublic java.util.Map getTraceContext()
Process.traceElement()
during process execution.public Process setWizard(java.lang.Boolean wizard) throws java.lang.IllegalStateException
wizard
- New wizard value. Default value is falseProcess
instance, for chaining setter callsjava.lang.IllegalStateException
- this property cannot be changed after the underlying component has been createdpublic java.lang.Boolean getWizard()
public com.google.gwt.event.shared.HandlerRegistration addFinishedHandler(FinishedHandler handler)
StringMethod called when a process completes, meaning the process executes a ProcessElement with no next element.
addFinishedHandler
in interface HasFinishedHandlers
handler
- the finished handlerHandlerRegistration
used to remove this handlerpublic ProcessElement getElement(java.lang.String ID)
ProcessElement
by it's IDID
- id of the process elementpublic java.lang.Object getLastTaskOutput()
TaskInputExpression
property is used (see ProcessElement.getDynamicValue()
).public java.lang.Object getLastTaskOutput(java.lang.String taskType)
TaskInputExpression
property is used (see ProcessElement.getDynamicValue()
).taskType
- the optional task type to lookup in last task outputpublic java.lang.Object getStateVariable(java.lang.String stateVariablePath)
process state
. Values can
be written into process state by setStateVariable()
,
setting ProcessElement.bindOutput
, or various
task output settings (See TaskIO
.)stateVariablePath
- path to variable in process state to set. segments are separated by a decimal point
(.)public void passThruTaskOutput(ProcessElement task)
last task output
and sets it as the task output
for the task
. This method is not just a shortcut to set output of a pass-thru task but it also records the correct schema of the passed-thru output so it can be quickly looked up.
task
- the workflow task setting the output (i.e. this)public void reset()
public void reset(Record state)
state
- new state of the processpublic void setNextElement()
null
is passed as the nextElement, the current process will be terminated instead.public void setNextElement(java.lang.String nextElement)
null
is passed as the nextElement, the current process will be terminated instead.nextElement
- ID of the next task execute or null to terminate processpublic void setStateVariable(java.lang.String stateVariablePath, java.lang.Object value)
process state
variable for later reference with getStateVariable()
or more commonly with a TaskInputExpression
property.stateVariablePath
- path to variable in process state to set. segments are separated by a decimal point
(.)value
- the value to savepublic void setTaskOutput(ProcessElement task, java.lang.Object value)
task
in the process state
so it can be used
by later tasks with getLastTaskOutput()
or more
commonly with a TaskInputExpression
property. If the task sets
bindOutput
the output value is also written into that process state
variable.
task
- the workflow task setting the output (i.e. this)value
- the output value for taskpublic void start()
startElement
. Also
used by asynchronous tasks to restart the workflow.public com.google.gwt.event.shared.HandlerRegistration addTraceElementHandler(TraceElementHandler handler)
StringMethod called during process execution before each task element is processed.
addTraceElementHandler
in interface HasTraceElementHandlers
handler
- the traceElement handlerHandlerRegistration
used to remove this handlerpublic static Process getProcess(java.lang.String processId)
loadProcess()
.processId
- process ID to retrieve.
See Identifier
Identifier
public Process setAttribute(java.lang.String attribute, ProcessElement[] value, boolean allowPostCreate)
public void setConfig(com.google.gwt.core.client.JavaScriptObject jsObj)
public static void loadProcess(java.lang.String processId, ProcessCallback callback)
public ProcessElement[] getProcessElements(java.lang.String attribute)
public ProcessElement[] getElements()
sequences
to reduce the need to explicitly define IDs for
elements and interlink them.public void setStartElement(ProcessElement startElement) throws java.lang.IllegalStateException
java.lang.IllegalStateException
setStartElement(String)