public abstract class HibernateReportQuery extends Object implements ReportQuery
convertToDto(java.util.List). The
corresponding ReportQueryDao, namely HibernateReportQueryDao is aware of that method and will invoke it.
That method is useful for any post processing like the use of a DataFilteringService DataFilteringService,
ReportQuery or complex computations that would have been difficult to get directly from the repository.
For convenience this implementation uses a class to explicitly design the criteria for that query, the
ReportCriterion. A ReportCriterion is meant to hold informations and possibly generate a Hibernate Criterion that
will be used in the main DetachedCriteria query, but it's up to the implementor to use it or rebuild the Criterion
from scratch.
Subclassing a HibernateReportQuery : ========================================
- The constructor must create the needed ReportCriterion and add then to the list of ReportCriterions.
- createHibernateQuery() may generate a DetachedCriteria, or return null.
- doInSession(Session session) will be executed if createHibernateQuery() returned null.
- convertToDto() accepting a list of Hibernate entities and returning a list of different objects that fits the
definition of the view (probably a .jasper). Trick : if you couldn't translate your criterion into Hibernate
Criterion when implementing the createHibernateQuery() interface, you can postprocess the results with the remaining
criteria in this step.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,ReportCriterion> |
criterions |
| Constructor and Description |
|---|
HibernateReportQuery() |
| Modifier and Type | Method and Description |
|---|---|
protected org.hibernate.criterion.DetachedCriteria |
addCriterion(org.hibernate.criterion.DetachedCriteria criteria,
String criterionName)
Short hand for including a Hibernate Criterion in a DetachedCriteria.
|
abstract List<?> |
convertToDto(List<?> rawData)
This method will convert the raw results from Hibernate into a suitable list of Dto object that the view will
process in turn.
|
abstract org.hibernate.criterion.DetachedCriteria |
createHibernateQuery() |
abstract List<?> |
doInSession(org.hibernate.Session session)
if you really need it.
|
Collection<String> |
getCriterionNames() |
protected Map<String,ReportCriterion> |
getCriterions()
For internal use of the subclasses, this will return the concrete implementation of the criterions holder.
|
protected DataFilteringService |
getDataFilteringService() |
ReportQueryFlavor |
getFlavor() |
Object[] |
getValue(String key) |
boolean |
isCriterionExists(String name)
Checks if the given name matches one of the criterion used by this query.
|
void |
setCriterion(String name,
Object... values)
This method will set a criterion.
|
void |
setDataFilteringService(DataFilteringService service)
setter for a DataFilteringService.
|
protected Map<String,ReportCriterion> criterions
public ReportQueryFlavor getFlavor()
getFlavor in interface ReportQuerypublic void setCriterion(String name, Object... values)
ReportQuerysetCriterion in interface ReportQueryname - the name of the criterion you will feed with one or several values.values - an array (which can contains 0, 1 or more elements) containing the actual parameters.public void setDataFilteringService(DataFilteringService service)
ReportQuerysetDataFilteringService in interface ReportQueryprotected DataFilteringService getDataFilteringService()
protected Map<String,ReportCriterion> getCriterions()
public Collection<String> getCriterionNames()
getCriterionNames in interface ReportQuerypublic boolean isCriterionExists(String name)
ReportQueryisCriterionExists in interface ReportQueryname - the name one wants to check.public Object[] getValue(String key)
getValue in interface ReportQuerykey - the name of the criterion one want to check or retrieve the actual paramtersprotected org.hibernate.criterion.DetachedCriteria addCriterion(org.hibernate.criterion.DetachedCriteria criteria,
String criterionName)
criteria - the DetachedCriteria query to which we add a Criterion.criterionName - the name of the corresponding ReportCriterion.public abstract org.hibernate.criterion.DetachedCriteria createHibernateQuery()
public abstract List<?> doInSession(org.hibernate.Session session)
session - public abstract List<?> convertToDto(List<?> rawData)
rawData - a List of Hibernate entities.Copyright © 2010-2015 Henix, henix.fr. All Rights Reserved.