Class WorkflowUtil
java.lang.Object
com.ssgllc.fish.service.util.registered.WorkflowUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.static 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) Evaluates a DMN decision table using the provided decision key and input variables, and returns a single matching result as a map.static 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.
-
Constructor Details
-
WorkflowUtil
public WorkflowUtil()
-
-
Method Details
-
getSingleMatchFromDecisionTable
public static Map<String,Object> getSingleMatchFromDecisionTable(String decisionKey, Map<String, Object> inputVariables) Evaluates a DMN decision table using the provided decision key and input variables, and returns a single matching result as a map.- Parameters:
decisionKey
- The unique key identifying the DMN decision table to be evaluated.inputVariables
- A map of input variables to be passed to the decision table.- Returns:
- A map representing the result of the decision table evaluation, or
null
if an exception occurs or no match is found.
Groovy example:
def inputs = ['first': 'def', 'second': 'ghi']
return workflowUtil.getSingleMatchFromDecisionTable('basic', inputs)
Returns:
["outOne": "456", "outTwo": "789"]
SpEL example:
#getSingleMatchFromDecisionTable('basic', {'first': 'def', 'second': 'ghi'})
Returns:
{"outOne":"456","outTwo":"789"}
Note: This method returns
null
if an exception occurs during evaluation or if no matching rule is found in the decision table.
-
getNotificationConfigFromString
public static 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:
AProcessNotificationConfigHolder
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 static 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 benull
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['
']
-
createBatches
public static 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
- IfsizePerSlice
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 static 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
- TheDelegateExecution
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.
-