Index: trunk/src/grails-app/controllers/TaskModificationController.groovy
===================================================================
--- trunk/src/grails-app/controllers/ModificationController.groovy	(revision 89)
+++ trunk/src/grails-app/controllers/TaskModificationController.groovy	(revision 93)
@@ -1,5 +1,5 @@
 import org.codehaus.groovy.grails.plugins.springsecurity.Secured
 
-class ModificationController extends BaseController {
+class TaskModificationController extends BaseController {
     
     def index = { redirect(action:list,params:params) }
@@ -9,27 +9,33 @@
 
     def list = {
-        if(!params.max) params.max = 10
-        [ modificationInstanceList: Modification.list( params ) ]
+        params.max = Math.min( params.max ? params.max.toInteger() : 10,  100)
+        [ taskModificationInstanceList: TaskModification.list( params ), taskModificationInstanceTotal: TaskModification.count() ]
     }
 
     def show = {
-        def modificationInstance = Modification.get( params.id )
+        def taskModificationInstance = TaskModification.get( params.id )
 
-        if(!modificationInstance) {
-            flash.message = "Modification not found with id ${params.id}"
+        if(!taskModificationInstance) {
+            flash.message = "TaskModification not found with id ${params.id}"
             redirect(action:list)
         }
-        else { return [ modificationInstance : modificationInstance ] }
+        else { return [ taskModificationInstance : taskModificationInstance ] }
     }
 
     def delete = {
-        def modificationInstance = Modification.get( params.id )
-        if(modificationInstance) {
-            modificationInstance.delete()
-            flash.message = "Modification ${params.id} deleted"
-            redirect(action:list)
+        def taskModificationInstance = TaskModification.get( params.id )
+        if(taskModificationInstance) {
+            try {
+                taskModificationInstance.delete()
+                flash.message = "TaskModification ${params.id} deleted"
+                redirect(action:list)
+            }
+            catch(org.springframework.dao.DataIntegrityViolationException e) {
+                flash.message = "TaskModification ${params.id} could not be deleted"
+                redirect(action:show,id:params.id)
+            }
         }
         else {
-            flash.message = "Modification not found with id ${params.id}"
+            flash.message = "TaskModification not found with id ${params.id}"
             redirect(action:list)
         }
@@ -37,29 +43,38 @@
 
     def edit = {
-        def modificationInstance = Modification.get( params.id )
+        def taskModificationInstance = TaskModification.get( params.id )
 
-        if(!modificationInstance) {
-            flash.message = "Modification not found with id ${params.id}"
+        if(!taskModificationInstance) {
+            flash.message = "TaskModification not found with id ${params.id}"
             redirect(action:list)
         }
         else {
-            return [ modificationInstance : modificationInstance ]
+            return [ taskModificationInstance : taskModificationInstance ]
         }
     }
 
     def update = {
-        def modificationInstance = Modification.get( params.id )
-        if(modificationInstance) {
-            modificationInstance.properties = params
-            if(!modificationInstance.hasErrors() && modificationInstance.save()) {
-                flash.message = "Modification ${params.id} updated"
-                redirect(action:show,id:modificationInstance.id)
+        def taskModificationInstance = TaskModification.get( params.id )
+        if(taskModificationInstance) {
+            if(params.version) {
+                def version = params.version.toLong()
+                if(taskModificationInstance.version > version) {
+                    
+                    taskModificationInstance.errors.rejectValue("version", "taskModification.optimistic.locking.failure", "Another user has updated this TaskModification while you were editing.")
+                    render(view:'edit',model:[taskModificationInstance:taskModificationInstance])
+                    return
+                }
+            }
+            taskModificationInstance.properties = params
+            if(!taskModificationInstance.hasErrors() && taskModificationInstance.save()) {
+                flash.message = "TaskModification ${params.id} updated"
+                redirect(action:show,id:taskModificationInstance.id)
             }
             else {
-                render(view:'edit',model:[modificationInstance:modificationInstance])
+                render(view:'edit',model:[taskModificationInstance:taskModificationInstance])
             }
         }
         else {
-            flash.message = "Modification not found with id ${params.id}"
+            flash.message = "TaskModification not found with id ${params.id}"
             redirect(action:edit,id:params.id)
         }
@@ -67,17 +82,17 @@
 
     def create = {
-        def modificationInstance = new Modification()
-        modificationInstance.properties = params
-        return ['modificationInstance':modificationInstance]
+        def taskModificationInstance = new TaskModification()
+        taskModificationInstance.properties = params
+        return ['taskModificationInstance':taskModificationInstance]
     }
 
     def save = {
-        def modificationInstance = new Modification(params)
-        if(!modificationInstance.hasErrors() && modificationInstance.save()) {
-            flash.message = "Modification ${modificationInstance.id} created"
-            redirect(action:show,id:modificationInstance.id)
+        def taskModificationInstance = new TaskModification(params)
+        if(!taskModificationInstance.hasErrors() && taskModificationInstance.save()) {
+            flash.message = "TaskModification ${taskModificationInstance.id} created"
+            redirect(action:show,id:taskModificationInstance.id)
         }
         else {
-            render(view:'create',model:[modificationInstance:modificationInstance])
+            render(view:'create',model:[taskModificationInstance:taskModificationInstance])
         }
     }
