- Timestamp:
- Mar 29, 2009, 11:56:11 PM (16 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grails-app/controllers/TaskModificationController.groovy
r92 r93 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 class ModificationController extends BaseController {3 class TaskModificationController extends BaseController { 4 4 5 5 def index = { redirect(action:list,params:params) } … … 9 9 10 10 def list = { 11 if(!params.max) params.max = 1012 [ modificationInstanceList: Modification.list( params) ]11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ taskModificationInstanceList: TaskModification.list( params ), taskModificationInstanceTotal: TaskModification.count() ] 13 13 } 14 14 15 15 def show = { 16 def modificationInstance =Modification.get( params.id )16 def taskModificationInstance = TaskModification.get( params.id ) 17 17 18 if(! modificationInstance) {19 flash.message = " Modification not found with id ${params.id}"18 if(!taskModificationInstance) { 19 flash.message = "TaskModification not found with id ${params.id}" 20 20 redirect(action:list) 21 21 } 22 else { return [ modificationInstance : modificationInstance ] }22 else { return [ taskModificationInstance : taskModificationInstance ] } 23 23 } 24 24 25 25 def delete = { 26 def modificationInstance = Modification.get( params.id ) 27 if(modificationInstance) { 28 modificationInstance.delete() 29 flash.message = "Modification ${params.id} deleted" 30 redirect(action:list) 26 def taskModificationInstance = TaskModification.get( params.id ) 27 if(taskModificationInstance) { 28 try { 29 taskModificationInstance.delete() 30 flash.message = "TaskModification ${params.id} deleted" 31 redirect(action:list) 32 } 33 catch(org.springframework.dao.DataIntegrityViolationException e) { 34 flash.message = "TaskModification ${params.id} could not be deleted" 35 redirect(action:show,id:params.id) 36 } 31 37 } 32 38 else { 33 flash.message = " Modification not found with id ${params.id}"39 flash.message = "TaskModification not found with id ${params.id}" 34 40 redirect(action:list) 35 41 } … … 37 43 38 44 def edit = { 39 def modificationInstance =Modification.get( params.id )45 def taskModificationInstance = TaskModification.get( params.id ) 40 46 41 if(! modificationInstance) {42 flash.message = " Modification not found with id ${params.id}"47 if(!taskModificationInstance) { 48 flash.message = "TaskModification not found with id ${params.id}" 43 49 redirect(action:list) 44 50 } 45 51 else { 46 return [ modificationInstance : modificationInstance ]52 return [ taskModificationInstance : taskModificationInstance ] 47 53 } 48 54 } 49 55 50 56 def update = { 51 def modificationInstance = Modification.get( params.id ) 52 if(modificationInstance) { 53 modificationInstance.properties = params 54 if(!modificationInstance.hasErrors() && modificationInstance.save()) { 55 flash.message = "Modification ${params.id} updated" 56 redirect(action:show,id:modificationInstance.id) 57 def taskModificationInstance = TaskModification.get( params.id ) 58 if(taskModificationInstance) { 59 if(params.version) { 60 def version = params.version.toLong() 61 if(taskModificationInstance.version > version) { 62 63 taskModificationInstance.errors.rejectValue("version", "taskModification.optimistic.locking.failure", "Another user has updated this TaskModification while you were editing.") 64 render(view:'edit',model:[taskModificationInstance:taskModificationInstance]) 65 return 66 } 67 } 68 taskModificationInstance.properties = params 69 if(!taskModificationInstance.hasErrors() && taskModificationInstance.save()) { 70 flash.message = "TaskModification ${params.id} updated" 71 redirect(action:show,id:taskModificationInstance.id) 57 72 } 58 73 else { 59 render(view:'edit',model:[ modificationInstance:modificationInstance])74 render(view:'edit',model:[taskModificationInstance:taskModificationInstance]) 60 75 } 61 76 } 62 77 else { 63 flash.message = " Modification not found with id ${params.id}"78 flash.message = "TaskModification not found with id ${params.id}" 64 79 redirect(action:edit,id:params.id) 65 80 } … … 67 82 68 83 def create = { 69 def modificationInstance = newModification()70 modificationInstance.properties = params71 return [' modificationInstance':modificationInstance]84 def taskModificationInstance = new TaskModification() 85 taskModificationInstance.properties = params 86 return ['taskModificationInstance':taskModificationInstance] 72 87 } 73 88 74 89 def save = { 75 def modificationInstance = newModification(params)76 if(! modificationInstance.hasErrors() && modificationInstance.save()) {77 flash.message = " Modification ${modificationInstance.id} created"78 redirect(action:show,id: modificationInstance.id)90 def taskModificationInstance = new TaskModification(params) 91 if(!taskModificationInstance.hasErrors() && taskModificationInstance.save()) { 92 flash.message = "TaskModification ${taskModificationInstance.id} created" 93 redirect(action:show,id:taskModificationInstance.id) 79 94 } 80 95 else { 81 render(view:'create',model:[ modificationInstance:modificationInstance])96 render(view:'create',model:[taskModificationInstance:taskModificationInstance]) 82 97 } 83 98 }
Note: See TracChangeset
for help on using the changeset viewer.