Package org.ametys.plugins.bpm
Class BPMWorkflowManager
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.bpm.BPMWorkflowManager
-
- All Implemented Interfaces:
LogEnabled,PluginAware,Initializable,Component,Contextualizable,Serviceable
public class BPMWorkflowManager extends AbstractLogEnabled implements Component, Serviceable, Initializable, Contextualizable, PluginAware
Manager for retrieving, creation, edition and suppression of workflows, and retrieving information on workflows definitions
-
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BPMWorkflowManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private UserIdentity_convertJsonToUser(Map<String,Object> user)protected ModifiableTraversableAmetysObject_getProcessesRootNode(JCRWorkflow workflow, boolean create)Gets the root of processes of a workflowprotected Map<String,Object>_getWorkflowDefinitionData(String workflowDefId)Get the list of variables and their properties for a workflow definitionprivate Map<? extends String,? extends Map<String,Object>>_getWorkflowDefinitionRegisters(Configuration[] registers)protected ModifiableTraversableAmetysObject_getWorkflowsRootNode(boolean create)Gets the root of contentsprivate List<Map<String,Object>>_groups2Json(GroupIdentity[] groups)private Map<String,Object>_processToJson(JCRWorkflowProcess process)private void_setProcessValues(JCRWorkflowProcess process, String title, String site, String description, List<PartOnDisk> uploadedAttachments)private void_setWorkflowValues(JCRWorkflow workflow, Map<String,Object> values)private Map<String,Object>_workflowToJson(JCRWorkflow workflow, Map<String,Object> workflowDefinitionData)Map<String,Object>addWorkflow(Map<String,Object> values)Add a new workflowbooleancanDelete(JCRWorkflowProcess process)Determines if the process can be deleted by the current uservoidcontextualize(Context context)JCRWorkflowProcesscreateProcess(String workflowId, String title, String site, String description, List<PartOnDisk> uploadedAttachments)Create a new processvoiddeleteProcess(JCRWorkflowProcess process)Delete a processMap<String,Object>deleteProcesses(List<String> processes)Delete a list of processesMap<String,Object>deleteWorkflow(List<String> workflowIds)Delete a list of workflowvoideditProcess(String processId, String title, String description, List<PartOnDisk> uploadedAttachments, List<String> attachmentsUntouched)Edit a processMap<String,Object>editWorkflow(String workflowId, Map<String,Object> values)Edit a workflow valuesPagegetCreateProcessPage(String siteName, String lang)Get the page with CREATE_PROCESS tagPagegetDashboardPage(String siteName, String lang)Get the page with PROCESS_DASHBOARD tagJCRWorkflowProcessgetProcess(String workflowName, String processName)Retrieve a processStringgetProcessPageUrl(JCRWorkflowProcess process, String siteName, String lang, boolean absolute)Get the url of a process pageStringgetTemplateForProcessPage(String siteName, String lang)Get the template to use for process renderingSet<JCRWorkflowProcess>getUserProcesses()Get the list of processes accessibles to the current userMap<String,Object>getWorkflowData(String workflowId)Retrieve the data of a workflow, in JSON format.Map<String,Object>getWorkflowDefinitions()Get the list of workflow definitionsMap<String,Object>getWorkflowDefinitionVariables(String workflowDefId)Retrieve the list of variables from a workflow definitionMap<String,Object>getWorkflowProcesses(String workflowId)Retrieve the list of process created from a workflowList<Object>getWorkflowProcessus(JCRWorkflow workflow)Retrieve the list of process created from a workflowMap<String,Object>getWorkflows()Retrieve the list of workflowsList<Map<String,Object>>getWorkflowsAvailables()Retrieve the list of workflows availables to the current user, in JSON formatObjectgetWorkflowVariable(String workflowId, String variableName)Retrieve the value of a variable from a workflowvoidinitialize()booleanisComplete(JCRWorkflowProcess process)Determines if the process is completebooleanisUserAllowedOnWorkflow(JCRWorkflow workflow)Check if the current user is allowed to create a process from the workflowbooleanisUserInWorkflowVariables(JCRWorkflow workflow)Test if the current user is present in any variable of the workflowvoidservice(ServiceManager manager)voidsetPluginInfo(String pluginName, String featureName, String id)Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
RIGHT_WORKFLOW_CREATE
public static final String RIGHT_WORKFLOW_CREATE
Right to create a new workflow- See Also:
- Constant Field Values
-
RIGHT_WORKFLOW_EDIT
public static final String RIGHT_WORKFLOW_EDIT
Right to edit any workflow- See Also:
- Constant Field Values
-
RIGHT_WORKFLOW_DELETE
public static final String RIGHT_WORKFLOW_DELETE
Right to delete any workflow- See Also:
- Constant Field Values
-
RIGHTS_PROCESS_MANAGE_PROCESSES
public static final String RIGHTS_PROCESS_MANAGE_PROCESSES
Right to manage processes- See Also:
- Constant Field Values
-
PAGE_TAG_CREATEPROCESS
public static final String PAGE_TAG_CREATEPROCESS
Tag for the create process page- See Also:
- Constant Field Values
-
PAGE_TAG_PROCESS_DASHBOARD
public static final String PAGE_TAG_PROCESS_DASHBOARD
Tag for the process dashboard page- See Also:
- Constant Field Values
-
WORKFLOW_ACTION_EDIT
public static final int WORKFLOW_ACTION_EDIT
The fixed id for the edit workflow action on processus- See Also:
- Constant Field Values
-
BPM_ROOT_NODE
public static final String BPM_ROOT_NODE
The plugin root node name- See Also:
- Constant Field Values
-
BPMWORKFLOW_ROOT_NODE
public static final String BPMWORKFLOW_ROOT_NODE
The BPM Workflows node name- See Also:
- Constant Field Values
-
BPMPROCESSES_ROOT_NODE
public static final String BPMPROCESSES_ROOT_NODE
The processes node name under each workflow- See Also:
- Constant Field Values
-
_BPM_PROCESS_TEMPLATE
private static final String _BPM_PROCESS_TEMPLATE
- See Also:
- Constant Field Values
-
_resolver
private AmetysObjectResolver _resolver
-
_workflowProvider
private WorkflowProvider _workflowProvider
-
_currentUserProvider
private CurrentUserProvider _currentUserProvider
-
_rightManager
private RightManager _rightManager
-
_jsonUtils
private JSONUtils _jsonUtils
-
_userHelper
private UserHelper _userHelper
-
_addOrUpdateResourceHelper
private AddOrUpdateResourceHelper _addOrUpdateResourceHelper
-
_workflowHelper
private WorkflowHelper _workflowHelper
-
_skinsManager
private SkinsManager _skinsManager
-
_ametysObjectResolver
private AmetysObjectResolver _ametysObjectResolver
-
_siteManager
private SiteManager _siteManager
-
_groupManager
private GroupManager _groupManager
-
_uriPrefixHandler
private URIPrefixHandler _uriPrefixHandler
-
_pluginName
private String _pluginName
-
_i18nUtils
private I18nUtils _i18nUtils
-
-
Constructor Detail
-
BPMWorkflowManager
public BPMWorkflowManager()
-
-
Method Detail
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize() throws Exception
- Specified by:
initializein interfaceInitializable- Throws:
Exception
-
setPluginInfo
public void setPluginInfo(String pluginName, String featureName, String id)
Description copied from interface:PluginAwareSets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level.- Specified by:
setPluginInfoin interfacePluginAware- Parameters:
pluginName- Unique identifier for the plugin hosting the extensionfeatureName- Unique feature identifier (unique for a given pluginName)id- Unique identifier of this component
-
getWorkflowDefinitions
public Map<String,Object> getWorkflowDefinitions()
Get the list of workflow definitions- Returns:
- The list of workflow definitions, mapped by name and label
-
getWorkflowVariable
public Object getWorkflowVariable(String workflowId, String variableName)
Retrieve the value of a variable from a workflow- Parameters:
workflowId- The workflow idvariableName- The variable name- Returns:
- The value
-
getWorkflowDefinitionVariables
public Map<String,Object> getWorkflowDefinitionVariables(String workflowDefId)
Retrieve the list of variables from a workflow definition- Parameters:
workflowDefId- The workflow definition id- Returns:
- The list of variables, with their attributes such as the label, type, multiple, if defined
-
getWorkflows
public Map<String,Object> getWorkflows()
Retrieve the list of workflows- Returns:
- The list of workflows
-
getWorkflowsAvailables
public List<Map<String,Object>> getWorkflowsAvailables()
Retrieve the list of workflows availables to the current user, in JSON format- Returns:
- The list of workflows
-
getWorkflowData
public Map<String,Object> getWorkflowData(String workflowId)
Retrieve the data of a workflow, in JSON format. Contains both the values of the workflow, and the workflow variables definitions- Parameters:
workflowId- The workflow id- Returns:
- The data of a workflow
-
addWorkflow
public Map<String,Object> addWorkflow(Map<String,Object> values) throws IllegalAccessException
Add a new workflow- Parameters:
values- The values for the new workflow. Must contains a "name", "workflowDef" and any variables mandatory for the workflowDef- Returns:
- The result, with the new workflow id if successful
- Throws:
IllegalAccessException- If a user with insufficient rights try to execute this method
-
editWorkflow
public Map<String,Object> editWorkflow(String workflowId, Map<String,Object> values) throws IllegalAccessException
Edit a workflow values- Parameters:
workflowId- The workflowvalues- The values- Returns:
- The result, with the workflow id if successful
- Throws:
IllegalAccessException- If a user with insufficient rights try to execute this method
-
deleteWorkflow
public Map<String,Object> deleteWorkflow(List<String> workflowIds)
Delete a list of workflow- Parameters:
workflowIds- The workflows- Returns:
- The result
-
getWorkflowProcesses
public Map<String,Object> getWorkflowProcesses(String workflowId)
Retrieve the list of process created from a workflow- Parameters:
workflowId- The workflow- Returns:
- The list of process
-
getWorkflowProcessus
public List<Object> getWorkflowProcessus(JCRWorkflow workflow)
Retrieve the list of process created from a workflow- Parameters:
workflow- The workflow- Returns:
- The list of process
-
createProcess
public JCRWorkflowProcess createProcess(String workflowId, String title, String site, String description, List<PartOnDisk> uploadedAttachments) throws com.opensymphony.workflow.WorkflowException, IllegalAccessException
Create a new process- Parameters:
workflowId- The workflow used by the processtitle- The process titlesite- The site on which the process was createddescription- The process descriptionuploadedAttachments- The process attachments- Returns:
- The new process
- Throws:
com.opensymphony.workflow.WorkflowException- If an error occurred creating the workflowIllegalAccessException- If the user is not allowed
-
editProcess
public void editProcess(String processId, String title, String description, List<PartOnDisk> uploadedAttachments, List<String> attachmentsUntouched) throws com.opensymphony.workflow.WorkflowException
Edit a process- Parameters:
processId- The process idtitle- The titledescription- The descriptionuploadedAttachments- The list of new attachments uploadedattachmentsUntouched- The list of untouched attachments names- Throws:
com.opensymphony.workflow.WorkflowException- If an error occurred while executing the workflow action
-
getProcess
public JCRWorkflowProcess getProcess(String workflowName, String processName)
Retrieve a process- Parameters:
workflowName- The workflow nameprocessName- The process name- Returns:
- The process
-
isComplete
public boolean isComplete(JCRWorkflowProcess process)
Determines if the process is complete- Parameters:
process- The process- Returns:
- True if the process is complete
-
canDelete
public boolean canDelete(JCRWorkflowProcess process)
Determines if the process can be deleted by the current user- Parameters:
process- The process- Returns:
- True if the process can be deleted
-
deleteProcess
public void deleteProcess(JCRWorkflowProcess process) throws IllegalAccessException
Delete a process- Parameters:
process- The process to delete- Throws:
IllegalAccessException- If a user tries to delete a process without being allowed
-
deleteProcesses
public Map<String,Object> deleteProcesses(List<String> processes) throws IllegalAccessException
Delete a list of processes- Parameters:
processes- The processes to delete- Returns:
- The result
- Throws:
IllegalAccessException- If a user tries to delete a process without being allowed
-
getProcessPageUrl
public String getProcessPageUrl(JCRWorkflowProcess process, String siteName, String lang, boolean absolute)
Get the url of a process page- Parameters:
process- The processsiteName- The current site name. Can not be null.lang- The current language. Can not be null.absolute- true to get absolute url.- Returns:
- the url of process page
-
getDashboardPage
public Page getDashboardPage(String siteName, String lang)
Get the page with PROCESS_DASHBOARD tag- Parameters:
siteName- The current site namelang- The language- Returns:
- The page or null if not found.
-
getCreateProcessPage
public Page getCreateProcessPage(String siteName, String lang)
Get the page with CREATE_PROCESS tag- Parameters:
siteName- The current site namelang- The language- Returns:
- The page or null if not found.
-
getTemplateForProcessPage
public String getTemplateForProcessPage(String siteName, String lang)
Get the template to use for process rendering- Parameters:
siteName- The site containing the pagelang- The sitemap of the page- Returns:
- The template to use for process rendering
-
isUserInWorkflowVariables
public boolean isUserInWorkflowVariables(JCRWorkflow workflow)
Test if the current user is present in any variable of the workflow- Parameters:
workflow- The workflow- Returns:
- True if the user is in the workflow variables
-
getUserProcesses
public Set<JCRWorkflowProcess> getUserProcesses()
Get the list of processes accessibles to the current user- Returns:
- The list of processes
-
isUserAllowedOnWorkflow
public boolean isUserAllowedOnWorkflow(JCRWorkflow workflow)
Check if the current user is allowed to create a process from the workflow- Parameters:
workflow- The workflow- Returns:
- True if the user is allowed
-
_setWorkflowValues
private void _setWorkflowValues(JCRWorkflow workflow, Map<String,Object> values)
-
_setProcessValues
private void _setProcessValues(JCRWorkflowProcess process, String title, String site, String description, List<PartOnDisk> uploadedAttachments)
-
_convertJsonToUser
private UserIdentity _convertJsonToUser(Map<String,Object> user)
-
_workflowToJson
private Map<String,Object> _workflowToJson(JCRWorkflow workflow, Map<String,Object> workflowDefinitionData)
-
_groups2Json
private List<Map<String,Object>> _groups2Json(GroupIdentity[] groups)
-
_getWorkflowsRootNode
protected ModifiableTraversableAmetysObject _getWorkflowsRootNode(boolean create)
Gets the root of contents- Parameters:
create-trueto create automatically the root when missing.- Returns:
- the root of workflows
- Throws:
UnknownAmetysObjectException- If root node does not exist
-
_getProcessesRootNode
protected ModifiableTraversableAmetysObject _getProcessesRootNode(JCRWorkflow workflow, boolean create)
Gets the root of processes of a workflow- Parameters:
workflow- The workflowcreate-trueto create automatically the root when missing.- Returns:
- the root of processes
- Throws:
UnknownAmetysObjectException- If root node does not exist
-
_getWorkflowDefinitionData
protected Map<String,Object> _getWorkflowDefinitionData(String workflowDefId)
Get the list of variables and their properties for a workflow definition- Parameters:
workflowDefId- The workflow definition id- Returns:
- The list of variables properties, mapped by variable id
-
_getWorkflowDefinitionRegisters
private Map<? extends String,? extends Map<String,Object>> _getWorkflowDefinitionRegisters(Configuration[] registers) throws ConfigurationException
- Throws:
ConfigurationException
-
_processToJson
private Map<String,Object> _processToJson(JCRWorkflowProcess process)
-
-