* @see org.andromda.timetracker.domain.TimecardDao#findByCriteria(org.andromda.timetracker.vo.TimecardSearchCriteriaVO)
*/
protected java.util.List handleFindByCriteria(org.andromda.timetracker.vo.TimecardSearchCriteriaVO criteria)
{
// Create the timecard criteria
Criteria timecardCriteria = this.getSession()
.createCriteria(Timecard.class)
.setFetchMode("submitter", FetchMode.JOIN)
.setFetchMode("approver", FetchMode.JOIN);
// Add submitter criteria
if (criteria.getSubmitterId() != null) {
timecardCriteria.createCriteria("submitter")
.add(Restrictions.idEq(criteria.getSubmitterId()));
}
// Add approver criteria
if (criteria.getApproverId() != null) {
timecardCriteria.createCriteria("approver")
.add(Restrictions.idEq(criteria.getApproverId()));
}
// Add status criteria
if (criteria.getStatus() != null) {
timecardCriteria.add(Restrictions.eq("status", criteria.getStatus()));
}
// Add startDateMin criteria
if (criteria.getStartDateMin() != null) {
timecardCriteria.add(Restrictions.ge("startDate", criteria.getStartDateMin()));
}
// Add startDateMax criteria
if (criteria.getStartDateMax() != null) {
timecardCriteria.add(Restrictions.le("startDate", criteria.getStartDateMax()));
}
java.util.List timecards = timecardCriteria.list();
if (logger.isDebugEnabled()) {
logger.debug(timecards.size() + " timecards found");
}
return timecards;
}