Class WorkflowHelper

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

Helper to get information on the workflow structures
  • Field Details

  • Constructor Details

  • Method Details

    • service

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

      public void contextualize(Context context) throws ContextException
      Specified by:
      contextualize in interface Contextualizable
      Throws:
      ContextException
    • getWorkflowNames

      Get a list of workflow names available
      Returns:
      String[] an array of workflow names.
    • getWorkflowDescriptor

      public com.opensymphony.workflow.loader.WorkflowDescriptor getWorkflowDescriptor(String workflowName)
      Returns a workflow definition object associated with the given name.
      Parameters:
      workflowName - the name of the workflow
      Returns:
      the object graph that represents a workflow definition
    • getAllActions

      public Set<Integer> getAllActions(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDesc)
      Retrieves all actions of the workflow of a particular type of workflow except initial actions.
      Parameters:
      workflowDesc - the workflow descriptor.
      Returns:
      all actions ids.
      Throws:
      IllegalArgumentException - If the workflow name is not valid.
    • getActionName

      public String getActionName(String workflowName, int actionID)
      Retrieves the name of an action.
      Parameters:
      workflowName - The name of the workflow.
      actionID - The id of the action.
      Returns:
      The name of the action or an empty string.
    • getStepName

      public String getStepName(String workflowName, int stepId)
      Retrieves the name of a step.
      Parameters:
      workflowName - the name of the workflow.
      stepId - the id of the step.
      Returns:
      the name of the step or an empty string.
    • getInitialAction

      public int getInitialAction(String workflowName)
      Retrieves the initial action id of a workflow.
      Parameters:
      workflowName - the name of the workflow.
      Returns:
      the first initial action id or -1 if the workflow does not exist.
    • getStepAt

      public List<com.opensymphony.workflow.spi.Step> getStepAt(com.opensymphony.workflow.Workflow workflow, long entryId, Date timestamp) throws com.opensymphony.workflow.WorkflowException
      Get the steps the workflow was "in" at a given date.
      Parameters:
      workflow - workflow
      entryId - the workflow entry ID.
      timestamp - the date.
      Returns:
      the list of steps the workflow was in.
      Throws:
      com.opensymphony.workflow.WorkflowException - if an error occurs.
    • getStepsBetween

      public List<com.opensymphony.workflow.spi.Step> getStepsBetween(com.opensymphony.workflow.Workflow workflow, long entryId, Date start, Date end) throws com.opensymphony.workflow.WorkflowException
      Get the steps the workflow was "in" between two dates.
      Parameters:
      workflow - workflow
      entryId - the workflow entry ID.
      start - the start date.
      end - the end date.
      Returns:
      the list of steps the workflow was in between the two dates.
      Throws:
      com.opensymphony.workflow.WorkflowException - if an error occurs.
    • getWorkflowLabel

      public I18nizableText getWorkflowLabel(String workflowName)
      Get the workflow label.
      Parameters:
      workflowName - The name of the workflow
      Returns:
      The label of the workflow with an i18n format.
    • getWorkflowCatalog

      public String getWorkflowCatalog(String workflowName)
      Get the catalog of the workflow.
      Parameters:
      workflowName - The name of the workflow
      Returns:
      The i18n catalog
    • getStepDescriptor

      public com.opensymphony.workflow.loader.StepDescriptor getStepDescriptor(WorkflowAwareAmetysObject ametysObject, int stepId)
      Get the step descriptor from WorkflowAwareAmetysObject
      Parameters:
      ametysObject - the targeted ametysObject
      stepId - the id of the step
      Returns:
      the step descriptor or null if an error occurred
    • workflowStep2JSON

      public Map<String,Object> workflowStep2JSON(com.opensymphony.workflow.loader.StepDescriptor step)
      Serialize a step descriptor to JSON
      Parameters:
      step - the step descriptor
      Returns:
      a JSON map including the stepId, name and icons of the step
    • getElementIconAsBase64

      public String getElementIconAsBase64(I18nizableText workflowElementName, String defaultPath)
      Return a valid encoded path from i18n key of workflow element, or a default path if URI can't be resolved
      Parameters:
      workflowElementName - i18nKey of the workflowlabel, is used in the path of associated icon
      defaultPath - path to default icon if uri can't be resolved
      Returns:
      the path to element icon
    • _resolveImageAsBase64

      Encode input stream in base64
      Parameters:
      path - the path to the icon
      Returns:
      the encoded path
    • getElementIconPath

      public String getElementIconPath(I18nizableText workflowElementName, String defaultPath)
      Return a valid path from i18n key of workflow element, or a default path if URI can't be resolved
      Parameters:
      workflowElementName - i18nKey of the workflowlabel, is used in the path of associated icon
      defaultPath - path to default icon if uri can't be resolved
      Returns:
      the resolved path to element icon
    • getElementIconURI

      public String getElementIconURI(I18nizableText workflowElementName)
      Get URI for an element icon
      Parameters:
      workflowElementName - the name of the icon
      Returns:
      the URI
    • getElementIconURI

      public String getElementIconURI(I18nizableText workflowElementName, String size)
      Get URI for an element icon
      Parameters:
      workflowElementName - the name of the icon
      size - the wanted size for the icon
      Returns:
      the URI
    • _imageURIExists

      protected boolean _imageURIExists(String path)
      Return if an image exist
      Parameters:
      path - path to the image
      Returns:
      true if image is found
    • getParamWorkflowDir

      Get the param workflows directory.
      Returns:
      the workflows directory in WEB-INF/param.