[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 | |
---|
[122] | 35 | /*********************** |
---|
| 36 | START OF UTILITIES |
---|
| 37 | ***********************/ |
---|
[118] | 38 | |
---|
[122] | 39 | //Site |
---|
| 40 | def siteInstance |
---|
[118] | 41 | |
---|
[122] | 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 | |
---|
[116] | 94 | //TypeOfPersonGroup |
---|
[64] | 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) |
---|
[58] | 102 | |
---|
[116] | 103 | //PersonGroup |
---|
[64] | 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) |
---|
[58] | 120 | |
---|
[116] | 121 | //Authority |
---|
[59] | 122 | def authInstance |
---|
| 123 | |
---|
[102] | 124 | authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.", |
---|
[71] | 125 | authority:"ROLE_AppAdmin") |
---|
[59] | 126 | BootStrapSaveAndTest(authInstance) |
---|
| 127 | |
---|
[91] | 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.", |
---|
[71] | 133 | authority:"ROLE_AppUser") |
---|
[59] | 134 | BootStrapSaveAndTest(authInstance) |
---|
[58] | 135 | |
---|
[116] | 136 | //Person |
---|
[73] | 137 | def passClearText = "pass" |
---|
| 138 | def passwordEncoded = authenticateService.encodePassword(passClearText) |
---|
[59] | 139 | def personInstance |
---|
[58] | 140 | |
---|
[102] | 141 | //Person #1 |
---|
[59] | 142 | personInstance = new Person(loginName:"admin", |
---|
[58] | 143 | firstName:"Admin", |
---|
| 144 | lastName:"Powers", |
---|
[73] | 145 | pass:passClearText, |
---|
[59] | 146 | password:passwordEncoded, |
---|
[58] | 147 | email:"admin@example.com") |
---|
| 148 | BootStrapSaveAndTest(personInstance) |
---|
[59] | 149 | personInstance.addToAuthorities(Authority.get(1)) |
---|
| 150 | personInstance.addToAuthorities(Authority.get(2)) |
---|
[91] | 151 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 152 | personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims")) |
---|
[58] | 153 | |
---|
[102] | 154 | //Person #2 |
---|
[91] | 155 | personInstance = new Person(loginName:"manager", |
---|
| 156 | firstName:"Meca", |
---|
| 157 | lastName:"Manager", |
---|
[73] | 158 | pass:passClearText, |
---|
| 159 | password:passwordEncoded, |
---|
[91] | 160 | email:"manager@example.com") |
---|
[73] | 161 | BootStrapSaveAndTest(personInstance) |
---|
| 162 | personInstance.addToAuthorities(Authority.get(2)) |
---|
[91] | 163 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[73] | 164 | personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims")) |
---|
| 165 | |
---|
[102] | 166 | //Person #3 |
---|
[59] | 167 | personInstance = new Person(loginName:"user", |
---|
| 168 | firstName:"Demo", |
---|
[102] | 169 | lastName:"User", |
---|
[73] | 170 | pass:passClearText, |
---|
[59] | 171 | password:passwordEncoded, |
---|
| 172 | email:"user@example.com") |
---|
| 173 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 174 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 175 | personInstance.addToPersonGroups(PersonGroup.findByName("Electrical")) |
---|
[58] | 176 | |
---|
[102] | 177 | //Person #4 |
---|
[59] | 178 | personInstance = new Person(loginName:"craig", |
---|
| 179 | firstName:"Craig", |
---|
[102] | 180 | lastName:"SuperSparky", |
---|
[73] | 181 | pass:passClearText, |
---|
[59] | 182 | password:passwordEncoded, |
---|
| 183 | email:"user@example.com") |
---|
| 184 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 185 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 186 | personInstance.addToPersonGroups(PersonGroup.findByName("Electrical")) |
---|
[58] | 187 | |
---|
[102] | 188 | //Person #5 |
---|
[73] | 189 | personInstance = new Person(loginName:"john", |
---|
| 190 | firstName:"John", |
---|
[102] | 191 | lastName:"SuperFitter", |
---|
[73] | 192 | pass:passClearText, |
---|
[59] | 193 | password:passwordEncoded, |
---|
| 194 | email:"user@example.com") |
---|
| 195 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 196 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 197 | personInstance.addToPersonGroups(PersonGroup.findByName("Mechanical")) |
---|
[58] | 198 | |
---|
[102] | 199 | //Person #6 |
---|
[59] | 200 | personInstance = new Person(loginName:"mann", |
---|
| 201 | firstName:"Production", |
---|
| 202 | lastName:"Mann", |
---|
[73] | 203 | pass:passClearText, |
---|
[59] | 204 | password:passwordEncoded, |
---|
| 205 | email:"user@example.com") |
---|
| 206 | BootStrapSaveAndTest(personInstance) |
---|
[91] | 207 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[66] | 208 | personInstance.addToPersonGroups(PersonGroup.findByName("Production")) |
---|
| 209 | |
---|
[122] | 210 | /********************* |
---|
| 211 | START OF TASK |
---|
| 212 | *********************/ |
---|
| 213 | |
---|
[116] | 214 | //TaskGroup |
---|
[69] | 215 | def taskGroupInstance |
---|
| 216 | |
---|
| 217 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
[131] | 218 | description:"Engineering daily activities") |
---|
[69] | 219 | BootStrapSaveAndTest(taskGroupInstance) |
---|
| 220 | |
---|
| 221 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
[131] | 222 | description:"Production daily activities") |
---|
[69] | 223 | BootStrapSaveAndTest(taskGroupInstance) |
---|
| 224 | |
---|
| 225 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
[131] | 226 | description:" ") |
---|
[69] | 227 | BootStrapSaveAndTest(taskGroupInstance) |
---|
| 228 | |
---|
[116] | 229 | //TaskStatus |
---|
[66] | 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 | |
---|
[116] | 241 | //TaskPriority |
---|
[69] | 242 | def taskPriorityInstance |
---|
[66] | 243 | |
---|
[127] | 244 | taskPriorityInstance = new TaskPriority(name:"Normal") |
---|
[69] | 245 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
[66] | 246 | |
---|
[127] | 247 | taskPriorityInstance = new TaskPriority(name:"Low") |
---|
[69] | 248 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
[66] | 249 | |
---|
[69] | 250 | taskPriorityInstance = new TaskPriority(name:"High") |
---|
| 251 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
[66] | 252 | |
---|
[69] | 253 | taskPriorityInstance = new TaskPriority(name:"Immediate") |
---|
| 254 | BootStrapSaveAndTest(taskPriorityInstance) |
---|
| 255 | |
---|
[116] | 256 | //TaskType |
---|
[69] | 257 | def taskTypeInstance |
---|
| 258 | |
---|
| 259 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") |
---|
| 260 | BootStrapSaveAndTest(taskTypeInstance) |
---|
| 261 | |
---|
[131] | 262 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") |
---|
[69] | 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 | |
---|
[116] | 274 | //Task |
---|
[66] | 275 | def taskInstance |
---|
[58] | 276 | |
---|
[116] | 277 | //Task #1 |
---|
[66] | 278 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 279 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
[69] | 280 | taskPriority:TaskPriority.get(2), |
---|
| 281 | taskType:TaskType.get(1), |
---|
[66] | 282 | leadPerson:Person.get(3), |
---|
| 283 | description:"Check specific level sensor", |
---|
[124] | 284 | comment:"Has been noted as problematic, try recalibrating.") |
---|
[66] | 285 | BootStrapSaveAndTest(taskInstance) |
---|
| 286 | |
---|
[116] | 287 | //Task #2 |
---|
[114] | 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) |
---|
[69] | 297 | |
---|
[116] | 298 | //Task #3 |
---|
[114] | 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 | |
---|
[116] | 309 | //Task #4 |
---|
[114] | 310 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[84] | 311 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 312 | taskPriority:TaskPriority.get(2), |
---|
| 313 | taskType:TaskType.get(1), |
---|
[102] | 314 | leadPerson:Person.get(4), |
---|
[84] | 315 | description:"Replace sensor at next opportunity.", |
---|
[114] | 316 | comment:"Nothing else has worked.", |
---|
| 317 | parentTask: Task.get(1)) |
---|
| 318 | BootStrapSaveAndTest(taskInstance) |
---|
[84] | 319 | |
---|
[116] | 320 | //Task #5 |
---|
[66] | 321 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"), |
---|
| 322 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
[69] | 323 | taskPriority:TaskPriority.get(2), |
---|
| 324 | taskType:TaskType.get(5), |
---|
[102] | 325 | leadPerson:Person.get(6), |
---|
[66] | 326 | description:"Production Report", |
---|
| 327 | comment:"Production report for specific production run or shift") |
---|
| 328 | BootStrapSaveAndTest(taskInstance) |
---|
| 329 | |
---|
[116] | 330 | //Task #6 |
---|
[69] | 331 | taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"), |
---|
[66] | 332 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
[69] | 333 | taskPriority:TaskPriority.get(2), |
---|
| 334 | taskType:TaskType.get(3), |
---|
[66] | 335 | leadPerson:Person.get(1), |
---|
| 336 | description:"Make killer CMMS app", |
---|
| 337 | comment:"Use Grails and get a move on!") |
---|
| 338 | BootStrapSaveAndTest(taskInstance) |
---|
| 339 | |
---|
[116] | 340 | //EntryType |
---|
[66] | 341 | def entryTypeInstance |
---|
[58] | 342 | |
---|
[66] | 343 | entryTypeInstance = new EntryType(name:"Fault") |
---|
| 344 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 345 | |
---|
| 346 | entryTypeInstance = new EntryType(name:"WorkDone") |
---|
| 347 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 348 | |
---|
[69] | 349 | entryTypeInstance = new EntryType(name:"Production Note") |
---|
[66] | 350 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 351 | |
---|
| 352 | entryTypeInstance = new EntryType(name:"Work Request") |
---|
| 353 | BootStrapSaveAndTest(entryTypeInstance) |
---|
| 354 | |
---|
[116] | 355 | //Entry |
---|
[84] | 356 | def entryInstance |
---|
| 357 | |
---|
[116] | 358 | //Entry #1 |
---|
[84] | 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 | |
---|
[116] | 366 | //Entry #2 |
---|
[84] | 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 | |
---|
[116] | 374 | //Entry #3 |
---|
[84] | 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 | |
---|
[116] | 382 | //ModificationType |
---|
[93] | 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() |
---|
[96] | 393 | |
---|
[116] | 394 | //AssignedPerson |
---|
[96] | 395 | def assignedPersonInstance |
---|
| 396 | |
---|
[116] | 397 | //AssignedPerson #1 |
---|
[96] | 398 | assignedPersonInstance = new AssignedPerson(person: Person.get(4), |
---|
| 399 | task: Task.get(1), |
---|
| 400 | estimatedHour: 1, |
---|
| 401 | estimatedMinute: 20) |
---|
| 402 | BootStrapSaveAndTest(assignedPersonInstance) |
---|
| 403 | |
---|
[116] | 404 | //AssignedPerson #2 |
---|
[96] | 405 | assignedPersonInstance = new AssignedPerson(person: Person.get(5), |
---|
| 406 | task: Task.get(1), |
---|
| 407 | estimatedHour: 3, |
---|
| 408 | estimatedMinute: 30) |
---|
| 409 | BootStrapSaveAndTest(assignedPersonInstance) |
---|
| 410 | |
---|
[131] | 411 | //TaskRecurringSchedule |
---|
| 412 | def taskRecurringScheduleInstance |
---|
[118] | 413 | |
---|
[131] | 414 | //TaskRecurringSchedule #1 |
---|
| 415 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
| 416 | recurEvery: 1, |
---|
[122] | 417 | period: Period.get(1), |
---|
[125] | 418 | nextDueDate: new Date()) |
---|
[131] | 419 | BootStrapSaveAndTest(taskRecurringScheduleInstance) |
---|
[118] | 420 | |
---|
[131] | 421 | //TaskRecurringSchedule #2 |
---|
| 422 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(2), |
---|
| 423 | recurEvery: 1, |
---|
| 424 | period: Period.get(1), |
---|
[125] | 425 | nextDueDate: new Date()) |
---|
[131] | 426 | BootStrapSaveAndTest(taskRecurringScheduleInstance) |
---|
[124] | 427 | |
---|
[122] | 428 | /************************* |
---|
| 429 | START OF INVENTORY |
---|
| 430 | **************************/ |
---|
[96] | 431 | |
---|
[116] | 432 | //InventoryStore |
---|
[124] | 433 | def inventoryStoreInstance |
---|
[117] | 434 | |
---|
| 435 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
[116] | 436 | BootStrapSaveAndTest(inventoryStoreInstance) |
---|
| 437 | |
---|
[117] | 438 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 439 | BootStrapSaveAndTest(inventoryStoreInstance) |
---|
| 440 | |
---|
[116] | 441 | //StoreLocation |
---|
[117] | 442 | def storeLocation |
---|
| 443 | |
---|
| 444 | storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "A1-2") |
---|
[116] | 445 | BootStrapSaveAndTest(storeLocation) |
---|
| 446 | |
---|
[117] | 447 | storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "C55") |
---|
| 448 | BootStrapSaveAndTest(storeLocation) |
---|
| 449 | |
---|
[116] | 450 | //InventoryGroup |
---|
| 451 | def inventoryGroupInstance |
---|
| 452 | |
---|
[117] | 453 | //InventoryGroup #1 |
---|
[116] | 454 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 455 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 456 | |
---|
[117] | 457 | //InventoryGroup #2 |
---|
| 458 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 459 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 460 | |
---|
| 461 | //InventoryGroup #3 |
---|
| 462 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 463 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 464 | |
---|
| 465 | //InventoryGroup #4 |
---|
| 466 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 467 | BootStrapSaveAndTest(inventoryGroupInstance) |
---|
| 468 | |
---|
[116] | 469 | //InventoryType |
---|
| 470 | def inventoryTypeInstance |
---|
| 471 | |
---|
| 472 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 473 | BootStrapSaveAndTest(inventoryTypeInstance) |
---|
| 474 | |
---|
| 475 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 476 | BootStrapSaveAndTest(inventoryTypeInstance) |
---|
| 477 | |
---|
| 478 | //InventoryItem |
---|
| 479 | def inventoryItemInstance |
---|
| 480 | |
---|
[117] | 481 | //InventoryItem #1 |
---|
[116] | 482 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 483 | inventoryType: InventoryType.get(1), |
---|
[117] | 484 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
| 485 | name: "J-Rope", |
---|
| 486 | description: "Twine wound J-Rope", |
---|
| 487 | reorderPoint: 0) |
---|
| 488 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 489 | |
---|
| 490 | //InventoryItem #2 |
---|
| 491 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 492 | inventoryType: InventoryType.get(1), |
---|
| 493 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
| 494 | name: "L-Rope", |
---|
| 495 | description: "Twine wound L-Rope", |
---|
| 496 | alternateItems: InventoryItem.get(1), |
---|
| 497 | reorderPoint: 0) |
---|
| 498 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 499 | |
---|
| 500 | //InventoryItem #3 |
---|
| 501 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 502 | inventoryType: InventoryType.get(1), |
---|
[116] | 503 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[117] | 504 | name: "2305-2RS", |
---|
| 505 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
| 506 | reorderPoint: 2) |
---|
| 507 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 508 | |
---|
| 509 | //InventoryItem #4 |
---|
| 510 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 511 | inventoryType: InventoryType.get(1), |
---|
| 512 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
| 513 | name: "L1592-K10", |
---|
| 514 | description: "10kW contactor", |
---|
[116] | 515 | reorderPoint: 0) |
---|
| 516 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 517 | |
---|
[117] | 518 | //InventoryItem #5 |
---|
| 519 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 520 | inventoryType: InventoryType.get(1), |
---|
| 521 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
| 522 | name: "6205-ZZ", |
---|
| 523 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
| 524 | reorderPoint: 2) |
---|
| 525 | BootStrapSaveAndTest(inventoryItemInstance) |
---|
| 526 | |
---|
[116] | 527 | //StoredItem |
---|
| 528 | def storedItemInstance |
---|
| 529 | |
---|
[117] | 530 | //StoredItem #1 |
---|
[116] | 531 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1), |
---|
| 532 | storeLocation: StoreLocation.get(1), |
---|
| 533 | quantity: 8) |
---|
| 534 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 535 | |
---|
[117] | 536 | //StoredItem #2 |
---|
| 537 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1), |
---|
| 538 | storeLocation: StoreLocation.get(2), |
---|
| 539 | quantity: 4) |
---|
| 540 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 541 | |
---|
| 542 | //StoredItem #3 |
---|
| 543 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(2), |
---|
| 544 | storeLocation: StoreLocation.get(1), |
---|
| 545 | quantity: 2) |
---|
| 546 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 547 | |
---|
| 548 | //StoredItem #4 |
---|
| 549 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(3), |
---|
| 550 | storeLocation: StoreLocation.get(1), |
---|
| 551 | quantity: 2) |
---|
| 552 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 553 | |
---|
| 554 | //StoredItem #5 |
---|
| 555 | storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(4), |
---|
| 556 | storeLocation: StoreLocation.get(1), |
---|
| 557 | quantity: 30) |
---|
| 558 | BootStrapSaveAndTest(storedItemInstance) |
---|
| 559 | |
---|
[118] | 560 | /******************* |
---|
| 561 | START OF ASSET |
---|
| 562 | *******************/ |
---|
| 563 | |
---|
[122] | 564 | //LifePlan |
---|
| 565 | def lifeplanInstance |
---|
[118] | 566 | |
---|
[122] | 567 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 568 | BootStrapSaveAndTest(lifeplanInstance) |
---|
[118] | 569 | |
---|
[122] | 570 | //MaintenancePolicy |
---|
[124] | 571 | def maintenancePolicyInstance |
---|
[118] | 572 | |
---|
[122] | 573 | //MaintenancePolicy #1 |
---|
| 574 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 575 | BootStrapSaveAndTest(maintenancePolicyInstance) |
---|
[118] | 576 | |
---|
[124] | 577 | //MaintenancePolicy #2 |
---|
| 578 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 579 | BootStrapSaveAndTest(maintenancePolicyInstance) |
---|
| 580 | |
---|
| 581 | //MaintenancePolicy #3 |
---|
| 582 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 583 | BootStrapSaveAndTest(maintenancePolicyInstance) |
---|
| 584 | |
---|
| 585 | //MaintenancePolicy #4 |
---|
| 586 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 587 | BootStrapSaveAndTest(maintenancePolicyInstance) |
---|
| 588 | |
---|
| 589 | //MaintenancePolicy #5 |
---|
| 590 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 591 | BootStrapSaveAndTest(maintenancePolicyInstance) |
---|
| 592 | |
---|
[131] | 593 | //TaskProcedure |
---|
| 594 | def taskProcedureInstance |
---|
[118] | 595 | |
---|
[131] | 596 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 597 | BootStrapSaveAndTest(taskProcedureInstance) |
---|
| 598 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
[118] | 599 | |
---|
[122] | 600 | //MaintenanceAction |
---|
| 601 | def maintenanceActionInstance |
---|
[118] | 602 | |
---|
[124] | 603 | //MaintenanceAction #1 |
---|
[131] | 604 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, active E-stop S1-S12 and ensure machine cannot run", |
---|
| 605 | procedureStepNumber: 1, |
---|
[122] | 606 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
[131] | 607 | taskProcedure: TaskProcedure.get(1)) |
---|
[122] | 608 | BootStrapSaveAndTest(maintenanceActionInstance) |
---|
[124] | 609 | |
---|
| 610 | //MaintenanceAction #2 |
---|
[131] | 611 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 612 | procedureStepNumber: 2, |
---|
[124] | 613 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
[131] | 614 | taskProcedure: TaskProcedure.get(1)) |
---|
[124] | 615 | BootStrapSaveAndTest(maintenanceActionInstance) |
---|
| 616 | |
---|
| 617 | //MaintenanceAction #3 |
---|
[131] | 618 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 619 | procedureStepNumber: 3, |
---|
[124] | 620 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
[131] | 621 | taskProcedure: TaskProcedure.get(1)) |
---|
[124] | 622 | BootStrapSaveAndTest(maintenanceActionInstance) |
---|
[122] | 623 | |
---|
[118] | 624 | //SystemSection |
---|
[124] | 625 | def systemSectionInstance |
---|
[118] | 626 | |
---|
[124] | 627 | //SystemSection #1 |
---|
[118] | 628 | systemSectionInstance = new SystemSection(name: "Press Section", |
---|
[122] | 629 | site: Site.get(1)) |
---|
[118] | 630 | BootStrapSaveAndTest(systemSectionInstance) |
---|
| 631 | |
---|
[124] | 632 | //SystemSection #2 |
---|
| 633 | systemSectionInstance = new SystemSection(name: "RO System", |
---|
| 634 | site: Site.get(2)) |
---|
| 635 | BootStrapSaveAndTest(systemSectionInstance) |
---|
| 636 | |
---|
| 637 | //SystemSection #3 |
---|
| 638 | systemSectionInstance = new SystemSection(name: "Auxilliray Section", |
---|
| 639 | site: Site.get(1)) |
---|
| 640 | BootStrapSaveAndTest(systemSectionInstance) |
---|
| 641 | |
---|
[118] | 642 | //AssetType |
---|
| 643 | def assetTypeInstance |
---|
[122] | 644 | |
---|
| 645 | //AssetType #1 |
---|
[124] | 646 | assetTypeInstance = new AssetType(name: "Print Unit") |
---|
[118] | 647 | BootStrapSaveAndTest(assetTypeInstance) |
---|
| 648 | |
---|
[122] | 649 | //AssetType #2 |
---|
[124] | 650 | assetTypeInstance = new AssetType(name: "Reactor Tower") |
---|
[118] | 651 | BootStrapSaveAndTest(assetTypeInstance) |
---|
| 652 | |
---|
| 653 | //Assembly |
---|
| 654 | def assemblyInstance |
---|
[122] | 655 | |
---|
| 656 | //Assembly #1 |
---|
[131] | 657 | assemblyInstance = new Assembly(name: "Print Couple", |
---|
| 658 | assetType: AssetType.get(1)) |
---|
[118] | 659 | BootStrapSaveAndTest(assemblyInstance) |
---|
[122] | 660 | // assemblyInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
| 661 | |
---|
| 662 | //Assembly #2 |
---|
[124] | 663 | assemblyInstance = new Assembly(name: "Agitator", |
---|
[131] | 664 | assetType: AssetType.get(2)) |
---|
[118] | 665 | BootStrapSaveAndTest(assemblyInstance) |
---|
| 666 | |
---|
| 667 | //SubAssembly |
---|
| 668 | def subAssemblyInstance |
---|
[122] | 669 | |
---|
| 670 | //SubAssembly #1 |
---|
[131] | 671 | subAssemblyInstance = new SubAssembly(name: "Cylinder", |
---|
| 672 | assembly: Assembly.get(1)) |
---|
[118] | 673 | BootStrapSaveAndTest(subAssemblyInstance) |
---|
[122] | 674 | |
---|
| 675 | //SubAssembly #2 |
---|
[131] | 676 | subAssemblyInstance = new SubAssembly(name: "Gearmotor", |
---|
| 677 | assembly: Assembly.get(2)) |
---|
[118] | 678 | BootStrapSaveAndTest(subAssemblyInstance) |
---|
| 679 | |
---|
| 680 | //ComponentItem |
---|
[122] | 681 | def componentItemInstance |
---|
| 682 | |
---|
| 683 | //ComponentItem #1 |
---|
[131] | 684 | componentItemInstance = new ComponentItem(name: "Bearing", |
---|
| 685 | subAssembly: SubAssembly.get(1)) |
---|
[122] | 686 | BootStrapSaveAndTest(componentItemInstance) |
---|
[118] | 687 | |
---|
[122] | 688 | //ComponentItem #2 |
---|
[131] | 689 | componentItemInstance = new ComponentItem(name: "Drive shaft oil seal", |
---|
| 690 | subAssembly: SubAssembly.get(2)) |
---|
[122] | 691 | BootStrapSaveAndTest(componentItemInstance) |
---|
[118] | 692 | |
---|
| 693 | //Asset |
---|
| 694 | def assetInstance |
---|
| 695 | |
---|
| 696 | //Asset #1 |
---|
[124] | 697 | assetInstance = new Asset(name: "Print Unit 22", |
---|
| 698 | assetType: AssetType.get(1), |
---|
| 699 | systemSection: SystemSection.get(1)) |
---|
| 700 | BootStrapSaveAndTest(assetInstance) |
---|
| 701 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
| 702 | |
---|
| 703 | //Asset #2 |
---|
| 704 | assetInstance = new Asset(name: "Print Unit 21", |
---|
| 705 | assetType: AssetType.get(1), |
---|
| 706 | systemSection: SystemSection.get(1)) |
---|
| 707 | BootStrapSaveAndTest(assetInstance) |
---|
| 708 | |
---|
| 709 | //Asset #3 |
---|
[118] | 710 | assetInstance = new Asset(name: "Print Unit 23", |
---|
| 711 | assetType: AssetType.get(1), |
---|
[122] | 712 | systemSection: SystemSection.get(1)) |
---|
[118] | 713 | BootStrapSaveAndTest(assetInstance) |
---|
| 714 | |
---|
[124] | 715 | //Asset #4 |
---|
| 716 | assetInstance = new Asset(name: "RO 1", |
---|
| 717 | assetType: AssetType.get(2), |
---|
| 718 | systemSection: SystemSection.get(2)) |
---|
| 719 | BootStrapSaveAndTest(assetInstance) |
---|
| 720 | |
---|
| 721 | //AssetExtendedAttributeType |
---|
| 722 | def assetExtendedAttributeInstanceType |
---|
| 723 | |
---|
| 724 | //AssetExtendedAttributeType #1 |
---|
| 725 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Model Number") |
---|
| 726 | BootStrapSaveAndTest(assetExtendedAttributeInstanceType) |
---|
| 727 | |
---|
| 728 | //AssetExtendedAttributeType #2 |
---|
| 729 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Purchase Cost") |
---|
| 730 | BootStrapSaveAndTest(assetExtendedAttributeInstanceType) |
---|
| 731 | |
---|
| 732 | //AssetExtendedAttributeType #3 |
---|
| 733 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Serial Number") |
---|
| 734 | BootStrapSaveAndTest(assetExtendedAttributeInstanceType) |
---|
| 735 | |
---|
| 736 | //AssetExtendedAttributeType #4 |
---|
| 737 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Manufactured Date") |
---|
| 738 | BootStrapSaveAndTest(assetExtendedAttributeInstanceType) |
---|
| 739 | |
---|
| 740 | //AssetExtendedAttributeType #5 |
---|
| 741 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Location Description") |
---|
| 742 | BootStrapSaveAndTest(assetExtendedAttributeInstanceType) |
---|
| 743 | |
---|
| 744 | //AssetExtendedAttribute |
---|
| 745 | def assetExtendedAttributeInstance |
---|
| 746 | |
---|
| 747 | //AssetExtendedAttribute #1 |
---|
| 748 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 749 | asset: Asset.get(1), |
---|
| 750 | assetExtendedAttributeType: AssetExtendedAttributeType.get(1)) |
---|
| 751 | BootStrapSaveAndTest(assetExtendedAttributeInstance) |
---|
| 752 | |
---|
| 753 | //AssetExtendedAttribute #2 |
---|
| 754 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 755 | asset: Asset.get(1), |
---|
| 756 | assetExtendedAttributeType: AssetExtendedAttributeType.get(5)) |
---|
| 757 | BootStrapSaveAndTest(assetExtendedAttributeInstance) |
---|
| 758 | |
---|
| 759 | /************************* |
---|
| 760 | Finally did it all work. |
---|
| 761 | **************************/ |
---|
[58] | 762 | if(BootStrapDemoDataSuccessful) { |
---|
| 763 | println "BootStrapping demo data...successful." |
---|
| 764 | } |
---|
| 765 | else println "BootStrapping demo data...failed." |
---|
| 766 | } |
---|
[116] | 767 | |
---|
[124] | 768 | /**************************************** |
---|
| 769 | Call this function instead of .save() |
---|
| 770 | *****************************************/ |
---|
[58] | 771 | void BootStrapSaveAndTest(object) { |
---|
| 772 | if(!object.save()) { |
---|
| 773 | BootStrapDemoDataSuccessful = false |
---|
| 774 | println "'${object}' failed to save!" |
---|
| 775 | println object.errors |
---|
| 776 | |
---|
| 777 | } |
---|
| 778 | } |
---|
| 779 | } |
---|