Changeset 737 for trunk/grails-app/services
- Timestamp:
- Dec 8, 2010, 12:04:47 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/services/TaskSearchService.groovy
r736 r737 21 21 def getQuickSearchSelection() { 22 22 [ 'allTasks': g.message(code: 'task.search.text.all.tasks'), 23 'budgetPlanned': g.message(code: 'task.search.text.budget.planned'),24 'budgetUnplanned': g.message(code: 'task.search.text.budget.unplanned'),25 23 'personsImmediateCallouts': g.message(code: 'task.search.text.persons.immediate.callouts'), 26 24 'personsTasks': g.message(code: 'task.search.text.persons.tasks') … … 188 186 case "allTasks": 189 187 allTasks() 190 break191 case "budgetUnplanned":192 result.taskInstanceList = getBudgetTasks(params, TaskBudgetStatus.read(1), result.startDate, result.endDate+1)193 if(result.taskInstanceList.totalCount > 0) {194 if(result.startDate == result.endDate)195 result.message = getMessage(code:"task.search.text.budget.unplanned.message",196 args:[ formatted(result.startDate) ])197 else198 result.message = getMessage(code:"task.search.text.budget.unplanned.between.message",199 args:[ formatted(result.startDate), formatted(result.endDate) ])200 }201 else {202 if(result.startDate == result.endDate)203 result.message = getMessage(code:"task.search.text.budget.unplanned.none.found",204 args:[ formatted(result.startDate) ])205 else206 result.message = getMessage(code:"task.search.text.budget.unplanned.between.none.found",207 args:[ formatted(result.startDate), formatted(result.endDate) ])208 }209 break210 case "budgetPlanned":211 result.taskInstanceList = getBudgetTasks(params, TaskBudgetStatus.read(2), result.startDate, result.endDate+1)212 if(result.taskInstanceList.totalCount > 0) {213 if(result.startDate == result.endDate)214 result.message = getMessage(code:"task.search.text.budget.planned.message",215 args:[ formatted(result.startDate) ])216 else217 result.message = getMessage(code:"task.search.text.budget.planned.between.message",218 args:[ formatted(result.startDate), formatted(result.endDate) ])219 }220 else {221 if(result.startDate == result.endDate)222 result.message = getMessage(code:"task.search.text.budget.planned.none.found",223 args:[ formatted(result.startDate) ])224 else225 result.message = getMessage(code:"task.search.text.budget.planned.between.none.found",226 args:[ formatted(result.startDate), formatted(result.endDate) ])227 }228 188 break 229 189 default: … … 402 362 403 363 /** 404 * Get tasks by budget status, by default planned in the last week.405 * @param params The request params.406 * @param budgetStatus Defaults to planned.407 * @param startDate The start date to get tasks for, defaults to the start of today and is inclusive (greater than or equal to).408 * @param endDate The end date to get tasks for, defaults to the start of tomorrow and is exclusive (less than).409 */410 def getBudgetTasks(params, taskBudgetStatus=null, startDate=null, endDate=null) {411 def paginateParams = [:]412 paginateParams.max = Math.min(params?.max?.toInteger() ?: 10, paramsMax)413 paginateParams.offset = params?.offset?.toInteger() ?: 0414 415 def sort = "task." + (params?.sort ?: "targetStartDate")416 def order = params?.order == "desc" ? "desc" : "asc"417 def orderBy = " order by " + sort + ' ' + order418 419 def namedParams = [:]420 namedParams.taskBudgetStatus = taskBudgetStatus ?: TaskBudgetStatus.read(2) // Planned.421 namedParams.startDate = startDate ?: dateUtilService.today422 namedParams.endDate = endDate ?: dateUtilService.tomorrow423 424 def baseQuery = "from Task as task \425 where (task.trash = false \426 and task.taskBudgetStatus = :taskBudgetStatus \427 and task.targetStartDate < :endDate \428 and task.targetCompletionDate >= :startDate \429 )"430 431 def searchQuery = "select distinct task " + baseQuery + orderBy432 def list = Task.executeQuery(searchQuery, namedParams, paginateParams)433 434 def countQuery = "select count(distinct task) as taskCount " + baseQuery435 def totalCount = Task.executeQuery(countQuery, namedParams)[0].toInteger()436 437 def taskInstanceList = new PagedResultList(list, totalCount)438 return taskInstanceList439 } // getBudgetTasks()440 441 /**442 364 * Get work done by person and date. 443 365 * A person ID and date may be specified in params otherwise the current user and today are used.
Note: See TracChangeset
for help on using the changeset viewer.