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