Class JCRTasksDAO
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.explorer.tasks.jcr.JCRTasksDAO
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
- Direct Known Subclasses:
WorkspaceTaskDAO
public class JCRTasksDAO extends AbstractLogEnabled implements Serviceable, Component
DAO for interacting with JCRTasks
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JCRTasksDAO.TaskListResult
Simple structure used to store a list of task and some metadata.
-
Field Summary
Fields Modifier and Type Field Description protected CurrentUserProvider
_currentUserProvider
Current user providerprotected ExplorerResourcesDAO
_explorerResourcesDAO
DAO for the explorer resourcesprotected ObservationManager
_observationManager
The observation managerprotected AmetysObjectResolver
_resolver
Ametys object resolverprotected RightManager
_rightManager
The rights managerprotected UserHelper
_userHelper
The user helperprotected UserManager
_userManager
The user managerstatic String
RIGHTS_ADD_TASK
Rights to add a taskstatic String
RIGHTS_DELETE_ALL_TASK
Rights to delete_all the tasksstatic String
RIGHTS_DELETE_TASK
Rights to delete a taskstatic String
RIGHTS_EDIT_TASK
Rights to edit a taskstatic String
RIGHTS_VIEW_TASKS
Rights to view the tasksstatic String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description JCRTasksDAO()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected List<Map<String,Object>>
_assignmentToJSON(Task task)
Transform assignments of a task to JSON dataprivate List<JCRTask>
_getTasksById(List<String> taskIds, Map<String,Object> result, String right, boolean allowAssigned)
private void
_handleAssignedOrSubscribedExprs(List<Expression> andExprs, boolean assignedToUser, boolean userSubscribed, UserIdentity currentUser)
private boolean
_isTaskParameterEquals(Object newValue, Object oldValue, String valueName, Map<String,Object> updatedValues)
protected Map<String,Object>
_setTaskParameters(JCRTask task, Map<String,Object> parameters, Integer index, boolean setDescription)
Set task's propertiesprotected List<Map<String,Object>>
_subscribersToJSON(Task task)
Transform subscribers of a task to JSON dataprivate List<Map<String,Object>>
_tasksToJson(List<Task> tasks)
Map<String,Object>
addTask(String parentId, Map<String,Object> parameters)
Add a new taskMap<String,Object>
assignTasks(List<String> taskIds, List<String> users)
Assign one or more task to one or more usersMap<String,Object>
deleteTasks(List<String> taskIds)
Delete one or more tasksMap<String,Object>
editTask(String id, Map<String,Object> parameters)
Edit a taskMap<String,Object>
getTask(String taskId, boolean isEdition)
Get the data of a taskprotected Map<String,Object>
getTask(Task task, boolean isEdition)
Transform a task to JSON dataprotected String
getTaskDescription(Task task)
Get the description of a task as a Stringprotected String
getTaskDescriptionForEdition(Task task)
Get the description of a task to edit as a StringJCRTasksDAO.TaskListResult
getTaskList(List<String> parentIds, boolean assignedToUser, boolean userSubscribed, Integer offset, Integer limit, String filter, String orderBy, Boolean orderAsc)
Get the list of tasksMap<String,Object>
getTasks(List<String> parentIds, boolean assignedToUser, boolean userSubscribed, Integer offset, Integer limit, String filter, String orderBy, Boolean orderAsc)
Get the list of tasksstatic String
getTasksXpathQuery(String rootPath, Expression tasksExpression, SortCriteria sortCriteria)
Creates the XPath query corresponding to specifiedExpression
.void
service(ServiceManager manager)
protected void
setTaskDescription(ModifiableTask task, String description)
Update the description of a taskMap<String,Object>
setTasksProgress(List<String> taskIds, Integer progress)
Update the progress of one or multiple tasksMap<String,Object>
setTasksStatus(List<String> taskIds, String statusString)
Update the status of one or multiple tasks-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
RIGHTS_VIEW_TASKS
public static final String RIGHTS_VIEW_TASKS
Rights to view the tasks- See Also:
- Constant Field Values
-
RIGHTS_ADD_TASK
public static final String RIGHTS_ADD_TASK
Rights to add a task- See Also:
- Constant Field Values
-
RIGHTS_EDIT_TASK
public static final String RIGHTS_EDIT_TASK
Rights to edit a task- See Also:
- Constant Field Values
-
RIGHTS_DELETE_TASK
public static final String RIGHTS_DELETE_TASK
Rights to delete a task- See Also:
- Constant Field Values
-
RIGHTS_DELETE_ALL_TASK
public static final String RIGHTS_DELETE_ALL_TASK
Rights to delete_all the tasks- See Also:
- Constant Field Values
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver
-
_explorerResourcesDAO
protected ExplorerResourcesDAO _explorerResourcesDAO
DAO for the explorer resources
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
Current user provider
-
_userManager
protected UserManager _userManager
The user manager
-
_observationManager
protected ObservationManager _observationManager
The observation manager
-
_rightManager
protected RightManager _rightManager
The rights manager
-
_userHelper
protected UserHelper _userHelper
The user helper
-
-
Constructor Detail
-
JCRTasksDAO
public JCRTasksDAO()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
addTask
public Map<String,Object> addTask(String parentId, Map<String,Object> parameters) throws IllegalAccessException
Add a new task- Parameters:
parentId
- The parent node idparameters
- The task parameters- Returns:
- The task data
- Throws:
IllegalAccessException
- If an error occurs when checking the rights
-
editTask
public Map<String,Object> editTask(String id, Map<String,Object> parameters) throws IllegalAccessException
Edit a task- Parameters:
id
- The id of the task to editparameters
- The task parameters- Returns:
- The task data
- Throws:
IllegalAccessException
- If an error occurs when checking the rights
-
_setTaskParameters
protected Map<String,Object> _setTaskParameters(JCRTask task, Map<String,Object> parameters, Integer index, boolean setDescription)
Set task's properties- Parameters:
task
- The task to editparameters
- The JS parametersindex
- The index of tasksetDescription
-true
to edit description- Returns:
- The map of updated values
-
_isTaskParameterEquals
private boolean _isTaskParameterEquals(Object newValue, Object oldValue, String valueName, Map<String,Object> updatedValues)
-
setTaskDescription
protected void setTaskDescription(ModifiableTask task, String description)
Update the description of a task- Parameters:
task
- The task to updatedescription
- The description as string
-
getTaskDescription
protected String getTaskDescription(Task task) throws AmetysRepositoryException
Get the description of a task as a String- Parameters:
task
- the task- Returns:
- The content as String
- Throws:
AmetysRepositoryException
- if failed to parse description
-
getTaskDescriptionForEdition
protected String getTaskDescriptionForEdition(Task task) throws AmetysRepositoryException
Get the description of a task to edit as a String- Parameters:
task
- the task- Returns:
- The content as String
- Throws:
AmetysRepositoryException
- if failed to parse description
-
getTask
public Map<String,Object> getTask(String taskId, boolean isEdition)
Get the data of a task- Parameters:
taskId
- the task idisEdition
- true to get the task in edit mode- Returns:
- The task data
-
getTaskList
public JCRTasksDAO.TaskListResult getTaskList(List<String> parentIds, boolean assignedToUser, boolean userSubscribed, Integer offset, Integer limit, String filter, String orderBy, Boolean orderAsc) throws ProcessingException
Get the list of tasks- Parameters:
parentIds
- The tasks parentsassignedToUser
- Filter only the tasks assigned to the current useruserSubscribed
- Filter only the tasks for which current user subscribedoffset
- Offset the list of resultslimit
- The maximum number of results to returnfilter
- Return only tasks matching the filterorderBy
- Order the list by this property. Default to the creation dateorderAsc
- Sort the list by order ascendant or descendant. Default to ascendant.- Returns:
- The list as a
JCRTasksDAO.TaskListResult
object - Throws:
ProcessingException
- If an error occurred
-
_handleAssignedOrSubscribedExprs
private void _handleAssignedOrSubscribedExprs(List<Expression> andExprs, boolean assignedToUser, boolean userSubscribed, UserIdentity currentUser)
-
getTasksXpathQuery
public static String getTasksXpathQuery(String rootPath, Expression tasksExpression, SortCriteria sortCriteria) throws RepositoryException
Creates the XPath query corresponding to specifiedExpression
.- Parameters:
rootPath
- the path to the node containing the taskstasksExpression
- the query predicates.sortCriteria
- the sort criteria.- Returns:
- the created XPath query.
- Throws:
RepositoryException
- if an error occurred
-
getTasks
public Map<String,Object> getTasks(List<String> parentIds, boolean assignedToUser, boolean userSubscribed, Integer offset, Integer limit, String filter, String orderBy, Boolean orderAsc) throws ProcessingException
Get the list of tasks- Parameters:
parentIds
- The tasks parentsassignedToUser
- Filter only the tasks assigned to the current useruserSubscribed
- Filter only the tasks for which current user subscribedoffset
- Offset the list of resultslimit
- The maximum number of results to returnfilter
- Return only tasks matching the filterorderBy
- Order the list by this property. Default to the creation dateorderAsc
- Sort the list by order ascendant or descendant. Default to ascendant.- Returns:
- The list of tasks
- Throws:
ProcessingException
- If an error occurred
-
assignTasks
public Map<String,Object> assignTasks(List<String> taskIds, List<String> users) throws IllegalAccessException
Assign one or more task to one or more users- Parameters:
taskIds
- The tasks idsusers
- The users- Returns:
- The tasks data, updated
- Throws:
IllegalAccessException
- If an error occurs
-
setTasksStatus
public Map<String,Object> setTasksStatus(List<String> taskIds, String statusString) throws IllegalAccessException
Update the status of one or multiple tasks- Parameters:
taskIds
- The tasks idsstatusString
- The status- Returns:
- The tasks data updated
- Throws:
IllegalAccessException
- If an error occurs
-
setTasksProgress
public Map<String,Object> setTasksProgress(List<String> taskIds, Integer progress) throws IllegalAccessException
Update the progress of one or multiple tasks- Parameters:
taskIds
- The tasks idsprogress
- The progress- Returns:
- The tasks data updated
- Throws:
IllegalAccessException
- If an error occurs
-
deleteTasks
public Map<String,Object> deleteTasks(List<String> taskIds) throws IllegalAccessException
Delete one or more tasks- Parameters:
taskIds
- The tasks ids- Returns:
- The list of tasks ids
- Throws:
IllegalAccessException
- If an error occurs
-
_getTasksById
private List<JCRTask> _getTasksById(List<String> taskIds, Map<String,Object> result, String right, boolean allowAssigned) throws IllegalAccessException
- Throws:
IllegalAccessException
-
getTask
protected Map<String,Object> getTask(Task task, boolean isEdition)
Transform a task to JSON data- Parameters:
task
- The taskisEdition
- true to get the task in edit mode- Returns:
- The JSON data
-
_assignmentToJSON
protected List<Map<String,Object>> _assignmentToJSON(Task task)
Transform assignments of a task to JSON data- Parameters:
task
- The task- Returns:
- The JSON data
-
-