Ignore:
Timestamp:
Oct 3, 2009, 2:51:02 AM (15 years ago)
Author:
gav
Message:

Busy adding TaskSearchService?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/TaskDetailedController.groovy

    r140 r143  
    55    def authenticateService
    66    def dateUtilService
     7    def taskSearchService
    78    def filterService
    89
     
    1314
    1415    def list = {
    15         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
     16        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100 )
    1617        [ taskInstanceList: Task.list( params ), taskInstanceTotal: Task.count() ]
    1718    }
    18    
     19
    1920    def search = {
    20         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    21        
    22         if(!params._action_search)
     21        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100 )
     22
     23        if(!params.filter)
    2324        {
    24             // Default:
    25             def taskInstanceActivesList = Task.findAllByIsActive(true, params)
    26             def taskInstanceActivesTotal = Task.countByIsActive(true)
    27             return [taskInstanceList: taskInstanceActivesList, taskInstanceTotal: taskInstanceActivesTotal]
    28         }
    29         render( view:'search',
    30             model:[ taskInstanceList: filterService.filter( params, Task ),
    31             taskInstanceTotal: filterService.count( params, Task ),
    32             filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),
    33             params:params ] )
    34     }
    35    
     25//             if(params.searchMyTodays) { def taskInstanceList = taskSearchService.getMyTodays(params) }
     26//             else { def taskInstanceList = taskSearchService.getTodays(params) }
     27           
     28            def taskInstanceList = taskSearchService.getTodays(params)
     29
     30            if(taskInstanceList.totalCount > 0) { params.message = "Today's tasks" }
     31            else { params.message = "No tasks found for today" }
     32            return[ taskInstanceList: taskInstanceList, taskInstanceTotal: taskInstanceList.totalCount]
     33        }
     34        // filterPane:
     35        return[ taskInstanceList: filterService.filter( params, Task ),
     36            taskInstanceTotal: filterService.count( params, Task ),
     37            filterParams: com.zeddware.grails.plugins.filterpane.FilterUtils.extractFilterParams(params),
     38            params:params ]
     39    }
     40
    3641    def advancedSearch = {
    37         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
     42        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100 )
    3843
    3944        if(!params._action_advancedSearch)
     
    5156    }
    5257   
    53     def searchTodays = {
    54         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    55            
    56         def taskInstanceList = Task.createCriteria().list() {
    57                 eq("targetStartDate", dateUtilService.getToday())
    58                 eq("isActive", true)
    59         }
    60            
    61         def taskInstanceTotal = Task.createCriteria().count() {
    62                 eq("targetStartDate", dateUtilService.getToday())
    63                 eq("isActive", true)
    64         }
    65        
    66         if(taskInstanceTotal > 0)
    67         {
    68             flash.message = "Today's tasks"
    69         }
    70         else { flash.message = "No tasks found for today" }
    71        
    72         render( view:'search',
    73             model:[ taskInstanceList: taskInstanceList,
    74             taskInstanceTotal: taskInstanceTotal])
    75     }
    76    
    77     def searchMyTodays = {
    78         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
    79            
    80         def taskInstanceList = Task.createCriteria().list() {
    81                 eq("leadPerson", Person.get(authenticateService.userDomain().id))
    82                 ge("targetStartDate", dateUtilService.getToday())
    83                 eq("isActive", true)
    84         }
    85            
    86         def taskInstanceTotal = Task.createCriteria().count() {
    87                 eq("leadPerson", Person.get(authenticateService.userDomain().id))
    88                 ge("targetStartDate", dateUtilService.getToday())
    89                 eq("isActive", true)
    90         }
    91        
    92         if(taskInstanceTotal > 0)
    93         {
    94             flash.message = "Today's tasks"
    95         }
    96         else { flash.message = "No tasks found for today" }
    97        
    98         render( view:'search',
    99             model:[ taskInstanceList: taskInstanceList,
    100             taskInstanceTotal: taskInstanceTotal])
    101     }
     58//     def searchTodays = {
     59//         def taskInstanceList = taskSearchService.getTodays(params)
     60//         
     61//         if(taskInstanceList.totalCount > 0)
     62//         {
     63//             flash.message = "Today's tasks"
     64//         }
     65//         else { flash.message = "No tasks found for today" }
     66//         
     67//         render( view:'search',
     68//             model:[ taskInstanceList: taskInstanceList,
     69//             taskInstanceTotal: taskInstanceList.totalCount])
     70//     }
     71   
     72//     def searchMyTodays = {
     73//         params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
     74//             
     75//         def taskInstanceList = Task.createCriteria().list() {
     76//                 eq("leadPerson", Person.get(authenticateService.userDomain().id))
     77//                 ge("targetStartDate", dateUtilService.getToday())
     78//                 eq("isActive", true)
     79//         }
     80//             
     81//         def taskInstanceTotal = Task.createCriteria().count() {
     82//                 eq("leadPerson", Person.get(authenticateService.userDomain().id))
     83//                 ge("targetStartDate", dateUtilService.getToday())
     84//                 eq("isActive", true)
     85//         }
     86//         
     87//         if(taskInstanceTotal > 0)
     88//         {
     89//             flash.message = "Today's tasks"
     90//         }
     91//         else { flash.message = "No tasks found for today" }
     92//         
     93//         render( view:'search',
     94//             model:[ taskInstanceList: taskInstanceList,
     95//             taskInstanceTotal: taskInstanceTotal])
     96//     }
    10297   
    10398    def searchInTheLastWeek = {
     
    284279        else {
    285280            def criteria = taskInstance.createCriteria()
    286             def results = criteria {
     281            def result = criteria {
    287282                and {
    288283                    notEqual('id', taskInstance.id)
    289284                    }
    290285            }
    291             return [ taskInstance : taskInstance, possibleParentList: results ]
     286            return [ taskInstance : taskInstance, possibleParentList: result ]
    292287        }
    293288    }
Note: See TracChangeset for help on using the changeset viewer.