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
FieldsModifier and TypeFieldDescriptionprotected ObservationManagerThe observation managerprotected CurrentUserProviderThe current user providerstatic final StringPropery key for delete accessstatic final StringPropery key for edit rights accessstatic final StringThe right id to handle query containerstatic final StringThe right id to handle querystatic final StringPropery key for read accessstatic final StringPropery key for rename accessstatic final StringThe Avalon rolestatic final StringThe alias id of the rootQueryContainerstatic final StringPropery key for write access -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_isRoot(QueryContainer queryContainer) Determines if the query container is the root nodebooleancanAssignRights(UserIdentity userIdentity, Query query) Check if a user can edit rights on a querybooleancanAssignRights(UserIdentity userIdentity, QueryContainer queryContainer) Check if a user can edit rights on a query containerbooleancanCreate(UserIdentity userIdentity, QueryContainer queryContainer) Check if a user has creation rights on a query containerbooleancanDelete(UserIdentity userIdentity, Query query) Determines if the user can delete a querybooleancanDelete(UserIdentity userIdentity, QueryContainer queryContainer) Determines if the user can delete a query containerbooleancanRead(UserIdentity userIdentity, Query query) Determine if user has read access on a querybooleancanRead(UserIdentity userIdentity, QueryContainer queryContainer) Determines if the user has read access on a query containerbooleancanRename(UserIdentity userIdentity, QueryContainer queryContainer) Determines if the user can rename a query containerbooleancanWrite(UserIdentity userIdentity, Query query) Determines if the user has write access on a querybooleancanWrite(UserIdentity userIdentity, QueryContainer queryContainer) Check if a user has write access on a query containerbooleancanWrite(UserIdentity userIdentity, QueryContainer queryContainer, boolean recursively) Check if a user has write access on a query containercreateQuery(String title, String desc, String documentation, String type, String content, String parentId) Creates a newQuerycreateQueryContainer(String parentId, String name) Creates a newQueryContainerdeleteQuery(List<String> ids) DeletesQuery(ies)deleteQueryContainer(List<String> ids) DeletesQueryContainer(s)filterQueries(String rootNode, String search, boolean ownerOnly, boolean requestType, boolean solrType, boolean scriptType, boolean formattingType) Filter queries on the server sidegetChildQueriesForAdministrator(QueryContainer parent, boolean onlyDirect, List<String> acceptedTypes) Gets all queries for administrator for given parentgetChildQueriesInReadAccess(QueryContainer parent, boolean onlyDirect, UserIdentity user, List<String> acceptedTypes) Gets all queries in READ access for given parentgetChildQueriesInRightAccess(QueryContainer parent, boolean onlyDirect, UserIdentity user, List<String> acceptedTypes) Gets all queries in WRITE access for given parentgetChildQueriesInWriteAccess(QueryContainer parent, boolean onlyDirect, UserIdentity user, List<String> acceptedTypes) 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 propertiesGet the root container propertiesbooleanhasAnyAssignableDescendant(UserIdentity userIdentity, QueryContainer queryContainer) Check if a folder have descendant in right assignment access for a given userbooleanhasAnyReadableDescendant(UserIdentity userIdentity, QueryContainer queryContainer) Check if a folder have a descendant in read access for a given userhasAnyWritableDescendant(UserIdentity userIdentity, QueryContainer queryContainer) Check if a query container have descendant in write access for a given userMoves aQuerymoveQueryContainer(String id, String newParentId) Moves aQueryContainerbooleanmustWarnBeforeDeletion(List<String> ids) Determines if application must warn before deleting the givenQueryContainersrenameQueryContainer(String id, String newName) Renames aQueryContainerSaves aQueryvoidservice(ServiceManager serviceManager) updateQuery(String id, String title, String desc, String documentation) Edits aQueryMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
The Avalon role -
QUERY_HANDLE_RIGHT_ID
The right id to handle query- See Also:
-
QUERY_CONTAINER_HANDLE_RIGHT_ID
The right id to handle query container- See Also:
-
ROOT_QUERY_CONTAINER_ID
The alias id of the rootQueryContainer- See Also:
-
READ_ACCESS_PROPERTY
Propery key for read access- See Also:
-
WRITE_ACCESS_PROPERTY
Propery key for write access- See Also:
-
RENAME_ACCESS_PROPERTY
Propery key for rename access- See Also:
-
DELETE_ACCESS_PROPERTY
Propery key for delete access- See Also:
-
EDIT_RIGHTS_ACCESS_PROPERTY
Propery key for edit rights access- See Also:
-
_userProvider
The current user provider -
_observationManager
The observation manager
-
-
Constructor Details
-
QueryDAO
public QueryDAO()
-
-
Method Details
-
service
- Specified by:
servicein 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
-
getRootProperties
Get the root container properties- Returns:
- The root container properties
-
getQueryContainerProperties
Get the query container properties- Parameters:
id- The query container id. Can beROOT_QUERY_CONTAINER_IDfor the root container.- Returns:
- The query container properties
-
getQueryContainerProperties
Get the query container properties- Parameters:
queryContainer- The query container- Returns:
- The query container properties
-
filterQueries
public List<String> filterQueries(String rootNode, String search, boolean ownerOnly, boolean requestType, boolean solrType, boolean scriptType, boolean formattingType) Filter queries on the server side- Parameters:
rootNode- The root node where to seek (to refresh subtrees)search- Textual searchownerOnly- Only queries of the owner will be returnedrequestType- Only simple/advanced requests will be returnedsolrType- Only Solr requests will be returnedscriptType- Only script requests will be returnedformattingType- Only formatting will be returned- Returns:
- The list of query path
-
createQuery
public Map<String,Object> createQuery(String title, String desc, String documentation, String type, String content, String parentId) Creates a newQuery- Parameters:
title- The title of the querydesc- The description of the querydocumentation- The documentation of the querytype- The type of the querycontent- The content of the queryparentId- The id of the parent of the query. UseROOT_QUERY_CONTAINER_IDfor the root container.- Returns:
- A result map
-
createQueryContainer
Creates a newQueryContainer- Parameters:
parentId- The id of the parent. UseROOT_QUERY_CONTAINER_IDfor 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 querydocumentation- The documentation 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_IDfor 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_IDfor 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
-
mustWarnBeforeDeletion
Determines if application must warn before deleting the givenQueryContainers- Parameters:
ids- TheQueryContainerids- Returns:
trueif application must warn
-
deleteQueryContainer
DeletesQueryContainer(s)- Parameters:
ids- The ids of the query containers to delete- Returns:
- A result map
-
getChildQueriesForAdministrator
public AmetysObjectIterable<Query> getChildQueriesForAdministrator(QueryContainer parent, boolean onlyDirect, List<String> acceptedTypes) Gets all queries for administrator for given parent- Parameters:
parent- TheQueryContainer, defining the context from which getting childrenonlyDirect-truein order to have only direct child queries from parent path,falseotherwise to have all queries at any level underneath the parent pathacceptedTypes- The type of queries. Can be null or empty to accept all types.- Returns:
- all queries for administrator for given parent
-
getChildQueriesInReadAccess
public Stream<Query> getChildQueriesInReadAccess(QueryContainer parent, boolean onlyDirect, UserIdentity user, List<String> acceptedTypes) Gets all queries in READ access for given parent- Parameters:
parent- TheQueryContainer, defining the context from which getting childrenonlyDirect-truein order to have only direct child queries from parent path,falseotherwise to have all queries at any level underneath the parent pathuser- The useracceptedTypes- The type of queries. Can be null or empty to accept all types.- Returns:
- all queries in READ access for given parent
-
canRead
Determine if user has read access on a query- Parameters:
userIdentity- the userquery- the query- Returns:
- true if the user have read rights on a query
-
canRead
Determines if the user has read access on a query container- Parameters:
userIdentity- the userqueryContainer- the query container- Returns:
- true if the user has read access on the query container
-
getChildQueriesInWriteAccess
public Stream<Query> getChildQueriesInWriteAccess(QueryContainer parent, boolean onlyDirect, UserIdentity user, List<String> acceptedTypes) Gets all queries in WRITE access for given parent- Parameters:
parent- TheQueryContainer, defining the context from which getting childrenonlyDirect-truein order to have only direct child queries from parent path,falseotherwise to have all queries at any level underneath the parent pathuser- The useracceptedTypes- The type of queries. Can be null or empty to accept all types.- Returns:
- all queries in WRITE access for given parent
-
canWrite
Determines if the user has write access on a query- Parameters:
userIdentity- the userquery- the query- Returns:
- true if the user has write access on query
-
canDelete
Determines if the user can delete a query- Parameters:
userIdentity- the userquery- the query- Returns:
- true if the user can delete the query
-
canRename
Determines if the user can rename a query container- Parameters:
userIdentity- the userqueryContainer- the query container- Returns:
- true if the user can delete the query
-
canDelete
Determines if the user can delete a query container- Parameters:
userIdentity- the userqueryContainer- the query container- Returns:
- true if the user can delete the query container
-
_isRoot
Determines if the query container is the root node- Parameters:
queryContainer- the query container- Returns:
- true if is root
-
getChildQueriesInRightAccess
public Stream<Query> getChildQueriesInRightAccess(QueryContainer parent, boolean onlyDirect, UserIdentity user, List<String> acceptedTypes) Gets all queries in WRITE access for given parent- Parameters:
parent- TheQueryContainer, defining the context from which getting childrenonlyDirect-truein order to have only direct child queries from parent path,falseotherwise to have all queries at any level underneath the parent pathuser- The useracceptedTypes- The type of queries. Can be null or empty to accept all types.- Returns:
- all queries in WRITE access for given parent
-
canAssignRights
Check if a user can edit rights on a query- Parameters:
userIdentity- the userquery- the query- Returns:
- true if the user can edit rights on a query
-
canCreate
Check if a user has creation rights on a query container- Parameters:
userIdentity- the user identityqueryContainer- the query container- Returns:
- true if the user has creation rights on a query container
-
canWrite
Check if a user has write access on a query container- Parameters:
userIdentity- the user identityqueryContainer- the query container- Returns:
- true if the user has write access on the a query container
-
canWrite
public boolean canWrite(UserIdentity userIdentity, QueryContainer queryContainer, boolean recursively) Check if a user has write access on a query container- Parameters:
userIdentity- the user user identityqueryContainer- the query containerrecursively- true to check write access on all descendants recursively- Returns:
- true if the user has write access on the a query container
-
canAssignRights
Check if a user can edit rights on a query container- Parameters:
userIdentity- the userqueryContainer- the query container- Returns:
- true if the user can edit rights on a query
-
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
-
hasAnyReadableDescendant
Check if a folder have a descendant in read access for a given user- Parameters:
userIdentity- the userqueryContainer- the query container- Returns:
- true if the user have read right for at least one child of this container
-
hasAnyWritableDescendant
Check if a query container have descendant in write access for a given user- Parameters:
userIdentity- the user identityqueryContainer- the query container- Returns:
- true if the user have write right for at least one child of this container
-
hasAnyAssignableDescendant
Check if a folder have descendant in right assignment access for a given user- Parameters:
userIdentity- the user identityqueryContainer- the query container- Returns:
- true if the user have right assignment right for at least one child of this container
-