Last update: 2011-06-23

org.proteios.core
Class DataQuery<I extends BasicData>

java.lang.Object
  extended by org.proteios.core.DataQuery<I>
All Implemented Interfaces:
EntityQuery, HqlQuery, Query

public class DataQuery<I extends BasicData>
extends Object

An implementation of the Query interface that returns data objects. This type of query is only used for batchable items, like reporters and raw data.

Version:
2.0
Author:
Nicklas
Last modified
$Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $

Method Summary
 int count(DbControl dc)
          Count the number of items/rows that are returned by the query.
 void exclude(Include... excludes)
          Specify options for which items to exclude from the result.
 int getFirstResult()
          The number of the row the query should start returning.
 Item getItemType()
          The type of items the query returns.
 int getMaxResults()
          The maximum number of rows returned by the query.
 QueryType getQueryType()
          Get the type of query.
 String getRootAlias()
          The alias of the item that is returned by this query.
 void group(Expression expression)
          Not supported.
 void groupPermanent(Expression expression)
          Not supported.
 boolean hasParameterValue(String name)
          Check if a value for the specified parameter has been set or not.
 void having(Restriction restriction)
          Not supported.
 void havingPermanent(Restriction restriction)
          Not supported.
 void include(Include... includes)
          Specify options for which items to include in the result.
 boolean isCachingResult()
          If the query results are cached or not.
 boolean isDistinct()
          If this query returns distinct results of not.
 boolean isIncluded(Include... includes)
          Check which options are set for the items to include in the result
 boolean isReadonly()
          If this query is readonly and cannot be structurally modified.
 boolean isReturningTotalCount()
          If this query returns the total count or not.
 DataResultIterator<I> iterate(DbControl dc)
          Execute the query and return the results as an iterator.
 void join(Join join)
          Add a join query element to the join list.
 void joinPermanent(Join join)
          Permanently add a join query element to the join list.
 void order(Order order)
          Add an ordering query element to the orderby list.
 void orderPermanent(Order order)
          Permanently add an ordering query element to the orderby list.
 void reset()
          Reset all non-permanent query elements of the query and clear cached queries.
 void restrict(Restriction restriction)
          Add a restriction query element to the restriction list.
 void restrictPermanent(Restriction restriction)
          Permanently add a restriction query element to the restriction list.
 void select(Select select)
          Not supported.
 void selectPermanent(Select select)
          Not supported.
 void setCacheResult(boolean flag)
          Specify if the query results should be cached or not.
 void setDistinct(boolean flag)
          Specify if the query should only return distinct rows.
 void setFirstResult(int firstResult)
          Specify that the query should start returning rows from the specified row number. 0 = start returning from the first row.
 void setMaxResults(int maxResults)
          Specify that the query should at most return the specified number of rows.
 void setParameter(String name, Object value, Type valueType)
          Set the value of a query parameter.
 void setPermanentParameter(String name, Object value, Type valueType)
          Permanently set the value of a query parameter.
 void setReturnTotalCount(boolean flag)
          Specify if the query should return a count for the total number of items that would have been returned if the Query.setFirstResult(int) and Query.setMaxResults(int) had been disabled, or if the results are loaded by an iterator where the number of rows not are known beforehand.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.proteios.core.query.Query
getFirstResult, getMaxResults, hasParameterValue, isDistinct, isReturningTotalCount, join, joinPermanent, order, orderPermanent, restrict, restrictPermanent, setDistinct, setFirstResult, setMaxResults, setParameter, setPermanentParameter, setReturnTotalCount
 

Method Detail

iterate

public DataResultIterator<I> iterate(DbControl dc)
                                                throws BaseException
Execute the query and return the results as an iterator.

Parameters:
dc - The DbControl used to access the database and check permissions
Throws:
BaseException - If there is an error

select

public void select(Select select)
Not supported.

Specified by:
select in interface Query
Parameters:
select - The query element to add
Throws:
UnsupportedOperationException - Always
See Also:
Query.selectPermanent(Select)

selectPermanent

public void selectPermanent(Select select)
Not supported.

Specified by:
selectPermanent in interface Query
Parameters:
select - The query element to add
Throws:
UnsupportedOperationException - Always
See Also:
Query.select(Select)

group

public void group(Expression expression)
Not supported.

Specified by:
group in interface Query
Parameters:
expression - The query element to add
Throws:
UnsupportedOperationException - Always
See Also:
Query.groupPermanent(Expression)

groupPermanent

public void groupPermanent(Expression expression)
Not supported.

Specified by:
groupPermanent in interface Query
Parameters:
expression - The query element to add
Throws:
UnsupportedOperationException - Always
See Also:
Query.group(Expression)

having

public void having(Restriction restriction)
Not supported.

Specified by:
having in interface Query
Parameters:
restriction - The query element to add
Throws:
UnsupportedOperationException - Always
See Also:
Query.havingPermanent(Restriction)

havingPermanent

public void havingPermanent(Restriction restriction)
Not supported.

Specified by:
havingPermanent in interface Query
Parameters:
restriction - The query element to add
Throws:
UnsupportedOperationException - Always
See Also:
Query.having(Restriction)

getQueryType

public QueryType getQueryType()
Description copied from interface: Query
Get the type of query. Ie. The query language.

Specified by:
getQueryType in interface Query
Returns:
QueryType.HQL

getRootAlias

public String getRootAlias()
The alias of the item that is returned by this query.

Specified by:
getRootAlias in interface Query
See Also:
Item.getAlias()

isReadonly

public boolean isReadonly()
Description copied from interface: Query
If this query is readonly and cannot be structurally modified. Ie. no more query elements can be added. It is still possible to set parameter values. A call to Query.reset() would unlock the query and allow it to be modified again.

Specified by:
isReadonly in interface Query
Returns:
TRUE if the query is readonly, FALSE otherwise

reset

public void reset()
Reset all non-permanent query elements of the query and clear cached queries.

Specified by:
reset in interface Query

count

public int count(DbControl dc)
          throws BaseException
Description copied from interface: Query
Count the number of items/rows that are returned by the query. The method ignores the Query.getFirstResult() and Query.getMaxResults() settings.

Specified by:
count in interface Query
Returns:
The number of rows/items returned by the query
Throws:
BaseException - If there is an error

setCacheResult

public void setCacheResult(boolean flag)
Description copied from interface: HqlQuery
Specify if the query results should be cached or not.

Specified by:
setCacheResult in interface HqlQuery
Parameters:
flag - TRUE if the query results should be cached, FALSE otherwise

isCachingResult

public boolean isCachingResult()
Description copied from interface: HqlQuery
If the query results are cached or not.

Specified by:
isCachingResult in interface HqlQuery
See Also:
HqlQuery.setCacheResult(boolean)

getItemType

public Item getItemType()
Description copied from interface: EntityQuery
The type of items the query returns.

Specified by:
getItemType in interface EntityQuery

include

public void include(Include... includes)
Description copied from interface: EntityQuery
Specify options for which items to include in the result.

Specified by:
include in interface EntityQuery
Parameters:
includes - An array of items that should be included
See Also:
EntityQuery.exclude(Include[])

exclude

public void exclude(Include... excludes)
Description copied from interface: EntityQuery
Specify options for which items to exclude from the result.

Specified by:
exclude in interface EntityQuery
Parameters:
excludes - An array of options that should be excluded
See Also:
EntityQuery.include(Include[])

isIncluded

public boolean isIncluded(Include... includes)
Description copied from interface: EntityQuery
Check which options are set for the items to include in the result

Specified by:
isIncluded in interface EntityQuery
Parameters:
includes - The options to check
Returns:
TRUE If all specified options are included, FALSE otherwise

join

public void join(Join join)
          throws InvalidDataException,
                 BaseException
Description copied from interface: Query
Add a join query element to the join list.

Specified by:
join in interface Query
Parameters:
join - The query element to add
Throws:
InvalidDataException
BaseException
See Also:
Query.joinPermanent(Join)

joinPermanent

public void joinPermanent(Join join)
                   throws InvalidDataException,
                          BaseException
Description copied from interface: Query
Permanently add a join query element to the join list. The query element is not cleared by the Query.reset() method.

Specified by:
joinPermanent in interface Query
Parameters:
join - The query element to add
Throws:
InvalidDataException
BaseException
See Also:
Query.join(Join)

restrict

public void restrict(Restriction restriction)
              throws InvalidDataException,
                     BaseException
Description copied from interface: Query
Add a restriction query element to the restriction list.

Specified by:
restrict in interface Query
Parameters:
restriction - The query element to add
Throws:
InvalidDataException
BaseException
See Also:
Query.restrictPermanent(Restriction)

restrictPermanent

public void restrictPermanent(Restriction restriction)
                       throws InvalidDataException,
                              BaseException
Description copied from interface: Query
Permanently add a restriction query element to the restriction list. The query element is not cleared by the Query.reset() method.

Specified by:
restrictPermanent in interface Query
Parameters:
restriction - The query element to add
Throws:
InvalidDataException
BaseException
See Also:
Query.restrict(Restriction)

order

public void order(Order order)
           throws InvalidDataException,
                  BaseException
Description copied from interface: Query
Add an ordering query element to the orderby list.

Specified by:
order in interface Query
Parameters:
order - The query element to add
Throws:
InvalidDataException
BaseException
See Also:
Query.orderPermanent(Order)

orderPermanent

public void orderPermanent(Order order)
                    throws InvalidDataException,
                           BaseException
Description copied from interface: Query
Permanently add an ordering query element to the orderby list. The query element is not cleared by the Query.reset() method.

Specified by:
orderPermanent in interface Query
Parameters:
order - The query element to add
Throws:
InvalidDataException
BaseException
See Also:
Query.order(Order)

setParameter

public void setParameter(String name,
                         Object value,
                         Type valueType)
                  throws InvalidDataException,
                         BaseException
Description copied from interface: Query
Set the value of a query parameter. If the value of this parameter has already been set by a call to the Query.setPermanentParameter(String, Object, Type) method, an InvalidDataException is thrown.

Specified by:
setParameter in interface Query
Parameters:
name - The name of the parameter
value - The value of the parameter
valueType - The type of the value, or null if not needed
Throws:
InvalidDataException - If the value of the parameter has already been permanently set
BaseException
See Also:
Query.setPermanentParameter(String, Object, Type)

setPermanentParameter

public void setPermanentParameter(String name,
                                  Object value,
                                  Type valueType)
                           throws InvalidDataException,
                                  BaseException
Description copied from interface: Query
Permanently set the value of a query parameter. If the value of this parameter has already been set by a call to this method, an InvalidDataException is thrown.

Specified by:
setPermanentParameter in interface Query
Parameters:
name - The name of the parameter
value - The value of the parameter
valueType - The type of the value, or null if not needed
Throws:
InvalidDataException - If the value of the parameter has already been permanently set
BaseException
See Also:
Query.setParameter(String, Object, Type)

hasParameterValue

public boolean hasParameterValue(String name)
Description copied from interface: Query
Check if a value for the specified parameter has been set or not. The method should check both permanent and non-permanent parameters.

Specified by:
hasParameterValue in interface Query
Returns:
TRUE if a value (including null) has been set, FALSE otherwise

setFirstResult

public void setFirstResult(int firstResult)
Description copied from interface: Query
Specify that the query should start returning rows from the specified row number. 0 = start returning from the first row. If the value is higher than the total number of rows, no rows are returned. This option is best combined with the Query.setMaxResults(int) option.

Specified by:
setFirstResult in interface Query
Parameters:
firstResult - The number of the first row starting at 0
See Also:
Query.setMaxResults(int)

getFirstResult

public int getFirstResult()
Description copied from interface: Query
The number of the row the query should start returning.

Specified by:
getFirstResult in interface Query
See Also:
Query.setFirstResult(int)

setMaxResults

public void setMaxResults(int maxResults)
Description copied from interface: Query
Specify that the query should at most return the specified number of rows. If the matching number of rows is less than this value only the matching rows are returned. A value of 0 disabled this option. This option is best combined with the Query.setFirstResult(int) option.

Specified by:
setMaxResults in interface Query
Parameters:
maxResults - The maximum number of rows to return
See Also:
Query.setFirstResult(int)

getMaxResults

public int getMaxResults()
Description copied from interface: Query
The maximum number of rows returned by the query. A value of 0 indicates no limit.

Specified by:
getMaxResults in interface Query
See Also:
Query.setMaxResults(int)

setReturnTotalCount

public void setReturnTotalCount(boolean flag)
Description copied from interface: Query
Specify if the query should return a count for the total number of items that would have been returned if the Query.setFirstResult(int) and Query.setMaxResults(int) had been disabled, or if the results are loaded by an iterator where the number of rows not are known beforehand.

Specified by:
setReturnTotalCount in interface Query
Parameters:
flag - TRUE if the query should return the total count, FALSE otherwise

isReturningTotalCount

public boolean isReturningTotalCount()
Description copied from interface: Query
If this query returns the total count or not.

Specified by:
isReturningTotalCount in interface Query
See Also:
Query.setReturnTotalCount(boolean)

setDistinct

public void setDistinct(boolean flag)
Description copied from interface: Query
Specify if the query should only return distinct rows. Exctly what this means depends on what is selected by the query. For example, if we are selecting items no item would be returned more than once, if we are selecting numbers the same number wouldn't be returned more than once.

Specified by:
setDistinct in interface Query
Parameters:
flag - TRUE if the query should return distinct results, FALSE otherwise

isDistinct

public boolean isDistinct()
Description copied from interface: Query
If this query returns distinct results of not.

Specified by:
isDistinct in interface Query
See Also:
Query.setDistinct(boolean)

Last update: 2011-06-23