WorkflowUtils

Utility class with static helper methods for querying workflow process instances and their log entries. All methods are static and may throw WorkflowException if the workflow engine is unavailable.

Process instance queries

findProcessInstancesByNode

Description:

MethodReturn valuesDescription

findProcessInstancesByNode(String uuid)

List<ProcessInstance>

Returns all process instances associated with the repository node identified by the given UUID. The UUID can belong to a document, folder, mail, or record. Returns an empty list if the UUID is null or no instances are found.

uuid: The UUID of the document, folder, mail, or record.

Example:

package com.openkm;

import com.openkm.bean.workflow.ProcessInstance;
import com.openkm.util.WorkflowUtils;

public class Test {

    public static void main(String[] args) {
        try {
            String uuid = "d50133e3-dbfa-4d01-a109-28785cd48f40";
            for (ProcessInstance pi : WorkflowUtils.findProcessInstancesByNode(uuid)) {
                System.out.println(pi);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findLogsByProcessInstance

Description:

MethodReturn valuesDescription

findLogsByProcessInstance(long processInstanceId)

List<ProcessInstanceLogEntry>

Returns the log entries associated with the given process instance ID, sorted by date. Each entry contains: processDefinitionId, processDefinitionName, processInstanceId, token, date, type, and info.

processInstanceId: The numeric ID of the process instance.

Example:

package com.openkm;

import com.openkm.bean.workflow.ProcessInstance;
import com.openkm.util.WorkflowUtils;
import com.openkm.util.WorkflowUtils.ProcessInstanceLogEntry;

public class Test {

    public static void main(String[] args) {
        try {
            String uuid = "d50133e3-dbfa-4d01-a109-28785cd48f40";
            for (ProcessInstance pi : WorkflowUtils.findProcessInstancesByNode(uuid)) {
                System.out.println("Process instance: " + pi.getId());
                for (ProcessInstanceLogEntry entry : WorkflowUtils.findLogsByProcessInstance(pi.getId())) {
                    System.out.println("  [" + entry.getDate() + "] " + entry.getType() + ": " + entry.getInfo());
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getRunningWorkflowNodes

Description:

MethodReturn valuesDescription

getRunningWorkflowNodes()

Set<String>

Returns the set of repository node UUIDs that have at least one running (not yet ended) workflow process instance. Returns an empty set if no workflows are currently running or if the workflow engine is unavailable.

Example:

package com.openkm;

import com.openkm.util.WorkflowUtils;
import java.util.Set;

public class Test {

    public static void main(String[] args) {
        Set<String> runningNodes = WorkflowUtils.getRunningWorkflowNodes();
        System.out.println("Nodes with active workflows: " + runningNodes.size());
        runningNodes.forEach(uuid -> System.out.println("  " + uuid));
    }
}

Process instance conversion

copy

Description:

MethodReturn valuesDescription

copy(ProcessInstanceRef piRef)

ProcessInstance

Converts a jBPM-specific ProcessInstanceRef adapter object to an OpenKM ProcessInstance bean. Used internally by the workflow adapter layer.

Inner classes

ProcessInstanceLogEntry

A data class representing a single log entry for a process instance. Fields:

  • processInstanceId (long): The process instance ID.
  • processDefinitionId (long): The process definition ID.
  • processDefinitionName (String): The name of the process definition.
  • token (String): The workflow token identifier.
  • date (Date): The timestamp of the log entry.
  • type (String): The type of log event.
  • info (String): Additional information about the event.

DiagramInfo

Holds layout information for a workflow process diagram. Fields:

  • width (int): Total diagram width in pixels.
  • height (int): Total diagram height in pixels.
  • nodeMap (Map<String, DiagramNodeInfo>): Map from node name to its layout info.

Method: getNodes() ? returns an unmodifiable list of all DiagramNodeInfo entries.

DiagramNodeInfo

Holds position and size information for a single node in a workflow diagram. Fields:

  • name (String): The node name.
  • x (int): Horizontal position in pixels.
  • y (int): Vertical position in pixels.
  • width (int): Node width in pixels.
  • height (int): Node height in pixels.