Changeset 240 for trunk/grails-app/controllers
- Timestamp:
- Dec 22, 2009, 5:38:37 PM (15 years ago)
- Location:
- trunk/grails-app/controllers
- Files:
-
- 1 added
- 1 deleted
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/AssignedGroupDetailedController.groovy
r233 r240 1 1 import org.codehaus.groovy.grails.plugins.springsecurity.Secured 2 2 3 class Assigned PersonDetailedController extends BaseController {3 class AssignedGroupDetailedController extends BaseController { 4 4 5 5 def index = { redirect(action:list,params:params) } … … 10 10 def list = { 11 11 params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) 12 [ assigned PersonInstanceList: AssignedPerson.list( params ), assignedPersonInstanceTotal: AssignedPerson.count() ]12 [ assignedGroupInstanceList: AssignedGroup.list( params ), assignedGroupInstanceTotal: AssignedGroup.count() ] 13 13 } 14 14 15 15 def show = { 16 def assigned PersonInstance = AssignedPerson.get( params.id )16 def assignedGroupInstance = AssignedGroup.get( params.id ) 17 17 18 if(!assigned PersonInstance) {19 flash.message = "Assigned Personnot found with id ${params.id}"18 if(!assignedGroupInstance) { 19 flash.message = "AssignedGroup not found with id ${params.id}" 20 20 redirect(action:list) 21 21 } 22 else { return [ assigned PersonInstance : assignedPersonInstance ] }22 else { return [ assignedGroupInstance : assignedGroupInstance ] } 23 23 } 24 24 25 25 def delete = { 26 def assigned PersonInstance = AssignedPerson.get( params.id )27 if(assigned PersonInstance) {26 def assignedGroupInstance = AssignedGroup.get( params.id ) 27 if(assignedGroupInstance) { 28 28 try { 29 def taskId = assigned PersonInstance.task.id30 assigned PersonInstance.delete()31 flash.message = "Assigned Person${params.id} deleted"29 def taskId = assignedGroupInstance.task.id 30 assignedGroupInstance.delete() 31 flash.message = "AssignedGroup ${params.id} deleted" 32 32 redirect(controller:"taskDetailed", action:"show", id: taskId) 33 33 } 34 34 catch(org.springframework.dao.DataIntegrityViolationException e) { 35 flash.message = "Assigned Person${params.id} could not be deleted"35 flash.message = "AssignedGroup ${params.id} could not be deleted" 36 36 redirect(action:show,id:params.id) 37 37 } 38 38 } 39 39 else { 40 flash.message = "Assigned Personnot found with id ${params.id}"40 flash.message = "AssignedGroup not found with id ${params.id}" 41 41 redirect(action:list) 42 42 } … … 44 44 45 45 def edit = { 46 def assigned PersonInstance = AssignedPerson.get( params.id )46 def assignedGroupInstance = AssignedGroup.get( params.id ) 47 47 48 if(!assigned PersonInstance) {49 flash.message = "Assigned Personnot found with id ${params.id}"48 if(!assignedGroupInstance) { 49 flash.message = "AssignedGroup not found with id ${params.id}" 50 50 redirect(action:list) 51 51 } 52 52 else { 53 return [ assigned PersonInstance : assignedPersonInstance ]53 return [ assignedGroupInstance : assignedGroupInstance ] 54 54 } 55 55 } 56 56 57 57 def update = { 58 def assigned PersonInstance = AssignedPerson.get( params.id )59 if(assigned PersonInstance) {58 def assignedGroupInstance = AssignedGroup.get( params.id ) 59 if(assignedGroupInstance) { 60 60 if(params.version) { 61 61 def version = params.version.toLong() 62 if(assigned PersonInstance.version > version) {62 if(assignedGroupInstance.version > version) { 63 63 64 assigned PersonInstance.errors.rejectValue("version", "assignedPerson.optimistic.locking.failure", "Another user has updated this AssignedPersonwhile you were editing.")65 render(view:'edit',model:[assigned PersonInstance:assignedPersonInstance])64 assignedGroupInstance.errors.rejectValue("version", "assignedGroup.optimistic.locking.failure", "Another user has updated this AssignedGroup while you were editing.") 65 render(view:'edit',model:[assignedGroupInstance:assignedGroupInstance]) 66 66 return 67 67 } 68 68 } 69 assigned PersonInstance.properties = params70 if(!assigned PersonInstance.hasErrors() && assignedPersonInstance.save(flush: true)) {71 flash.message = "Assigned Person${params.id} updated"72 redirect(action:show,id:assigned PersonInstance.id)69 assignedGroupInstance.properties = params 70 if(!assignedGroupInstance.hasErrors() && assignedGroupInstance.save(flush: true)) { 71 flash.message = "AssignedGroup ${params.id} updated" 72 redirect(action:show,id:assignedGroupInstance.id) 73 73 } 74 74 else { 75 render(view:'edit',model:[assigned PersonInstance:assignedPersonInstance])75 render(view:'edit',model:[assignedGroupInstance:assignedGroupInstance]) 76 76 } 77 77 } 78 78 else { 79 flash.message = "Assigned Personnot found with id ${params.id}"79 flash.message = "AssignedGroup not found with id ${params.id}" 80 80 redirect(action:edit,id:params.id) 81 81 } … … 84 84 def create = { 85 85 if(!params.task?.id) { 86 flash.message = "Please select a task and then 'Add Assigned Person'"87 redirect(controller: "taskDetailed", action: search)86 flash.message = "Please select a task and then 'Add Assigned Group'" 87 redirect(controller: "taskDetailed", action: "search") 88 88 } 89 89 else { 90 def assigned PersonInstance = new AssignedPerson()91 assigned PersonInstance.properties = params92 return ['assigned PersonInstance':assignedPersonInstance]90 def assignedGroupInstance = new AssignedGroup() 91 assignedGroupInstance.properties = params 92 return ['assignedGroupInstance':assignedGroupInstance] 93 93 } 94 94 } 95 95 96 96 def save = { 97 def assigned PersonInstance = new AssignedPerson(params)97 def assignedGroupInstance = new AssignedGroup(params) 98 98 99 if(!assigned PersonInstance.hasErrors() && assignedPersonInstance.save(flush: true)) {100 flash.message = "Assigned Person ${assignedPersonInstance.id} created"99 if(!assignedGroupInstance.hasErrors() && assignedGroupInstance.save(flush: true)) { 100 flash.message = "AssignedGroup ${assignedGroupInstance.id} created" 101 101 redirect(controller:"taskDetailed", action:"show", id: params.task.id) 102 102 } 103 103 else { 104 render(view:'create',model:[assigned PersonInstance:assignedPersonInstance])104 render(view:'create',model:[assignedGroupInstance:assignedGroupInstance]) 105 105 } 106 106 }
Note: See TracChangeset
for help on using the changeset viewer.