Class Task

All Implemented Interfaces:
HasHandlers
Direct Known Subclasses:
ComponentTask, DSRequestTask, ScriptTask, StateTask, UserTask

public class Task extends ProcessElement
A Task is an abstract superclass for all Task types that can be involved in a Process, such as a DSRequestTask.
  • Constructor Details

  • Method Details

    • getOrCreateRef

      public static Task getOrCreateRef(JavaScriptObject jsObj)
    • create

      public JavaScriptObject create()
      Overrides:
      create in class ProcessElement
    • setInputFieldList

      public Task setInputFieldList(String... inputFieldList) throws IllegalStateException
      Deprecated.
      In favor of inputs as of SmartGWT release 13.1
      List of multiple fields from the process state which are provided as input data to this task. See TaskIO.
      Parameters:
      inputFieldList - New inputFieldList value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getInputFieldList

      public String[] getInputFieldList()
      Deprecated.
      In favor of inputs as of SmartGWT release 13.1
      List of multiple fields from the process state which are provided as input data to this task. See TaskIO.
      Returns:
      Current inputFieldList value. Default value is null
      See Also:
    • setInputs

      public Task setInputs(Map inputs) throws IllegalStateException
      Defines how fields in the process state are extracted for the input record to this task. inputs may be:
      • a single StatePath or TaskInputExpression: the value it refers to is the task's $input. If that value is a Record, its fields form the input record; otherwise the value is stored in the input record under the last segment of the path.
      • an Array of StatePaths: each value is stored in the input record under the last segment of its path.
      • an Object: each key is a StatePath (in its setter form) into the input record, and each value is a TaskInputExpression, a StatePath into Process.state, or, for a non-String value, a literal. Because a String value is always resolved, a literal String cannot be supplied this way. $input cannot be referenced here, since it is the result of these inputs.
      When neither inputs nor the deprecated inputFieldList is set, the input record is the entire process state. See TaskIO for details and examples.
      Parameters:
      inputs - New inputs value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getInputs

      public Map getInputs()
      Defines how fields in the process state are extracted for the input record to this task. inputs may be:
      • a single StatePath or TaskInputExpression: the value it refers to is the task's $input. If that value is a Record, its fields form the input record; otherwise the value is stored in the input record under the last segment of the path.
      • an Array of StatePaths: each value is stored in the input record under the last segment of its path.
      • an Object: each key is a StatePath (in its setter form) into the input record, and each value is a TaskInputExpression, a StatePath into Process.state, or, for a non-String value, a literal. Because a String value is always resolved, a literal String cannot be supplied this way. $input cannot be referenced here, since it is the result of these inputs.
      When neither inputs nor the deprecated inputFieldList is set, the input record is the entire process state. See TaskIO for details and examples.
      Returns:
      Current inputs value. Default value is null
      See Also:
    • setInputs

      public Task setInputs(String... inputs) throws IllegalStateException
      Defines how fields in the process state are extracted for the input record to this task. inputs may be:
      • a single StatePath or TaskInputExpression: the value it refers to is the task's $input. If that value is a Record, its fields form the input record; otherwise the value is stored in the input record under the last segment of the path.
      • an Array of StatePaths: each value is stored in the input record under the last segment of its path.
      • an Object: each key is a StatePath (in its setter form) into the input record, and each value is a TaskInputExpression, a StatePath into Process.state, or, for a non-String value, a literal. Because a String value is always resolved, a literal String cannot be supplied this way. $input cannot be referenced here, since it is the result of these inputs.
      When neither inputs nor the deprecated inputFieldList is set, the input record is the entire process state. See TaskIO for details and examples.
      Parameters:
      inputs - New inputs value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getInputsAsStringArray

      public String[] getInputsAsStringArray()
      Defines how fields in the process state are extracted for the input record to this task. inputs may be:
      • a single StatePath or TaskInputExpression: the value it refers to is the task's $input. If that value is a Record, its fields form the input record; otherwise the value is stored in the input record under the last segment of the path.
      • an Array of StatePaths: each value is stored in the input record under the last segment of its path.
      • an Object: each key is a StatePath (in its setter form) into the input record, and each value is a TaskInputExpression, a StatePath into Process.state, or, for a non-String value, a literal. Because a String value is always resolved, a literal String cannot be supplied this way. $input cannot be referenced here, since it is the result of these inputs.
      When neither inputs nor the deprecated inputFieldList is set, the input record is the entire process state. See TaskIO for details and examples.
      Returns:
      Current inputs value. Default value is null
      See Also:
    • setInputs

      public Task setInputs(String inputs) throws IllegalStateException
      Defines how fields in the process state are extracted for the input record to this task. inputs may be:
      • a single StatePath or TaskInputExpression: the value it refers to is the task's $input. If that value is a Record, its fields form the input record; otherwise the value is stored in the input record under the last segment of the path.
      • an Array of StatePaths: each value is stored in the input record under the last segment of its path.
      • an Object: each key is a StatePath (in its setter form) into the input record, and each value is a TaskInputExpression, a StatePath into Process.state, or, for a non-String value, a literal. Because a String value is always resolved, a literal String cannot be supplied this way. $input cannot be referenced here, since it is the result of these inputs.
      When neither inputs nor the deprecated inputFieldList is set, the input record is the entire process state. See TaskIO for details and examples.
      Parameters:
      inputs - New inputs value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getInputsAsString

      public String getInputsAsString()
      Defines how fields in the process state are extracted for the input record to this task. inputs may be:
      • a single StatePath or TaskInputExpression: the value it refers to is the task's $input. If that value is a Record, its fields form the input record; otherwise the value is stored in the input record under the last segment of the path.
      • an Array of StatePaths: each value is stored in the input record under the last segment of its path.
      • an Object: each key is a StatePath (in its setter form) into the input record, and each value is a TaskInputExpression, a StatePath into Process.state, or, for a non-String value, a literal. Because a String value is always resolved, a literal String cannot be supplied this way. $input cannot be referenced here, since it is the result of these inputs.
      When neither inputs nor the deprecated inputFieldList is set, the input record is the entire process state. See TaskIO for details and examples.
      Returns:
      Current inputs value. Default value is null
      See Also:
    • setOutputExpression

      public Task setOutputExpression(String outputExpression) throws IllegalStateException
      Special expression to write task output directly into a DataBoundComponent. See TaskIO.
      Parameters:
      outputExpression - New outputExpression value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getOutputExpression

      public String getOutputExpression()
      Special expression to write task output directly into a DataBoundComponent. See TaskIO.
      Returns:
      Current outputExpression value. Default value is null
      See Also:
    • setOutputField

      public Task setOutputField(String outputField) throws IllegalStateException
      Field in the process state where this task writes outputs. See TaskIO.
      Parameters:
      outputField - New outputField value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getOutputField

      public String getOutputField()
      Field in the process state where this task writes outputs. See TaskIO.
      Returns:
      Current outputField value. Default value is null
      See Also:
    • setOutputFieldList

      public Task setOutputFieldList(String... outputFieldList) throws IllegalStateException
      List of multiple fields in the process state where this task will write outputs. See TaskIO.

      If outputField is also specified, it will be implicitly added to the outputFieldList if it is not already present.

      Parameters:
      outputFieldList - New outputFieldList value. Default value is null
      Returns:
      Task instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the underlying component has been created
      See Also:
    • getOutputFieldList

      public String[] getOutputFieldList()
      List of multiple fields in the process state where this task will write outputs. See TaskIO.

      If outputField is also specified, it will be implicitly added to the outputFieldList if it is not already present.

      Returns:
      Current outputFieldList value. Default value is null
      See Also:
    • setStrictPaths

      public Task setStrictPaths(Boolean strictPaths)
      If set to true, the task will not allow any intermediate state to be set via setState() that is not explicitly defined first. This requirement can be overridden by an optional value in the setState() call.

      This setting can be applied to the entire process with Process.strictPaths.

      Parameters:
      strictPaths - New strictPaths value. Default value is null
      Returns:
      Task instance, for chaining setter calls
    • getStrictPaths

      public Boolean getStrictPaths()
      If set to true, the task will not allow any intermediate state to be set via setState() that is not explicitly defined first. This requirement can be overridden by an optional value in the setState() call.

      This setting can be applied to the entire process with Process.strictPaths.

      Returns:
      Current strictPaths value. Default value is null
    • getCriteriaExpressionValue

      public Criteria getCriteriaExpressionValue(Criteria value)
      Get the value of a Criteria or AdvancedCriteria by resolving any values containing taskInputExpressions. The criteria passed in is not modified; a resolved copy is returned.

      Data values in the criteria prefixed with "$" will be treated as dynamic expressions as detailed in TaskInputExpression. Specifically, this means that for simple criteria, any property value that is a String and is prefixed with "$" will be assumed to be an expression, and for AdvancedCriteria, the same treatment will be applied to Criterion.value. To use a literal value starting with "$", escape it with a backslash: the value \$last resolves to the String $last.

      For AdvancedCriteria only, when Process.ruleScope is set, a dynamic criteria containing Criterion.valuePath values is also resolved against the ruleScope component's ruleContext.

      Returns null when called outside of a running process.

      Parameters:
      value - criteria to resolve
      Returns:
      resolved copy of criteria
      See Also:
    • getCriteriaExpressionValueAsAdvancedCriteria

      public AdvancedCriteria getCriteriaExpressionValueAsAdvancedCriteria(Criteria value)
      Get the value of a Criteria or AdvancedCriteria by resolving any values containing taskInputExpressions. The criteria passed in is not modified; a resolved copy is returned.

      Data values in the criteria prefixed with "$" will be treated as dynamic expressions as detailed in TaskInputExpression. Specifically, this means that for simple criteria, any property value that is a String and is prefixed with "$" will be assumed to be an expression, and for AdvancedCriteria, the same treatment will be applied to Criterion.value. To use a literal value starting with "$", escape it with a backslash: the value \$last resolves to the String $last.

      For AdvancedCriteria only, when Process.ruleScope is set, a dynamic criteria containing Criterion.valuePath values is also resolved against the ruleScope component's ruleContext.

      Returns null when called outside of a running process.

      Parameters:
      value - criteria to resolve
      Returns:
      resolved copy of criteria
    • getExpressionValue

      public Object getExpressionValue(String value)
      Get the value of a inputExpression. A String that does not start with "$" is treated as a StatePath into Process.state; any other non-null value is a literal and returned unchanged. Expressions are resolved as by Process.getExpressionValue(), plus $input, drawn from this task's inputs.

      Outside of a running process a String expression resolves to null.

      Parameters:
      value - expression to evaluate, or a StatePath. See TaskInputExpression
      Returns:
      value of expression
      See Also:
    • getExpressionValue

      public Object getExpressionValue(Object value)
      Get the value of a inputExpression. A String that does not start with "$" is treated as a StatePath into Process.state; any other non-null value is a literal and returned unchanged. Expressions are resolved as by Process.getExpressionValue(), plus $input, drawn from this task's inputs.

      Outside of a running process a String expression resolves to null.

      Parameters:
      value - expression to evaluate, or a StatePath. See TaskInputExpression
      Returns:
      value of expression
      See Also:
    • getInputRecord

      public Record getInputRecord()
      Get all inputs to the task as specified by the inputs, as a Record. When the task declares no inputs, the input record is a shallow copy of the entire Process.state: fields can be added to or replaced in the returned record without affecting the process state, but nested objects are shared with it and must not be modified. See TaskIO for how each form of inputs contributes to the input record.

      Outside of a running process, for example while a task is being edited, there is no state to draw from and declared inputs have no values.

      Returns:
      input record
      See Also:
    • getState

      public Object getState(String statePath)
      Returns a value from the process state. Values can be written into the process state by setState(), setting ProcessElement.bindOutput, or various task output settings (See TaskIO.)
      Parameters:
      statePath - path to the value in the process state to retrieve. See StatePath
      Returns:
      the value found at the path
      See Also:
    • setOutput

      public void setOutput(Object output)
      Sets the task output available to the next task via Process.getLastTaskOutput() or more commonly, with a TaskInputExpression property. If outputFieldList is specified, the output will also be written to the specified fields in the process state (See TaskIO).

      To have the output written as-is to the process state, see bindOutput.

      Parameters:
      output - output record to provide to next task
    • setState

      public void setState(String statePath, String value, Boolean strict)
      Sets a process state value for later reference with Process.getStateVariable() or more commonly, with a TaskInputExpression property.

      The path, which is one or more valid identifiers separated by periods, is used to identify the variable. By appending an empty pair of brackets ([]) the value will be placed into an existing or new array at the specified path.

      Parameters:
      statePath - path to the variable in the process state to set. segments are separated by a decimal point (.). See StatePath
      value - the value to save. See TaskInputExpression
      strict - if true, every intermediate segment of the path must already exist in the state; the final segment is always created or replaced. If false, missing intermediate objects are created. Defaults to strictPaths, then Process.strictPaths, when null.