Class MetadataUtils

java.lang.Object
io.axoniq.framework.workflow.runtime.util.MetadataUtils

@Internal public class MetadataUtils extends Object
Utility to work on metadata of workflow events.
Since:
5.4.0
Author:
Simon Zambrovski, Stefan Dragisic
  • Field Details

    • METADATA_KEY_WORKFLOW_ID

      public static final String METADATA_KEY_WORKFLOW_ID
      Metadata key storing the workflow instance identifier.
      See Also:
    • METADATA_KEY_TYPE

      public static final String METADATA_KEY_TYPE
      Metadata key storing the step status value.
      See Also:
    • METADATA_KEY_STEP_PRIMITIVE

      public static final String METADATA_KEY_STEP_PRIMITIVE
      Metadata key storing the step primitive classification.
      See Also:
    • METADATA_KEY_MODIFY_PAYLOAD

      public static final String METADATA_KEY_MODIFY_PAYLOAD
      Metadata key storing the payload reducer name to apply after a step result.
      See Also:
    • METADATA_KEY_STEP_NAME

      public static final String METADATA_KEY_STEP_NAME
      Metadata key storing the workflow step name.
      See Also:
    • METADATA_KEY_WORKFLOW_STATUS

      public static final String METADATA_KEY_WORKFLOW_STATUS
      Metadata key storing the workflow lifecycle status value.
      See Also:
    • METADATA_KEY_WORKFLOW_DEFINITION_NAME

      public static final String METADATA_KEY_WORKFLOW_DEFINITION_NAME
      Metadata key storing the workflow definition name.
      See Also:
    • METADATA_KEY_WORKFLOW_DEFINITION_VERSION

      public static final String METADATA_KEY_WORKFLOW_DEFINITION_VERSION
      Metadata key storing the workflow definition version.
      See Also:
    • METADATA_KEY_VERSION_CHANGE_ID

      public static final String METADATA_KEY_VERSION_CHANGE_ID
      Metadata key storing the identifier of a recorded workflow version change.
      See Also:
    • METADATA_KEY_VERSION

      public static final String METADATA_KEY_VERSION
      Metadata key storing the workflow version associated with a version marker event.
      See Also:
    • STEP_PRIMITIVE_WAIT_FOR_EVENT

      public static final String STEP_PRIMITIVE_WAIT_FOR_EVENT
      Marker value identifying a step as a wait-for-event primitive.
      See Also:
    • STEP_PRIMITIVE_PUBLISH

      public static final String STEP_PRIMITIVE_PUBLISH
      Marker value identifying a step as a publish primitive: a business event that is also the completed step.
      See Also:
  • Method Details

    • create

      public static Metadata create(String workflowId)
      Creates a new metadata instance with the given workflow id.
      Parameters:
      workflowId - the workflow id
      Returns:
      metadata instance
    • create

      public static Metadata create(String workflowId, String stepName, StepStatus stepStatus)
      Creates a new metadata instance with the given workflow id and step name.
      Parameters:
      workflowId - the workflow id
      stepName - the step name
      stepStatus - the step status
      Returns:
      metadata instance
    • create

      public static Metadata create(String workflowId, WorkflowStatus workflowStatus)
      Creates a new metadata instance with the given workflow id and workflow status.
      Parameters:
      workflowId - the workflow id
      workflowStatus - the workflow status
      Returns:
      metadata instance
    • create

      public static Metadata create(String workflowId, WorkflowStatus workflowStatus, VersionedType workflowDefinitionId)
      Creates a new metadata instance with the given workflow id, workflow status, and workflow definition id.
      Parameters:
      workflowId - the workflow id
      workflowStatus - the workflow status
      workflowDefinitionId - the workflow definition identifier
      Returns:
      metadata instance
    • createVersionMigrationStep

      public static Metadata createVersionMigrationStep(String workflowId, String changeId, String version)
      Metadata for a version-marker event: a COMPLETED step event with stepName = changeId plus marker keys (versionChangeId, version) whose presence flags this as a version marker.
      Parameters:
      workflowId - the workflow id
      changeId - the change id
      version - the version
      Returns:
      metadata instance
    • markWaitForEventStep

      public static Metadata markWaitForEventStep(Metadata metadata)
      Marks the given metadata as a step that is waiting for an event.
      Parameters:
      metadata - metadata to mark
      Returns:
      enriched metadata
    • getWorkflowStatus

      public static Optional<WorkflowStatus> getWorkflowStatus(Metadata metadata)
      Returns the workflow status if present in the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      optional of workflow status
    • getStepStatus

      public static Optional<StepStatus> getStepStatus(Metadata metadata)
      Returns the step status if present in the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      optional of step status
    • getVersionChangeId

      public static Optional<String> getVersionChangeId(Metadata metadata)
      Returns the version change id if present in the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      optional of version change id
    • getVersion

      public static Optional<String> getVersion(Metadata metadata)
      Returns the version if present in the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      optional of version of the workflow
    • withWorkflowDefinitionId

      public static Metadata withWorkflowDefinitionId(Metadata metadata, VersionedType workflowDefinitionId)
      Enriches metadata with the workflow definition id.
      Parameters:
      metadata - metadata to enrich
      workflowDefinitionId - workflow definition id to store
      Returns:
      enriched metadata
    • getWorkflowDefinitionId

      public static Optional<VersionedType> getWorkflowDefinitionId(Metadata metadata)
      Returns the workflow definition id if present in the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      optional workflow definition id
    • isVersionMigrationStep

      public static boolean isVersionMigrationStep(Metadata metadata)
      Returns whether the given metadata carries a version marker.
      Returns:
      true if the metadata carries a versionChangeId key — i.e. it's a version marker.
    • payloadReducer

      public static Optional<String> payloadReducer(Metadata metadata)
      Returns the payload reducer if present in the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      optional of payload reducer
    • getWorkflowId

      public static String getWorkflowId(Metadata metadata)
      Returns the workflow id from the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      workflow id
    • getStepName

      public static String getStepName(Metadata metadata)
      Returns the step name from the metadata.
      Parameters:
      metadata - metadata to inspect
      Returns:
      step name
    • isWaitForEventStep

      public static boolean isWaitForEventStep(Metadata metadata)
      Returns whether the given metadata carries a step that is waiting for an event.
      Parameters:
      metadata - metadata to inspect
      Returns:
      true iff the metadata carries a stepPrimitive key with value WAIT_FOR_EVENT.
    • workflowIdFilter

      public static Predicate<Metadata> workflowIdFilter(String workflowId)
      Returns a predicate that matches metadata with the given workflow id.
      Parameters:
      workflowId - workflow id to match
      Returns:
      predicate on metadata
    • hasWorkflowId

      public static Predicate<Metadata> hasWorkflowId()
      Predicate that matches metadata that contain a workflow id.
      Returns:
      predicate on metadata
    • isPublishStep

      public static boolean isPublishStep(Metadata metadata)
      Checks whether the metadata marks a publish step.
      Parameters:
      metadata - metadata to inspect
      Returns:
      true iff the metadata carries a stepPrimitive key with value PUBLISH