Class WorkflowSessionHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.workflow.support.WorkflowSessionHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class WorkflowSessionHelper
extends AbstractLogEnabled
implements Component, Serviceable, Contextualizable
Helper for workflow in session
-
Field Summary
Modifier and TypeFieldDescriptionprotected Context
The contextprotected I18nHelper
The helper for i18n translations and catalogsprotected I18nUtils
I18n Utilsprotected SourceResolver
The source resolverprotected WorkflowHelper
The workflow helperprotected WorkflowLanguageManager
The workflow language managerstatic final String
The Avalon role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cloneImages
(String workflowName) Clone kernel workflow images into WEB-INF/workflow_resources with new labels as namesvoid
contextualize
(Context context) void
deleteSession
(String workflowName) Remove workflow from sessioncom.opensymphony.workflow.loader.WorkflowDescriptor
Duplicate a workflowgetOldLabelKeyIfCloned
(String workflowName, I18nizableText label) Get the original label key used for this element if the workflow is a clonegetTranslation
(String workflowName, I18nizableText i18nKey) Get the translation for this key, null if it doesn't existgetTranslations
(String workflowName) Get translations map for current workflowcom.opensymphony.workflow.loader.WorkflowDescriptor
getWorkflowDescriptor
(String workflowName, boolean initSessionIfNull) Get workflow descriptor from session if exist, from xml if notgetWorkflowLabel
(String workflowName) Get the label for current workflowgetWorkflowLabelTranslations
(String workflowName) Get the translations for current workflow namesGet the list of workflow names in useboolean
hasChanges
(String workflowName) True if the workflow has non saved changesvoid
removeTranslation
(String workflowName, I18nizableText key) Remove an entry from the translations mapvoid
service
(ServiceManager smanager) void
updateTranslations
(String workflowName, I18nizableText labelKey, Map<String, String> translations) Update the translations mapvoid
updateWorkflowDescriptor
(com.opensymphony.workflow.loader.WorkflowDescriptor workflow) Update session cache with workflow descriptor changesvoid
updateWorkflowNames
(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor) Update the session workflow names list with current workflow nameMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
_workflowLanguageManager
The workflow language manager -
_context
The context -
_i18nUtils
I18n Utils -
_workflowHelper
The workflow helper -
_i18nHelper
The helper for i18n translations and catalogs -
_sourceResolver
The source resolver
-
-
Constructor Details
-
WorkflowSessionHelper
public WorkflowSessionHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
hasChanges
True if the workflow has non saved changes- Parameters:
workflowName
- unique name of workflow- Returns:
true
if there is a session for this workflow
-
getWorkflowLabel
Get the label for current workflow- Parameters:
workflowName
- the workflow's unique name- Returns:
- the label as String or i18nizableText
-
getWorkflowLabelTranslations
Get the translations for current workflow names- Parameters:
workflowName
- the workflow's unique name- Returns:
- a map with available transitions, key is language, value is translation
-
getTranslations
Get translations map for current workflow- Parameters:
workflowName
- the current workflow's id- Returns:
- the map of traslations, key is i18n key, value is map of language, translation
-
getTranslation
Get the translation for this key, null if it doesn't exist- Parameters:
workflowName
- the worflow's unique idi18nKey
- the key to get translation for- Returns:
- the multilangual translation
-
updateTranslations
public void updateTranslations(String workflowName, I18nizableText labelKey, Map<String, String> translations) Update the translations map- Parameters:
workflowName
- the workflow's unique namelabelKey
- i18n keytranslations
- the map of translations (language, translation) to put in the map
-
removeTranslation
Remove an entry from the translations map- Parameters:
workflowName
- the workflow's unique namekey
- the key of the entry to remove
-
getWorkflowNames
Get the list of workflow names in use- Returns:
- a set of the names
-
updateWorkflowNames
public void updateWorkflowNames(com.opensymphony.workflow.loader.WorkflowDescriptor workflowDescriptor) Update the session workflow names list with current workflow name- Parameters:
workflowDescriptor
- the current workflow descriptor
-
getWorkflowDescriptor
public com.opensymphony.workflow.loader.WorkflowDescriptor getWorkflowDescriptor(String workflowName, boolean initSessionIfNull) Get workflow descriptor from session if exist, from xml if not- Parameters:
workflowName
- the current workflow's idinitSessionIfNull
-true
to create a new WorkflowToSave if session doesn't have it- Returns:
- the workflow
-
updateWorkflowDescriptor
Update session cache with workflow descriptor changes- Parameters:
workflow
- the workflow to update
-
duplicateWorkflow
public com.opensymphony.workflow.loader.WorkflowDescriptor duplicateWorkflow(String newWorkflowName, Map<String, String> labels, String workflowToCloneName) Duplicate a workflow- Parameters:
newWorkflowName
- the unique name for the duplicatelabels
- the duplicate's labelsworkflowToCloneName
- the duplicated workflow's name- Returns:
- the duplicate
-
deleteSession
Remove workflow from session- Parameters:
workflowName
- unique name of the workflow
-
cloneImages
Clone kernel workflow images into WEB-INF/workflow_resources with new labels as names- Parameters:
workflowName
- the current workflow name
-
getOldLabelKeyIfCloned
Get the original label key used for this element if the workflow is a clone- Parameters:
workflowName
- the current workflow namelabel
- the current label key of the workflow element- Returns:
- the original label if exist, the same label if not
-