public class QueryDAO extends AbstractLogEnabled implements Serviceable, Component
Modifier and Type | Field and Description |
---|---|
private static String |
__PLUGIN_NODE_NAME |
protected GroupManager |
_groupManager
The group manager
|
private AmetysObjectResolver |
_resolver
The Ametys object resolver
|
private RightManager |
_rightManager |
private UserHelper |
_userHelper |
protected CurrentUserProvider |
_userProvider
The current user provider
|
static String |
ROLE
The Avalon role
|
static String |
ROOT_QUERY_CONTAINER_ID
The alias id of the root
QueryContainer |
Constructor and Description |
---|
QueryDAO() |
Modifier and Type | Method and Description |
---|---|
private Map<String,Object> |
_assignRights(String queryId,
String profileId,
String type,
List<Map<String,String>> users,
List<Map<String,String>> groups) |
private boolean |
_canDeleteQueryContainer(String id) |
private boolean |
_containsNotOwnQueries(AmetysObjectIterable<Query> allQueries) |
private boolean |
_containsSharedQueries(AmetysObjectIterable<Query> allQueries) |
private static AmetysObject |
_getOrCreateNode(ModifiableTraversableAmetysObject parentNode,
String nodeName,
String nodeType) |
private QueryContainer |
_getOrCreateRootNode() |
private QueryContainer |
_getQueryContainer(String id) |
protected boolean |
_hasRight(Query query)
Test if the current user has the right required to access the query
|
private void |
_move(MovableAmetysObject obj,
String newParentId,
Map<String,Object> results) |
private boolean |
_mustWarnBeforeDeletion(String id) |
Map<String,Object> |
addGrantedGroups(String queryId,
String profileId,
List<Map<String,String>> groups)
Assign rigths to the given groups on the given query
|
Map<String,Object> |
addGrantedUsers(String queryId,
String profileId,
List<Map<String,String>> users)
Assign rights to the given users on the given query
|
protected boolean |
canDeleteAllQueryContainers(List<String> ids)
Can the current user delete all the
QueryContainer s from the list ? |
Map<String,Boolean> |
canDeleteQueryContainers(List<String> ids)
Determines if the current user can delete the given
QueryContainer s |
Map<String,Object> |
changeVisibility(String queryId,
String visibilityStr)
Changes the visibility of a
Query |
Map<String,Object> |
createQuery(String title,
String desc,
String type,
String content,
String parentId)
Creates a new
Query |
Map<String,Object> |
createQueryContainer(String parentId,
String name)
Creates a new
QueryContainer |
Map<String,Object> |
deleteQuery(List<String> ids)
Deletes
Query (ies) |
Map<String,Object> |
deleteQueryContainer(List<String> ids)
Deletes
QueryContainer (s) |
AmetysObjectIterable<Query> |
getChildQueriesForAdministrator(QueryContainer parent,
boolean onlyDirect,
Optional<String> type)
Gets all queries for administrator for given parent
|
AmetysObjectIterable<Query> |
getChildQueriesInReadAccess(QueryContainer parent,
boolean onlyDirect,
QueryHelper.Visibility visibility,
Optional<String> type)
Gets all queries in READ access for given parent
|
AmetysObjectIterable<Query> |
getChildQueriesInWriteAccess(QueryContainer parent,
boolean onlyDirect,
QueryHelper.Visibility visibility,
Optional<String> type)
Gets all queries in WRITE access for given parent
|
AmetysObjectIterable<QueryContainer> |
getChildQueryContainers(QueryContainer parent)
Gets all query containers for given parent
|
List<String> |
getIdsOfPath(String queryId)
Gets the ids of the path elements of a query or query container, i.e.
|
Map<String,Object> |
getQueriesProperties(List<String> queryIds)
Get queries' properties
|
QueryContainer |
getQueriesRootNode()
Get the root plugin storage object.
|
Map<String,Object> |
getQueryContainerProperties(QueryContainer queryContainer)
Get the query container properties
|
Map<String,Object> |
getQueryContainerProperties(String id)
Get the query container properties
|
Map<String,Object> |
getQueryProperties(Query query)
Get the query properties
|
boolean |
hasRightOnContainers()
Determines if the current user has right to handle
QueryContainer s |
boolean |
isAdministrator()
Determines if the current user is administrator of queries
|
Map<String,Object> |
moveQuery(String id,
String newParentId)
Moves a
Query |
Map<String,Object> |
moveQueryContainer(String id,
String newParentId)
Moves a
QueryContainer |
boolean |
mustWarnBeforeDeletion(List<String> ids)
Determines if application must warn before deleting the given
QueryContainer s |
Map<String,Object> |
removeAssignment(String queryId,
String profileId,
List<Map<String,String>> users,
List<Map<String,String>> groups)
Remove rights to the given users on the given query
|
Map<String,Object> |
renameQueryContainer(String id,
String newName)
Renames a
QueryContainer |
Map<String,Object> |
saveQuery(String id,
String type,
String content)
Saves a
Query |
void |
service(ServiceManager serviceManager) |
Map<String,Object> |
updateQuery(String id,
String title,
String desc)
Edits a
Query |
getLogger, setLogger
public static final String ROOT_QUERY_CONTAINER_ID
QueryContainer
private static final String __PLUGIN_NODE_NAME
protected CurrentUserProvider _userProvider
protected GroupManager _groupManager
private AmetysObjectResolver _resolver
private UserHelper _userHelper
private RightManager _rightManager
public QueryDAO()
public void service(ServiceManager serviceManager) throws ServiceException
service
in interface Serviceable
ServiceException
public QueryContainer getQueriesRootNode() throws AmetysRepositoryException
AmetysRepositoryException
- if a repository error occurs.private QueryContainer _getOrCreateRootNode() throws AmetysRepositoryException
AmetysRepositoryException
private static AmetysObject _getOrCreateNode(ModifiableTraversableAmetysObject parentNode, String nodeName, String nodeType) throws AmetysRepositoryException
AmetysRepositoryException
public Map<String,Object> getQueriesProperties(List<String> queryIds)
queryIds
- The ids of queries to retrievepublic Map<String,Object> getQueryProperties(Query query)
query
- The querypublic List<String> getIdsOfPath(String queryId)
queryId
- The id of the querypublic boolean hasRightOnContainers()
QueryContainer
strue
if the current user has right to handle QueryContainer
spublic Map<String,Object> getQueryContainerProperties(String id)
id
- The query container id. Can be ROOT_QUERY_CONTAINER_ID
for the root container.public Map<String,Object> getQueryContainerProperties(QueryContainer queryContainer)
queryContainer
- The query containerpublic Map<String,Object> createQuery(String title, String desc, String type, String content, String parentId)
Query
title
- The title of the querydesc
- The description of the querytype
- The type of the querycontent
- The content of the queryparentId
- The id of the parent of the query. Use ROOT_QUERY_CONTAINER_ID
for the root container.public Map<String,Object> createQueryContainer(String parentId, String name)
QueryContainer
parentId
- The id of the parent. Use ROOT_QUERY_CONTAINER_ID
for the root container.name
- The desired name for the new QueryContainer
public Map<String,Object> updateQuery(String id, String title, String desc)
Query
id
- The id of the querytitle
- The title of the querydesc
- The description of the querypublic Map<String,Object> renameQueryContainer(String id, String newName)
QueryContainer
id
- The id of the query containernewName
- The new name of the containerpublic Map<String,Object> moveQuery(String id, String newParentId)
Query
id
- The id of the querynewParentId
- The id of the new parent container of the query. Use ROOT_QUERY_CONTAINER_ID
for the root container.public Map<String,Object> moveQueryContainer(String id, String newParentId)
QueryContainer
id
- The id of the query containernewParentId
- The id of the new parent container of the query container. Use ROOT_QUERY_CONTAINER_ID
for the root container.private QueryContainer _getQueryContainer(String id)
public Map<String,Object> saveQuery(String id, String type, String content)
Query
id
- The id of the querytype
- The type of the querycontent
- The content of the querypublic Map<String,Object> deleteQuery(List<String> ids)
Query
(ies)ids
- The ids of the queries to deleteprotected boolean canDeleteAllQueryContainers(List<String> ids)
QueryContainer
s from the list ?ids
- The QueryContainer
idstrue
if he canpublic Map<String,Boolean> canDeleteQueryContainers(List<String> ids)
QueryContainer
sids
- The QueryContainer
idstrue
for each id if the current user can delete the associated QueryContainer
private boolean _canDeleteQueryContainer(String id)
public boolean mustWarnBeforeDeletion(List<String> ids)
QueryContainer
sids
- The QueryContainer
idstrue
if application must warnprivate boolean _mustWarnBeforeDeletion(String id)
private boolean _containsNotOwnQueries(AmetysObjectIterable<Query> allQueries)
private boolean _containsSharedQueries(AmetysObjectIterable<Query> allQueries)
public Map<String,Object> deleteQueryContainer(List<String> ids)
QueryContainer
(s)ids
- The ids of the query containers to deletepublic Map<String,Object> changeVisibility(String queryId, String visibilityStr)
Query
queryId
- The id of the queryvisibilityStr
- The new visibilitypublic Map<String,Object> addGrantedUsers(String queryId, String profileId, List<Map<String,String>> users)
queryId
- The query idprofileId
- The profile idusers
- The users to grantpublic Map<String,Object> addGrantedGroups(String queryId, String profileId, List<Map<String,String>> groups)
queryId
- The query idprofileId
- The profile idgroups
- The groups to grantprivate Map<String,Object> _assignRights(String queryId, String profileId, String type, List<Map<String,String>> users, List<Map<String,String>> groups)
public Map<String,Object> removeAssignment(String queryId, String profileId, List<Map<String,String>> users, List<Map<String,String>> groups)
queryId
- The query idprofileId
- The profile idusers
- The users to removegroups
- The groups to removepublic boolean isAdministrator()
true
if current user is administratorprotected boolean _hasRight(Query query)
query
- The querypublic AmetysObjectIterable<Query> getChildQueriesForAdministrator(QueryContainer parent, boolean onlyDirect, Optional<String> type)
parent
- The QueryContainer
, defining the context from which getting childrenonlyDirect
- true
in order to have only direct child queries from parent path, false
otherwise to have all queries at any level underneath the parent pathtype
- The query typepublic AmetysObjectIterable<Query> getChildQueriesInReadAccess(QueryContainer parent, boolean onlyDirect, QueryHelper.Visibility visibility, Optional<String> type)
parent
- The QueryContainer
, defining the context from which getting childrenonlyDirect
- true
in order to have only direct child queries from parent path, false
otherwise to have all queries at any level underneath the parent pathvisibility
- The user and its groups for checking visibilitytype
- The query typepublic AmetysObjectIterable<Query> getChildQueriesInWriteAccess(QueryContainer parent, boolean onlyDirect, QueryHelper.Visibility visibility, Optional<String> type)
parent
- The QueryContainer
, defining the context from which getting childrenonlyDirect
- true
in order to have only direct child queries from parent path, false
otherwise to have all queries at any level underneath the parent pathvisibility
- The user and its groups for checking visibilitytype
- The query typepublic AmetysObjectIterable<QueryContainer> getChildQueryContainers(QueryContainer parent)
parent
- The QueryContainer
, defining the context from which getting children