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