[21] | 1 | import grails.util.GrailsUtil |
---|
[16] | 2 | |
---|
[21] | 3 | class BootStrap |
---|
| 4 | { |
---|
| 5 | def init = { servletContext -> |
---|
[19] | 6 | |
---|
[39] | 7 | println "**** BootStrap GrailsUtil.environment = ${GrailsUtil.environment}" |
---|
[21] | 8 | |
---|
| 9 | switch (GrailsUtil.environment) |
---|
| 10 | { |
---|
| 11 | case "development": |
---|
[39] | 12 | bootStrapDemoData() |
---|
[21] | 13 | break |
---|
| 14 | case "test": |
---|
| 15 | break |
---|
| 16 | case "production": |
---|
[39] | 17 | bootStrapDemoData() |
---|
[21] | 18 | break |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | def destroy = { |
---|
| 24 | } |
---|
[39] | 25 | |
---|
| 26 | //Insert some demo/startup data. |
---|
| 27 | void bootStrapDemoData() |
---|
[21] | 28 | { |
---|
[39] | 29 | println "BootStrapping demo data..." |
---|
[21] | 30 | |
---|
[19] | 31 | //TypeOfPersonGroup |
---|
[21] | 32 | new PersonGroupType(name:"Department").save() |
---|
| 33 | new PersonGroupType(name:"Contractor").save() |
---|
| 34 | new PersonGroupType(name:"ProjectTeam").save() |
---|
| 35 | |
---|
| 36 | //PersonGroup |
---|
[25] | 37 | new PersonGroup(personGroupType:PersonGroupType.findByName("Department"), |
---|
| 38 | name:"Electrical").save() |
---|
| 39 | new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
| 40 | name:"Kewl AirCon Guys").save() |
---|
| 41 | new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
[31] | 42 | name:"gnuMims").save() |
---|
[21] | 43 | |
---|
| 44 | //Person |
---|
| 45 | new Person(personGroup:PersonGroup.get(1), |
---|
[40] | 46 | firstName:"Admin", |
---|
| 47 | lastName:"Powers", |
---|
| 48 | userId:"admin", |
---|
| 49 | password:"pass").save() |
---|
| 50 | new Person(personGroup:PersonGroup.get(1), |
---|
| 51 | firstName:"User", |
---|
| 52 | lastName:"Tester", |
---|
| 53 | userId:"user", |
---|
| 54 | password:"pass").save() |
---|
| 55 | new Person(personGroup:PersonGroup.get(1), |
---|
| 56 | firstName:"Craig", |
---|
| 57 | lastName:"SuperTech", |
---|
| 58 | userId:"craig", |
---|
| 59 | password:"pass").save() |
---|
[21] | 60 | new Person(personGroup:PersonGroup.get(2), |
---|
[40] | 61 | firstName:"Joe", |
---|
| 62 | lastName:"Samples", |
---|
| 63 | userId:"joe", |
---|
| 64 | password:"pass").save() |
---|
[39] | 65 | new Person(personGroup:PersonGroup.get(1), |
---|
[40] | 66 | firstName:"Production", |
---|
| 67 | lastName:"Mann", |
---|
| 68 | userId:"Mann", |
---|
| 69 | password:"pass").save() |
---|
[25] | 70 | |
---|
| 71 | //TaskGroup |
---|
| 72 | new TaskGroup(name:"Engineering", |
---|
| 73 | description:"Engineering task group").save() |
---|
| 74 | new TaskGroup(name:"Production", |
---|
| 75 | description:"Production task group").save() |
---|
| 76 | new TaskGroup(name:"NewProject(s)", |
---|
| 77 | description:" ").save() |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | //Task |
---|
| 81 | new Task(taskGroup:TaskGroup.findByName("Engineering"), |
---|
[40] | 82 | person:Person.get(3), |
---|
[25] | 83 | name:"Check specific level sensor", |
---|
| 84 | description:"Has been noted as problematic, try recallibrating", |
---|
| 85 | scheduledDate: new Date(), |
---|
| 86 | targetDate: new Date() ).save() |
---|
| 87 | new Task(taskGroup:TaskGroup.findByName("Production"), |
---|
[40] | 88 | person:Person.get(5), |
---|
[25] | 89 | name:"Production Report", |
---|
| 90 | description:"Production report for specific production run or shift", |
---|
| 91 | scheduledDate: new Date(), |
---|
| 92 | targetDate: new Date() ).save() |
---|
[40] | 93 | new Task(taskGroup:TaskGroup.findByName("NewProject(s)"), |
---|
| 94 | person:Person.get(1), |
---|
| 95 | name:"Make killer CMMS app", |
---|
| 96 | description:"Use Grails and get a move on!", |
---|
| 97 | scheduledDate: new Date(), |
---|
| 98 | targetDate: new Date() ).save() |
---|
[25] | 99 | |
---|
| 100 | //EntryType |
---|
| 101 | new EntryType(name:"Fault").save() |
---|
| 102 | new EntryType(name:"WorkDone").save() |
---|
[39] | 103 | new EntryType(name:"Production Report").save() |
---|
[34] | 104 | |
---|
| 105 | //ModificationType |
---|
| 106 | new ModificationType(name:"Created").save() |
---|
| 107 | new ModificationType(name:"Completed").save() |
---|
| 108 | new ModificationType(name:"Closed").save() |
---|
| 109 | new ModificationType(name:"Altered").save() |
---|
| 110 | new ModificationType(name:"TargetDateModified").save() |
---|
| 111 | new ModificationType(name:"ScheduledDateModified").save() |
---|
| 112 | new ModificationType(name:"DescriptionModified").save() |
---|
| 113 | new ModificationType(name:"AssignedToModified").save() |
---|
| 114 | new ModificationType(name:"NameModified").save() |
---|
[39] | 115 | |
---|
| 116 | println "BootStrapping demo data...completed." |
---|
[21] | 117 | |
---|
| 118 | } |
---|
[20] | 119 | |
---|
[19] | 120 | } |
---|