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