com.smartgwt.client.util.workflow

## Class Process

- java.lang.Object
- - com.smartgwt.client.core.BaseClass
  - - com.smartgwt.client.util.workflow.ProcessElement
    - - com.smartgwt.client.util.workflow.Task
      - - com.smartgwt.client.util.workflow.Process

- All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers

      public class Process
      extends Task

  A instance of Process represents a stateful process executing a series of Tasks, which may be:
  - user interactions
  - calls to DataSources (hence: any database or web service)
  - arbitrary code
  - other Processes
  A Process is stateful in the sense that it maintains `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 `XORGateway` and `DecisionGateway`.

  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, gateways 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 Workflow module `Optional Modules` before you can use `Process`.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `Process.ProcessCallback`

  - ### Field Summary

    - ### Fields inherited from class com.smartgwt.client.core.BaseClass

      `config, configOnly, factoryCreated, factoryProperties, id, scClassName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Process()`
    `Process(com.google.gwt.core.client.JavaScriptObject jsObj)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.gwt.core.client.JavaScriptObject` | `create()`
    `void` | `finished(Record state)` StringMethod called when a process completes, meaning the process executes a ProcessElement with no next element.
    `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.
    `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.
    `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()` The ID of either a `sequence` or an `element` which should be the starting point of the process.
    `Record` | `getState()` Current state of a process.
    `java.util.Map` | `getTraceContext()` Context object to be passed to `traceElement()` during process execution.
    `java.lang.Boolean` | `getWizard()` If wizard is set then current workflow will be handled as wizard.
    `static void` | `loadProcess(java.lang.String processId, Process.ProcessCallback callback)`
    `protected void` | `onInit_Process()`
    `protected void` | `onInit()`
    `void` | `reset(Record state)` Reset process to it's initial state, so process can be started again.
    `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.
    `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)` The ID of either a `sequence` or an `element` which should be the starting point of the process.
    `Process` | `setState(Record state)` Current state of a process.
    `Process` | `setTraceContext(java.util.Map traceContext)` Context object to be passed to `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`.
    `void` | `traceElement(Task element, java.util.Map context)` StringMethod called during process execution before each task element is processed.

    - ### Methods inherited from class com.smartgwt.client.util.workflow.Task

      `getInputField, getInputFieldList, getOutputExpression, getOutputField, getOutputFieldList, setInputField, setInputFieldList, setOutputExpression, setOutputField, setOutputFieldList`

    - ### Methods inherited from class com.smartgwt.client.util.workflow.ProcessElement

      `convertToJavaScriptArray, getClassDescription, getDescription, getEditorType, getElementDescription, getID, getJsObj, getNextElement, getOrCreateJsObj, getPassThruOutput, getProcessElements, getTitle, isCreated, setAttribute, setClassDescription, setDescription, setEditorType, setID, setJavaScriptObject, setNextElement, setPassThruOutput, setTitle`

    - ### Methods inherited from class com.smartgwt.client.core.BaseClass

      `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, 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, setProperty, setProperty, setProperty, setProperty, setScClassName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Process

          public Process()

    - #### Process

          public Process(com.google.gwt.core.client.JavaScriptObject jsObj)

  - ### Method Detail

    - #### getOrCreateRef

          public static Process getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### create

          public com.google.gwt.core.client.JavaScriptObject create()

      Overrides:
        `create` in class `Task`

    - #### setContainerId

          public Process setContainerId(java.lang.String containerId)

      Identifier of canvas where UI elements created by using `inline view` property should be added using addMember.
      Parameters:
        `containerId` - New containerId value. Default value is null
      Returns:
        `Process` instance, for chaining setter calls
      See Also:
        `GlobalId`

    - #### getContainerId

          public java.lang.String getContainerId()

      Identifier of canvas where UI elements created by using `inline view` property should be added using addMember.
      Returns:
        Current containerId value. Default value is null
      See Also:
        `GlobalId`

    - #### setElements

          public Process setElements(ProcessElement... elements)
                              throws java.lang.IllegalStateException

      Elements involved in this Process. You can also group elements into `sequences` to reduce the need to explicitly define IDs for elements and interlink them.
      Parameters:
        `elements` - New elements value. Default value is null
      Returns:
        `Process` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### setRuleScope

          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`.
      Overrides:
        `setRuleScope` in class `BaseClass`
      Parameters:
        `ruleScope` - New ruleScope value. Default value is null
      Returns:
        `Process` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created
      See Also:
        `Canvas.setRuleScope(java.lang.String)`

    - #### getRuleScope

          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`.
      Overrides:
        `getRuleScope` in class `BaseClass`
      Returns:
        Current ruleScope value. Default value is null
      See Also:
        `Canvas.getRuleScope()`

    - #### setSequences

          public Process setSequences(ProcessSequence... sequences)
                               throws java.lang.IllegalStateException

      Sequences of ProcessElements. By defining a sequences of elements you can make the `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, decisionGateway),
                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();

      Parameters:
        `sequences` - New sequences value. Default value is null
      Returns:
        `Process` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getSequences

          public ProcessSequence[] getSequences()

      Sequences of ProcessElements. By defining a sequences of elements you can make the `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, decisionGateway),
                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();

      Returns:
        Current sequences value. Default value is null

    - #### setStartElement

          public Process setStartElement(java.lang.String startElement)
                                  throws java.lang.IllegalStateException

      The ID of either a `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 elements
      Parameters:
        `startElement` - New startElement value. Default value is null
      Returns:
        `Process` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getStartElement

          public java.lang.String getStartElement()

      The ID of either a `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 elements
      Returns:
        Current startElement value. Default value is null

    - #### setState

          public Process setState(Record state)

      Current state of a process. As with Records in general, any field of a Record may contain a nested Record or Array of Records, so the process state is essentially a hierarchical data structure.

      #### Transient state

      In addition to the explicit process state there is a "transient state." The transient state represents the complete output of each of the last tasks of each type within the current process execution. This allows easy reference to the previous task output with `taskInputExpressions`.
      If this method is called after the component has been drawn/initialized: Set process state for current process
      Parameters:
        `state` - the new process state. Default value is null
      Returns:
        `Process` instance, for chaining setter calls

    - #### getState

          public Record getState()

      Current state of a process. As with Records in general, any field of a Record may contain a nested Record or Array of Records, so the process state is essentially a hierarchical data structure.

      #### Transient state

      In addition to the explicit process state there is a "transient state." The transient state represents the complete output of each of the last tasks of each type within the current process execution. This allows easy reference to the previous task output with `taskInputExpressions`.
      Returns:
        Current state value. Default value is null

    - #### setTraceContext

          public Process setTraceContext(java.util.Map traceContext)

      Context object to be passed to `traceElement()` during process execution.

      Note : This is an advanced setting

      Parameters:
        `traceContext` - New traceContext value. Default value is null
      Returns:
        `Process` instance, for chaining setter calls

    - #### getTraceContext

          public java.util.Map getTraceContext()

      Context object to be passed to `traceElement()` during process execution.
      Returns:
        Current traceContext value. Default value is null

    - #### setWizard

          public Process setWizard(java.lang.Boolean wizard)
                            throws java.lang.IllegalStateException

      If wizard is set then current workflow will be handled as wizard. Every userTask will hide associated form after user finished step.
      Parameters:
        `wizard` - New wizard value. Default value is false
      Returns:
        `Process` instance, for chaining setter calls
      Throws:
        `java.lang.IllegalStateException` - this property cannot be changed after the underlying component has been created

    - #### getWizard

          public java.lang.Boolean getWizard()

      If wizard is set then current workflow will be handled as wizard. Every userTask will hide associated form after user finished step.
      Returns:
        Current wizard value. Default value is false

    - #### finished

          public void finished(Record state)

      StringMethod called when a process completes, meaning the process executes a ProcessElement with no next element.
      Parameters:
        `state` - the final process state

    - #### getElement

          public ProcessElement getElement(java.lang.String ID)

      Retrieve a `ProcessElement` by it's ID
      Parameters:
        `ID` - id of the process element
      Returns:
        the indicated process element, or null if no such element exists

    - #### reset

          public void reset(Record state)

      Reset process to it's initial state, so process can be started again.
      Parameters:
        `state` - new state of the process

    - #### start

          public void start()

      Starts this task by executing the `startElement`. Also used by asynchronous tasks to restart the workflow.

    - #### traceElement

          public void traceElement(Task element,
                                   java.util.Map context)

      StringMethod called during process execution before each task element is processed.
      Parameters:
        `element` - the `Task` being executed
        `context` - the `traceContext`, if set

    - #### getProcess

          public static Process getProcess(java.lang.String processId)

      Get a Process instance by it's ID. See `loadProcess()`.
      Parameters:
        `processId` - process IDs to retrieve. See `Identifier`
      Returns:
        the process, or null if not loaded
      See Also:
        `Identifier`

    - #### setConfig

          public void setConfig(com.google.gwt.core.client.JavaScriptObject jsObj)

      Overrides:
        `setConfig` in class `BaseClass`

    - #### loadProcess

          public static void loadProcess(java.lang.String processId,
                                         Process.ProcessCallback callback)

    - #### getElements

          public ProcessElement[] getElements()

      Elements involved in this Process. You can also group elements into `sequences` to reduce the need to explicitly define IDs for elements and interlink them.
      Returns:
        ProcessElement

    - #### setStartElement

          public void setStartElement(ProcessElement startElement)
                               throws java.lang.IllegalStateException

      Throws:
        `java.lang.IllegalStateException`
      See Also:
        `setStartElement(String)`

    - #### onInit_Process

          protected void onInit_Process()

    - #### onInit

          protected void onInit()

      Overrides:
        `onInit` in class `ProcessElement`