Class ValidationHelper

java.lang.Object
de.xima.fc.workflow.designer.helper.ValidationHelper

public class ValidationHelper extends Object
UI helper utilities for running the workflow validator and extracting and converting workflow validation messages.
Since:
7.0.0
Author:
XIMA MEDIA GmbH
  • Method Details

    • addExternalResultToModel

      public static void addExternalResultToModel(WorkflowValidationModel validationModel, IWorkflowValidationResult result)
      Parameters:
      validationModel - Validation model to which to add the result.
      result - Validation result to merge into the model.
    • collectValidatedElements

      public static Set<ElementKey> collectValidatedElements(IWorkflowValidationResult result)
      Parameters:
      result - A validation result obtained from running the IWorkflowValidator.
      Returns:
      A set of all workflow element keys (nodes / triggers) that are contained in the given result.
    • createValidatorBuilder

      public static WorkflowValidator.Builder createValidatorBuilder(IWorkflowValidationEnvironmentData params)
      Parameters:
      params - Params for the validation process.
      Returns:
      A new workflow validator builder with the given params.
    • findErronousNodes

      public static Set<NodeKey> findErronousNodes(ProcessModel process, IWorkflowValidationResult result)
      Parameters:
      process - Current process with all nodes and their children.
      result - A validation result.
      Returns:
      The UUIDs of all nodes that are either invalid themselves or contain an invalid child.
    • findErronousTasks

      public static Set<UUID> findErronousTasks(IWorkflowValidationResult result)
      Parameters:
      result - A validation result.
      Returns:
      The UUIDs of all tasks that are either invalid themselves or contain an invalid element (node or trigger).
    • performBackgroundValidation

      public static void performBackgroundValidation(FlowchartModel flowchartModel, AssociatesModel associatesModel, WorkflowValidationModel validationModel, IWorkflowProvider provider) throws FastJsonException
      Validate the current workflow in the background while the user is editing the workflow. This provides incremental feedback to the user. Once they attempt to save the workflow, a full validation is performed.
      Parameters:
      flowchartModel - Current flowchart model.
      validationModel - Current validation model.
      associatesModel - Current associates model.
      provider - Workflow provider to use.
      Throws:
      FastJsonException - When serialized element properties could not be deserialized.
    • performFullValidation

      public static IWorkflowValidationResult performFullValidation(WorkflowProcess process, FlowchartModel flowchartModel, WorkflowValidationModel validationModel, ViewSettingsModel viewSettingsModel, IWorkflowProvider provider) throws FastJsonException
      Performs a full validation of the workflow and validates all elements. Adds the validation messages to the flowchart. Also shows any invalid workflow elements that are hidden so the user can see the error.
      Parameters:
      process - Workflow process to validate.
      flowchartModel - Current flowchart model.
      validationModel - Current validation model.
      viewSettingsModel - Current view settings model,
      provider - Workflow provider to use. Can be null for a new database provider.
      Returns:
      The result of the validation.
      Throws:
      FastJsonException - When serialized element properties could not be deserialized.
    • performInitialValidation

      public static void performInitialValidation(IWorkflowValidationEnvironmentData params, IWorkflowProvider provider, FlowchartModel flowchartModel, WorkflowProcess process, WorkflowValidationModel validationModel)
      Performs the initial full validation when the workflow designer is opened.
      Parameters:
      params - Params for the validation process.
      provider - Provider to use. When not given, a new database provider is created.
      flowchartModel - Flowchart model to validate.
      process - Process to validate.
      validationModel - Current UI validation messages model.
    • toElementMessagesSet

      public static Map<ElementKey,ElementMessageSetModel> toElementMessagesSet(IWorkflowValidationResult validationResult)
      Parameters:
      validationResult - Validation result obtained from running the IWorkflowValidator.
      Returns:
      The validation messages for all elements, merged into a message set that can be sent to the client.
    • toMessageSet

      public static ElementMessageSetModel toMessageSet(IWorkflowElementValidationResult result)
      Parameters:
      result - A validation result.
      Returns:
      The messages of the validation result as a message set that can be sent to the client.
    • toTaskMessageSet

      public static ElementMessageSetModel toTaskMessageSet(WorkflowValidationModel validationModel, UUID taskUuid)
      Parameters:
      validationModel - UI validation model used by the workflow designer.
      taskUuid - UUID of a task that was validated.
      Returns:
      The validation messages for the given task, merged into a message set that can be sent to the client.
    • toTaskMessagesSet

      public static Map<UUID,ElementMessageSetModel> toTaskMessagesSet(IWorkflowValidationResult validationResult)
      Parameters:
      validationResult - Validation result obtained from running the IWorkflowValidator.
      Returns:
      The validation messages for all tasks, added to a message set that can be sent to the client.
    • toTaskMessagesSet

      public static Map<UUID,ElementMessageSetModel> toTaskMessagesSet(WorkflowValidationModel validationModel)
      Parameters:
      validationModel - Validation result stored in the workflow designer UI.
      Returns:
      The validation messages for all tasks, added to a message set that can be sent to the client.
    • validate

      public static IWorkflowValidationResult validate(IWorkflowValidationEnvironmentData params, FlowchartModel flowchartModel, Set<ElementKey> elementsToValidate, WorkflowFlowAnalysis executionAnalysis, IWorkflowProvider provider, EWorkflowValidationGroup... groups) throws FastJsonException
      Validates the workflow for the given flowchart model.
      Parameters:
      params - Params for the validation process.
      flowchartModel - Flowchart model with a workflow process to validate.
      elementsToValidate - Set with elements to include in the validation.
      executionAnalysis - Analysis to reuse, may be null, which creates a new analysis.
      provider - Optional provider to use.
      groups - Validation groups to perform.
      Returns:
      Result of the validation.
      Throws:
      FastJsonException - When the flowchart model data from the client could not be deserialized.
    • validate

      public static IWorkflowValidationResult validate(IWorkflowValidationEnvironmentData params, WorkflowProcess process, Set<ElementKey> elementsToValidate, WorkflowFlowAnalysis executionAnalysis, IWorkflowProvider provider, EWorkflowValidationGroup... groups)
      Validates the workflow for the given process.
      Parameters:
      params - Params for the validation process.
      process - Workflow process to validate.
      elementsToValidate - Set with elements to include in the validation.
      executionAnalysis - Execution analysis to reuse.
      provider - Optional provider to use.
      groups - Validation groups to perform.
      Returns:
      Result of the validation.