Ignore:
Timestamp:
Mar 31, 2009, 5:43:09 AM (16 years ago)
Author:
gav
Message:

Implemented the bulk of AssignedPerson? domain

File:
1 edited

Legend:

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

    r85 r96  
    11import org.codehaus.groovy.grails.plugins.springsecurity.Secured
    22
    3 @Secured(['ROLE_AppAdmin'])
    4 class TaskController extends BaseController {
     3class TaskController extends BaseAppAdminController {
    54   
    65    def index = { redirect(action:list,params:params) }
     
    109
    1110    def list = {
    12         if(!params.max) params.max = 10
    13         [ taskInstanceList: Task.list( params ) ]
     11        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
     12        [ taskInstanceList: Task.list( params ), taskInstanceTotal: Task.count() ]
    1413    }
     14
    1515    def show = {
    1616        def taskInstance = Task.get( params.id )
     
    2222        else { return [ taskInstance : taskInstance ] }
    2323    }
    24  
     24
    2525    def delete = {
    2626        def taskInstance = Task.get( params.id )
    2727        if(taskInstance) {
    28             taskInstance.delete()
    29             flash.message = "Task ${params.id} deleted"
    30             redirect(action:list)
     28            try {
     29                taskInstance.delete()
     30                flash.message = "Task ${params.id} deleted"
     31                redirect(action:list)
     32            }
     33            catch(org.springframework.dao.DataIntegrityViolationException e) {
     34                flash.message = "Task ${params.id} could not be deleted"
     35                redirect(action:show,id:params.id)
     36            }
    3137        }
    3238        else {
     
    5157        def taskInstance = Task.get( params.id )
    5258        if(taskInstance) {
     59            if(params.version) {
     60                def version = params.version.toLong()
     61                if(taskInstance.version > version) {
     62                   
     63                    taskInstance.errors.rejectValue("version", "task.optimistic.locking.failure", "Another user has updated this Task while you were editing.")
     64                    render(view:'edit',model:[taskInstance:taskInstance])
     65                    return
     66                }
     67            }
    5368            taskInstance.properties = params
    5469            if(!taskInstance.hasErrors() && taskInstance.save()) {
     
    8297        }
    8398    }
    84 
    8599}
Note: See TracChangeset for help on using the changeset viewer.