Changeset 512 for trunk/grails-app/services
- Timestamp:
- Apr 28, 2010, 11:14:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskSearchService.groovy
r511 r512 157 157 */ 158 158 def getTasks(params, startDate=null, endDate=null) { 159 params.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 160 params.offset = params?.offset?.toInteger() ?: 0 161 params.sort = params?.sort ?: "attentionFlag" 162 params.order = params?.order ?: "desc" 163 164 startDate = startDate ?: dateUtilService.today 165 endDate = endDate ?: dateUtilService.tomorrow 166 167 def taskInstanceList = Task.createCriteria().list( 168 max: params.max, 169 offset: params.offset, 170 sort: params.sort, 171 order: params.order) { 172 lt("targetStartDate", endDate) 173 ge("targetCompletionDate", startDate) 174 eq("trash", false) 175 } // createCriteria 176 } // getTasks() 159 def paginateParams = [:] 160 paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax) 161 paginateParams.offset = params?.offset?.toInteger() ?: 0 162 163 def sort = "task." + (params?.sort ?: "attentionFlag") 164 def order = params?.order == "asc" ? "asc" : "desc" 165 def orderBy = " order by " + sort + ' ' + order 166 167 def namedParams = [:] 168 namedParams.startDate = startDate ?: dateUtilService.today 169 namedParams.endDate = endDate ?: dateUtilService.tomorrow 170 171 def baseQuery = "from Task as task \ 172 where (task.trash = false \ 173 and task.targetStartDate < :endDate \ 174 and task.targetCompletionDate >= :startDate \ 175 )" 176 177 def searchQuery = "select distinct task " + baseQuery + orderBy 178 def list = Task.executeQuery(searchQuery, namedParams, paginateParams) 179 180 def countQuery = "select count(distinct task) as taskCount " + baseQuery 181 def totalCount = Task.executeQuery(countQuery, namedParams)[0].toInteger() 182 183 def taskInstanceList = new PagedResultList(list, totalCount) 184 return taskInstanceList 185 } // getPTasks() 177 186 178 187 /**
Note: See TracChangeset
for help on using the changeset viewer.