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
,Serviceable
Manager to list and execute queries
-
Field Summary
Modifier and TypeFieldDescriptionprotected ServiceManager
The service managerstatic final String
global configuration about queriesstatic final String
site configuration about queriesstatic final String
global configuration about queries limitstatic final String
Avalon Role -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionexecuteQuery
(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 contentgetQueries
(AmetysObject ametysObject) Get all queries available in a specificQueryContainer
getQueries
(Site site) List all queries available for the mobile appgetQueriesForResult
(String contentId, Site site) Execute all queries to return the list of the queries that return this objectgetQueriesForResult
(List<String> contents, Site site) Execute all queries to return the list of the queries that return this objectgetQueriesForResult
(AmetysObject content, Site site) 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_CONTAINER_SITE_CONF_ID
site configuration about queries- See Also:
-
QUERY_LIMIT_CONF_ID
global configuration about queries limit- See Also:
-
_manager
The service manager
-
-
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
-
getQueries
List all queries available for the mobile app- Parameters:
site
- the site. May be null- 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 testsite
- the site. May be null- 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 idsite
- the site. May be null- 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 testsite
- the site. May be null- 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
-