[149] | 1 | /** |
---|
| 2 | * Provides a data service to create base and demo data. |
---|
[180] | 3 | * Beware that most, if not all, base data is referenced by "Id" throughout the program. |
---|
| 4 | * This allows changing the text of the 'name' property to something of the same meaning. |
---|
| 5 | * But be sure to maintain the correct Id during creation, indicated by #1, #2 etc. |
---|
[149] | 6 | */ |
---|
| 7 | class CreateDataService { |
---|
| 8 | |
---|
| 9 | boolean transactional = false |
---|
| 10 | |
---|
[182] | 11 | def personService |
---|
[180] | 12 | def taskService |
---|
[210] | 13 | def dateUtilService |
---|
[180] | 14 | |
---|
[149] | 15 | /******************************************* |
---|
| 16 | Start of Group methods. |
---|
| 17 | Generally use these methods to create data. |
---|
| 18 | *******************************************/ |
---|
| 19 | |
---|
| 20 | /** |
---|
[199] | 21 | * Always call this at startup to ensure that we have admin access |
---|
| 22 | * and that the system pseudo person is available. |
---|
[149] | 23 | */ |
---|
[199] | 24 | def ensureSystemAndAdminAccess() { |
---|
[149] | 25 | if(!Authority.findByAuthority("ROLE_AppAdmin") ) { |
---|
[199] | 26 | log.warn "ROLE_AppAdmin not found, calling createAdminAuthority()." |
---|
[149] | 27 | createAdminAuthority() |
---|
| 28 | } |
---|
[199] | 29 | if(!Person.findByloginName("system") ) { |
---|
| 30 | log.warn "LoginName 'system' not found, calling createSystemPerson()." |
---|
| 31 | createSystemPerson() |
---|
| 32 | } |
---|
[149] | 33 | if(!Person.findByloginName("admin") ) { |
---|
[199] | 34 | log.warn "LoginName 'admin' not found, calling createAdminPerson()." |
---|
[149] | 35 | createAdminPerson() |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Create the base data required for the application to function. |
---|
| 41 | */ |
---|
| 42 | def createBaseData() { |
---|
[199] | 43 | log.info "Creating base data..." |
---|
[149] | 44 | // Person and Utils |
---|
| 45 | createBaseAuthorities() |
---|
| 46 | createBasePersonGroups() |
---|
| 47 | createBaseUnitsOfMeasure() |
---|
| 48 | createBasePeriods() |
---|
[175] | 49 | createBaseSupplierType() |
---|
| 50 | createBaseManufacturerType() |
---|
[149] | 51 | // Tasks |
---|
[180] | 52 | createBaseTaskGroups() |
---|
[149] | 53 | createBaseTaskStatus() |
---|
| 54 | createBaseTaskPriorities() |
---|
| 55 | createBaseTaskTypes() |
---|
[180] | 56 | createBaseTaskModificationTypes() |
---|
[149] | 57 | createBaseEntryTypes() |
---|
| 58 | // Inventory |
---|
| 59 | createBaseInventoryTypes() |
---|
[175] | 60 | createBaseInventoryMovementTypes() |
---|
[149] | 61 | createBaseMaintenancePolicies() |
---|
| 62 | // Assets |
---|
| 63 | createBaseAssetExtenededAttributeTypes() |
---|
| 64 | |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | /** |
---|
| 68 | * Create demo data for some example sites. |
---|
| 69 | */ |
---|
| 70 | def createDemoData() { |
---|
[199] | 71 | log.info "Creating demo data..." |
---|
[149] | 72 | // Person and Utils |
---|
| 73 | createDemoPersons() |
---|
| 74 | createDemoSites() |
---|
[162] | 75 | createDemoDepartments() |
---|
[175] | 76 | createDemoSuppliers() |
---|
| 77 | createDemoManufacturers() |
---|
[149] | 78 | // Tasks |
---|
| 79 | createDemoTasks() |
---|
| 80 | createDemoEntries() |
---|
| 81 | createDemoAssignedPersons() |
---|
| 82 | createDemoTaskRecurringSchedules() |
---|
| 83 | // Inventory |
---|
| 84 | createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
[175] | 85 | createDemoInventoryLocations() |
---|
[149] | 86 | createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
| 87 | createDemoInventoryItems() |
---|
| 88 | // Assets |
---|
| 89 | createDemoLifePlan() |
---|
| 90 | createDemoTaskProcedure() |
---|
| 91 | createDemoMaintenanceActions() |
---|
| 92 | createDemoSystemSections() |
---|
| 93 | createDemoAssetTypes() |
---|
| 94 | createDemoAssemblies() |
---|
| 95 | createDemoSubAssemblies() |
---|
| 96 | createDemoComponentItems() |
---|
| 97 | createDemoAssets() |
---|
| 98 | createDemoAssetExtenedAttributes() |
---|
| 99 | } |
---|
| 100 | |
---|
| 101 | /****************** |
---|
| 102 | Start of Person |
---|
| 103 | *******************/ |
---|
| 104 | |
---|
| 105 | def createAdminAuthority() { |
---|
| 106 | def authInstance |
---|
| 107 | |
---|
| 108 | authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.", |
---|
| 109 | authority:"ROLE_AppAdmin") |
---|
| 110 | saveAndTest(authInstance) |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | def createBaseAuthorities() { |
---|
| 114 | |
---|
| 115 | def authInstance |
---|
| 116 | |
---|
| 117 | authInstance = new Authority(description:"Business manager, grants full management access.", |
---|
| 118 | authority:"ROLE_Manager") |
---|
| 119 | saveAndTest(authInstance) |
---|
| 120 | |
---|
| 121 | authInstance = new Authority(description:"Application User, all application users need this base role to allow login.", |
---|
| 122 | authority:"ROLE_AppUser") |
---|
| 123 | saveAndTest(authInstance) |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | void createBasePersonGroups() { |
---|
| 127 | //TypeOfPersonGroup |
---|
| 128 | def personGroupTypeInstance |
---|
[164] | 129 | personGroupTypeInstance = new PersonGroupType(name:"Team") |
---|
[149] | 130 | saveAndTest(personGroupTypeInstance) |
---|
| 131 | personGroupTypeInstance = new PersonGroupType(name:"Contractor") |
---|
| 132 | saveAndTest(personGroupTypeInstance) |
---|
| 133 | personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam") |
---|
| 134 | saveAndTest(personGroupTypeInstance) |
---|
| 135 | |
---|
| 136 | //PersonGroup |
---|
| 137 | def personGroupInstance |
---|
[164] | 138 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 139 | name:"Electrical") |
---|
| 140 | saveAndTest(personGroupInstance) |
---|
[164] | 141 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 142 | name:"Mechanical") |
---|
| 143 | saveAndTest(personGroupInstance) |
---|
[164] | 144 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 145 | name:"Production") |
---|
| 146 | saveAndTest(personGroupInstance) |
---|
| 147 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
| 148 | name:"Kewl AirCon Guys") |
---|
| 149 | saveAndTest(personGroupInstance) |
---|
| 150 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
| 151 | name:"gnuMims") |
---|
| 152 | saveAndTest(personGroupInstance) |
---|
| 153 | } |
---|
| 154 | |
---|
[199] | 155 | def createSystemPerson() { |
---|
| 156 | //Person |
---|
| 157 | def passClearText = "pass" |
---|
| 158 | def passwordEncoded = personService.encodePassword(passClearText) |
---|
| 159 | def personInstance |
---|
| 160 | |
---|
| 161 | //Person #1 |
---|
| 162 | personInstance = new Person(loginName:"system", |
---|
| 163 | firstName:"gnuMims", |
---|
| 164 | lastName:"System", |
---|
| 165 | description:'''This is a pseudo person that the application uses to insert data. DO NOT |
---|
| 166 | assign login authorities or change the details of this person.''', |
---|
| 167 | pass:passClearText, |
---|
| 168 | password:passwordEncoded, |
---|
| 169 | email:"system@example.com") |
---|
| 170 | saveAndTest(personInstance) |
---|
| 171 | } |
---|
| 172 | |
---|
[149] | 173 | def createAdminPerson() { |
---|
| 174 | //Person |
---|
| 175 | def passClearText = "pass" |
---|
[182] | 176 | def passwordEncoded = personService.encodePassword(passClearText) |
---|
[149] | 177 | def personInstance |
---|
| 178 | |
---|
[199] | 179 | //Person #2 |
---|
[149] | 180 | personInstance = new Person(loginName:"admin", |
---|
| 181 | firstName:"Admin", |
---|
| 182 | lastName:"Powers", |
---|
[199] | 183 | description:'''Every time the application starts it ensures that the 'admin' login name is available. |
---|
| 184 | DO update the password and other details but keep the login name as 'admin'. ''', |
---|
[149] | 185 | pass:passClearText, |
---|
| 186 | password:passwordEncoded, |
---|
| 187 | email:"admin@example.com") |
---|
| 188 | saveAndTest(personInstance) |
---|
| 189 | personInstance.addToAuthorities(Authority.get(1)) |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | def createBasePersons() { |
---|
[199] | 193 | } |
---|
| 194 | |
---|
| 195 | def createDemoPersons() { |
---|
[149] | 196 | //Person |
---|
| 197 | def passClearText = "pass" |
---|
[182] | 198 | def passwordEncoded = personService.encodePassword(passClearText) |
---|
[149] | 199 | def personInstance |
---|
| 200 | |
---|
[199] | 201 | //Person #1 is system. |
---|
| 202 | //Person #2 is admin. |
---|
[149] | 203 | |
---|
[199] | 204 | //Person #3 |
---|
[149] | 205 | personInstance = new Person(loginName:"manager", |
---|
| 206 | firstName:"Demo", |
---|
| 207 | lastName:"Manager", |
---|
| 208 | pass:passClearText, |
---|
| 209 | password:passwordEncoded, |
---|
| 210 | email:"manager@example.com") |
---|
| 211 | saveAndTest(personInstance) |
---|
| 212 | personInstance.addToAuthorities(Authority.get(2)) |
---|
| 213 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 214 | personInstance.addToPersonGroups(PersonGroup.get(5)) |
---|
[149] | 215 | |
---|
[199] | 216 | //Person #4 |
---|
[149] | 217 | personInstance = new Person(loginName:"user", |
---|
| 218 | firstName:"Demo", |
---|
| 219 | lastName:"User", |
---|
| 220 | pass:passClearText, |
---|
| 221 | password:passwordEncoded, |
---|
| 222 | email:"user@example.com") |
---|
| 223 | saveAndTest(personInstance) |
---|
| 224 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 225 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 226 | |
---|
[199] | 227 | //Person #5 |
---|
[149] | 228 | personInstance = new Person(loginName:"craig", |
---|
| 229 | firstName:"Craig", |
---|
| 230 | lastName:"SuperSparky", |
---|
| 231 | pass:passClearText, |
---|
| 232 | password:passwordEncoded, |
---|
| 233 | email:"user@example.com") |
---|
| 234 | saveAndTest(personInstance) |
---|
| 235 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 236 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 237 | |
---|
[199] | 238 | //Person #6 |
---|
[149] | 239 | personInstance = new Person(loginName:"john", |
---|
| 240 | firstName:"John", |
---|
| 241 | lastName:"SuperFitter", |
---|
| 242 | pass:passClearText, |
---|
| 243 | password:passwordEncoded, |
---|
| 244 | email:"user@example.com") |
---|
| 245 | saveAndTest(personInstance) |
---|
| 246 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 247 | personInstance.addToPersonGroups(PersonGroup.get(2)) |
---|
[149] | 248 | |
---|
[199] | 249 | //Person #7 |
---|
[149] | 250 | personInstance = new Person(loginName:"mann", |
---|
| 251 | firstName:"Production", |
---|
| 252 | lastName:"Mann", |
---|
| 253 | pass:passClearText, |
---|
| 254 | password:passwordEncoded, |
---|
| 255 | email:"user@example.com") |
---|
| 256 | saveAndTest(personInstance) |
---|
| 257 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 258 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
[149] | 259 | } |
---|
| 260 | |
---|
| 261 | /*********************** |
---|
| 262 | START OF UTILITIES |
---|
| 263 | ***********************/ |
---|
| 264 | |
---|
| 265 | def createDemoSites() { |
---|
| 266 | //Site |
---|
| 267 | def siteInstance |
---|
| 268 | |
---|
| 269 | siteInstance = new Site(name: "Creek Mill") |
---|
| 270 | saveAndTest(siteInstance) |
---|
| 271 | |
---|
| 272 | siteInstance = new Site(name: "Jasper Street Depot") |
---|
| 273 | saveAndTest(siteInstance) |
---|
[162] | 274 | |
---|
| 275 | siteInstance = new Site(name: "River Press") |
---|
| 276 | saveAndTest(siteInstance) |
---|
[149] | 277 | } |
---|
| 278 | |
---|
[162] | 279 | def createDemoDepartments() { |
---|
| 280 | |
---|
| 281 | //Department |
---|
| 282 | def departmentInstance |
---|
| 283 | |
---|
| 284 | //Department #1 |
---|
| 285 | departmentInstance = new Department(name: "Print Centre", |
---|
| 286 | site: Site.get(1)) |
---|
| 287 | saveAndTest(departmentInstance) |
---|
| 288 | |
---|
| 289 | //Department #2 |
---|
| 290 | departmentInstance = new Department(name: "Pulp Mill 2", |
---|
| 291 | site: Site.get(2)) |
---|
| 292 | saveAndTest(departmentInstance) |
---|
| 293 | } |
---|
| 294 | |
---|
[149] | 295 | def createBaseUnitsOfMeasure() { |
---|
| 296 | |
---|
| 297 | //UnitOfMeasure |
---|
| 298 | def unitOfMeasureInstance |
---|
| 299 | |
---|
| 300 | //UnitOfMeasure #1 |
---|
| 301 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 302 | saveAndTest(unitOfMeasureInstance) |
---|
| 303 | |
---|
| 304 | //UnitOfMeasure #2 |
---|
| 305 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 306 | saveAndTest(unitOfMeasureInstance) |
---|
| 307 | |
---|
| 308 | //UnitOfMeasure #3 |
---|
| 309 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 310 | saveAndTest(unitOfMeasureInstance) |
---|
| 311 | |
---|
| 312 | //UnitOfMeasure #4 |
---|
| 313 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 314 | saveAndTest(unitOfMeasureInstance) |
---|
| 315 | |
---|
| 316 | //UnitOfMeasure #5 |
---|
| 317 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 318 | saveAndTest(unitOfMeasureInstance) |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | def createBasePeriods() { |
---|
| 322 | |
---|
| 323 | //Period |
---|
| 324 | def periodInstance |
---|
| 325 | |
---|
| 326 | //Period #1 |
---|
| 327 | periodInstance = new Period(period: "Day(s)") |
---|
| 328 | saveAndTest(periodInstance) |
---|
| 329 | |
---|
| 330 | //Period #2 |
---|
| 331 | periodInstance = new Period(period: "Week(s)") |
---|
| 332 | saveAndTest(periodInstance) |
---|
| 333 | |
---|
| 334 | //Period #3 |
---|
| 335 | periodInstance = new Period(period: "Month(s)") |
---|
| 336 | saveAndTest(periodInstance) |
---|
| 337 | |
---|
| 338 | //Period #4 |
---|
| 339 | periodInstance = new Period(period: "Year(s)") |
---|
| 340 | saveAndTest(periodInstance) |
---|
| 341 | } |
---|
| 342 | |
---|
[175] | 343 | def createBaseSupplierType() { |
---|
| 344 | |
---|
| 345 | // SupplierType |
---|
| 346 | def supplierTypeInstance |
---|
| 347 | |
---|
| 348 | // SupplierType #1 |
---|
| 349 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
| 350 | description: "Original equipment supplier") |
---|
| 351 | saveAndTest(supplierTypeInstance) |
---|
| 352 | |
---|
| 353 | // SupplierType #2 |
---|
| 354 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
| 355 | description: "Local supplier") |
---|
| 356 | saveAndTest(supplierTypeInstance) |
---|
| 357 | } |
---|
| 358 | |
---|
| 359 | def createBaseManufacturerType() { |
---|
| 360 | |
---|
| 361 | // ManufacturerType |
---|
| 362 | def manufacturerTypeInstance |
---|
| 363 | |
---|
| 364 | // ManufacturerType #1 |
---|
| 365 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
| 366 | description: "Original equipment manufacturer") |
---|
| 367 | saveAndTest(manufacturerTypeInstance) |
---|
| 368 | |
---|
| 369 | // ManufacturerType #2 |
---|
| 370 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
| 371 | description: "Not original equipment manufacturer") |
---|
| 372 | saveAndTest(manufacturerTypeInstance) |
---|
| 373 | |
---|
| 374 | } |
---|
| 375 | |
---|
| 376 | def createDemoSuppliers() { |
---|
| 377 | |
---|
| 378 | // Supplier |
---|
| 379 | def supplierInstance |
---|
| 380 | |
---|
| 381 | // Supplier #1 |
---|
| 382 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
| 383 | supplierType: SupplierType.get(1)) |
---|
| 384 | saveAndTest(supplierInstance) |
---|
| 385 | |
---|
| 386 | // Supplier #2 |
---|
| 387 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
| 388 | supplierType: SupplierType.get(2)) |
---|
| 389 | saveAndTest(supplierInstance) |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | def createDemoManufacturers() { |
---|
| 393 | |
---|
| 394 | // Manufacturer |
---|
| 395 | def manufacturerInstance |
---|
| 396 | |
---|
| 397 | // Manufacturer #1 |
---|
| 398 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
| 399 | manufacturerType: ManufacturerType.get(1)) |
---|
| 400 | saveAndTest(manufacturerInstance) |
---|
| 401 | |
---|
| 402 | // Manufacturer #2 |
---|
| 403 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
| 404 | manufacturerType: ManufacturerType.get(2)) |
---|
| 405 | saveAndTest(manufacturerInstance) |
---|
| 406 | } |
---|
| 407 | |
---|
[149] | 408 | /********************* |
---|
| 409 | START OF TASK |
---|
| 410 | *********************/ |
---|
| 411 | |
---|
[180] | 412 | def createBaseTaskGroups() { |
---|
[149] | 413 | //TaskGroup |
---|
| 414 | def taskGroupInstance |
---|
| 415 | |
---|
| 416 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 417 | description:"Engineering daily activities") |
---|
| 418 | saveAndTest(taskGroupInstance) |
---|
| 419 | |
---|
| 420 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 421 | description:"Production daily activities") |
---|
| 422 | saveAndTest(taskGroupInstance) |
---|
| 423 | |
---|
| 424 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
| 425 | description:" ") |
---|
| 426 | saveAndTest(taskGroupInstance) |
---|
| 427 | } |
---|
| 428 | |
---|
| 429 | def createBaseTaskStatus() { |
---|
| 430 | |
---|
| 431 | //TaskStatus |
---|
| 432 | def taskStatusInstance |
---|
| 433 | |
---|
[181] | 434 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
[149] | 435 | saveAndTest(taskStatusInstance) |
---|
| 436 | |
---|
[181] | 437 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
[149] | 438 | saveAndTest(taskStatusInstance) |
---|
| 439 | |
---|
[222] | 440 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
[149] | 441 | saveAndTest(taskStatusInstance) |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | def createBaseTaskPriorities() { |
---|
| 445 | |
---|
| 446 | //TaskPriority |
---|
| 447 | def taskPriorityInstance |
---|
| 448 | |
---|
[199] | 449 | taskPriorityInstance = new TaskPriority(name:"Normal") // #1 |
---|
[149] | 450 | saveAndTest(taskPriorityInstance) |
---|
| 451 | |
---|
[199] | 452 | taskPriorityInstance = new TaskPriority(name:"Low") // #2 |
---|
[149] | 453 | saveAndTest(taskPriorityInstance) |
---|
| 454 | |
---|
[199] | 455 | taskPriorityInstance = new TaskPriority(name:"High") // #3 |
---|
[149] | 456 | saveAndTest(taskPriorityInstance) |
---|
| 457 | |
---|
[199] | 458 | taskPriorityInstance = new TaskPriority(name:"Immediate") // #4 |
---|
[149] | 459 | saveAndTest(taskPriorityInstance) |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | def createBaseTaskTypes() { |
---|
| 463 | |
---|
| 464 | //TaskType |
---|
| 465 | def taskTypeInstance |
---|
| 466 | |
---|
[199] | 467 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1 |
---|
[149] | 468 | saveAndTest(taskTypeInstance) |
---|
| 469 | |
---|
[199] | 470 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2 |
---|
[149] | 471 | saveAndTest(taskTypeInstance) |
---|
| 472 | |
---|
[199] | 473 | taskTypeInstance = new TaskType(name:"Project") // #3 |
---|
[149] | 474 | saveAndTest(taskTypeInstance) |
---|
| 475 | |
---|
[199] | 476 | taskTypeInstance = new TaskType(name:"Turnaround") // #4 |
---|
[149] | 477 | saveAndTest(taskTypeInstance) |
---|
| 478 | |
---|
[199] | 479 | taskTypeInstance = new TaskType(name:"Production Run") // #5 |
---|
[149] | 480 | saveAndTest(taskTypeInstance) |
---|
| 481 | } |
---|
| 482 | |
---|
[180] | 483 | def createBaseTaskModificationTypes() { |
---|
| 484 | |
---|
| 485 | //ModificationType |
---|
| 486 | def taskModificationTypeInstance |
---|
| 487 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
| 488 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
| 489 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
| 490 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
| 491 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
| 492 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
| 493 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
| 494 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
| 495 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
| 496 | } |
---|
| 497 | |
---|
[149] | 498 | def createDemoTasks() { |
---|
| 499 | |
---|
[180] | 500 | def taskResult |
---|
| 501 | def p = [:] |
---|
[149] | 502 | |
---|
| 503 | //Task #1 |
---|
[180] | 504 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 505 | taskPriority:TaskPriority.get(2), |
---|
| 506 | taskType:TaskType.get(1), |
---|
| 507 | leadPerson:Person.get(2), |
---|
| 508 | description:"Check specific level sensor", |
---|
| 509 | comment:"Has been noted as problematic, try recalibrating.", |
---|
[210] | 510 | targetStartDate: dateUtilService.today] |
---|
[149] | 511 | |
---|
[180] | 512 | taskResult = taskService.create(p) |
---|
| 513 | |
---|
[149] | 514 | //Task #2 |
---|
[180] | 515 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 516 | taskPriority:TaskPriority.get(2), |
---|
| 517 | taskType:TaskType.get(1), |
---|
| 518 | leadPerson:Person.get(5), |
---|
| 519 | description:"Some follow-up work", |
---|
| 520 | comment:"Some help required", |
---|
[210] | 521 | targetStartDate: dateUtilService.tomorrow, |
---|
[180] | 522 | parentTask: Task.get(1)] |
---|
[149] | 523 | |
---|
[180] | 524 | taskResult = taskService.create(p) |
---|
| 525 | |
---|
[149] | 526 | //Task #3 |
---|
[180] | 527 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 528 | taskPriority:TaskPriority.get(2), |
---|
| 529 | taskType:TaskType.get(1), |
---|
| 530 | leadPerson:Person.get(5), |
---|
| 531 | description:"A Sub Task can be created by setting the Parent Task value", |
---|
| 532 | comment:"Some help required", |
---|
[210] | 533 | targetStartDate: dateUtilService.yesterday, |
---|
[180] | 534 | parentTask: Task.get(1)] |
---|
[149] | 535 | |
---|
[180] | 536 | taskResult = taskService.create(p) |
---|
| 537 | |
---|
[149] | 538 | //Task #4 |
---|
[180] | 539 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 540 | taskPriority:TaskPriority.get(2), |
---|
| 541 | taskType:TaskType.get(1), |
---|
| 542 | leadPerson:Person.get(4), |
---|
| 543 | description:"Replace sensor at next opportunity.", |
---|
| 544 | comment:"Nothing else has worked.", |
---|
[210] | 545 | targetStartDate: dateUtilService.oneWeekFromNow, |
---|
[180] | 546 | parentTask: Task.get(1)] |
---|
[149] | 547 | |
---|
[180] | 548 | taskResult = taskService.create(p) |
---|
| 549 | |
---|
[149] | 550 | //Task #5 |
---|
[180] | 551 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
[149] | 552 | taskPriority:TaskPriority.get(2), |
---|
| 553 | taskType:TaskType.get(5), |
---|
| 554 | leadPerson:Person.get(6), |
---|
| 555 | description:"Production Report", |
---|
| 556 | comment:"Production report for specific production run or shift", |
---|
[210] | 557 | targetStartDate: dateUtilService.today - 6] |
---|
[149] | 558 | |
---|
[180] | 559 | taskResult = taskService.create(p) |
---|
| 560 | |
---|
[149] | 561 | //Task #6 |
---|
[199] | 562 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 563 | taskPriority:TaskPriority.get(1), |
---|
| 564 | taskType:TaskType.get(2), |
---|
| 565 | leadPerson:Person.get(4), |
---|
| 566 | description:"This is a recurring task", |
---|
| 567 | comment:"If there is a parent task specified then this is a generated sub task, if there is a recurring schedule specified then this is a parent task.", |
---|
[210] | 568 | targetStartDate: dateUtilService.today] |
---|
[180] | 569 | |
---|
| 570 | taskResult = taskService.create(p) |
---|
[149] | 571 | } |
---|
| 572 | |
---|
| 573 | def createBaseEntryTypes() { |
---|
| 574 | |
---|
| 575 | //EntryType |
---|
| 576 | def entryTypeInstance |
---|
| 577 | |
---|
[190] | 578 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
[149] | 579 | saveAndTest(entryTypeInstance) |
---|
| 580 | |
---|
[190] | 581 | entryTypeInstance = new EntryType(name:"Work Done") // #2 |
---|
[149] | 582 | saveAndTest(entryTypeInstance) |
---|
| 583 | |
---|
[190] | 584 | entryTypeInstance = new EntryType(name:"Production Note") // #3 |
---|
[149] | 585 | saveAndTest(entryTypeInstance) |
---|
| 586 | |
---|
[190] | 587 | entryTypeInstance = new EntryType(name:"Work Request") // #4 |
---|
[149] | 588 | saveAndTest(entryTypeInstance) |
---|
| 589 | } |
---|
| 590 | |
---|
| 591 | def createDemoEntries() { |
---|
| 592 | |
---|
[190] | 593 | def entryResult |
---|
| 594 | def p = [:] |
---|
[149] | 595 | |
---|
| 596 | //Entry #1 |
---|
[190] | 597 | p = [task: Task.get(1), |
---|
| 598 | entryType: EntryType.get(1), |
---|
| 599 | comment: "This level sensor is causing us trouble.", |
---|
| 600 | durationMinute: 20] |
---|
[149] | 601 | |
---|
[190] | 602 | entryResult = taskService.createEntry(p) |
---|
| 603 | |
---|
[149] | 604 | //Entry #2 |
---|
[190] | 605 | p = [task: Task.get(1), |
---|
| 606 | entryType: EntryType.get(2), |
---|
| 607 | comment: "Cleaned sensor, see how it goes.", |
---|
| 608 | durationMinute: 30] |
---|
[149] | 609 | |
---|
[190] | 610 | entryResult = taskService.createEntry(p) |
---|
| 611 | |
---|
[149] | 612 | //Entry #3 |
---|
[190] | 613 | p = [task: Task.get(1), |
---|
| 614 | entryType: EntryType.get(2), |
---|
| 615 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
| 616 | durationMinute: 20] |
---|
| 617 | |
---|
| 618 | entryResult = taskService.createEntry(p) |
---|
[149] | 619 | } |
---|
| 620 | |
---|
| 621 | def createDemoAssignedPersons() { |
---|
| 622 | |
---|
| 623 | //AssignedPerson |
---|
| 624 | def assignedPersonInstance |
---|
| 625 | |
---|
| 626 | //AssignedPerson #1 |
---|
| 627 | assignedPersonInstance = new AssignedPerson(person: Person.get(4), |
---|
| 628 | task: Task.get(1), |
---|
| 629 | estimatedHour: 1, |
---|
| 630 | estimatedMinute: 20) |
---|
| 631 | saveAndTest(assignedPersonInstance) |
---|
| 632 | |
---|
| 633 | //AssignedPerson #2 |
---|
| 634 | assignedPersonInstance = new AssignedPerson(person: Person.get(5), |
---|
| 635 | task: Task.get(1), |
---|
| 636 | estimatedHour: 3, |
---|
| 637 | estimatedMinute: 30) |
---|
| 638 | saveAndTest(assignedPersonInstance) |
---|
| 639 | } |
---|
| 640 | |
---|
| 641 | def createDemoTaskRecurringSchedules() { |
---|
| 642 | |
---|
| 643 | //TaskRecurringSchedule |
---|
| 644 | def taskRecurringScheduleInstance |
---|
| 645 | |
---|
| 646 | //TaskRecurringSchedule #1 |
---|
| 647 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
| 648 | recurEvery: 1, |
---|
[199] | 649 | recurPeriod: Period.get(2), |
---|
[210] | 650 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 651 | generateAhead: 1, |
---|
[199] | 652 | taskDuration: 2, |
---|
| 653 | taskDurationPeriod: Period.get(1), |
---|
| 654 | enabled: false) |
---|
[149] | 655 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 656 | |
---|
| 657 | //TaskRecurringSchedule #2 |
---|
[199] | 658 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6), |
---|
[149] | 659 | recurEvery: 1, |
---|
| 660 | recurPeriod: Period.get(1), |
---|
[210] | 661 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 662 | generateAhead: 1, |
---|
| 663 | taskDuration: 1, |
---|
[199] | 664 | taskDurationPeriod: Period.get(1), |
---|
| 665 | enabled: true) |
---|
[149] | 666 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 667 | } |
---|
| 668 | |
---|
| 669 | /************************* |
---|
| 670 | START OF INVENTORY |
---|
| 671 | **************************/ |
---|
| 672 | |
---|
| 673 | def createDemoInventoryStores() { |
---|
| 674 | |
---|
| 675 | //InventoryStore |
---|
| 676 | def inventoryStoreInstance |
---|
| 677 | |
---|
| 678 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 679 | saveAndTest(inventoryStoreInstance) |
---|
| 680 | |
---|
| 681 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 682 | saveAndTest(inventoryStoreInstance) |
---|
| 683 | } |
---|
| 684 | |
---|
[175] | 685 | def createDemoInventoryLocations() { |
---|
[149] | 686 | |
---|
[175] | 687 | // InventoryLocation |
---|
| 688 | def inventoryLocation |
---|
[149] | 689 | |
---|
[175] | 690 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 691 | saveAndTest(inventoryLocation) |
---|
[149] | 692 | |
---|
[175] | 693 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "C55") |
---|
| 694 | saveAndTest(inventoryLocation) |
---|
[149] | 695 | } |
---|
| 696 | |
---|
| 697 | def createDemoInventoryGroups() { |
---|
| 698 | |
---|
| 699 | //InventoryGroup |
---|
| 700 | def inventoryGroupInstance |
---|
| 701 | |
---|
| 702 | //InventoryGroup #1 |
---|
| 703 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 704 | saveAndTest(inventoryGroupInstance) |
---|
| 705 | |
---|
| 706 | //InventoryGroup #2 |
---|
| 707 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 708 | saveAndTest(inventoryGroupInstance) |
---|
| 709 | |
---|
| 710 | //InventoryGroup #3 |
---|
| 711 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 712 | saveAndTest(inventoryGroupInstance) |
---|
| 713 | |
---|
| 714 | //InventoryGroup #4 |
---|
| 715 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 716 | saveAndTest(inventoryGroupInstance) |
---|
| 717 | } |
---|
| 718 | |
---|
| 719 | def createBaseInventoryTypes() { |
---|
| 720 | |
---|
| 721 | //InventoryType |
---|
| 722 | def inventoryTypeInstance |
---|
| 723 | |
---|
| 724 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 725 | saveAndTest(inventoryTypeInstance) |
---|
| 726 | |
---|
| 727 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 728 | saveAndTest(inventoryTypeInstance) |
---|
| 729 | } |
---|
| 730 | |
---|
[175] | 731 | def createBaseInventoryMovementTypes() { |
---|
| 732 | |
---|
| 733 | // InventoryMovementType |
---|
| 734 | def inventoryMovementTypeInstance |
---|
| 735 | |
---|
| 736 | // InventoryMovementType #1 |
---|
[177] | 737 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 738 | incrementsInventory: false) |
---|
[175] | 739 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 740 | |
---|
| 741 | // InventoryMovementType #2 |
---|
[177] | 742 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 743 | incrementsInventory: true) |
---|
[175] | 744 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 745 | |
---|
| 746 | // InventoryMovementType #3 |
---|
[177] | 747 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 748 | incrementsInventory: true) |
---|
[175] | 749 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 750 | |
---|
| 751 | // InventoryMovementType #4 |
---|
| 752 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 753 | incrementsInventory: true) |
---|
| 754 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 755 | |
---|
| 756 | // InventoryMovementType #5 |
---|
| 757 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 758 | incrementsInventory: false) |
---|
| 759 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 760 | } |
---|
| 761 | |
---|
[149] | 762 | def createDemoInventoryItems() { |
---|
| 763 | |
---|
| 764 | //InventoryItem |
---|
| 765 | def inventoryItemInstance |
---|
| 766 | |
---|
| 767 | //InventoryItem #1 |
---|
| 768 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 769 | inventoryType: InventoryType.get(1), |
---|
| 770 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 771 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 772 | name: "Hemp rope", |
---|
| 773 | description: "Natural hemp rope.", |
---|
[175] | 774 | unitsInStock: 2, |
---|
[149] | 775 | reorderPoint: 0) |
---|
| 776 | saveAndTest(inventoryItemInstance) |
---|
| 777 | |
---|
| 778 | //InventoryItem #2 |
---|
| 779 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 780 | inventoryType: InventoryType.get(1), |
---|
| 781 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 782 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 783 | name: "Cotton Rope 12mm", |
---|
| 784 | description: "A soft natural rope made from cotton.", |
---|
[149] | 785 | alternateItems: InventoryItem.get(1), |
---|
[175] | 786 | unitsInStock: 2, |
---|
[149] | 787 | reorderPoint: 0) |
---|
| 788 | saveAndTest(inventoryItemInstance) |
---|
| 789 | |
---|
| 790 | //InventoryItem #3 |
---|
| 791 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 792 | inventoryType: InventoryType.get(1), |
---|
| 793 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 794 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 795 | name: "2305-2RS", |
---|
| 796 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[175] | 797 | unitsInStock: 3, |
---|
[149] | 798 | reorderPoint: 2) |
---|
| 799 | saveAndTest(inventoryItemInstance) |
---|
| 800 | |
---|
| 801 | //InventoryItem #4 |
---|
| 802 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 803 | inventoryType: InventoryType.get(1), |
---|
| 804 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 805 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 806 | name: "L1592-K10", |
---|
| 807 | description: "10kW contactor", |
---|
[175] | 808 | unitsInStock: 4, |
---|
[149] | 809 | reorderPoint: 0) |
---|
| 810 | saveAndTest(inventoryItemInstance) |
---|
| 811 | |
---|
| 812 | //InventoryItem #5 |
---|
| 813 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 814 | inventoryType: InventoryType.get(1), |
---|
| 815 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 816 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 817 | name: "6205-ZZ", |
---|
| 818 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[175] | 819 | unitsInStock: 5, |
---|
[149] | 820 | reorderPoint: 2) |
---|
| 821 | saveAndTest(inventoryItemInstance) |
---|
| 822 | } |
---|
| 823 | |
---|
| 824 | /******************* |
---|
| 825 | START OF ASSET |
---|
| 826 | *******************/ |
---|
| 827 | |
---|
| 828 | def createDemoLifePlan() { |
---|
| 829 | |
---|
| 830 | //LifePlan |
---|
| 831 | def lifeplanInstance |
---|
| 832 | |
---|
| 833 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 834 | saveAndTest(lifeplanInstance) |
---|
| 835 | } |
---|
| 836 | |
---|
| 837 | def createBaseMaintenancePolicies() { |
---|
| 838 | |
---|
| 839 | //MaintenancePolicy |
---|
| 840 | def maintenancePolicyInstance |
---|
| 841 | |
---|
| 842 | //MaintenancePolicy #1 |
---|
| 843 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 844 | saveAndTest(maintenancePolicyInstance) |
---|
| 845 | |
---|
| 846 | //MaintenancePolicy #2 |
---|
| 847 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 848 | saveAndTest(maintenancePolicyInstance) |
---|
| 849 | |
---|
| 850 | //MaintenancePolicy #3 |
---|
| 851 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 852 | saveAndTest(maintenancePolicyInstance) |
---|
| 853 | |
---|
| 854 | //MaintenancePolicy #4 |
---|
| 855 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 856 | saveAndTest(maintenancePolicyInstance) |
---|
| 857 | |
---|
| 858 | //MaintenancePolicy #5 |
---|
| 859 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 860 | saveAndTest(maintenancePolicyInstance) |
---|
| 861 | } |
---|
| 862 | |
---|
| 863 | def createDemoTaskProcedure() { |
---|
| 864 | |
---|
| 865 | //TaskProcedure |
---|
| 866 | def taskProcedureInstance |
---|
| 867 | |
---|
| 868 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 869 | saveAndTest(taskProcedureInstance) |
---|
| 870 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | def createDemoMaintenanceActions() { |
---|
| 874 | |
---|
| 875 | //MaintenanceAction |
---|
| 876 | def maintenanceActionInstance |
---|
| 877 | |
---|
| 878 | //MaintenanceAction #1 |
---|
| 879 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 880 | procedureStepNumber: 1, |
---|
| 881 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 882 | taskProcedure: TaskProcedure.get(1)) |
---|
| 883 | saveAndTest(maintenanceActionInstance) |
---|
| 884 | |
---|
| 885 | //MaintenanceAction #2 |
---|
| 886 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 887 | procedureStepNumber: 2, |
---|
| 888 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 889 | taskProcedure: TaskProcedure.get(1)) |
---|
| 890 | saveAndTest(maintenanceActionInstance) |
---|
| 891 | |
---|
| 892 | //MaintenanceAction #3 |
---|
| 893 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 894 | procedureStepNumber: 3, |
---|
| 895 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 896 | taskProcedure: TaskProcedure.get(1)) |
---|
| 897 | saveAndTest(maintenanceActionInstance) |
---|
| 898 | } |
---|
| 899 | |
---|
| 900 | def createDemoSystemSections() { |
---|
| 901 | |
---|
| 902 | //SystemSection |
---|
| 903 | def systemSectionInstance |
---|
| 904 | |
---|
| 905 | //SystemSection #1 |
---|
| 906 | systemSectionInstance = new SystemSection(name: "Press Section", |
---|
[162] | 907 | site: Site.get(1), |
---|
| 908 | department: Department.get(1)) |
---|
[149] | 909 | saveAndTest(systemSectionInstance) |
---|
| 910 | |
---|
| 911 | //SystemSection #2 |
---|
| 912 | systemSectionInstance = new SystemSection(name: "RO System", |
---|
[162] | 913 | site: Site.get(2), |
---|
| 914 | department: Department.get(2)) |
---|
[149] | 915 | saveAndTest(systemSectionInstance) |
---|
| 916 | |
---|
| 917 | //SystemSection #3 |
---|
| 918 | systemSectionInstance = new SystemSection(name: "Auxilliray Section", |
---|
[162] | 919 | site: Site.get(1), |
---|
| 920 | department: Department.get(1)) |
---|
[149] | 921 | saveAndTest(systemSectionInstance) |
---|
| 922 | } |
---|
| 923 | |
---|
| 924 | def createDemoAssetTypes() { |
---|
| 925 | |
---|
| 926 | //AssetType |
---|
| 927 | def assetTypeInstance |
---|
| 928 | |
---|
| 929 | //AssetType #1 |
---|
| 930 | assetTypeInstance = new AssetType(name: "Print Unit") |
---|
| 931 | saveAndTest(assetTypeInstance) |
---|
| 932 | |
---|
| 933 | //AssetType #2 |
---|
| 934 | assetTypeInstance = new AssetType(name: "Reactor Tower") |
---|
| 935 | saveAndTest(assetTypeInstance) |
---|
| 936 | } |
---|
| 937 | |
---|
| 938 | def createDemoAssemblies() { |
---|
| 939 | |
---|
| 940 | //Assembly |
---|
| 941 | def assemblyInstance |
---|
| 942 | |
---|
| 943 | //Assembly #1 |
---|
| 944 | assemblyInstance = new Assembly(name: "Print Couple", |
---|
| 945 | assetType: AssetType.get(1)) |
---|
| 946 | saveAndTest(assemblyInstance) |
---|
| 947 | // assemblyInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
| 948 | |
---|
| 949 | //Assembly #2 |
---|
| 950 | assemblyInstance = new Assembly(name: "Agitator", |
---|
| 951 | assetType: AssetType.get(2)) |
---|
| 952 | saveAndTest(assemblyInstance) |
---|
| 953 | } |
---|
| 954 | |
---|
| 955 | def createDemoSubAssemblies() { |
---|
| 956 | |
---|
| 957 | //SubAssembly |
---|
| 958 | def subAssemblyInstance |
---|
| 959 | |
---|
| 960 | //SubAssembly #1 |
---|
| 961 | subAssemblyInstance = new SubAssembly(name: "Cylinder", |
---|
| 962 | assembly: Assembly.get(1)) |
---|
| 963 | saveAndTest(subAssemblyInstance) |
---|
| 964 | |
---|
| 965 | //SubAssembly #2 |
---|
| 966 | subAssemblyInstance = new SubAssembly(name: "Gearmotor", |
---|
| 967 | assembly: Assembly.get(2)) |
---|
| 968 | saveAndTest(subAssemblyInstance) |
---|
| 969 | } |
---|
| 970 | |
---|
| 971 | def createDemoComponentItems() { |
---|
| 972 | |
---|
| 973 | //ComponentItem |
---|
| 974 | def componentItemInstance |
---|
| 975 | |
---|
| 976 | //ComponentItem #1 |
---|
| 977 | componentItemInstance = new ComponentItem(name: "Bearing", |
---|
| 978 | subAssembly: SubAssembly.get(1)) |
---|
| 979 | saveAndTest(componentItemInstance) |
---|
| 980 | |
---|
| 981 | //ComponentItem #2 |
---|
| 982 | componentItemInstance = new ComponentItem(name: "Drive shaft oil seal", |
---|
| 983 | subAssembly: SubAssembly.get(2)) |
---|
| 984 | saveAndTest(componentItemInstance) |
---|
| 985 | } |
---|
| 986 | |
---|
| 987 | def createDemoAssets() { |
---|
| 988 | |
---|
| 989 | //Asset |
---|
| 990 | def assetInstance |
---|
| 991 | |
---|
| 992 | //Asset #1 |
---|
| 993 | assetInstance = new Asset(name: "Print Unit 22", |
---|
| 994 | assetType: AssetType.get(1), |
---|
| 995 | systemSection: SystemSection.get(1)) |
---|
| 996 | saveAndTest(assetInstance) |
---|
| 997 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
| 998 | |
---|
| 999 | //Asset #2 |
---|
| 1000 | assetInstance = new Asset(name: "Print Unit 21", |
---|
| 1001 | assetType: AssetType.get(1), |
---|
| 1002 | systemSection: SystemSection.get(1)) |
---|
| 1003 | saveAndTest(assetInstance) |
---|
| 1004 | |
---|
| 1005 | //Asset #3 |
---|
| 1006 | assetInstance = new Asset(name: "Print Unit 23", |
---|
| 1007 | assetType: AssetType.get(1), |
---|
| 1008 | systemSection: SystemSection.get(1)) |
---|
| 1009 | saveAndTest(assetInstance) |
---|
| 1010 | |
---|
| 1011 | //Asset #4 |
---|
| 1012 | assetInstance = new Asset(name: "RO 1", |
---|
| 1013 | assetType: AssetType.get(2), |
---|
| 1014 | systemSection: SystemSection.get(2)) |
---|
| 1015 | saveAndTest(assetInstance) |
---|
| 1016 | } |
---|
| 1017 | |
---|
| 1018 | def createBaseAssetExtenededAttributeTypes() { |
---|
| 1019 | |
---|
| 1020 | //AssetExtendedAttributeType |
---|
| 1021 | def assetExtendedAttributeInstanceType |
---|
| 1022 | |
---|
| 1023 | //AssetExtendedAttributeType #1 |
---|
| 1024 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Model Number") |
---|
| 1025 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1026 | |
---|
| 1027 | //AssetExtendedAttributeType #2 |
---|
| 1028 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Purchase Cost") |
---|
| 1029 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1030 | |
---|
| 1031 | //AssetExtendedAttributeType #3 |
---|
| 1032 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Serial Number") |
---|
| 1033 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1034 | |
---|
| 1035 | //AssetExtendedAttributeType #4 |
---|
| 1036 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Manufactured Date") |
---|
| 1037 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1038 | |
---|
| 1039 | //AssetExtendedAttributeType #5 |
---|
| 1040 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Location Description") |
---|
| 1041 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1042 | } |
---|
| 1043 | |
---|
| 1044 | def createDemoAssetExtenedAttributes() { |
---|
| 1045 | |
---|
| 1046 | //AssetExtendedAttribute |
---|
| 1047 | def assetExtendedAttributeInstance |
---|
| 1048 | |
---|
| 1049 | //AssetExtendedAttribute #1 |
---|
| 1050 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 1051 | asset: Asset.get(1), |
---|
| 1052 | assetExtendedAttributeType: AssetExtendedAttributeType.get(1)) |
---|
| 1053 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1054 | |
---|
| 1055 | //AssetExtendedAttribute #2 |
---|
| 1056 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1057 | asset: Asset.get(1), |
---|
| 1058 | assetExtendedAttributeType: AssetExtendedAttributeType.get(5)) |
---|
| 1059 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1060 | } |
---|
| 1061 | |
---|
| 1062 | |
---|
| 1063 | /**************************************** |
---|
| 1064 | Call this function instead of .save() |
---|
| 1065 | *****************************************/ |
---|
| 1066 | private boolean saveAndTest(object) { |
---|
| 1067 | if(!object.save()) { |
---|
| 1068 | // DemoDataSuccessful = false |
---|
[199] | 1069 | log.error "'${object}' failed to save!" |
---|
| 1070 | log.error object.errors |
---|
[149] | 1071 | return false |
---|
| 1072 | } |
---|
| 1073 | return true |
---|
| 1074 | } |
---|
| 1075 | } |
---|