[58] | 1 | import grails.util.GrailsUtil |
---|
[55] | 2 | |
---|
[58] | 3 | class BootStrap |
---|
| 4 | { |
---|
| 5 | //Required to be right here for Acegi plugin. |
---|
| 6 | def authenticateService |
---|
| 7 | Boolean BootStrapDemoDataSuccessful = true |
---|
| 8 | |
---|
| 9 | def init = { servletContext -> |
---|
| 10 | |
---|
| 11 | println "**** BootStrap GrailsUtil.environment = ${GrailsUtil.environment}" |
---|
| 12 | |
---|
| 13 | switch (GrailsUtil.environment) |
---|
| 14 | { |
---|
| 15 | case "development": |
---|
| 16 | bootStrapDemoData() |
---|
| 17 | break |
---|
| 18 | case "test": |
---|
| 19 | break |
---|
| 20 | case "production": |
---|
| 21 | bootStrapDemoData() |
---|
| 22 | break |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | def destroy = { |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | //Insert some demo/startup data. |
---|
| 31 | void bootStrapDemoData() |
---|
| 32 | { |
---|
| 33 | println "BootStrapping demo data..." |
---|
[118] | 34 | |
---|
| 35 | /******************* |
---|
| 36 | START OF TASK |
---|
| 37 | |
---|
| 38 | *******************/ |
---|
| 39 | |
---|
[116] | 40 | //TypeOfPersonGroup |
---|
[64] | 41 | def personGroupTypeInstance |
---|
| 42 | personGroupTypeInstance = new PersonGroupType(name:"Department") |
---|
| 43 | BootStrapSaveAndTest(personGroupTypeInstance) |
---|
| 44 | personGroupTypeInstance = new PersonGroupType(name:"Contractor") |
---|
| 45 | BootStrapSaveAndTest(personGroupTypeInstance) |
---|
| 46 | personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam") |
---|
| 47 | BootStrapSaveAndTest(personGroupTypeInstance) |
---|
[58] | 48 | |
---|
[116] | 49 | //PersonGroup |
---|
[64] | 50 | def personGroupInstance |
---|
| 51 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"), |
---|
| 52 | name:"Electrical") |
---|
| 53 | BootStrapSaveAndTest(personGroupInstance) |
---|
| 54 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"), |
---|
| 55 | name:"Mechanical") |
---|
| 56 | BootStrapSaveAndTest(personGroupInstance) |
---|
| 57 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"), |
---|
| 58 | name:"Production") |
---|
| 59 | BootStrapSaveAndTest(personGroupInstance) |
---|
| 60 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
| 61 | name:"Kewl AirCon Guys") |
---|
| 62 | BootStrapSaveAndTest(personGroupInstance) |
---|
| 63 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
| 64 | name:"gnuMims") |
---|
| 65 | BootStrapSaveAndTest(personGroupInstance) |
---|
[58] | 66 | |
---|
[116] | 67 | //Authority |
---|
[59] | 68 | def authInstance |
---|
| 69 | |
---|
[102] | 70 | authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.", |
---|
[71] | 71 | authority:"ROLE_AppAdmin") |
---|
[59] | 72 | BootStrapSaveAndTest(authInstance) |
---|
| 73 | |
---|
[91] | 74 | authInstance = new Authority(description:"Business manager, grants full management access.", |
---|
| 75 | authority:"ROLE_Manager") |
---|
| 76 | BootStrapSaveAndTest(authInstance) |
---|
| 77 | |
---|
| 78 | authInstance = new Authority(description:"Application User, all application users need this base role to allow login.", |
---|
[71] | 79 | authority:"ROLE_AppUser") |
---|
[59] | 80 | BootStrapSaveAndTest(authInstance) |
---|
[58] | 81 | |
---|
[116] | 82 | //Person |
---|
[73] | 83 | def passClearText = "pass" |
---|
| 84 | def passwordEncoded = authenticateService.encodePassword(passClearText) |
---|
[59] | 85 | def personInstance |
---|
[58] | 86 | |
---|
[102] | 87 | //Person #1 |
---|
[59] | 88 | personInstance = new Person(loginName:"admin", |
---|
[58] | 89 | firstName:"Admin", |
---|
| 90 | lastName:"Powers", |
---|
[73] | 91 | pass:passClearText, |
---|
[59] | 92 | password:passwordEncoded, |
---|
[58] | 93 | email:"admin@example.com") |
---|
| 94 | BootStrapSaveAndTest(personInstance) |
---|
[59] | 95 | personInstance.addToAuthorities(Authority.get(1)) |
---|
| 96 | personInstance.addToAuthorities(Authority.get(2)) |
---|
[91] | 97 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 98 | personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims")) |
---|
[58] | 99 | |
---|
[102] | 100 | //Person #2 |
---|
[91] | 101 | personInstance = new Person(loginName:"manager", |
---|
| 102 | firstName:"Meca", |
---|
| 103 | lastName:"Manager", |
---|
[73] | 104 | pass:passClearText, |
---|
| 105 | password:passwordEncoded, |
---|
[91] | 106 | email:"manager@example.com") |
---|
[73] | 107 | BootStrapSaveAndTest(personInstance) |
---|
| 108 | personInstance.addToAuthorities(Authority.get(2)) |
---|
[91] | 109 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[73] | 110 | personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims")) |
---|
| 111 | |
---|
[102] | 112 | //Person #3 |
---|
[59] | 113 | personInstance = new Person(loginName:"user", |
---|
| 114 | firstName:"Demo", |
---|
[102] | 115 | lastName:"User", |
---|
[73] | 116 | pass:passClearText, |
---|
[59] | 117 | password:passwordEncoded, |
---|
| 118 | email:"user@example.com") |
---|
| 119 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 120 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 121 | personInstance.addToPersonGroups(PersonGroup.findByName("Electrical")) |
---|
[58] | 122 | |
---|
[102] | 123 | //Person #4 |
---|
[59] | 124 | personInstance = new Person(loginName:"craig", |
---|
| 125 | firstName:"Craig", |
---|
[102] | 126 | lastName:"SuperSparky", |
---|
[73] | 127 | pass:passClearText, |
---|
[59] | 128 | password:passwordEncoded, |
---|
| 129 | email:"user@example.com") |
---|
| 130 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 131 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 132 | personInstance.addToPersonGroups(PersonGroup.findByName("Electrical")) |
---|
[58] | 133 | |
---|
[102] | 134 | //Person #5 |
---|
[73] | 135 | personInstance = new Person(loginName:"john", |
---|
| 136 | firstName:"John", |
---|
[102] | 137 | lastName:"SuperFitter", |
---|
[73] | 138 | pass:passClearText, |
---|
[59] | 139 | password:passwordEncoded, |
---|
| 140 | email:"user@example.com") |
---|
| 141 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 142 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 143 | personInstance.addToPersonGroups(PersonGroup.findByName("Mechanical")) |
---|
[58] | 144 | |
---|
[102] | 145 | //Person #6 |
---|
[59] | 146 | personInstance = new Person(loginName:"mann", |
---|
| 147 | firstName:"Production", |
---|
| 148 | lastName:"Mann", |
---|
[73] | 149 | pass:passClearText, |
---|
[59] | 150 | password:passwordEncoded, |
---|
| 151 | email:"user@example.com") |
---|
| 152 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 153 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 154 | personInstance.addToPersonGroups(PersonGroup.findByName("Production")) |
---|
| 155 | |
---|
[116] | 156 | //TaskGroup |
---|
[69] | 157 | def taskGroupInstance |
---|
| 158 | |
---|
| 159 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 160 | description:"Engineering daily activities") |
---|
| 161 | BootStrapSaveAndTest(taskGroupInstance) |
---|
| 162 | |
---|
| 163 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 164 | description:"Production daily activities") |
---|
| 165 | BootStrapSaveAndTest(taskGroupInstance) |
---|
| 166 | |
---|
| 167 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
| 168 | description:" ") |
---|
| 169 | BootStrapSaveAndTest(taskGroupInstance) |
---|
| 170 | |
---|
[116] | 171 | //TaskStatus |
---|
[66] | 172 | def taskStatusInstance |
---|
| 173 | |
---|
| 174 | taskStatusInstance = new TaskStatus(name:"Not Started") |
---|
| 175 | BootStrapSaveAndTest(taskStatusInstance) |
---|
| 176 | |
---|
| 177 | taskStatusInstance = new TaskStatus(name:"In Progress") |
---|
| 178 | BootStrapSaveAndTest(taskStatusInstance) |
---|
| 179 | |
---|
| 180 | taskStatusInstance = new TaskStatus(name:"Completed") |
---|
| 181 | BootStrapSaveAndTest(taskStatusInstance) |
---|
| 182 | |
---|
[116] | 183 | //TaskPriority |
---|
[69] | 184 | def taskPriorityInstance |
---|
[66] | 185 | |
---|
[69] | 186 | taskPriorityInstance = new TaskPriority(name:"Low") |
---|
| 187 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
[66] | 188 | |
---|
[69] | 189 | taskPriorityInstance = new TaskPriority(name:"Normal") |
---|
| 190 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
[66] | 191 | |
---|
[69] | 192 | taskPriorityInstance = new TaskPriority(name:"High") |
---|
| 193 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
[66] | 194 | |
---|
[69] | 195 | taskPriorityInstance = new TaskPriority(name:"Immediate") |
---|
| 196 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
| 197 | |
---|
[116] | 198 | //TaskType |
---|
[69] | 199 | def taskTypeInstance |
---|
| 200 | |
---|
| 201 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") |
---|
| 202 | BootStrapSaveAndTest(taskTypeInstance) |
---|
| 203 | |
---|
| 204 | taskTypeInstance = new TaskType(name:"Planned Maintenance") |
---|
| 205 | BootStrapSaveAndTest(taskTypeInstance) |
---|
| 206 | |
---|
| 207 | taskTypeInstance = new TaskType(name:"Project") |
---|
| 208 | BootStrapSaveAndTest(taskTypeInstance) |
---|
| 209 | |
---|
| 210 | taskTypeInstance = new TaskType(name:"Turnaround") |
---|
| 211 | BootStrapSaveAndTest(taskTypeInstance) |
---|
| 212 | |
---|
| 213 | taskTypeInstance = new TaskType(name:"Production Run") |
---|
| 214 | BootStrapSaveAndTest(taskTypeInstance) |
---|
| 215 | |
---|
[116] | 216 | //Task |
---|
[66] | 217 | def taskInstance |
---|
[58] | 218 | |
---|
[116] | 219 | //Task #1 |
---|
[66] | 220 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 221 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
[69] | 222 | taskPriority:TaskPriority.get(2), |
---|
| 223 | taskType:TaskType.get(1), |
---|
[66] | 224 | leadPerson:Person.get(3), |
---|
| 225 | description:"Check specific level sensor", |
---|
| 226 | comment:"Has been noted as problematic, try recallibrating") |
---|
| 227 | BootStrapSaveAndTest(taskInstance) |
---|
| 228 | |
---|
[116] | 229 | //Task #2 |
---|
[114] | 230 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 231 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 232 | taskPriority:TaskPriority.get(2), |
---|
| 233 | taskType:TaskType.get(1), |
---|
| 234 | leadPerson:Person.get(5), |
---|
| 235 | description:"Some follow-up work", |
---|
| 236 | comment:"Some help required", |
---|
| 237 | parentTask: Task.get(1)) |
---|
| 238 | BootStrapSaveAndTest(taskInstance) |
---|
[69] | 239 | |
---|
[116] | 240 | //Task #3 |
---|
[114] | 241 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 242 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 243 | taskPriority:TaskPriority.get(2), |
---|
| 244 | taskType:TaskType.get(1), |
---|
| 245 | leadPerson:Person.get(5), |
---|
| 246 | description:"A Sub Task can be created by setting the Parent Task value", |
---|
| 247 | comment:"Some help required", |
---|
| 248 | parentTask: Task.get(1)) |
---|
| 249 | BootStrapSaveAndTest(taskInstance) |
---|
| 250 | |
---|
[116] | 251 | //Task #4 |
---|
[114] | 252 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[84] | 253 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 254 | taskPriority:TaskPriority.get(2), |
---|
| 255 | taskType:TaskType.get(1), |
---|
[102] | 256 | leadPerson:Person.get(4), |
---|
[84] | 257 | description:"Replace sensor at next opportunity.", |
---|
[114] | 258 | comment:"Nothing else has worked.", |
---|
| 259 | parentTask: Task.get(1)) |
---|
| 260 | BootStrapSaveAndTest(taskInstance) |
---|
[84] | 261 | |
---|
[116] | 262 | //Task #5 |
---|
[66] | 263 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"), |
---|
| 264 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
[69] | 265 | taskPriority:TaskPriority.get(2), |
---|
| 266 | taskType:TaskType.get(5), |
---|
[102] | 267 | leadPerson:Person.get(6), |
---|
[66] | 268 | description:"Production Report", |
---|
| 269 | comment:"Production report for specific production run or shift") |
---|
| 270 | BootStrapSaveAndTest(taskInstance) |
---|
| 271 | |
---|
[116] | 272 | //Task #6 |
---|
[69] | 273 | taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"), |
---|
[66] | 274 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
[69] | 275 | taskPriority:TaskPriority.get(2), |
---|
| 276 | taskType:TaskType.get(3), |
---|
[66] | 277 | leadPerson:Person.get(1), |
---|
| 278 | description:"Make killer CMMS app", |
---|
| 279 | comment:"Use Grails and get a move on!") |
---|
| 280 | BootStrapSaveAndTest(taskInstance) |
---|
| 281 | |
---|
[116] | 282 | //EntryType |
---|
[66] | 283 | def entryTypeInstance |
---|
[58] | 284 | |
---|
[66] | 285 | entryTypeInstance = new EntryType(name:"Fault") |
---|
| 286 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 287 | |
---|
| 288 | entryTypeInstance = new EntryType(name:"WorkDone") |
---|
| 289 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 290 | |
---|
[69] | 291 | entryTypeInstance = new EntryType(name:"Production Note") |
---|
[66] | 292 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 293 | |
---|
| 294 | entryTypeInstance = new EntryType(name:"Work Request") |
---|
| 295 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 296 | |
---|
[116] | 297 | //Entry |
---|
[84] | 298 | def entryInstance |
---|
| 299 | |
---|
[116] | 300 | //Entry #1 |
---|
[84] | 301 | entryInstance = new Entry(enteredBy: Person.get(6), |
---|
| 302 | task: Task.get(1), |
---|
| 303 | entryType: EntryType.findByName("Fault"), |
---|
| 304 | comment: "This level sensor is causing us trouble.", |
---|
| 305 | durationMinute: 20) |
---|
| 306 | BootStrapSaveAndTest(entryInstance) |
---|
| 307 | |
---|
[116] | 308 | //Entry #2 |
---|
[84] | 309 | entryInstance = new Entry(enteredBy: Person.get(4), |
---|
| 310 | task: Task.get(1), |
---|
| 311 | entryType: EntryType.findByName("WorkDone"), |
---|
| 312 | comment: "Cleaned sensor, see how it goes.", |
---|
| 313 | durationMinute: 30) |
---|
| 314 | BootStrapSaveAndTest(entryInstance) |
---|
| 315 | |
---|
[116] | 316 | //Entry #3 |
---|
[84] | 317 | entryInstance = new Entry(enteredBy: Person.get(4), |
---|
| 318 | task: Task.get(1), |
---|
| 319 | entryType: EntryType.findByName("WorkDone"), |
---|
| 320 | comment: "Checked up on it later and sensor is dropping out intermittently, created subTask to replace sensor.", |
---|
| 321 | durationMinute: 20) |
---|
| 322 | BootStrapSaveAndTest(entryInstance) |
---|
| 323 | |
---|
[116] | 324 | //ModificationType |
---|
[93] | 325 | def taskModificationTypeInstance |
---|
| 326 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() |
---|
| 327 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() |
---|
| 328 | taskModificationTypeInstance = new TaskModificationType(name:"Closed").save() |
---|
| 329 | taskModificationTypeInstance = new TaskModificationType(name:"Altered").save() |
---|
| 330 | taskModificationTypeInstance = new TaskModificationType(name:"TargetDateModified").save() |
---|
| 331 | taskModificationTypeInstance = new TaskModificationType(name:"ScheduledDateModified").save() |
---|
| 332 | taskModificationTypeInstance = new TaskModificationType(name:"DescriptionModified").save() |
---|
| 333 | taskModificationTypeInstance = new TaskModificationType(name:"AssignedToModified").save() |
---|
| 334 | taskModificationTypeInstance = new TaskModificationType(name:"NameModified").save() |
---|
[96] | 335 | |
---|
[116] | 336 | //AssignedPerson |
---|
[96] | 337 | def assignedPersonInstance |
---|
| 338 | |
---|
[116] | 339 | //AssignedPerson #1 |
---|
[96] | 340 | assignedPersonInstance = new AssignedPerson(person: Person.get(4), |
---|
| 341 | task: Task.get(1), |
---|
| 342 | estimatedHour: 1, |
---|
| 343 | estimatedMinute: 20) |
---|
| 344 | BootStrapSaveAndTest(assignedPersonInstance) |
---|
| 345 | |
---|
[116] | 346 | //AssignedPerson #2 |
---|
[96] | 347 | assignedPersonInstance = new AssignedPerson(person: Person.get(5), |
---|
| 348 | task: Task.get(1), |
---|
| 349 | estimatedHour: 3, |
---|
| 350 | estimatedMinute: 30) |
---|
| 351 | BootStrapSaveAndTest(assignedPersonInstance) |
---|
| 352 | |
---|
[118] | 353 | /******************* |
---|
| 354 | START OF INVENTORY |
---|
| 355 | |
---|
| 356 | *******************/ |
---|
| 357 | |
---|
[116] | 358 | //Site |
---|
| 359 | def siteInstance |
---|
[96] | 360 | |
---|
[117] | 361 | siteInstance = new Site(name: "Creek Mill") |
---|
[116] | 362 | BootStrapSaveAndTest(siteInstance) |
---|
| 363 | |
---|
[117] | 364 | siteInstance = new Site(name: "Jasper Street Depot") |
---|
| 365 | BootStrapSaveAndTest(siteInstance) |
---|
| 366 | |
---|
[116] | 367 | //InventoryStore |
---|
[117] | 368 | def inventoryStoreInstance |
---|
| 369 | |
---|
| 370 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
[116] | 371 | BootStrapSaveAndTest(inventoryStoreInstance) |
---|
| 372 | |
---|
[117] | 373 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 374 | BootStrapSaveAndTest(inventoryStoreInstance) |
---|
| 375 | |
---|
[116] | 376 | //StoreLocation |
---|
[117] | 377 | def storeLocation |
---|
| 378 | |
---|
| 379 | storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "A1-2") |
---|
[116] | 380 | BootStrapSaveAndTest(storeLocation) |
---|
| 381 | |
---|
[117] | 382 | storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "C55") |
---|
| 383 | BootStrapSaveAndTest(storeLocation) |
---|
| 384 | |
---|
[116] | 385 | //UnitOfMeasure |
---|
| 386 | def unitOfMeasureInstance |
---|
| 387 | |
---|
[117] | 388 | //UnitOfMeasure #1 |
---|
[116] | 389 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 390 | BootStrapSaveAndTest(unitOfMeasureInstance) |
---|
| 391 | |
---|
[117] | 392 | //UnitOfMeasure #2 |
---|
[116] | 393 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 394 | BootStrapSaveAndTest(unitOfMeasureInstance) |
---|
| 395 | |
---|
[117] | 396 | //UnitOfMeasure #3 |
---|
[116] | 397 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 398 | BootStrapSaveAndTest(unitOfMeasureInstance) |
---|
| 399 | |
---|
[117] | 400 | //UnitOfMeasure #4 |
---|
[116] | 401 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 402 | BootStrapSaveAndTest(unitOfMeasureInstance) |
---|
| 403 | |
---|
[117] | 404 | //UnitOfMeasure #5 |
---|
[116] | 405 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 406 | BootStrapSaveAndTest(unitOfMeasureInstance) |
---|
| 407 | |
---|
| 408 | //InventoryGroup |
---|
| 409 | def inventoryGroupInstance |
---|
| 410 | |
---|
[117] | 411 | //InventoryGroup #1 |
---|
[116] | 412 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 413 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 414 | |
---|
[117] | 415 | //InventoryGroup #2 |
---|
| 416 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 417 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 418 | |
---|
| 419 | //InventoryGroup #3 |
---|
| 420 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 421 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 422 | |
---|
| 423 | //InventoryGroup #4 |
---|
| 424 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 425 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 426 | |
---|
[116] | 427 | //InventoryType |
---|
| 428 | def inventoryTypeInstance |
---|
| 429 | |
---|
| 430 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 431 | BootStrapSaveAndTest(inventoryTypeInstance) |
---|
| 432 | |
---|
| 433 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 434 | BootStrapSaveAndTest(inventoryTypeInstance) |
---|
| 435 | |
---|
| 436 | //InventoryItem |
---|
| 437 | def inventoryItemInstance |
---|
| 438 | |
---|
[117] | 439 | //InventoryItem #1 |
---|
[116] | 440 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 441 | inventoryType: InventoryType.get(1), |
---|
[117] | 442 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
| 443 | name: "J-Rope", |
---|
| 444 | description: "Twine wound J-Rope", |
---|
| 445 | reorderPoint: 0) |
---|
| 446 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 447 | |
---|
| 448 | //InventoryItem #2 |
---|
| 449 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 450 | inventoryType: InventoryType.get(1), |
---|
| 451 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
| 452 | name: "L-Rope", |
---|
| 453 | description: "Twine wound L-Rope", |
---|
| 454 | alternateItems: InventoryItem.get(1), |
---|
| 455 | reorderPoint: 0) |
---|
| 456 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 457 | |
---|
| 458 | //InventoryItem #3 |
---|
| 459 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 460 | inventoryType: InventoryType.get(1), |
---|
[116] | 461 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[117] | 462 | name: "2305-2RS", |
---|
| 463 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
| 464 | reorderPoint: 2) |
---|
| 465 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 466 | |
---|
| 467 | //InventoryItem #4 |
---|
| 468 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 469 | inventoryType: InventoryType.get(1), |
---|
| 470 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
| 471 | name: "L1592-K10", |
---|
| 472 | description: "10kW contactor", |
---|
[116] | 473 | reorderPoint: 0) |
---|
| 474 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 475 | |
---|
[117] | 476 | //InventoryItem #5 |
---|
| 477 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 478 | inventoryType: InventoryType.get(1), |
---|
| 479 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
| 480 | name: "6205-ZZ", |
---|
| 481 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
| 482 | reorderPoint: 2) |
---|
| 483 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 484 | |
---|
[116] | 485 | //StoredItem |
---|
| 486 | def storedItemInstance |
---|
| 487 | |
---|
[117] | 488 | //StoredItem #1 |
---|
[116] | 489 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1), |
---|
| 490 | storeLocation: StoreLocation.get(1), |
---|
| 491 | quantity: 8) |
---|
| 492 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 493 | |
---|
[117] | 494 | //StoredItem #2 |
---|
| 495 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1), |
---|
| 496 | storeLocation: StoreLocation.get(2), |
---|
| 497 | quantity: 4) |
---|
| 498 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 499 | |
---|
| 500 | //StoredItem #3 |
---|
| 501 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(2), |
---|
| 502 | storeLocation: StoreLocation.get(1), |
---|
| 503 | quantity: 2) |
---|
| 504 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 505 | |
---|
| 506 | //StoredItem #4 |
---|
| 507 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(3), |
---|
| 508 | storeLocation: StoreLocation.get(1), |
---|
| 509 | quantity: 2) |
---|
| 510 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 511 | |
---|
| 512 | //StoredItem #5 |
---|
| 513 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(4), |
---|
| 514 | storeLocation: StoreLocation.get(1), |
---|
| 515 | quantity: 30) |
---|
| 516 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 517 | |
---|
[118] | 518 | /******************* |
---|
| 519 | START OF ASSET |
---|
| 520 | |
---|
| 521 | *******************/ |
---|
| 522 | |
---|
| 523 | //Frequency |
---|
| 524 | def frequencyInstance |
---|
| 525 | |
---|
| 526 | //Frequency #1 |
---|
| 527 | frequencyInstance = new Frequency(frequency: "Daily") |
---|
| 528 | BootStrapSaveAndTest(frequencyInstance) |
---|
| 529 | |
---|
| 530 | //Frequency #2 |
---|
| 531 | frequencyInstance = new Frequency(frequency: "Monthly") |
---|
| 532 | BootStrapSaveAndTest(frequencyInstance) |
---|
| 533 | |
---|
| 534 | //Frequency #3 |
---|
| 535 | frequencyInstance = new Frequency(frequency: "Quarterly") |
---|
| 536 | BootStrapSaveAndTest(frequencyInstance) |
---|
| 537 | |
---|
| 538 | //Frequency #4 |
---|
| 539 | frequencyInstance = new Frequency(frequency: "Annually") |
---|
| 540 | BootStrapSaveAndTest(frequencyInstance) |
---|
| 541 | |
---|
| 542 | //LifePlan |
---|
| 543 | def lifeplanInstance |
---|
| 544 | |
---|
| 545 | lifeplanInstance = new LifePlan(name: "Initial Plan", |
---|
| 546 | timeInHours: 1, |
---|
| 547 | maintenanceAction: "Visual inspection") |
---|
| 548 | BootStrapSaveAndTest(lifeplanInstance) |
---|
| 549 | |
---|
| 550 | //Form |
---|
| 551 | def formInstance |
---|
| 552 | |
---|
| 553 | formInstance = new Form(name: "Form 1") |
---|
| 554 | BootStrapSaveAndTest(formInstance) |
---|
| 555 | |
---|
| 556 | //SystemSection |
---|
| 557 | def systemSectionInstance |
---|
| 558 | |
---|
| 559 | systemSectionInstance = new SystemSection(name: "Press Section", |
---|
| 560 | lifeplan: LifePlan.get(1)) |
---|
| 561 | BootStrapSaveAndTest(systemSectionInstance) |
---|
| 562 | |
---|
| 563 | //AssetType |
---|
| 564 | def assetTypeInstance |
---|
| 565 | assetTypeInstance = new AssetType(name: "Folder", |
---|
| 566 | lifeplan: LifePlan.get(1), |
---|
| 567 | systemSection: SystemSection.get(1)) |
---|
| 568 | BootStrapSaveAndTest(assetTypeInstance) |
---|
| 569 | |
---|
| 570 | assetTypeInstance = new AssetType(name: "Print Unit", |
---|
| 571 | lifeplan: LifePlan.get(1), |
---|
| 572 | systemSection: SystemSection.get(1)) |
---|
| 573 | BootStrapSaveAndTest(assetTypeInstance) |
---|
| 574 | |
---|
| 575 | //Assembly |
---|
| 576 | def assemblyInstance |
---|
| 577 | assemblyInstance = new Assembly(name: "Delivery Belts", |
---|
| 578 | lifeplan: LifePlan.get(1)) |
---|
| 579 | BootStrapSaveAndTest(assemblyInstance) |
---|
| 580 | |
---|
| 581 | assemblyInstance = new Assembly(name: "Print Couple", |
---|
| 582 | lifeplan: LifePlan.get(1)) |
---|
| 583 | BootStrapSaveAndTest(assemblyInstance) |
---|
| 584 | |
---|
| 585 | //SubAssembly |
---|
| 586 | def subAssemblyInstance |
---|
| 587 | subAssemblyInstance = new SubAssembly(name: "Centre Belt", |
---|
| 588 | lifeplan: LifePlan.get(1)) |
---|
| 589 | BootStrapSaveAndTest(subAssemblyInstance) |
---|
| 590 | |
---|
| 591 | subAssemblyInstance = new SubAssembly(name: "Form Roller", |
---|
| 592 | lifeplan: LifePlan.get(1)) |
---|
| 593 | BootStrapSaveAndTest(subAssemblyInstance) |
---|
| 594 | |
---|
| 595 | //ComponentItem |
---|
| 596 | def componentItemInstance |
---|
| 597 | componentItemInstance = new ComponentItem(name: "Centre Pulley", |
---|
| 598 | fmeaNumber: 1, |
---|
| 599 | lifeplan: LifePlan.get(1)) |
---|
| 600 | BootStrapSaveAndTest(componentItemInstance) |
---|
| 601 | |
---|
| 602 | componentItemInstance = new ComponentItem(name: "Bearing", |
---|
| 603 | fmeaNumber: 1, |
---|
| 604 | lifeplan: LifePlan.get(1)) |
---|
| 605 | BootStrapSaveAndTest(componentItemInstance) |
---|
| 606 | |
---|
| 607 | |
---|
| 608 | //Asset |
---|
| 609 | def assetInstance |
---|
| 610 | |
---|
| 611 | //Asset #1 |
---|
| 612 | assetInstance = new Asset(name: "Print Unit 23", |
---|
| 613 | lifeplan: LifePlan.get(1), |
---|
| 614 | assetType: AssetType.get(1), |
---|
| 615 | riskPriorityNumber: 1) |
---|
| 616 | BootStrapSaveAndTest(assetInstance) |
---|
| 617 | |
---|
[116] | 618 | //Finally did it all work. |
---|
[58] | 619 | if(BootStrapDemoDataSuccessful) { |
---|
| 620 | println "BootStrapping demo data...successful." |
---|
| 621 | } |
---|
| 622 | else println "BootStrapping demo data...failed." |
---|
| 623 | } |
---|
[116] | 624 | |
---|
| 625 | //Call this function instead of .save() |
---|
[58] | 626 | void BootStrapSaveAndTest(object) { |
---|
| 627 | if(!object.save()) { |
---|
| 628 | BootStrapDemoDataSuccessful = false |
---|
| 629 | println "'${object}' failed to save!" |
---|
| 630 | println object.errors |
---|
| 631 | |
---|
| 632 | } |
---|
| 633 | } |
---|
| 634 | } |
---|