[62] | 1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
| 2 | |
---|
[471] | 3 | @Secured(['ROLE_AppAdmin', 'ROLE_Manager']) |
---|
| 4 | class PersonGroupTypeDetailedController extends BaseController { |
---|
[122] | 5 | |
---|
[59] | 6 | def index = { redirect(action:list,params:params) } |
---|
| 7 | |
---|
| 8 | // the delete, save and update actions only accept POST requests |
---|
[74] | 9 | static allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
[59] | 10 | |
---|
| 11 | def list = { |
---|
[122] | 12 | params.max = Math.min( params.max ? params.max.toInteger() : 10, 100) |
---|
| 13 | [ personGroupTypeInstanceList: PersonGroupType.list( params ), personGroupTypeInstanceTotal: PersonGroupType.count() ] |
---|
[59] | 14 | } |
---|
| 15 | |
---|
| 16 | def show = { |
---|
| 17 | def personGroupTypeInstance = PersonGroupType.get( params.id ) |
---|
| 18 | |
---|
| 19 | if(!personGroupTypeInstance) { |
---|
| 20 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
| 21 | redirect(action:list) |
---|
| 22 | } |
---|
| 23 | else { return [ personGroupTypeInstance : personGroupTypeInstance ] } |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | def delete = { |
---|
| 27 | def personGroupTypeInstance = PersonGroupType.get( params.id ) |
---|
| 28 | if(personGroupTypeInstance) { |
---|
[122] | 29 | try { |
---|
[178] | 30 | personGroupTypeInstance.delete(flush:true) |
---|
[122] | 31 | flash.message = "PersonGroupType ${params.id} deleted" |
---|
| 32 | redirect(action:list) |
---|
| 33 | } |
---|
| 34 | catch(org.springframework.dao.DataIntegrityViolationException e) { |
---|
| 35 | flash.message = "PersonGroupType ${params.id} could not be deleted" |
---|
| 36 | redirect(action:show,id:params.id) |
---|
| 37 | } |
---|
[59] | 38 | } |
---|
| 39 | else { |
---|
| 40 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
| 41 | redirect(action:list) |
---|
| 42 | } |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | def edit = { |
---|
| 46 | def personGroupTypeInstance = PersonGroupType.get( params.id ) |
---|
| 47 | |
---|
| 48 | if(!personGroupTypeInstance) { |
---|
| 49 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
| 50 | redirect(action:list) |
---|
| 51 | } |
---|
| 52 | else { |
---|
| 53 | return [ personGroupTypeInstance : personGroupTypeInstance ] |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | def update = { |
---|
| 58 | def personGroupTypeInstance = PersonGroupType.get( params.id ) |
---|
| 59 | if(personGroupTypeInstance) { |
---|
[122] | 60 | if(params.version) { |
---|
| 61 | def version = params.version.toLong() |
---|
| 62 | if(personGroupTypeInstance.version > version) { |
---|
| 63 | |
---|
[403] | 64 | personGroupTypeInstance.errors.rejectValue("version", "default.optimistic.locking.failure") |
---|
[122] | 65 | render(view:'edit',model:[personGroupTypeInstance:personGroupTypeInstance]) |
---|
| 66 | return |
---|
| 67 | } |
---|
| 68 | } |
---|
[59] | 69 | personGroupTypeInstance.properties = params |
---|
[178] | 70 | if(!personGroupTypeInstance.hasErrors() && personGroupTypeInstance.save(flush: true)) { |
---|
[59] | 71 | flash.message = "PersonGroupType ${params.id} updated" |
---|
| 72 | redirect(action:show,id:personGroupTypeInstance.id) |
---|
| 73 | } |
---|
| 74 | else { |
---|
| 75 | render(view:'edit',model:[personGroupTypeInstance:personGroupTypeInstance]) |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | else { |
---|
| 79 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
[178] | 80 | redirect(action:list) |
---|
[59] | 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | def create = { |
---|
| 85 | def personGroupTypeInstance = new PersonGroupType() |
---|
| 86 | personGroupTypeInstance.properties = params |
---|
| 87 | return ['personGroupTypeInstance':personGroupTypeInstance] |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | def save = { |
---|
| 91 | def personGroupTypeInstance = new PersonGroupType(params) |
---|
[178] | 92 | if(!personGroupTypeInstance.hasErrors() && personGroupTypeInstance.save(flush: true)) { |
---|
[59] | 93 | flash.message = "PersonGroupType ${personGroupTypeInstance.id} created" |
---|
| 94 | redirect(action:show,id:personGroupTypeInstance.id) |
---|
| 95 | } |
---|
| 96 | else { |
---|
| 97 | render(view:'create',model:[personGroupTypeInstance:personGroupTypeInstance]) |
---|
| 98 | } |
---|
| 99 | } |
---|
| 100 | } |
---|