info.magnolia.cms.util
Class QueryUtil

java.lang.Object
  extended by info.magnolia.cms.util.QueryUtil

public class QueryUtil
extends Object

Util to execute queries as simple as possible.

Version:
$Id$

Constructor Summary
QueryUtil()
           
 
Method Summary
static String buildQuery(String statement, String startPath)
          Creates a simple SQL2 query statement.
static String createDateExpression(Calendar calendar)
          Deprecated. since 4.5.4 use info.magnolia.cms.util.DateUtil.createDateExpression(calendar)
static String createDateExpression(int year, int month, int day)
          Deprecated.  
static String createDateTimeExpression(Calendar calendar)
          Deprecated. since 4.5.4 use info.magnolia.cms.util.DateUtil.createDateTimeExpression(calendar)
static String createDateTimeExpression(int year, int month, int day, int hour, int minutes, int seconds)
          Deprecated.  
static String createDateTimeExpressionIgnoreTimeZone(Calendar calendar)
          Deprecated. since 4.5.4 use info.magnolia.cms.util.DateUtil.createDateTimeExpressionIgnoreTimeZone(calendar)
static String createDateTimeExpressionIgnoreTimeZone(int year, int month, int day, int hour, int minutes, int seconds)
          Deprecated.  
static Collection<Content> exceptionThrowingQuery(String repository, String statement, String language, String returnItemType)
          Deprecated. Since 4.5.4 use search methods.
static Collection<Content> exceptionThrowingQuery(String repository, String statement, String language, String returnItemType, long maxResultSize)
          Deprecated. Since 4.5.4 use search methods.
static Collection<Content> query(String repository, String statement)
          Deprecated. Since 4.5.4 use search methods.
static Collection<Content> query(String repository, String statement, String language)
          Deprecated. Since 4.5.4 use search methods.
static Collection<Content> query(String repository, String statement, String language, String returnItemType)
          Deprecated. Since 4.5.4 use search methods.
static Collection<Content> query(String repository, String statement, String language, String returnItemType, long maxResultSize)
          Deprecated. Since 4.5.4 use search methods.
static javax.jcr.NodeIterator search(javax.jcr.query.qom.QueryObjectModel model, String returnItemType)
          Executes the query based on QOM and then pops-up in the node hierarchy until returnItemType is found.
static javax.jcr.NodeIterator search(String workspace, String statement)
          Executes the query using JCR SQL2 language.
static javax.jcr.NodeIterator search(String workspace, String statement, String language)
          Executes the query with given language.Unlike in the old API item type has to be specified in query itself.
static javax.jcr.NodeIterator search(String workspace, String statement, String language, String returnItemType)
          Searches for statement and then pops-up in the node hierarchy until returnItemType is found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryUtil

public QueryUtil()
Method Detail

query

public static Collection<Content> query(String repository,
                                        String statement)
Deprecated. Since 4.5.4 use search methods.

Executes a query.


query

public static Collection<Content> query(String repository,
                                        String statement,
                                        String language)
Deprecated. Since 4.5.4 use search methods.

Executes a query.


exceptionThrowingQuery

public static Collection<Content> exceptionThrowingQuery(String repository,
                                                         String statement,
                                                         String language,
                                                         String returnItemType)
                                                  throws javax.jcr.RepositoryException
Deprecated. Since 4.5.4 use search methods.

Throws:
javax.jcr.RepositoryException

exceptionThrowingQuery

public static Collection<Content> exceptionThrowingQuery(String repository,
                                                         String statement,
                                                         String language,
                                                         String returnItemType,
                                                         long maxResultSize)
                                                  throws javax.jcr.RepositoryException
Deprecated. Since 4.5.4 use search methods.

Executes a query, throwing any exceptions that arise as a result.

Throws:
javax.jcr.RepositoryException

query

public static Collection<Content> query(String repository,
                                        String statement,
                                        String language,
                                        String returnItemType)
Deprecated. Since 4.5.4 use search methods.


query

public static Collection<Content> query(String repository,
                                        String statement,
                                        String language,
                                        String returnItemType,
                                        long maxResultSize)
Deprecated. Since 4.5.4 use search methods.

Executes a query - if an exception is thrown, it is logged and an empty collection is returned.


createDateExpression

public static String createDateExpression(int year,
                                          int month,
                                          int day)
Deprecated. 

Parameters:
month - 1-12 (as opposed to java.util.Calendar 0-11 notation)

createDateExpression

public static String createDateExpression(Calendar calendar)
Deprecated. since 4.5.4 use info.magnolia.cms.util.DateUtil.createDateExpression(calendar)

Expression representing a date.


createDateTimeExpression

public static String createDateTimeExpression(int year,
                                              int month,
                                              int day,
                                              int hour,
                                              int minutes,
                                              int seconds)
Deprecated. 

Parameters:
month - 1-12 (as opposed to java.util.Calendar 0-11 notation)

createDateTimeExpression

public static String createDateTimeExpression(Calendar calendar)
Deprecated. since 4.5.4 use info.magnolia.cms.util.DateUtil.createDateTimeExpression(calendar)

Expression representing a date and time.


createDateTimeExpressionIgnoreTimeZone

public static String createDateTimeExpressionIgnoreTimeZone(int year,
                                                            int month,
                                                            int day,
                                                            int hour,
                                                            int minutes,
                                                            int seconds)
Deprecated. 

Parameters:
month - 1-12 (as opposed to java.util.Calendar 0-11 notation)

createDateTimeExpressionIgnoreTimeZone

public static String createDateTimeExpressionIgnoreTimeZone(Calendar calendar)
Deprecated. since 4.5.4 use info.magnolia.cms.util.DateUtil.createDateTimeExpressionIgnoreTimeZone(calendar)

Do not consider the timezone.


search

public static javax.jcr.NodeIterator search(javax.jcr.query.qom.QueryObjectModel model,
                                            String returnItemType)
                                     throws javax.jcr.query.InvalidQueryException,
                                            javax.jcr.RepositoryException
Executes the query based on QOM and then pops-up in the node hierarchy until returnItemType is found. If the result is not returnItemType or none of its parents are then next node in result is checked. Duplicate nodes are removed from result. For date/time expressions use DateUtil.create*Expression() methods.

Parameters:
model -
returnItemType -
Returns:
Result as NodeIterator
Throws:
javax.jcr.query.InvalidQueryException
javax.jcr.RepositoryException

search

public static javax.jcr.NodeIterator search(String workspace,
                                            String statement,
                                            String language)
                                     throws javax.jcr.query.InvalidQueryException,
                                            javax.jcr.RepositoryException
Executes the query with given language.Unlike in the old API item type has to be specified in query itself. SELECT * FROM [mgnl:page] example for selecting just pages in JCR SQL2 language. Duplicate nodes are removed from result. For date/time expressions use DateUtil.create*Expression() methods.

Parameters:
workspace -
statement -
language -
Returns:
Result as NodeIterator
Throws:
javax.jcr.query.InvalidQueryException
javax.jcr.RepositoryException

search

public static javax.jcr.NodeIterator search(String workspace,
                                            String statement)
                                     throws javax.jcr.query.InvalidQueryException,
                                            javax.jcr.RepositoryException
Executes the query using JCR SQL2 language. Unlike in the old API item type has to be specified in query itself. SELECT * FROM [mgnl:page] example for selecting just pages. For executing old query use info.magnolia.cms.util.QueryUtil.search(String workspace, String statement, String language) where you specify Query.SQL as the language. For date/time expressions use DateUtil.create*Expression() methods.

Parameters:
workspace -
statement -
Returns:
Result as NodeIterator
Throws:
javax.jcr.query.InvalidQueryException
javax.jcr.RepositoryException

search

public static javax.jcr.NodeIterator search(String workspace,
                                            String statement,
                                            String language,
                                            String returnItemType)
                                     throws javax.jcr.LoginException,
                                            javax.jcr.RepositoryException
Searches for statement and then pops-up in the node hierarchy until returnItemType is found. If the result is not returnItemType or none of its parents are then next node in result is checked. Duplicate nodes are removed from result. For date/time expressions use DateUtil.create*Expression() methods.

Parameters:
workspace -
statement -
language -
returnItemType -
Returns:
query result as collection of nodes
Throws:
javax.jcr.LoginException
javax.jcr.RepositoryException

buildQuery

public static String buildQuery(String statement,
                                String startPath)
Creates a simple SQL2 query statement.

Parameters:
statement -
startPath -


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