Class WorkflowHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.workflow.support.WorkflowHelper
- All Implemented Interfaces:
LogEnabled,Component,Contextualizable,Serviceable
public class WorkflowHelper
extends AbstractLogEnabled
implements Component, Serviceable, Contextualizable
Helper to get information on the workflow structures
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ContextThe contextprotected SourceResolverThe source resolverprotected WorkflowProviderThe content types extension pointstatic final StringThe Avalon role -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_imageURIExist(String path) Return if an image existprotected String_resolveImageAsBase64(String path) Encode input stream in base64voidcontextualize(Context context) getActionName(String workflowName, int actionID) Retrieves the name of an action.int[]getAllActions(String workflowName) Retrieves all actions of the workflow of a particular type of workflow except initial actions.int[]getAllActionsFromStep(String workflowName, int stepId) Retrieves the action ids from a particular step.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 resolvedgetElementIconPath(I18nizableText workflowElementName, String defaultPath) Return a valid path from i18n key of workflow element, or a default path if URI can't be resolvedintgetInitialAction(String workflowName) Retrieves the initial action id of a workflow.List<com.opensymphony.workflow.spi.Step>Get the steps the workflow was "in" at a given date.com.opensymphony.workflow.loader.StepDescriptorgetStepDescriptor(WorkflowAwareAmetysObject ametysObject, int stepId) Get the step descriptor fromWorkflowAwareAmetysObjectgetStepName(String workflowName, int stepId) Retrieves the name of a step.List<com.opensymphony.workflow.spi.Step>getStepsBetween(com.opensymphony.workflow.Workflow workflow, long entryId, Date start, Date end) Get the steps the workflow was "in" between two dates.com.opensymphony.workflow.loader.WorkflowDescriptorgetWorkflowDescriptor(String workflowName) Returns a workflow definition object associated with the given name.getWorkflowLabel(String workflowName) Get the workflow label.String[]Get a list of workflow names availablevoidservice(ServiceManager smanager) workflowStep2JSON(com.opensymphony.workflow.loader.StepDescriptor step) Serialize a step descriptor to JSONMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
_workflowProvider
The content types extension point -
_sourceResolver
The source resolver -
_context
The context
-
-
Constructor Details
-
WorkflowHelper
public WorkflowHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
- Specified by:
contextualizein interfaceContextualizable- 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
Retrieves all actions of the workflow of a particular type of workflow except initial actions.- Parameters:
workflowName- the name of the workflow.- Returns:
- all actions ids.
- Throws:
IllegalArgumentException- If the workflow name is not valid.
-
getActionName
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
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
Retrieves the initial action id of a workflow.- Parameters:
workflowName- the name of the workflow.- Returns:
- the first initial action id or
-1if the workflow does not exist.
-
getAllActionsFromStep
Retrieves the action ids from a particular step.- Parameters:
workflowName- the name of the workflow.stepId- the id of the step.- Returns:
- the ids of the actions of the step.
-
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- workflowentryId- 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- workflowentryId- 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
Get the workflow label.- Parameters:
workflowName- The name of the workflow- Returns:
- The label of the workflow with an i18n format.
-
getStepDescriptor
public com.opensymphony.workflow.loader.StepDescriptor getStepDescriptor(WorkflowAwareAmetysObject ametysObject, int stepId) Get the step descriptor fromWorkflowAwareAmetysObject- Parameters:
ametysObject- the targeted ametysObjectstepId- the id of the step- Returns:
- the step descriptor or null if an error occurred
-
workflowStep2JSON
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
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 icondefaultPath- 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
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 icondefaultPath- path to default icon if uri can't be resolved- Returns:
- the path to element icon
-
_imageURIExist
Return if an image exist- Parameters:
path- path to the image- Returns:
- true if image is found
-