Class QueriesHelper

All Implemented Interfaces:
LogEnabled, Component, Serviceable

public class QueriesHelper extends AbstractLogEnabled implements Serviceable, Component
Manager to list and execute queries
  • Field Details

  • Constructor Details

  • Method Details

    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      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

      public List<Query> getQueries(Site site)
      List all queries available for the mobile app
      Parameters:
      site - the site. May be null
      Returns:
      a list of Query
    • getQueries

      public List<Query> getQueries(AmetysObject ametysObject)
      Get all queries available in a specific QueryContainer
      Parameters:
      ametysObject - a QueryContainer to parse, or directly a Query to return in a list
      Returns:
      a list containing all Query available in this QueryContainer
    • executeQuery

      public AmetysObjectIterable<Content> executeQuery(Query query, List<Sort> sort, boolean checkRights)
      Execute a query, with a forced sort
      Parameters:
      query - the query to execute
      sort - a list of sert elements, can contain lastValidation
      checkRights - check the rights while executing the query
      Returns:
      the results of the query
    • getQueriesForResult

      public Set<Query> getQueriesForResult(AmetysObject content, Site site)
      Execute all queries to return the list of the queries that return this object
      Parameters:
      content - the object to test
      site - the site. May be null
      Returns:
      a list containing all the impacted queries
    • getQueriesForResult

      public Set<Query> getQueriesForResult(String contentId, Site site)
      Execute all queries to return the list of the queries that return this object
      Parameters:
      contentId - the content id
      site - the site. May be null
      Returns:
      a list containing all the impacted queries
    • getQueriesForResult

      public Map<String,Set<Query>> getQueriesForResult(List<String> contents, Site site)
      Execute all queries to return the list of the queries that return this object
      Parameters:
      contents - a list of object to test
      site - the site. May be null
      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 executed
      moreThanOne - 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

      public Instant toInstant(Object o1, Object o2)
      Transform a ZonedDateTime, LocalDate or Date to an instant
      Parameters:
      o1 - the date to transform
      o2 - 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 read
      field - the field to check
      Returns:
      the iso formatted date