Class TaskUtil

java.lang.Object
com.ssgllc.fish.service.util.published.TaskUtil

@Component public class TaskUtil extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.flowable.form.api.FormService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    updateCompletedFormVariables(String formKey, String taskId, String processInstanceId, Map<String,Object> variablesToUpdate)
    Updates form variables for a task that has already been completed.
    void
    updateFormVariables(String formKey, String taskId, String processInstanceId, Map<String,Object> variablesToUpdate)
    Updates form variables for the given task identifiers by applying the provided values and preserving existing ones.
    Use this overload when only the raw identifiers are available rather than a TaskEntity.
    Only fields present in the form and the update map are modified.
    void
    updateFormVariables(org.flowable.task.service.impl.persistence.entity.TaskEntity task, Map<String,Object> variablesToUpdate)
    Updates form variables for the given task by applying the provided values and preserving existing ones.
    Only fields present in the form and the update map are modified.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • formService

      @Autowired protected org.flowable.form.api.FormService formService
  • Constructor Details

    • TaskUtil

      public TaskUtil()
  • Method Details

    • updateFormVariables

      public void updateFormVariables(org.flowable.task.service.impl.persistence.entity.TaskEntity task, Map<String,Object> variablesToUpdate)
      Updates form variables for the given task by applying the provided values and preserving existing ones.
      Only fields present in the form and the update map are modified.
      Parameters:
      task - The task whose form variables are to be updated.
      variablesToUpdate - A map of field names and their new values.

      Groovy example:
      formUtil.updateFormVariables(task, ["field1": "newVal", "field2": 42])
      Note: No update occurs if the task has no form or no fields.
    • updateFormVariables

      public void updateFormVariables(String formKey, String taskId, String processInstanceId, Map<String,Object> variablesToUpdate)
      Updates form variables for the given task identifiers by applying the provided values and preserving existing ones.
      Use this overload when only the raw identifiers are available rather than a TaskEntity.
      Only fields present in the form and the update map are modified.
      Parameters:
      formKey - The form key of the task.
      taskId - The id of the task.
      processInstanceId - The process instance id of the task.
      variablesToUpdate - A map of field names and their new values.

      For a task that is already completed, use updateCompletedFormVariables(java.lang.String, java.lang.String, java.lang.String, java.util.Map<java.lang.String, java.lang.Object>) instead; this method requires the task to still be active.

      Groovy example:
      formUtil.updateFormVariables(formKey, taskId, processInstanceId, ["field1": "newVal", "field2": 42])
      Note: No update occurs if the task has no form or no fields.
    • updateCompletedFormVariables

      public void updateCompletedFormVariables(String formKey, String taskId, String processInstanceId, Map<String,Object> variablesToUpdate)
      Updates form variables for a task that has already been completed. updateFormVariables(org.flowable.task.service.impl.persistence.entity.TaskEntity, java.util.Map<java.lang.String, java.lang.Object>) cannot be used for a completed task because the underlying save rejects it. The live process variables are updated and the saved form-instance snapshot is updated with the new values, so this requires the process instance to still be active.
      Only the supplied fields are changed; no expression fields are re-evaluated.

      The new value is set on the process variable as-is (the same way a normal task completion sets it), so inspect the current value's format first and supply a value of the same shape. Read the current value with execution.getVariable(fieldId) (e.g. a table field comes back as a List of row Maps), then modify and pass the whole value back. Do not, for example, hand a JSON String for a field whose variable is a List, or the variable's type would change.
      Parameters:
      formKey - The form key of the task.
      taskId - The id of the completed task.
      processInstanceId - The still-active process instance the task belongs to.
      variablesToUpdate - A map of field names and their new values.

      Groovy example (updating a column of a table field's first row):
      def table = execution.getVariable("table") // List<Map>
      table[0]["score"] = 222
      taskUtil.updateCompletedFormVariables(formKey, taskId, processInstanceId, ["table": table])