info.magnolia.module.rssaggregator.util
Interface MagnoliaQueryOperations

All Known Implementing Classes:
MagnoliaTemplate

public interface MagnoliaQueryOperations

Specifies a basic set of Magnolia query operations. Implemented by MagnoliaTemplate. Not often used directly, but a useful option to enhance testability, as it can easily be mocked or stubbed.

Author:
Rob van der Linden Vooren
See Also:
MagnoliaTemplate

Method Summary
<T> List<T>
queryForList(String repository, String query, String language, String type, ContentMapper<T> mapper)
          Execute a query for a result list of type T, for the given query.
<T> T
queryForObject(String repository, String query, String language, String type, ContentMapper<T> mapper)
          Execute a query for a single or null result object, for the given query.
 javax.jcr.Node xpathQueryForContent(String repository, String query, String type)
          Execute an XPath query for a Content node.
<T> List<T>
xpathQueryForList(String repository, String query, String type, ContentMapper<T> mapper)
          Execute an XPath query for a result list of type T, for the given query.
<T> T
xpathQueryForObject(String repository, String query, String type, ContentMapper<T> mapper)
          Execute an XPath query for a single or null result object, for the given query.
 

Method Detail

queryForObject

<T> T queryForObject(String repository,
                     String query,
                     String language,
                     String type,
                     ContentMapper<T> mapper)
                 throws DataAccessException
Execute a query for a single or null result object, for the given query.

This method is useful for running queries with a known outcome. The query is expected to be a single result query; the returned result will be directly mapped to the corresponding object type.

Parameters:
repository - the repository to execute query against
query - query to execute
language - query language (either XPATH or SQL).
type - the type of the item to query for
mapper - the mapper used
Returns:
the result object of the required type, or null in case of a null query
Throws:
IncorrectResultSizeDataAccessException - if the query returns more than one results
DataAccessException - if there is any problem executing the query

queryForList

<T> List<T> queryForList(String repository,
                         String query,
                         String language,
                         String type,
                         ContentMapper<T> mapper)
                     throws DataAccessException
Execute a query for a result list of type T, for the given query.

Parameters:
repository - the repository to execute query against
query - query to execute
language - query language (either XPATH or SQL).
type - the type of the item to query for
mapper - the mapper used
Returns:
the result object of the required type, or null in case of a null query
Throws:
DataAccessException - if there is any problem executing the query

xpathQueryForObject

<T> T xpathQueryForObject(String repository,
                          String query,
                          String type,
                          ContentMapper<T> mapper)
                      throws DataAccessException
Execute an XPath query for a single or null result object, for the given query.

This method is useful for running queries with a known outcome. The query is expected to be a single result query; the returned result will be directly mapped to the corresponding object type.

Parameters:
repository - the repository to execute query against
query - query to execute
type - the type of the item to query for
mapper - the mapper used
Returns:
the result object of the required type, or null in case of a null query
Throws:
IncorrectResultSizeDataAccessException - if the query returns more than one results
DataAccessException - if there is any problem executing the query

xpathQueryForList

<T> List<T> xpathQueryForList(String repository,
                              String query,
                              String type,
                              ContentMapper<T> mapper)
                          throws DataAccessException
Execute an XPath query for a result list of type T, for the given query.

Parameters:
repository - the repository to execute query against
query - query to execute
type - the type of the item to query for
mapper - the mapper used
Returns:
the result object of the required type, or null in case of a null Xpath query
Throws:
DataAccessException - if there is any problem executing the query

xpathQueryForContent

javax.jcr.Node xpathQueryForContent(String repository,
                                    String query,
                                    String type)
                                    throws DataAccessException
Execute an XPath query for a Content node.

Parameters:
repository - the repository to execute query against
query - query to execute
type - the type of the item to query for
Returns:
the result Content node, or null if no such node exists
Throws:
DataAccessException - if there is any problem executing the query


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.