Changeset 21 for trunk/src/grails-app/conf
- Timestamp:
- Jan 19, 2009, 8:31:46 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/grails-app/conf/BootStrap.groovy
r20 r21 1 class BootStrap { 1 import grails.util.GrailsUtil 2 2 3 def init = { servletContext -> 3 class BootStrap 4 { 5 def init = { servletContext -> 4 6 5 //TypeOfPersonGroup 6 new TypeOfPersonGroup(name:"Department").save() 7 new TypeOfPersonGroup(name:"Contractor").save() 8 new TypeOfPersonGroup(name:"ProjectTeam").save() 9 10 //PersonGroup 11 new PersonGroup(typeOfPersonGroup:TypeOfPersonGroup.get(1), 12 name:"Electrical").save() 13 new PersonGroup(typeOfPersonGroup:TypeOfPersonGroup.get(2), 14 name:"Kewl AirCon Guys").save() 15 new PersonGroup(typeOfPersonGroup:TypeOfPersonGroup.get(3), 16 name:"openMim").save() 17 } 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 } 18 26 19 27 def destroy = { 20 } 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 21 74 }
Note: See TracChangeset
for help on using the changeset viewer.