1 | import grails.util.GrailsUtil |
---|
2 | |
---|
3 | class BootStrap |
---|
4 | { |
---|
5 | def init = { servletContext -> |
---|
6 | |
---|
7 | println "**** BootStrap; GrailsUtil.environment: ${GrailsUtil.environment}" |
---|
8 | |
---|
9 | switch (GrailsUtil.environment) |
---|
10 | { |
---|
11 | case "development": |
---|
12 | println "**** BootStrap detected development" |
---|
13 | configureForDevelopment() |
---|
14 | break |
---|
15 | case "test": |
---|
16 | println "**** BootStrap detected test" |
---|
17 | configureForTest() |
---|
18 | break |
---|
19 | case "production": |
---|
20 | println "**** BootStrap detected production" |
---|
21 | configureForProduction() |
---|
22 | break |
---|
23 | } |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | def destroy = { |
---|
28 | } |
---|
29 | |
---|
30 | /* |
---|
31 | Tasks to do when Grails is running in each environment. |
---|
32 | */ |
---|
33 | void configureForDevelopment() |
---|
34 | { |
---|
35 | println "BootStrap configureForDevelopment() called" |
---|
36 | |
---|
37 | //TypeOfPersonGroup |
---|
38 | new PersonGroupType(name:"Department").save() |
---|
39 | println "PersonGroup = ${PersonGroupType.get(1)}" |
---|
40 | new PersonGroupType(name:"Contractor").save() |
---|
41 | new PersonGroupType(name:"ProjectTeam").save() |
---|
42 | |
---|
43 | //PersonGroup |
---|
44 | new PersonGroup(PersonGroupType:PersonGroupType.findByName("Department"), name:"Electrical").save() |
---|
45 | new PersonGroup( |
---|
46 | PersonGroupType:PersonGroupType.get(2), |
---|
47 | name:"Kewl AirCon Guys").save() |
---|
48 | new PersonGroup( |
---|
49 | PersonGroupType:PersonGroupType.get(3), |
---|
50 | name:"openMim").save() |
---|
51 | |
---|
52 | //Person |
---|
53 | new Person(personGroup:PersonGroup.get(1), |
---|
54 | firstName:"FirstNameTech1", |
---|
55 | lastName:"LastNameTech1").save() |
---|
56 | new Person(personGroup:PersonGroup.get(2), |
---|
57 | firstName:"Joe", |
---|
58 | lastName:"Samples").save() |
---|
59 | |
---|
60 | } |
---|
61 | |
---|
62 | //--------------------------------------------------------- |
---|
63 | void configureForTest() |
---|
64 | { |
---|
65 | println "BootStrap configureForTest() called" |
---|
66 | } |
---|
67 | |
---|
68 | //--------------------------------------------------------- |
---|
69 | void configureForProduction() |
---|
70 | { |
---|
71 | println "BootStrap configureForProduction() called" |
---|
72 | } |
---|
73 | |
---|
74 | } |
---|