public class JCRTasksDAO extends AbstractLogEnabled implements Serviceable, Component
Modifier and Type | Class and Description |
---|---|
static class |
JCRTasksDAO.TaskListResult
Simple structure used to store a list of task and some metadata.
|
Modifier and Type | Field and Description |
---|---|
protected CurrentUserProvider |
_currentUserProvider
Current user provider
|
protected ExplorerResourcesDAO |
_explorerResourcesDAO
DAO for the explorer resources
|
protected ObservationManager |
_observationManager
The observation manager
|
protected AmetysObjectResolver |
_resolver
Ametys object resolver
|
protected RightManager |
_rightManager
The rights manager
|
protected UserHelper |
_userHelper
The user helper
|
protected UserManager |
_userManager
The user manager
|
static String |
RIGHTS_ADD_TASK
Rights to add a task
|
static String |
RIGHTS_DELETE_ALL_TASK
Rights to delete_all the tasks
|
static String |
RIGHTS_DELETE_TASK
Rights to delete a task
|
static String |
RIGHTS_EDIT_TASK
Rights to edit a task
|
static String |
RIGHTS_VIEW_TASKS
Rights to view the tasks
|
static String |
ROLE
Avalon Role
|
Constructor and Description |
---|
JCRTasksDAO() |
Modifier and Type | Method and Description |
---|---|
protected List<Map<String,Object>> |
_assignmentToJSON(Task task)
Transform assignments of a task to JSON data
|
private List<JCRTask> |
_getTasksById(List<String> taskIds,
Map<String,Object> result,
String right) |
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 properties
|
protected List<Map<String,Object>> |
_subscribersToJSON(Task task)
Transform subscribers of a task to JSON data
|
private List<Map<String,Object>> |
_tasksToJson(List<Task> tasks) |
Map<String,Object> |
addTask(String parentId,
Map<String,Object> parameters)
Add a new task
|
Map<String,Object> |
assignTasks(List<String> taskIds,
List<String> users)
Assign one or more task to one or more users
|
Map<String,Object> |
deleteTasks(List<String> taskIds)
Delete one or more tasks
|
Map<String,Object> |
editTask(String id,
Map<String,Object> parameters)
Edit a task
|
Map<String,Object> |
getTask(String taskId,
boolean isEdition)
Get the data of a task
|
protected Map<String,Object> |
getTask(Task task,
boolean isEdition)
Transform a task to JSON data
|
protected String |
getTaskDescription(Task task)
Get the description of a task as a String
|
protected String |
getTaskDescriptionForEdition(Task task)
Get the description of a task to edit as a String
|
JCRTasksDAO.TaskListResult |
getTaskList(List<String> parentIds,
boolean assignedToUser,
boolean userSubscribed,
Integer offset,
Integer limit,
String filter,
String orderBy,
Boolean orderAsc)
Get the list of tasks
|
Map<String,Object> |
getTasks(List<String> parentIds,
boolean assignedToUser,
boolean userSubscribed,
Integer offset,
Integer limit,
String filter,
String orderBy,
Boolean orderAsc)
Get the list of tasks
|
static String |
getTasksXpathQuery(String rootPath,
Expression tasksExpression,
SortCriteria sortCriteria)
Creates the XPath query corresponding to specified
Expression . |
void |
service(ServiceManager manager) |
protected void |
setTaskDescription(ModifiableTask task,
String description)
Update the description of a task
|
Map<String,Object> |
setTasksProgress(List<String> taskIds,
Integer progress)
Update the progress of one or multiple tasks
|
Map<String,Object> |
setTasksStatus(List<String> taskIds,
String statusString)
Update the status of one or multiple tasks
|
getLogger, setLogger
public static final String RIGHTS_VIEW_TASKS
public static final String RIGHTS_ADD_TASK
public static final String RIGHTS_EDIT_TASK
public static final String RIGHTS_DELETE_TASK
public static final String RIGHTS_DELETE_ALL_TASK
protected AmetysObjectResolver _resolver
protected ExplorerResourcesDAO _explorerResourcesDAO
protected CurrentUserProvider _currentUserProvider
protected UserManager _userManager
protected ObservationManager _observationManager
protected RightManager _rightManager
protected UserHelper _userHelper
public JCRTasksDAO()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public Map<String,Object> addTask(String parentId, Map<String,Object> parameters) throws IllegalAccessException
parentId
- The parent node idparameters
- The task parametersIllegalAccessException
- If an error occurs when checking the rightspublic Map<String,Object> editTask(String id, Map<String,Object> parameters) throws IllegalAccessException
id
- The id of the task to editparameters
- The task parametersIllegalAccessException
- If an error occurs when checking the rightsprotected Map<String,Object> _setTaskParameters(JCRTask task, Map<String,Object> parameters, Integer index, boolean setDescription)
task
- The task to editparameters
- The JS parametersindex
- The index of tasksetDescription
- true
to edit descriptionprivate boolean _isTaskParameterEquals(Object newValue, Object oldValue, String valueName, Map<String,Object> updatedValues)
protected void setTaskDescription(ModifiableTask task, String description)
task
- The task to updatedescription
- The description as stringprotected String getTaskDescription(Task task) throws AmetysRepositoryException
task
- the taskAmetysRepositoryException
- if failed to parse descriptionprotected String getTaskDescriptionForEdition(Task task) throws AmetysRepositoryException
task
- the taskAmetysRepositoryException
- if failed to parse descriptionpublic Map<String,Object> getTask(String taskId, boolean isEdition)
taskId
- the task idisEdition
- true to get the task in edit modepublic JCRTasksDAO.TaskListResult getTaskList(List<String> parentIds, boolean assignedToUser, boolean userSubscribed, Integer offset, Integer limit, String filter, String orderBy, Boolean orderAsc) throws ProcessingException
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.JCRTasksDAO.TaskListResult
objectProcessingException
- If an error occurredprivate void _handleAssignedOrSubscribedExprs(List<Expression> andExprs, boolean assignedToUser, boolean userSubscribed, UserIdentity currentUser)
public static String getTasksXpathQuery(String rootPath, Expression tasksExpression, SortCriteria sortCriteria) throws RepositoryException
Expression
.rootPath
- the path to the node containing the taskstasksExpression
- the query predicates.sortCriteria
- the sort criteria.RepositoryException
- if an error occurredpublic Map<String,Object> getTasks(List<String> parentIds, boolean assignedToUser, boolean userSubscribed, Integer offset, Integer limit, String filter, String orderBy, Boolean orderAsc) throws ProcessingException
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.ProcessingException
- If an error occurredpublic Map<String,Object> assignTasks(List<String> taskIds, List<String> users) throws IllegalAccessException
taskIds
- The tasks idsusers
- The usersIllegalAccessException
- If an error occurspublic Map<String,Object> setTasksStatus(List<String> taskIds, String statusString) throws IllegalAccessException
taskIds
- The tasks idsstatusString
- The statusIllegalAccessException
- If an error occurspublic Map<String,Object> setTasksProgress(List<String> taskIds, Integer progress) throws IllegalAccessException
taskIds
- The tasks idsprogress
- The progressIllegalAccessException
- If an error occurspublic Map<String,Object> deleteTasks(List<String> taskIds) throws IllegalAccessException
taskIds
- The tasks idsIllegalAccessException
- If an error occursprivate List<JCRTask> _getTasksById(List<String> taskIds, Map<String,Object> result, String right) throws IllegalAccessException
IllegalAccessException
protected Map<String,Object> getTask(Task task, boolean isEdition)
task
- The taskisEdition
- true to get the task in edit modeprotected List<Map<String,Object>> _assignmentToJSON(Task task)
task
- The task