Class DefaultWorkflowService<P extends Workflow>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.workflow.service.DefaultWorkflowService<P>
Type Parameters:
P - The possibly extended type of Workflow
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, WorkflowService<P>

public class DefaultWorkflowService<P extends Workflow> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements WorkflowService<P>
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultWorkflowService(WorkflowRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.orchestration.spring.SimpleWorkflowFactory factory, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender sender, WorkflowRunner workflowRunner, SideEffectRepository<com.broadleafcommerce.data.tracking.core.Trackable> sideEffectRepository, com.broadleafcommerce.orchestration.internal.LogHandler logHandler)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    appendLogs(String id, com.broadleafcommerce.orchestration.client.History history)
     
    void
    cancel(String id, boolean fail, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Cancel a PROCESSING or QUEUED workflow.
    protected com.broadleafcommerce.orchestration.client.History
    compressHistory(com.broadleafcommerce.orchestration.client.History history)
     
    protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>
     
    void
    goToStep(String id, String stepName, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Transition activity execution to a targeted step (backward or forward).
    void
    pause(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Pause a PROCESSING workflow.
    org.springframework.data.domain.Page<P>
    readAll(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Retrieve all matching the RSQL filters.
    org.springframework.data.domain.Page<P>
    readAllByDescription(String description, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Retrieve all matching the RSQL filters, with an option to explicitly filter on the Workflow's description.
    readByReference(String reference, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Find a workflow by its reference value.
    com.broadleafcommerce.orchestration.client.History
    readHistoryElements(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Find the step-by-step history of execution (including timing and result status) for a workflow.
    com.broadleafcommerce.orchestration.client.SimpleOrchestrationMap
    readOrchestrationMap(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Find the ordered list of information items related to the SimpleActivity members of the current workflow.
    void
    resume(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Resume a PAUSED workflow.
    void
    setParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
     
    start(String workflowName, String reference, Map<String,String> workflowContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Start a new workflow execution
    update(String id, Map<String,String> workflowContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Update the Workflow.setContextValues(Set) information only.

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService

    getRsqlHelper, readAll, readAll, readAll

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService

    convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

    create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll
  • Constructor Details

    • DefaultWorkflowService

      public DefaultWorkflowService(WorkflowRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.orchestration.spring.SimpleWorkflowFactory factory, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.common.messaging.notification.DetachedDurableMessageSender sender, WorkflowRunner workflowRunner, SideEffectRepository<com.broadleafcommerce.data.tracking.core.Trackable> sideEffectRepository, com.broadleafcommerce.orchestration.internal.LogHandler logHandler)
  • Method Details

    • start

      public P start(String workflowName, @Nullable String reference, Map<String,String> workflowContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Start a new workflow execution
      Specified by:
      start in interface WorkflowService<P extends Workflow>
      Parameters:
      workflowName - The name of the workflow. Must match a bean name for a SimpleWorkflow prototype bean.
      reference - Optional. A reference value to which this workflow is correlated. The system will not start more than one workflow for a given reference value. The value must be less than or equal to 36 chars in length.
      workflowContext - The key/value pair information to pass to the workflow execution. Can be used by activities to inform logic execution.
      contextInfo - The data tracking context information.
      Returns:
      The persisted state of the workflow, queued for execution.
    • update

      public P update(String id, @Nullable Map<String,String> workflowContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Update the Workflow.setContextValues(Set) information only.
      Specified by:
      update in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      workflowContext - he key/value pair information to pass to the workflow execution.
      contextInfo - The data tracking context information.
      Returns:
      The persisted state of the workflow
    • cancel

      public void cancel(String id, boolean fail, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Cancel a PROCESSING or QUEUED workflow. Cancel will occur upon completion of the current activity. Wait activities will short circuit with an interrupt. SimpleActivity implementations may also short circuit (if applicable) by overriding InterruptAware.interrupt().
      Specified by:
      cancel in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      fail - Whether the cancellation should result in a FAIL status (false results in COMPLETED status)
      contextInfo - The data tracking context information
    • pause

      public void pause(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Pause a PROCESSING workflow. Paused workflows may be resumed at the point where they left off. Pause will occur upon completion of the current activity. Wait activities will short circuit with an interrupt. SimpleActivity implementations may also short circuit (if applicable) by overriding InterruptAware.interrupt().
      Specified by:
      pause in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      contextInfo - The data tracking context information
    • resume

      public void resume(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Resume a PAUSED workflow.
      Specified by:
      resume in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      contextInfo - The data tracking context information
    • goToStep

      @Transactional(transactionManager="workflowTransactionManager") public void goToStep(String id, String stepName, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Transition activity execution to a targeted step (backward or forward). Execution will transition upon completion of the current activity. Wait activities will short circuit with an interrupt. SimpleActivity implementations may also short circuit (if applicable) by overriding InterruptAware.interrupt().
      Specified by:
      goToStep in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      stepName - The name of the activity to transition to. See SimpleActivity.getName(). The name must match the bean name of the SimpleActivity singleton bean in Spring.
      contextInfo - The data tracking context information.
    • readHistoryElements

      public com.broadleafcommerce.orchestration.client.History readHistoryElements(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Find the step-by-step history of execution (including timing and result status) for a workflow.
      Specified by:
      readHistoryElements in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      contextInfo - The data tracking context information
      Returns:
      The step-by-step history of execution
    • readOrchestrationMap

      public com.broadleafcommerce.orchestration.client.SimpleOrchestrationMap readOrchestrationMap(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Find the ordered list of information items related to the SimpleActivity members of the current workflow. This information can be used to drive a visual representation of past and future execution based on a pipeline of available activities. The metadata also indicates what options are available for each step based on configuration and current state.
      Specified by:
      readOrchestrationMap in interface WorkflowService<P extends Workflow>
      Parameters:
      id - The primary key
      contextInfo - The data tracking context information
      Returns:
      The ordered list of information items
    • readAll

      public org.springframework.data.domain.Page<P> readAll(@Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: WorkflowService
      Retrieve all matching the RSQL filters.
      Specified by:
      readAll in interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P extends Workflow>
      Specified by:
      readAll in interface WorkflowService<P extends Workflow>
      Overrides:
      readAll in class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P extends Workflow>
      Parameters:
      filters - RSQL filters. Special support here for the JpaWorkflow.getContextValues() collection. A special selector (`contextValue`) may be used to find workflows with specific value matches for context params. For example, status=='PROCESSING';contextValue=='jeff' would find all processing workflows with an exact context value match for the name jeff. See RSQL spec for different operators supported.
      pageable - Paging configuration
      context - Data tracking context information
      Returns:
      A page of matching data
    • readAllByDescription

      public org.springframework.data.domain.Page<P> readAllByDescription(@Nullable String description, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: WorkflowService
      Retrieve all matching the RSQL filters, with an option to explicitly filter on the Workflow's description.
      Specified by:
      readAllByDescription in interface WorkflowService<P extends Workflow>
      Parameters:
      description - the text query to filter on against the Workflow's description
      filters - RSQL filters. Special support here for the JpaWorkflow.getContextValues() collection. A special selector (`contextValue`) may be used to find workflows with specific value matches for context params. For example, status=='PROCESSING';contextValue=='jeff' would find all processing workflows with an exact context value match for the name jeff. See RSQL spec for different operators supported.
      page - Paging configuration
      context - Data tracking context information
      Returns:
      A page of matching data for the Workflow description provided
    • readByReference

      public P readByReference(String reference, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: WorkflowService
      Find a workflow by its reference value.
      Specified by:
      readByReference in interface WorkflowService<P extends Workflow>
      Parameters:
      reference - The reference value
      contextInfo - The data tracking context information
      Returns:
      The workflow, if available
    • appendLogs

      protected void appendLogs(String id, com.broadleafcommerce.orchestration.client.History history)
    • compressHistory

      protected com.broadleafcommerce.orchestration.client.History compressHistory(com.broadleafcommerce.orchestration.client.History history)
    • getParser

      protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> getParser()
    • setParser

      @Autowired public void setParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)