org.jboss.seam.framework
Class Query<T,E>

java.lang.Object
  extended by org.jboss.seam.framework.Controller
      extended by org.jboss.seam.framework.PersistenceController<T>
          extended by org.jboss.seam.framework.Query<T,E>
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
EntityQuery, HibernateEntityQuery

public abstract class Query<T,E>
extends PersistenceController<T>

Base class for components which manage a query result set. This class may be reused by either configuration or extension, and may be bound directly to a view, or accessed by some intermediate Seam component.

Author:
Gavin King
See Also:
Serialized Form

Constructor Summary
Query()
           
 
Method Summary
protected  void clearDataModel()
           
protected  void evaluateAllParameters()
           
 void first()
          Move the result set cursor to the beginning of the first page
protected  java.lang.String getCountEjbql()
          Return the ejbql to used in a count query (for calculating number of results)
 javax.faces.model.DataModel getDataModel()
          Wrap the result set in a JSF DataModel Delegates to DataModels.getDataModel(Query)
 E getDataModelSelection()
          Get the selected row of the JSF DataModel
 int getDataModelSelectionIndex()
          Get the index of the selected row of the JSF DataModel
 java.lang.String getEjbql()
           
 java.lang.Integer getFirstResult()
          Returns the index of the first result of the current page
 java.lang.String getGroupBy()
           
 java.lang.Long getLastFirstResult()
          Get the index of the first result of the last page
 java.lang.Integer getMaxResults()
          The page size
 int getNextFirstResult()
          Get the index of the first result of the next page
 java.lang.String getOrder()
          The order clause of the query
 java.lang.String getOrderColumn()
           
 java.lang.String getOrderDirection()
           
 java.lang.Integer getPageCount()
          Get the total number of pages
 int getPreviousFirstResult()
          Get the index of the first result of the previous page
protected  java.util.List<Expressions.ValueExpression> getQueryParameters()
           
protected  java.util.List<java.lang.Object> getQueryParameterValues()
           
protected  java.lang.String getRenderedEjbql()
           
 java.util.List<java.lang.String> getRestrictionExpressionStrings()
           
 java.lang.String getRestrictionLogicOperator()
           
protected  java.util.List<Expressions.ValueExpression> getRestrictionParameters()
           
protected  java.util.List<java.lang.Object> getRestrictionParameterValues()
           
 java.util.List<Expressions.ValueExpression> getRestrictions()
          List of restrictions to apply to the query.
abstract  java.lang.Long getResultCount()
           
abstract  java.util.List<E> getResultList()
           
abstract  E getSingleResult()
           
protected  boolean isAnyParameterDirty()
           
abstract  boolean isNextExists()
          Returns true if next page exists
 boolean isPaginated()
          Returns true if the query is paginated, revealing whether navigation controls are needed.
 boolean isPreviousExists()
          Returns true if the previous page exists
protected  boolean isRestrictionParameterSet(java.lang.Object parameterValue)
           
protected  boolean isUseWildcardAsCountQuerySubject()
           
 void last()
          Move the result set cursor to the beginning of the last page
 void next()
          Move the result set cursor to the beginning of the next page
protected  void parseEjbql()
           
 void previous()
          Move the result set cursor to the beginning of the previous page
 void refresh()
           
 void setEjbql(java.lang.String ejbql)
          Set the ejbql to use.
 void setFirstResult(java.lang.Integer firstResult)
          Set the index at which the page to display should start
 void setGroupBy(java.lang.String groupBy)
           
 void setMaxResults(java.lang.Integer maxResults)
           
 void setOrder(java.lang.String order)
           
 void setOrderColumn(java.lang.String orderColumn)
           
 void setOrderDirection(java.lang.String orderDirection)
           
protected  void setQueryParameterValues(java.util.List<java.lang.Object> queryParameterValues)
           
 void setRestrictionExpressionStrings(java.util.List<java.lang.String> expressionStrings)
          A convenience method for registering the restrictions from Strings.
 void setRestrictionLogicOperator(java.lang.String operator)
           
protected  void setRestrictionParameterValues(java.util.List<java.lang.Object> restrictionParameterValues)
           
 void setRestrictions(java.util.List<Expressions.ValueExpression> restrictions)
          Calling setRestrictions causes the restrictions to be reparsed and the query refreshed
protected  void setUseWildcardAsCountQuerySubject(boolean useCompliantCountQuerySubject)
           
protected  java.util.List<E> truncResultList(java.util.List<E> results)
           
 void validate()
           
 
Methods inherited from class org.jboss.seam.framework.PersistenceController
getPersistenceContext, getPersistenceContextName, setPersistenceContext
 
Methods inherited from class org.jboss.seam.framework.Controller
addCookie, addFacesMessage, addFacesMessageFromResourceBundle, createValueExpression, createValueExpression, debug, debug, error, error, evaluateValueExpression, evaluateValueExpression, failValidation, fatal, fatal, getApplicationContext, getBusinessProcessContext, getComponentInstance, getComponentInstance, getConversation, getConversationContext, getCookie, getEventContext, getEvents, getFacesContext, getFacesMessages, getIdentity, getLog, getMessages, getMethodContext, getPageContext, getRedirect, getSessionContext, getStatusMessages, getValidator, getValidator, info, info, interpolate, invalidateSession, isTransactionMarkedRollback, raiseAsynchronousEvent, raiseEvent, raiseTransactionSuccessEvent, render, sendHttpError, sendHttpError, trace, trace, validationFailed, validationSucceeded, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Query

public Query()
Method Detail

getResultList

public abstract java.util.List<E> getResultList()

getSingleResult

public abstract E getSingleResult()

getResultCount

public abstract java.lang.Long getResultCount()

validate

@Create
public void validate()

getDataModel

@Transactional
public javax.faces.model.DataModel getDataModel()
Wrap the result set in a JSF DataModel Delegates to DataModels.getDataModel(Query)


getDataModelSelection

public E getDataModelSelection()
Get the selected row of the JSF DataModel


getDataModelSelectionIndex

public int getDataModelSelectionIndex()
Get the index of the selected row of the JSF DataModel


refresh

public void refresh()

last

@Transactional
public void last()
Move the result set cursor to the beginning of the last page


next

public void next()
Move the result set cursor to the beginning of the next page


previous

public void previous()
Move the result set cursor to the beginning of the previous page


first

public void first()
Move the result set cursor to the beginning of the first page


clearDataModel

protected void clearDataModel()

getLastFirstResult

@Transactional
public java.lang.Long getLastFirstResult()
Get the index of the first result of the last page


getNextFirstResult

public int getNextFirstResult()
Get the index of the first result of the next page


getPreviousFirstResult

public int getPreviousFirstResult()
Get the index of the first result of the previous page


getPageCount

@Transactional
public java.lang.Integer getPageCount()
Get the total number of pages


parseEjbql

protected void parseEjbql()

getRenderedEjbql

protected java.lang.String getRenderedEjbql()

isRestrictionParameterSet

protected boolean isRestrictionParameterSet(java.lang.Object parameterValue)

getCountEjbql

protected java.lang.String getCountEjbql()
Return the ejbql to used in a count query (for calculating number of results)

Returns:
String The ejbql query

getEjbql

public java.lang.String getEjbql()

setEjbql

public void setEjbql(java.lang.String ejbql)
Set the ejbql to use. Calling this causes the ejbql to be reparsed and the query to be refreshed


getFirstResult

public java.lang.Integer getFirstResult()
Returns the index of the first result of the current page


isPreviousExists

public boolean isPreviousExists()
Returns true if the previous page exists


isNextExists

public abstract boolean isNextExists()
Returns true if next page exists


isPaginated

public boolean isPaginated()
Returns true if the query is paginated, revealing whether navigation controls are needed.


setFirstResult

public void setFirstResult(java.lang.Integer firstResult)
Set the index at which the page to display should start


getMaxResults

public java.lang.Integer getMaxResults()
The page size


setMaxResults

public void setMaxResults(java.lang.Integer maxResults)

getRestrictions

public java.util.List<Expressions.ValueExpression> getRestrictions()
List of restrictions to apply to the query. For a query such as 'from Foo f' a restriction could be 'f.bar = #{foo.bar}'


setRestrictions

public void setRestrictions(java.util.List<Expressions.ValueExpression> restrictions)
Calling setRestrictions causes the restrictions to be reparsed and the query refreshed


setRestrictionExpressionStrings

public void setRestrictionExpressionStrings(java.util.List<java.lang.String> expressionStrings)
A convenience method for registering the restrictions from Strings. This method is primarily intended to be used from Java, not to expose a bean property for component configuration. Use setRestrictions() for the later.


getRestrictionExpressionStrings

public java.util.List<java.lang.String> getRestrictionExpressionStrings()

getGroupBy

public java.lang.String getGroupBy()

setGroupBy

public void setGroupBy(java.lang.String groupBy)

getOrder

public java.lang.String getOrder()
The order clause of the query


setOrder

public void setOrder(java.lang.String order)

getOrderDirection

public java.lang.String getOrderDirection()

setOrderDirection

public void setOrderDirection(java.lang.String orderDirection)

getOrderColumn

public java.lang.String getOrderColumn()

setOrderColumn

public void setOrderColumn(java.lang.String orderColumn)

getRestrictionLogicOperator

public java.lang.String getRestrictionLogicOperator()

setRestrictionLogicOperator

public void setRestrictionLogicOperator(java.lang.String operator)

getQueryParameters

protected java.util.List<Expressions.ValueExpression> getQueryParameters()

getRestrictionParameters

protected java.util.List<Expressions.ValueExpression> getRestrictionParameters()

evaluateAllParameters

protected void evaluateAllParameters()

isAnyParameterDirty

protected boolean isAnyParameterDirty()

getQueryParameterValues

protected java.util.List<java.lang.Object> getQueryParameterValues()

setQueryParameterValues

protected void setQueryParameterValues(java.util.List<java.lang.Object> queryParameterValues)

getRestrictionParameterValues

protected java.util.List<java.lang.Object> getRestrictionParameterValues()

setRestrictionParameterValues

protected void setRestrictionParameterValues(java.util.List<java.lang.Object> restrictionParameterValues)

truncResultList

protected java.util.List<E> truncResultList(java.util.List<E> results)

isUseWildcardAsCountQuerySubject

protected boolean isUseWildcardAsCountQuerySubject()

setUseWildcardAsCountQuerySubject

protected void setUseWildcardAsCountQuerySubject(boolean useCompliantCountQuerySubject)


Copyright © 2011 Seam Framework. All Rights Reserved.