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