Package org.ametys.plugins.mobileapp
Class QueriesHelper
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.mobileapp.QueriesHelper
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class QueriesHelper
extends AbstractLogEnabled
implements Serviceable, Component, Contextualizable
Manager to list and execute queries
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
global configuration about queriesprotected static final String
global configuration about queries limitprotected Context
The contextprotected ServiceManager
The service managerstatic final String
Avalon Role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
contextualize
(Context context) executeQuery
(Query query, List<Sort> sort, boolean checkRights) Execute a query, with a forced sortgetContentFormattedDate
(Content content, String field) Get the date of the content, can be the date requested in the field, or by default the last validation dateprotected ContentSearcherFactory
Getter for ContentSearcherFactory to avoid problems at startupprotected ContentTypesHelper
Getter for ContentTypesHelper to avoid problems at startupgetDataForContent
(Content content) Get a json object representing the contentList all queries available for the mobile appgetQueries
(AmetysObject ametysObject) Get all queries available in a specificQueryContainer
getQueriesForResult
(String contentId) Execute all queries to return the list of the queries that return this objectgetQueriesForResult
(List<String> contents) Execute all queries to return the list of the queries that return this objectgetQueriesForResult
(AmetysObject content) Execute all queries to return the list of the queries that return this objectprotected QueryHelper
Getter for QueriesManager to avoid problems at startupprotected AmetysObjectResolver
Getter for AmetysObjectResolver to avoid problems at startupprotected SearchUIModelExtensionPoint
Getter for SearchUIModelExtensionPoint to avoid problems at startupprotected SiteManager
Getter for SiteManager to avoid problems at startupgetSortProperty
(Query query, boolean moreThanOne) Generate a list of sort properties.void
service
(ServiceManager manager) Transform a ZonedDateTime, LocalDate or Date to an instantMethods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon Role -
__QUERY_CONTAINER_CONF_ID
global configuration about queries- See Also:
-
__QUERY_LIMIT_CONF_ID
global configuration about queries limit- See Also:
-
_manager
The service manager -
_context
The context
-
-
Constructor Details
-
QueriesHelper
public QueriesHelper()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getResolver
Getter for AmetysObjectResolver to avoid problems at startup- Returns:
- AmetysObjectResolver
-
getQueriesManager
Getter for QueriesManager to avoid problems at startup- Returns:
- QueriesManager
-
getSearchUIModelExtensionPoint
Getter for SearchUIModelExtensionPoint to avoid problems at startup- Returns:
- SearchUIModelExtensionPoint
-
getContentTypesHelper
Getter for ContentTypesHelper to avoid problems at startup- Returns:
- ContentTypesHelper
-
getSiteManager
Getter for SiteManager to avoid problems at startup- Returns:
- SiteManager
-
getContentSearcherFactory
Getter for ContentSearcherFactory to avoid problems at startup- Returns:
- ContentSearcherFactory
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
getQueries
List all queries available for the mobile app- Returns:
- a list of
Query
-
getQueries
Get all queries available in a specificQueryContainer
- Parameters:
ametysObject
- aQueryContainer
to parse, or directly aQuery
to return in a list- Returns:
- a list containing all
Query
available in thisQueryContainer
-
executeQuery
public AmetysObjectIterable<Content> executeQuery(Query query, List<Sort> sort, boolean checkRights) Execute a query, with a forced sort- Parameters:
query
- the query to executesort
- a list of sert elements, can contain lastValidationcheckRights
- check the rights while executing the query- Returns:
- the results of the query
-
getQueriesForResult
Execute all queries to return the list of the queries that return this object- Parameters:
content
- the object to test- Returns:
- a list containing all the impacted queries
-
getQueriesForResult
Execute all queries to return the list of the queries that return this object- Parameters:
contentId
- the content id- Returns:
- a list containing all the impacted queries
-
getQueriesForResult
Execute all queries to return the list of the queries that return this object- Parameters:
contents
- a list of object to test- Returns:
- a map containing, for each content, the list containing all the impacted queries
-
getSortProperty
Generate a list of sort properties. If there are multiple queries, they have to be sorted first by date ASC. If they already are, the sort is used, otherwise a sort on lastValidation is used- Parameters:
query
- the query that will be executedmoreThanOne
- if false and the query already contain a sort, the original sort will be returned- Returns:
- a list of sort, with the first one by date if moreThanOne is true
-
getDataForContent
Get a json object representing the content- Parameters:
content
- tho content to parse- Returns:
- a json map
-
toInstant
Transform a ZonedDateTime, LocalDate or Date to an instant- Parameters:
o1
- the date to transformo2
- a relative date, if it contains a timezone and the 1st does not, this timezone will bu used- Returns:
- an Instant
-
getContentFormattedDate
Get the date of the content, can be the date requested in the field, or by default the last validation date- Parameters:
content
- the content to readfield
- the field to check- Returns:
- the iso formatted date
-