| 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 | bootStrapDemoData() |
|---|
| 13 | break |
|---|
| 14 | case "test": |
|---|
| 15 | break |
|---|
| 16 | case "production": |
|---|
| 17 | bootStrapDemoData() |
|---|
| 18 | break |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | def destroy = { |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | //Insert some demo/startup data. |
|---|
| 27 | void bootStrapDemoData() |
|---|
| 28 | { |
|---|
| 29 | println "BootStrapping demo data..." |
|---|
| 30 | |
|---|
| 31 | //TypeOfPersonGroup |
|---|
| 32 | new PersonGroupType(name:"Department").save() |
|---|
| 33 | new PersonGroupType(name:"Contractor").save() |
|---|
| 34 | new PersonGroupType(name:"ProjectTeam").save() |
|---|
| 35 | |
|---|
| 36 | //PersonGroup |
|---|
| 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), |
|---|
| 42 | name:"gnuMims").save() |
|---|
| 43 | |
|---|
| 44 | //Person |
|---|
| 45 | new Person(personGroup:PersonGroup.get(3), |
|---|
| 46 | firstName:"Admin", |
|---|
| 47 | lastName:"Powers", |
|---|
| 48 | userId:"admin", |
|---|
| 49 | password:"pass").save() |
|---|
| 50 | new Person(personGroup:PersonGroup.get(1), |
|---|
| 51 | firstName:"Demo", |
|---|
| 52 | lastName:"Danza", |
|---|
| 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() |
|---|
| 60 | new Person(personGroup:PersonGroup.get(2), |
|---|
| 61 | firstName:"Joe", |
|---|
| 62 | lastName:"Samples", |
|---|
| 63 | userId:"joe", |
|---|
| 64 | password:"pass").save() |
|---|
| 65 | new Person(personGroup:PersonGroup.get(1), |
|---|
| 66 | firstName:"Production", |
|---|
| 67 | lastName:"Mann", |
|---|
| 68 | userId:"Mann", |
|---|
| 69 | password:"pass").save() |
|---|
| 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"), |
|---|
| 82 | leadPerson:Person.get(3), |
|---|
| 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"), |
|---|
| 88 | leadPerson:Person.get(5), |
|---|
| 89 | name:"Production Report", |
|---|
| 90 | description:"Production report for specific production run or shift", |
|---|
| 91 | scheduledDate: new Date(), |
|---|
| 92 | targetDate: new Date() ).save() |
|---|
| 93 | new Task(taskGroup:TaskGroup.findByName("NewProject(s)"), |
|---|
| 94 | leadPerson: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() |
|---|
| 99 | |
|---|
| 100 | //EntryType |
|---|
| 101 | new EntryType(name:"Fault").save() |
|---|
| 102 | new EntryType(name:"WorkDone").save() |
|---|
| 103 | new EntryType(name:"Production Report").save() |
|---|
| 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() |
|---|
| 115 | |
|---|
| 116 | println "BootStrapping demo data...completed." |
|---|
| 117 | |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | } |
|---|