Class QueryDAO
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.queriesdirectory.QueryDAO
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
DAO for manipulating queries
-
Field Summary
Modifier and TypeFieldDescriptionprotected GroupManager
The group managerprotected CurrentUserProvider
The current user providerstatic final String
The Avalon rolestatic final String
The alias id of the rootQueryContainer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Test if the current user has the right required to access the queryAssign rights to the given groups on the given queryAssign rights to the given users on the given queryprotected boolean
Can the current user delete all theQueryContainer
s from the list ?Determines if the current user can delete the givenQueryContainer
schangeVisibility
(String queryId, String visibilityStr) Changes the visibility of aQuery
Creates a newQuery
createQueryContainer
(String parentId, String name) Creates a newQueryContainer
deleteQuery
(List<String> ids) DeletesQuery
(ies)deleteQueryContainer
(List<String> ids) DeletesQueryContainer
(s)getChildQueriesForAdministrator
(QueryContainer parent, boolean onlyDirect, Optional<String> type) Gets all queries for administrator for given parentgetChildQueriesInReadAccess
(QueryContainer parent, boolean onlyDirect, QueryHelper.Visibility visibility, Optional<String> type) Gets all queries in READ access for given parentgetChildQueriesInWriteAccess
(QueryContainer parent, boolean onlyDirect, QueryHelper.Visibility visibility, Optional<String> type) Gets all queries in WRITE access for given parentGets all query containers for given parentgetIdsOfPath
(String queryId) Gets the ids of the path elements of a query or query container, i.e.getQueriesProperties
(List<String> queryIds) Get queries' propertiesGet the root plugin storage object.Get the query container propertiesgetQueryContainerProperties
(QueryContainer queryContainer) Get the query container propertiesgetQueryProperties
(Query query) Get the query propertiesboolean
Determines if the current user has right to handleQueryContainer
sboolean
Determines if the current user is administrator of queriesMoves aQuery
moveQueryContainer
(String id, String newParentId) Moves aQueryContainer
boolean
mustWarnBeforeDeletion
(List<String> ids) Determines if application must warn before deleting the givenQueryContainer
sremoveAssignment
(String queryId, String profileId, List<Map<String, String>> users, List<Map<String, String>> groups) Remove rights to the given users on the given queryrenameQueryContainer
(String id, String newName) Renames aQueryContainer
Saves aQuery
void
service
(ServiceManager serviceManager) updateQuery
(String id, String title, String desc) Edits aQuery
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
ROOT_QUERY_CONTAINER_ID
The alias id of the rootQueryContainer
- See Also:
-
_userProvider
The current user provider -
_groupManager
The group manager
-
-
Constructor Details
-
QueryDAO
public QueryDAO()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getQueriesRootNode
Get the root plugin storage object.- Returns:
- the root plugin storage object.
- Throws:
AmetysRepositoryException
- if a repository error occurs.
-
getQueriesProperties
Get queries' properties- Parameters:
queryIds
- The ids of queries to retrieve- Returns:
- The queries' properties
-
getQueryProperties
Get the query properties- Parameters:
query
- The query- Returns:
- The query properties
-
getIdsOfPath
Gets the ids of the path elements of a query or query container, i.e. the parent ids.
For instance, if the query path is 'a/b/c', then the result list will be ["id-of-a", "id-of-b", "id-of-c"]- Parameters:
queryId
- The id of the query- Returns:
- the ids of the path elements of a query
-
hasRightOnContainers
Determines if the current user has right to handleQueryContainer
s- Returns:
true
if the current user has right to handleQueryContainer
s
-
getQueryContainerProperties
Get the query container properties- Parameters:
id
- The query container id. Can beROOT_QUERY_CONTAINER_ID
for the root container.- Returns:
- The query container properties
-
getQueryContainerProperties
Get the query container properties- Parameters:
queryContainer
- The query container- Returns:
- The query container properties
-
createQuery
public Map<String,Object> createQuery(String title, String desc, String type, String content, String parentId) Creates a newQuery
- Parameters:
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. UseROOT_QUERY_CONTAINER_ID
for the root container.- Returns:
- A result map
-
createQueryContainer
Creates a newQueryContainer
- Parameters:
parentId
- The id of the parent. UseROOT_QUERY_CONTAINER_ID
for the root container.name
- The desired name for the newQueryContainer
- Returns:
- A result map
-
updateQuery
Edits aQuery
- Parameters:
id
- The id of the querytitle
- The title of the querydesc
- The description of the query- Returns:
- A result map
-
renameQueryContainer
Renames aQueryContainer
- Parameters:
id
- The id of the query containernewName
- The new name of the container- Returns:
- A result map
-
moveQuery
Moves aQuery
- Parameters:
id
- The id of the querynewParentId
- The id of the new parent container of the query. UseROOT_QUERY_CONTAINER_ID
for the root container.- Returns:
- A result map
-
moveQueryContainer
Moves aQueryContainer
- Parameters:
id
- The id of the query containernewParentId
- The id of the new parent container of the query container. UseROOT_QUERY_CONTAINER_ID
for the root container.- Returns:
- A result map
-
saveQuery
Saves aQuery
- Parameters:
id
- The id of the querytype
- The type of the querycontent
- The content of the query- Returns:
- A result map
-
deleteQuery
DeletesQuery
(ies)- Parameters:
ids
- The ids of the queries to delete- Returns:
- A result map
-
canDeleteAllQueryContainers
Can the current user delete all theQueryContainer
s from the list ?- Parameters:
ids
- TheQueryContainer
ids- Returns:
true
if he can
-
canDeleteQueryContainers
Determines if the current user can delete the givenQueryContainer
s- Parameters:
ids
- TheQueryContainer
ids- Returns:
- A map with
true
for each id if the current user can delete the associatedQueryContainer
-
mustWarnBeforeDeletion
Determines if application must warn before deleting the givenQueryContainer
s- Parameters:
ids
- TheQueryContainer
ids- Returns:
true
if application must warn
-
deleteQueryContainer
DeletesQueryContainer
(s)- Parameters:
ids
- The ids of the query containers to delete- Returns:
- A result map
-
changeVisibility
Changes the visibility of aQuery
- Parameters:
queryId
- The id of the queryvisibilityStr
- The new visibility- Returns:
- A result map
-
addGrantedUsers
public Map<String,Object> addGrantedUsers(String queryId, String profileId, List<Map<String, String>> users) Assign rights to the given users on the given query- Parameters:
queryId
- The query idprofileId
- The profile idusers
- The users to grant- Returns:
- A result map
-
addGrantedGroups
public Map<String,Object> addGrantedGroups(String queryId, String profileId, List<Map<String, String>> groups) Assign rights to the given groups on the given query- Parameters:
queryId
- The query idprofileId
- The profile idgroups
- The groups to grant- Returns:
- A result map
-
removeAssignment
public 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- Parameters:
queryId
- The query idprofileId
- The profile idusers
- The users to removegroups
- The groups to remove- Returns:
- A result map
-
isAdministrator
Determines if the current user is administrator of queries- Returns:
true
if current user is administrator
-
_hasRight
Test if the current user has the right required to access the query- Parameters:
query
- The query- Returns:
- true if the user has the right needed, false otherwise.
-
getChildQueriesForAdministrator
public AmetysObjectIterable<Query> getChildQueriesForAdministrator(QueryContainer parent, boolean onlyDirect, Optional<String> type) Gets all queries for administrator for given parent- Parameters:
parent
- TheQueryContainer
, 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 type- Returns:
- all queries for administrator for given parent
-
getChildQueriesInReadAccess
public AmetysObjectIterable<Query> getChildQueriesInReadAccess(QueryContainer parent, boolean onlyDirect, QueryHelper.Visibility visibility, Optional<String> type) Gets all queries in READ access for given parent- Parameters:
parent
- TheQueryContainer
, 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 type- Returns:
- all queries in READ access for given parent
-
getChildQueriesInWriteAccess
public AmetysObjectIterable<Query> getChildQueriesInWriteAccess(QueryContainer parent, boolean onlyDirect, QueryHelper.Visibility visibility, Optional<String> type) Gets all queries in WRITE access for given parent- Parameters:
parent
- TheQueryContainer
, 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 type- Returns:
- all queries in WRITE access for given parent
-
getChildQueryContainers
Gets all query containers for given parent- Parameters:
parent
- TheQueryContainer
, defining the context from which getting children- Returns:
- all query containers for given parent
-