|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.squashtest.csp.tm.domain.report.query.hibernate.HibernateReportQuery
public abstract class HibernateReportQuery
This class is an implementation of ReportQuery meant for a Hibernate repository.
The goal of that Hibernate-oriented ReportQuery is to provide the Dao executing it with a DetachedCriteria query.
Note that an HibernateReportQuery will return a HibernateQueryFlavor by design.
That abstract class is a superclass for other queries. Note that this abstract class extends the ReportQuery interface by
far, including a post processing method 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.
| Field Summary | |
|---|---|
protected Map<String,ReportCriterion> |
criterions
|
| Constructor Summary | |
|---|---|
HibernateReportQuery()
|
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Map<String,ReportCriterion> criterions
| Constructor Detail |
|---|
public HibernateReportQuery()
| Method Detail |
|---|
public ReportQueryFlavor getFlavor()
getFlavor in interface ReportQuery
public void setCriterion(String name,
Object... values)
ReportQuery
setCriterion 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)
ReportQuery
SetDataFilteringService in interface ReportQueryprotected DataFilteringService getDataFilteringService()
protected Map<String,ReportCriterion> getCriterions()
public Collection<String> getCriterionNames()
getCriterionNames in interface ReportQuerypublic boolean isCriterionExists(String name)
ReportQuery
isCriterionExists 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 paramters
protected 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||