| 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 | new PersonGroupType(name:"Contractor").save() |
|---|
| 40 | new PersonGroupType(name:"ProjectTeam").save() |
|---|
| 41 | |
|---|
| 42 | //PersonGroup |
|---|
| 43 | new PersonGroup(personGroupType:PersonGroupType.findByName("Department"), |
|---|
| 44 | name:"Electrical").save() |
|---|
| 45 | new PersonGroup(personGroupType:PersonGroupType.get(2), |
|---|
| 46 | name:"Kewl AirCon Guys").save() |
|---|
| 47 | new PersonGroup(personGroupType:PersonGroupType.get(3), |
|---|
| 48 | name:"openMim").save() |
|---|
| 49 | |
|---|
| 50 | //Person |
|---|
| 51 | new Person(personGroup:PersonGroup.get(1), |
|---|
| 52 | firstName:"FirstNameTech1", |
|---|
| 53 | lastName:"LastNameTech1").save() |
|---|
| 54 | new Person(personGroup:PersonGroup.get(2), |
|---|
| 55 | firstName:"Joe", |
|---|
| 56 | lastName:"Samples").save() |
|---|
| 57 | |
|---|
| 58 | //TaskGroup |
|---|
| 59 | new TaskGroup(name:"Engineering", |
|---|
| 60 | description:"Engineering task group").save() |
|---|
| 61 | new TaskGroup(name:"Production", |
|---|
| 62 | description:"Production task group").save() |
|---|
| 63 | new TaskGroup(name:"NewProject(s)", |
|---|
| 64 | description:" ").save() |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | //Task |
|---|
| 68 | new Task(taskGroup:TaskGroup.findByName("Engineering"), |
|---|
| 69 | person:Person.get(1), |
|---|
| 70 | name:"Check specific level sensor", |
|---|
| 71 | description:"Has been noted as problematic, try recallibrating", |
|---|
| 72 | scheduledDate: new Date(), |
|---|
| 73 | targetDate: new Date() ).save() |
|---|
| 74 | new Task(taskGroup:TaskGroup.findByName("Production"), |
|---|
| 75 | person:Person.get(2), |
|---|
| 76 | name:"Production Report", |
|---|
| 77 | description:"Production report for specific production run or shift", |
|---|
| 78 | scheduledDate: new Date(), |
|---|
| 79 | targetDate: new Date() ).save() |
|---|
| 80 | |
|---|
| 81 | //EntryType |
|---|
| 82 | new EntryType(name:"Fault").save() |
|---|
| 83 | new EntryType(name:"WorkDone").save() |
|---|
| 84 | |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | //--------------------------------------------------------- |
|---|
| 88 | void configureForTest() |
|---|
| 89 | { |
|---|
| 90 | println "BootStrap configureForTest() called" |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | //--------------------------------------------------------- |
|---|
| 94 | void configureForProduction() |
|---|
| 95 | { |
|---|
| 96 | println "BootStrap configureForProduction() called" |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | } |
|---|