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
Fields Modifier and Type Field Description protected static String
__QUERY_CONTAINER_CONF_ID
global configuration about queriesprotected static String
__QUERY_LIMIT_CONF_ID
global configuration about queries limitprotected Context
_context
The contextprotected ServiceManager
_manager
The service managerstatic String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description QueriesHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
contextualize(Context context)
AmetysObjectIterable<Content>
executeQuery(Query query, List<Sort> sort, boolean checkRights)
Execute a query, with a forced sortString
getContentFormattedDate(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
getContentSearcherFactory()
Getter for ContentSearcherFactory to avoid problems at startupprotected ContentTypesHelper
getContentTypesHelper()
Getter for ContentTypesHelper to avoid problems at startupMap<String,String>
getDataForContent(Content content)
Get a json object representing the contentList<Query>
getQueries()
List all queries available for the mobile appList<Query>
getQueries(AmetysObject ametysObject)
Get all queries available in a specificQueryContainer
List<Query>
getQueriesForResult(String contentId)
Execute all queries to return the list of the queries that return this objectMap<String,List<Query>>
getQueriesForResult(List<String> contents)
Execute all queries to return the list of the queries that return this objectList<Query>
getQueriesForResult(AmetysObject content)
Execute all queries to return the list of the queries that return this objectprotected QueryHelper
getQueriesManager()
Getter for QueriesManager to avoid problems at startupprotected AmetysObjectResolver
getResolver()
Getter for AmetysObjectResolver to avoid problems at startupprotected SearchUIModelExtensionPoint
getSearchUIModelExtensionPoint()
Getter for SearchUIModelExtensionPoint to avoid problems at startupprotected SiteManager
getSiteManager()
Getter for SiteManager to avoid problems at startupList<Sort>
getSortProperty(Query query, boolean moreThanOne)
Generate a list of sort properties.void
service(ServiceManager manager)
Instant
toInstant(Object o1, Object o2)
Transform a ZonedDateTime, LocalDate or Date to an instant-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__QUERY_CONTAINER_CONF_ID
protected static final String __QUERY_CONTAINER_CONF_ID
global configuration about queries- See Also:
- Constant Field Values
-
__QUERY_LIMIT_CONF_ID
protected static final String __QUERY_LIMIT_CONF_ID
global configuration about queries limit- See Also:
- Constant Field Values
-
_manager
protected ServiceManager _manager
The service manager
-
-
Constructor Detail
-
QueriesHelper
public QueriesHelper()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getResolver
protected AmetysObjectResolver getResolver()
Getter for AmetysObjectResolver to avoid problems at startup- Returns:
- AmetysObjectResolver
-
getQueriesManager
protected QueryHelper getQueriesManager()
Getter for QueriesManager to avoid problems at startup- Returns:
- QueriesManager
-
getSearchUIModelExtensionPoint
protected SearchUIModelExtensionPoint getSearchUIModelExtensionPoint()
Getter for SearchUIModelExtensionPoint to avoid problems at startup- Returns:
- SearchUIModelExtensionPoint
-
getContentTypesHelper
protected ContentTypesHelper getContentTypesHelper()
Getter for ContentTypesHelper to avoid problems at startup- Returns:
- ContentTypesHelper
-
getSiteManager
protected SiteManager getSiteManager()
Getter for SiteManager to avoid problems at startup- Returns:
- SiteManager
-
getContentSearcherFactory
protected ContentSearcherFactory getContentSearcherFactory()
Getter for ContentSearcherFactory to avoid problems at startup- Returns:
- ContentSearcherFactory
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
getQueries
public List<Query> getQueries()
List all queries available for the mobile app- Returns:
- a list of
Query
-
getQueries
public List<Query> getQueries(AmetysObject ametysObject)
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
public List<Query> getQueriesForResult(AmetysObject content)
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
public List<Query> getQueriesForResult(String contentId)
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
public Map<String,List<Query>> getQueriesForResult(List<String> contents)
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
public List<Sort> getSortProperty(Query query, boolean moreThanOne)
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
public Map<String,String> getDataForContent(Content content)
Get a json object representing the content- Parameters:
content
- tho content to parse- Returns:
- a json map
-
toInstant
public Instant toInstant(Object o1, Object o2)
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
public String getContentFormattedDate(Content content, String field)
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
-
-