Class WorkflowStepDAO

java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.workflow.dao.WorkflowStepDAO
All Implemented Interfaces:
LogEnabled, Component, Serviceable

public class WorkflowStepDAO extends AbstractLogEnabled implements Component, Serviceable
DAO for workflow steps
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager smanager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • hasSteps

      public boolean hasSteps(String workflowName)
      Verify that current workflow has steps
      Parameters:
      workflowName - the workflow's unique name
      Returns:
      true if worflow has steps
    • getStepInfos

      public Map<String,Object> getStepInfos(String workflowName, Integer stepId)
      Get the step editable infos
      Parameters:
      workflowName - current workflow's id
      stepId - current step's id
      Returns:
      a map of step infos and non-available ids
    • createStep

      public Map<String,Object> createStep(String workflowName, Integer stepId, Map<String,String> labels)
      Create a new step and add it to current workflow
      Parameters:
      workflowName - current workflow's id
      stepId - the new step id
      labels - the new step labels
      Returns:
      map of the step infos
    • editStepLabel

      public Map<String,Object> editStepLabel(String workflowName, Integer stepId, String newMainLabel)
      Edit the step label
      Parameters:
      workflowName - current workflow's id
      stepId - the step's id
      newMainLabel - the new label in the current application's language
      Returns:
      map of the step infos if edit worked, contain error message else
    • editStep

      public Map<String,Object> editStep(String workflowName, Integer oldId, Integer id, Map<String,String> labels)
      Edit the step
      Parameters:
      workflowName - current workflow's id
      oldId - the step's last id
      id - the step's new id
      labels - the new step labels
      Returns:
      map of the step infos if edit worked, contain error message else
    • deleteStep

      public Map<String,Object> deleteStep(String workflowName, Integer stepId)
      Delete the step from workflow
      Parameters:
      workflowName - current workflow's id
      stepId - current step's id
      Returns:
      an error message if deleting couldn't proceed
    • getStepLabel

      public I18nizableText getStepLabel(com.opensymphony.workflow.loader.StepDescriptor stepDescriptor)
      Get the step label as new I18nizableText
      Parameters:
      stepDescriptor - the current step
      Returns:
      the step label
    • getStepNodes

      public Map<String,Object> getStepNodes(String currentNode, String workflowName)
      Get the workflow editor tree's nodes
      Parameters:
      currentNode - id of the current node
      workflowName - unique name of current workflow
      Returns:
      a map of the current node's children
    • _action2JSON

      protected Map<String,Object> _action2JSON(String stepId, com.opensymphony.workflow.loader.ActionDescriptor action, com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, boolean canWrite)
      Get the action infos for tree panel node
      Parameters:
      stepId - id of current step node
      action - currently processed action
      workflowDescriptor - current workflow
      canWrite - true if current user has edition right on current workflow
      Returns:
      map of the action infos
    • _getActionFinalSteps

      protected Set<org.ametys.plugins.workflow.dao.WorkflowStepDAO.StepWithIcon> _getActionFinalSteps(com.opensymphony.workflow.loader.ActionDescriptor action, com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor)
      Get the conditional and unconditional results of current action
      Parameters:
      action - the current action
      workflowDescriptor - the current workflow
      Returns:
      a list of the final steps as (stepId, stepLabel, StepIconPath)
    • getOutgoingSteps

      public Set<com.opensymphony.workflow.loader.StepDescriptor> getOutgoingSteps(com.opensymphony.workflow.loader.ActionDescriptor action, com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor)
      Get possible outgoing steps for action
      Parameters:
      action - the current action
      workflowDescriptor - the current workflow
      Returns:
      a set of the outgoing steps
    • getIncomingSteps

      public Set<com.opensymphony.workflow.loader.StepDescriptor> getIncomingSteps(int actionId, com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor)
      Get possible incoming steps for action
      Parameters:
      actionId - the current action's id
      workflowDescriptor - the current workflow
      Returns:
      a set of the action's incoming steps
    • getFinalSteps

      public Map<String,Object> getFinalSteps(String currentNode, String workflowName, Integer actionId)
      Get current action's final steps and associated conditions
      Parameters:
      currentNode - id of current node
      workflowName - unique name of current workflow
      actionId - id of current action
      Returns:
      a map of current node's children
    • _step2JSON

      protected Map<String,Object> _step2JSON(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, int stepId, boolean hasChildren, boolean showId, boolean canWrite)
      Get step infos
      Parameters:
      workflowDescriptor - current workflow
      stepId - id of current step
      hasChildren - true if step has actions
      showId - true if id needs to be displayed in the label
      canWrite - true if current user has edition right on current workflow
      Returns:
      a map of the step infos
    • getStatesToJson

      public Map<String,Object> getStatesToJson(String workflowName, Integer actionId, Boolean isInitialState)
      Get the workflow's steps available as unconditional result for actions
      Parameters:
      workflowName - the current workflow name
      actionId - id of current action if exist, can be null
      isInitialState - true if current selected state is the initial state
      Returns:
      a map of the workflow steps
    • getStepLabelAsString

      public String getStepLabelAsString(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, int stepId, boolean showId)
      Get the translated step label
      Parameters:
      workflowDescriptor - current workflow
      stepId - id of current step
      showId - true if id needs to be displayed in the label
      Returns:
      the step label as string
    • getStepIconPath

      public String getStepIconPath(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, int stepId)
      Get the step's icon path
      Parameters:
      workflowDescriptor - current worklfow
      stepId - id of current step
      Returns:
      the icon path
    • getStepIconPathAsBase64

      public String getStepIconPathAsBase64(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, int stepId)
      Get the step's icon path as base 64 for svg links
      Parameters:
      workflowDescriptor - current worklfow
      stepId - id of current step
      Returns:
      the icon path as base 64
    • getStepLabel

      public I18nizableText getStepLabel(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor, int stepId)
      Get the step i18n label
      Parameters:
      workflowDescriptor - current workflow
      stepId - id of current step
      Returns:
      the i18n step label
    • getOutgoingActions

      public List<com.opensymphony.workflow.loader.ActionDescriptor> getOutgoingActions(int stepId, com.opensymphony.workflow.loader.WorkflowDescriptor workflow)
      Get a list of actions outgoing from current step
      Parameters:
      stepId - id of current step
      workflow - current workflow
      Returns:
      the list of outgoing actions
    • getIncomingActions

      public Set<com.opensymphony.workflow.loader.ActionDescriptor> getIncomingActions(int stepId, com.opensymphony.workflow.loader.WorkflowDescriptor workflow)
      Get a set of actions incoming to current step
      Parameters:
      stepId - id of current step
      workflow - current workflow
      Returns:
      the set of outgoing actions
    • _getIncomingActionsFromList

      protected Set<com.opensymphony.workflow.loader.ActionDescriptor> _getIncomingActionsFromList(int stepId, List<com.opensymphony.workflow.loader.ActionDescriptor> actions)
      Get a set of incoming actions if present in actions list
      Parameters:
      stepId - id of current step
      actions - list of other step's actions
      Returns:
      a list containing other step's outgoing actions that are incoming to current step
    • getFirstParentStepId

      public String getFirstParentStepId(int stepId, List<com.opensymphony.workflow.loader.StepDescriptor> steps, Integer actionId)
      Get id of the first step having current action, INITIAL_STEP_ID if current action is an initial action
      Parameters:
      stepId - id of current step
      steps - list of all the steps in current workflow
      actionId - id of current action
      Returns:
      the id of the first found step having current action