1 | import org.codehaus.groovy.grails.plugins.springsecurity.Secured |
---|
2 | |
---|
3 | @Secured(['ROLE_AppAdmin']) |
---|
4 | class PersonGroupTypeController extends BaseController { |
---|
5 | |
---|
6 | def index = { redirect(action:list,params:params) } |
---|
7 | |
---|
8 | // the delete, save and update actions only accept POST requests |
---|
9 | static allowedMethods = [delete:'POST', save:'POST', update:'POST'] |
---|
10 | |
---|
11 | def list = { |
---|
12 | if(!params.max) params.max = 10 |
---|
13 | [ personGroupTypeInstanceList: PersonGroupType.list( params ) ] |
---|
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) { |
---|
29 | personGroupTypeInstance.delete() |
---|
30 | flash.message = "PersonGroupType ${params.id} deleted" |
---|
31 | redirect(action:list) |
---|
32 | } |
---|
33 | else { |
---|
34 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
35 | redirect(action:list) |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | def edit = { |
---|
40 | def personGroupTypeInstance = PersonGroupType.get( params.id ) |
---|
41 | |
---|
42 | if(!personGroupTypeInstance) { |
---|
43 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
44 | redirect(action:list) |
---|
45 | } |
---|
46 | else { |
---|
47 | return [ personGroupTypeInstance : personGroupTypeInstance ] |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | def update = { |
---|
52 | def personGroupTypeInstance = PersonGroupType.get( params.id ) |
---|
53 | if(personGroupTypeInstance) { |
---|
54 | personGroupTypeInstance.properties = params |
---|
55 | if(!personGroupTypeInstance.hasErrors() && personGroupTypeInstance.save()) { |
---|
56 | flash.message = "PersonGroupType ${params.id} updated" |
---|
57 | redirect(action:show,id:personGroupTypeInstance.id) |
---|
58 | } |
---|
59 | else { |
---|
60 | render(view:'edit',model:[personGroupTypeInstance:personGroupTypeInstance]) |
---|
61 | } |
---|
62 | } |
---|
63 | else { |
---|
64 | flash.message = "PersonGroupType not found with id ${params.id}" |
---|
65 | redirect(action:edit,id:params.id) |
---|
66 | } |
---|
67 | } |
---|
68 | |
---|
69 | def create = { |
---|
70 | def personGroupTypeInstance = new PersonGroupType() |
---|
71 | personGroupTypeInstance.properties = params |
---|
72 | return ['personGroupTypeInstance':personGroupTypeInstance] |
---|
73 | } |
---|
74 | |
---|
75 | def save = { |
---|
76 | def personGroupTypeInstance = new PersonGroupType(params) |
---|
77 | if(!personGroupTypeInstance.hasErrors() && personGroupTypeInstance.save()) { |
---|
78 | flash.message = "PersonGroupType ${personGroupTypeInstance.id} created" |
---|
79 | redirect(action:show,id:personGroupTypeInstance.id) |
---|
80 | } |
---|
81 | else { |
---|
82 | render(view:'create',model:[personGroupTypeInstance:personGroupTypeInstance]) |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|