Class WorkflowUtil

java.lang.Object
com.ssgllc.fish.service.util.registered.WorkflowUtil

@Component public class WorkflowUtil extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clearBatch(org.flowable.engine.delegate.DelegateExecution execution, String batchName)
    Clears all batch variables from the execution context that were created with the given batch name.
    createBatches(org.flowable.engine.delegate.DelegateExecution execution, String batchName, Collection collection, int sizePerSlice)
    Creates batches from a given collection and sets each batch as a process variable in the provided execution context.
    com.ssgllc.fish.service.dto.ProcessNotificationConfigHolder
    getNotificationConfigFromString(String notificationConfigString)
    Deserializes a JSON string into a process notification object.
    getSingleMatchFromDecisionTable(String decisionKey, Map<String,Object> inputVariables)
    Reads single matching rule from decision table
    void
    publishProcessEvent(String category, String action, org.flowable.task.service.impl.persistence.entity.TaskEntity taskEntity, org.flowable.engine.delegate.DelegateExecution execution, Map<String,Object> properties)
    Publishes a process event to handle workflow notifications for a specific custom category and action.
    This method triggers the notification handling logic to evaluate configured expressions, resolve recipients, and send notifications based on the provided event details.

    Methods inherited from class java.lang.Object

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

    • WorkflowUtil

      public WorkflowUtil()
  • Method Details

    • getSingleMatchFromDecisionTable

      public Map<String,Object> getSingleMatchFromDecisionTable(String decisionKey, Map<String,Object> inputVariables)
      Reads single matching rule from decision table
      Parameters:
      decisionKey - Decision key for the decision table.
      inputVariables - Input variables for the decision table.
      Returns:
      a Map with the decision(s) result(s) in case of match, returns null when no match or more than one match is found.
    • getNotificationConfigFromString

      public com.ssgllc.fish.service.dto.ProcessNotificationConfigHolder getNotificationConfigFromString(String notificationConfigString) throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, ClassNotFoundException, IOException
      Deserializes a JSON string into a process notification object.
      Parameters:
      notificationConfigString - The JSON string representing a the process notification object.
      Returns:
      The deserialized process notification object.
      Throws:
      com.fasterxml.jackson.core.JsonParseException - If the JSON string is malformed.
      com.fasterxml.jackson.databind.JsonMappingException - If the JSON mapping to the process notification object class fails.
      ClassNotFoundException - If the process notification object class cannot be found.
      IOException - If an I/O error occurs during deserialization.

      Groovy example:
      return workflowUtil.getNotificationConfigFromString(systemUtil.getTextTemplate("NotificationConfig"))

      Returns:
      A ProcessNotificationConfigHolder object populated with data from the JSON string.
      SpEL example:
      #getNotificationConfigFromString(#getTextTemplate("NotificationConfig"))

      Returns:
      A process notification object populated with data from the JSON string.
    • publishProcessEvent

      public void publishProcessEvent(String category, String action, org.flowable.task.service.impl.persistence.entity.TaskEntity taskEntity, org.flowable.engine.delegate.DelegateExecution execution, Map<String,Object> properties)
      Publishes a process event to handle workflow notifications for a specific custom category and action.
      This method triggers the notification handling logic to evaluate configured expressions, resolve recipients, and send notifications based on the provided event details.
      Parameters:
      category - The custom category of the event (e.g., "caseStatus").
      action - The specific action being performed (e.g., "reviewed").
      taskEntity - The task entity associated with the event. Can be null for process-level notifications.
      execution - The delegate execution object representing the current process instance.
      properties - A map of additional properties or context variables for use in notification processing.

      Groovy example:
      workflowUtil.publishProcessEvent('caseStatus', 'reviewed', currentTask, execution, [hello: 'world'])

      Effect:
      • Publishes a notification to the recipient(s) defined in the process configuration under "caseStatus".
      • The properties map is available for the notification expressions like properties['']
      Note: Ensure the process configuration includes the necessary notification settings under the specified category. If no notification is configured for the given category, no notification will be sent. Note that taskEntity can be null.
    • createBatches

      public List<String> createBatches(org.flowable.engine.delegate.DelegateExecution execution, String batchName, Collection collection, int sizePerSlice)
      Creates batches from a given collection and sets each batch as a process variable in the provided execution context. Each batch is named using the provided batch name and an index suffix (e.g., "batchName#0").
      Parameters:
      execution - The Execution context to set batch variables.
      batchName - The base name for each batch variable.
      collection - The collection to be split into batches.
      sizePerSlice - The maximum number of elements in each batch. Must be positive.
      Returns:
      A list of batch variable names created and set in the execution context.
      Throws:
      IllegalArgumentException - If sizePerSlice is less than or equal to zero.

      Groovy example:
      def range = mathUtil.createIntRange(1, 1015)
      def batchNames = workflowUtil.createBatches(execution, 'myBatch', range, 100)

      execution.setVariable("index", 0)
      execution.setVariable("numBatches", batchNames.size())

      Explanation:
      The above example creates batches from a range of integers (1 to 1015) with a maximum of 100 items per batch. The batches are named "myBatch#0", "myBatch#1", and so on, and stored as process variables in the execution context. The total number of batches is also set as a variable named "numBatches".
    • clearBatch

      public void clearBatch(org.flowable.engine.delegate.DelegateExecution execution, String batchName)
      Clears all batch variables from the execution context that were created with the given batch name.
      Parameters:
      execution - The DelegateExecution context from which to remove batch variables.
      batchName - The base name of the batch variables to clear.

      Groovy example:
      workflowUtil.clearBatch(execution, 'myBatch')

      Explanation:
      The above example removes all variables from the execution context that start with "myBatch#", such as "myBatch#0", "myBatch#1", and so on.