[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() |
---|
[265] | 57 | createBaseDefinitions() |
---|
[149] | 58 | createBaseUnitsOfMeasure() |
---|
| 59 | createBasePeriods() |
---|
[175] | 60 | createBaseSupplierType() |
---|
| 61 | createBaseManufacturerType() |
---|
[237] | 62 | |
---|
[149] | 63 | // Tasks |
---|
[180] | 64 | createBaseTaskGroups() |
---|
[149] | 65 | createBaseTaskStatus() |
---|
| 66 | createBaseTaskPriorities() |
---|
[252] | 67 | createBaseTaskBudgetStatus() |
---|
[149] | 68 | createBaseTaskTypes() |
---|
[180] | 69 | createBaseTaskModificationTypes() |
---|
[149] | 70 | createBaseEntryTypes() |
---|
[237] | 71 | |
---|
[149] | 72 | // Inventory |
---|
| 73 | createBaseInventoryTypes() |
---|
[175] | 74 | createBaseInventoryMovementTypes() |
---|
[237] | 75 | |
---|
[149] | 76 | // Assets |
---|
[270] | 77 | createBaseExtenededAttributeTypes() |
---|
| 78 | createBaseMaintenancePolicies() |
---|
[149] | 79 | |
---|
[237] | 80 | // Record that data has been created. |
---|
| 81 | appConfigService.set("baseDataCreated") |
---|
[149] | 82 | } |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * Create demo data for some example sites. |
---|
| 86 | */ |
---|
| 87 | def createDemoData() { |
---|
[237] | 88 | |
---|
| 89 | if(!appConfigService.exists("baseDataCreated")) { |
---|
| 90 | log.error "Demo data cannot be created until base data has been created." |
---|
| 91 | return false |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | if(appConfigService.exists("demoDataCreated")) { |
---|
| 95 | log.error "Demo data has already been created, will NOT recreate." |
---|
| 96 | return false |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | if(appConfigService.exists("demoDataCreationDisabled")) { |
---|
| 100 | log.error "Demo data creation has been disabled, will NOT create." |
---|
| 101 | return false |
---|
| 102 | } |
---|
| 103 | |
---|
[199] | 104 | log.info "Creating demo data..." |
---|
[237] | 105 | |
---|
[149] | 106 | // Person and Utils |
---|
| 107 | createDemoPersons() |
---|
| 108 | createDemoSites() |
---|
[162] | 109 | createDemoDepartments() |
---|
[175] | 110 | createDemoSuppliers() |
---|
| 111 | createDemoManufacturers() |
---|
[237] | 112 | |
---|
[149] | 113 | // Tasks |
---|
| 114 | createDemoTasks() |
---|
| 115 | createDemoEntries() |
---|
[242] | 116 | createDemoAssignedGroups() |
---|
[241] | 117 | createDemoAssignedPersons() |
---|
[149] | 118 | createDemoTaskRecurringSchedules() |
---|
[237] | 119 | |
---|
[149] | 120 | // Inventory |
---|
| 121 | createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
[175] | 122 | createDemoInventoryLocations() |
---|
[149] | 123 | createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
| 124 | createDemoInventoryItems() |
---|
[237] | 125 | |
---|
[149] | 126 | // Assets |
---|
| 127 | createDemoLifePlan() |
---|
| 128 | createDemoTaskProcedure() |
---|
| 129 | createDemoMaintenanceActions() |
---|
[268] | 130 | createDemoSections() |
---|
[276] | 131 | createDemoAssetTree() |
---|
[149] | 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 | |
---|
[265] | 302 | //These can redefined by the site at deployment time. |
---|
[266] | 303 | /// @todo: build an admin view so that only the value (definition) can be changed. |
---|
[265] | 304 | def createBaseDefinitions() { |
---|
| 305 | appConfigService.set("Department Definition", "A department as recongised by accounting.") |
---|
| 306 | appConfigService.set("Site Definition", "The site, plant or area.") |
---|
| 307 | appConfigService.set("Section Definition", "A logical grouping of assets as determined by design.") |
---|
| 308 | appConfigService.set("Asset Definition", "Asset definition") |
---|
[266] | 309 | appConfigService.set("Asset Sub Item 1 Name", "Asset Sub Item name") |
---|
| 310 | appConfigService.set("Asset Sub Item 1 Definition", "Asset Sub Item definition") |
---|
| 311 | appConfigService.set("Asset Sub Item 2 Name", "Asset Sub Item name") |
---|
| 312 | appConfigService.set("Asset Sub Item 2 Definition", "Asset Sub Item definition") |
---|
| 313 | appConfigService.set("Asset Sub Item 3 Name", "Asset Sub Item name") |
---|
| 314 | appConfigService.set("Asset Sub Item 3 Definition", "Asset Sub Item definition") |
---|
| 315 | appConfigService.set("Asset Sub Item 4 Name", "Asset Sub Item name") |
---|
| 316 | appConfigService.set("Asset Sub Item 4 Definition", "Asset Sub Item definition") |
---|
[265] | 317 | } |
---|
| 318 | |
---|
[149] | 319 | def createDemoSites() { |
---|
| 320 | //Site |
---|
| 321 | def siteInstance |
---|
| 322 | |
---|
| 323 | siteInstance = new Site(name: "Creek Mill") |
---|
| 324 | saveAndTest(siteInstance) |
---|
| 325 | |
---|
| 326 | siteInstance = new Site(name: "Jasper Street Depot") |
---|
| 327 | saveAndTest(siteInstance) |
---|
[162] | 328 | |
---|
| 329 | siteInstance = new Site(name: "River Press") |
---|
| 330 | saveAndTest(siteInstance) |
---|
[149] | 331 | } |
---|
| 332 | |
---|
[162] | 333 | def createDemoDepartments() { |
---|
| 334 | |
---|
| 335 | //Department |
---|
| 336 | def departmentInstance |
---|
| 337 | |
---|
| 338 | //Department #1 |
---|
| 339 | departmentInstance = new Department(name: "Print Centre", |
---|
| 340 | site: Site.get(1)) |
---|
| 341 | saveAndTest(departmentInstance) |
---|
| 342 | |
---|
| 343 | //Department #2 |
---|
| 344 | departmentInstance = new Department(name: "Pulp Mill 2", |
---|
| 345 | site: Site.get(2)) |
---|
| 346 | saveAndTest(departmentInstance) |
---|
| 347 | } |
---|
| 348 | |
---|
[149] | 349 | def createBaseUnitsOfMeasure() { |
---|
| 350 | |
---|
| 351 | //UnitOfMeasure |
---|
| 352 | def unitOfMeasureInstance |
---|
| 353 | |
---|
| 354 | //UnitOfMeasure #1 |
---|
| 355 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 356 | saveAndTest(unitOfMeasureInstance) |
---|
| 357 | |
---|
| 358 | //UnitOfMeasure #2 |
---|
| 359 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 360 | saveAndTest(unitOfMeasureInstance) |
---|
| 361 | |
---|
| 362 | //UnitOfMeasure #3 |
---|
| 363 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 364 | saveAndTest(unitOfMeasureInstance) |
---|
| 365 | |
---|
| 366 | //UnitOfMeasure #4 |
---|
| 367 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 368 | saveAndTest(unitOfMeasureInstance) |
---|
| 369 | |
---|
| 370 | //UnitOfMeasure #5 |
---|
| 371 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 372 | saveAndTest(unitOfMeasureInstance) |
---|
| 373 | } |
---|
| 374 | |
---|
| 375 | def createBasePeriods() { |
---|
| 376 | |
---|
| 377 | //Period |
---|
| 378 | def periodInstance |
---|
| 379 | |
---|
| 380 | //Period #1 |
---|
| 381 | periodInstance = new Period(period: "Day(s)") |
---|
| 382 | saveAndTest(periodInstance) |
---|
| 383 | |
---|
| 384 | //Period #2 |
---|
| 385 | periodInstance = new Period(period: "Week(s)") |
---|
| 386 | saveAndTest(periodInstance) |
---|
| 387 | |
---|
| 388 | //Period #3 |
---|
| 389 | periodInstance = new Period(period: "Month(s)") |
---|
| 390 | saveAndTest(periodInstance) |
---|
| 391 | |
---|
| 392 | //Period #4 |
---|
| 393 | periodInstance = new Period(period: "Year(s)") |
---|
| 394 | saveAndTest(periodInstance) |
---|
| 395 | } |
---|
| 396 | |
---|
[175] | 397 | def createBaseSupplierType() { |
---|
| 398 | |
---|
| 399 | // SupplierType |
---|
| 400 | def supplierTypeInstance |
---|
| 401 | |
---|
| 402 | // SupplierType #1 |
---|
| 403 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
| 404 | description: "Original equipment supplier") |
---|
| 405 | saveAndTest(supplierTypeInstance) |
---|
| 406 | |
---|
| 407 | // SupplierType #2 |
---|
| 408 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
| 409 | description: "Local supplier") |
---|
| 410 | saveAndTest(supplierTypeInstance) |
---|
| 411 | } |
---|
| 412 | |
---|
| 413 | def createBaseManufacturerType() { |
---|
| 414 | |
---|
| 415 | // ManufacturerType |
---|
| 416 | def manufacturerTypeInstance |
---|
| 417 | |
---|
| 418 | // ManufacturerType #1 |
---|
| 419 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
| 420 | description: "Original equipment manufacturer") |
---|
| 421 | saveAndTest(manufacturerTypeInstance) |
---|
| 422 | |
---|
| 423 | // ManufacturerType #2 |
---|
| 424 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
| 425 | description: "Not original equipment manufacturer") |
---|
| 426 | saveAndTest(manufacturerTypeInstance) |
---|
| 427 | |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | def createDemoSuppliers() { |
---|
| 431 | |
---|
| 432 | // Supplier |
---|
| 433 | def supplierInstance |
---|
| 434 | |
---|
| 435 | // Supplier #1 |
---|
| 436 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
| 437 | supplierType: SupplierType.get(1)) |
---|
| 438 | saveAndTest(supplierInstance) |
---|
| 439 | |
---|
| 440 | // Supplier #2 |
---|
| 441 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
| 442 | supplierType: SupplierType.get(2)) |
---|
| 443 | saveAndTest(supplierInstance) |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | def createDemoManufacturers() { |
---|
| 447 | |
---|
| 448 | // Manufacturer |
---|
| 449 | def manufacturerInstance |
---|
| 450 | |
---|
| 451 | // Manufacturer #1 |
---|
| 452 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
| 453 | manufacturerType: ManufacturerType.get(1)) |
---|
| 454 | saveAndTest(manufacturerInstance) |
---|
| 455 | |
---|
| 456 | // Manufacturer #2 |
---|
| 457 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
| 458 | manufacturerType: ManufacturerType.get(2)) |
---|
| 459 | saveAndTest(manufacturerInstance) |
---|
| 460 | } |
---|
| 461 | |
---|
[149] | 462 | /********************* |
---|
| 463 | START OF TASK |
---|
| 464 | *********************/ |
---|
| 465 | |
---|
[180] | 466 | def createBaseTaskGroups() { |
---|
[149] | 467 | //TaskGroup |
---|
| 468 | def taskGroupInstance |
---|
| 469 | |
---|
[258] | 470 | //TaskGroup #1 |
---|
[149] | 471 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 472 | description:"Engineering daily activities") |
---|
| 473 | saveAndTest(taskGroupInstance) |
---|
| 474 | |
---|
[258] | 475 | //TaskGroup #2 |
---|
[149] | 476 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 477 | description:"Production daily activities") |
---|
| 478 | saveAndTest(taskGroupInstance) |
---|
| 479 | |
---|
[258] | 480 | //TaskGroup #3 |
---|
[149] | 481 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
| 482 | description:" ") |
---|
| 483 | saveAndTest(taskGroupInstance) |
---|
| 484 | } |
---|
| 485 | |
---|
| 486 | def createBaseTaskStatus() { |
---|
| 487 | |
---|
| 488 | //TaskStatus |
---|
| 489 | def taskStatusInstance |
---|
| 490 | |
---|
[181] | 491 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
[149] | 492 | saveAndTest(taskStatusInstance) |
---|
| 493 | |
---|
[181] | 494 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
[149] | 495 | saveAndTest(taskStatusInstance) |
---|
| 496 | |
---|
[222] | 497 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
[149] | 498 | saveAndTest(taskStatusInstance) |
---|
| 499 | } |
---|
| 500 | |
---|
| 501 | def createBaseTaskPriorities() { |
---|
| 502 | |
---|
| 503 | //TaskPriority |
---|
| 504 | def taskPriorityInstance |
---|
| 505 | |
---|
[199] | 506 | taskPriorityInstance = new TaskPriority(name:"Normal") // #1 |
---|
[149] | 507 | saveAndTest(taskPriorityInstance) |
---|
| 508 | |
---|
[199] | 509 | taskPriorityInstance = new TaskPriority(name:"Low") // #2 |
---|
[149] | 510 | saveAndTest(taskPriorityInstance) |
---|
| 511 | |
---|
[199] | 512 | taskPriorityInstance = new TaskPriority(name:"High") // #3 |
---|
[149] | 513 | saveAndTest(taskPriorityInstance) |
---|
| 514 | |
---|
[199] | 515 | taskPriorityInstance = new TaskPriority(name:"Immediate") // #4 |
---|
[149] | 516 | saveAndTest(taskPriorityInstance) |
---|
| 517 | } |
---|
| 518 | |
---|
[252] | 519 | def createBaseTaskBudgetStatus() { |
---|
| 520 | |
---|
| 521 | //TaskBudgetStatus |
---|
| 522 | def taskBudgetStatusInstance |
---|
| 523 | |
---|
| 524 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
| 525 | saveAndTest(taskBudgetStatusInstance) |
---|
| 526 | |
---|
| 527 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
| 528 | saveAndTest(taskBudgetStatusInstance) |
---|
| 529 | } |
---|
| 530 | |
---|
[149] | 531 | def createBaseTaskTypes() { |
---|
| 532 | |
---|
| 533 | //TaskType |
---|
| 534 | def taskTypeInstance |
---|
| 535 | |
---|
[199] | 536 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1 |
---|
[149] | 537 | saveAndTest(taskTypeInstance) |
---|
| 538 | |
---|
[199] | 539 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2 |
---|
[149] | 540 | saveAndTest(taskTypeInstance) |
---|
| 541 | |
---|
[199] | 542 | taskTypeInstance = new TaskType(name:"Project") // #3 |
---|
[149] | 543 | saveAndTest(taskTypeInstance) |
---|
| 544 | |
---|
[199] | 545 | taskTypeInstance = new TaskType(name:"Turnaround") // #4 |
---|
[149] | 546 | saveAndTest(taskTypeInstance) |
---|
| 547 | |
---|
[199] | 548 | taskTypeInstance = new TaskType(name:"Production Run") // #5 |
---|
[149] | 549 | saveAndTest(taskTypeInstance) |
---|
| 550 | } |
---|
| 551 | |
---|
[180] | 552 | def createBaseTaskModificationTypes() { |
---|
| 553 | |
---|
| 554 | //ModificationType |
---|
| 555 | def taskModificationTypeInstance |
---|
| 556 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
| 557 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
| 558 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
| 559 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
| 560 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
| 561 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
| 562 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
| 563 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
| 564 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
[251] | 565 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
| 566 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
[180] | 567 | } |
---|
| 568 | |
---|
[149] | 569 | def createDemoTasks() { |
---|
| 570 | |
---|
[180] | 571 | def taskResult |
---|
| 572 | def p = [:] |
---|
[149] | 573 | |
---|
| 574 | //Task #1 |
---|
[180] | 575 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 576 | taskPriority:TaskPriority.get(2), |
---|
| 577 | taskType:TaskType.get(1), |
---|
| 578 | leadPerson:Person.get(2), |
---|
| 579 | description:"Check specific level sensor", |
---|
| 580 | comment:"Has been noted as problematic, try recalibrating.", |
---|
[210] | 581 | targetStartDate: dateUtilService.today] |
---|
[149] | 582 | |
---|
[180] | 583 | taskResult = taskService.create(p) |
---|
| 584 | |
---|
[149] | 585 | //Task #2 |
---|
[180] | 586 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 587 | taskPriority:TaskPriority.get(2), |
---|
| 588 | taskType:TaskType.get(1), |
---|
| 589 | leadPerson:Person.get(5), |
---|
| 590 | description:"Some follow-up work", |
---|
| 591 | comment:"Some help required", |
---|
[210] | 592 | targetStartDate: dateUtilService.tomorrow, |
---|
[180] | 593 | parentTask: Task.get(1)] |
---|
[149] | 594 | |
---|
[180] | 595 | taskResult = taskService.create(p) |
---|
| 596 | |
---|
[149] | 597 | //Task #3 |
---|
[180] | 598 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 599 | taskPriority:TaskPriority.get(2), |
---|
| 600 | taskType:TaskType.get(1), |
---|
| 601 | leadPerson:Person.get(5), |
---|
| 602 | description:"A Sub Task can be created by setting the Parent Task value", |
---|
| 603 | comment:"Some help required", |
---|
[210] | 604 | targetStartDate: dateUtilService.yesterday, |
---|
[180] | 605 | parentTask: Task.get(1)] |
---|
[149] | 606 | |
---|
[180] | 607 | taskResult = taskService.create(p) |
---|
| 608 | |
---|
[149] | 609 | //Task #4 |
---|
[180] | 610 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 611 | taskPriority:TaskPriority.get(2), |
---|
| 612 | taskType:TaskType.get(1), |
---|
| 613 | leadPerson:Person.get(4), |
---|
| 614 | description:"Replace sensor at next opportunity.", |
---|
| 615 | comment:"Nothing else has worked.", |
---|
[210] | 616 | targetStartDate: dateUtilService.oneWeekFromNow, |
---|
[180] | 617 | parentTask: Task.get(1)] |
---|
[149] | 618 | |
---|
[180] | 619 | taskResult = taskService.create(p) |
---|
| 620 | |
---|
[149] | 621 | //Task #5 |
---|
[180] | 622 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
[149] | 623 | taskPriority:TaskPriority.get(2), |
---|
| 624 | taskType:TaskType.get(5), |
---|
| 625 | leadPerson:Person.get(6), |
---|
| 626 | description:"Production Report", |
---|
| 627 | comment:"Production report for specific production run or shift", |
---|
[210] | 628 | targetStartDate: dateUtilService.today - 6] |
---|
[149] | 629 | |
---|
[180] | 630 | taskResult = taskService.create(p) |
---|
| 631 | |
---|
[149] | 632 | //Task #6 |
---|
[199] | 633 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 634 | taskPriority:TaskPriority.get(1), |
---|
| 635 | taskType:TaskType.get(2), |
---|
| 636 | leadPerson:Person.get(4), |
---|
| 637 | description:"This is a recurring task", |
---|
| 638 | 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] | 639 | targetStartDate: dateUtilService.today] |
---|
[180] | 640 | |
---|
| 641 | taskResult = taskService.create(p) |
---|
[149] | 642 | } |
---|
| 643 | |
---|
| 644 | def createBaseEntryTypes() { |
---|
| 645 | |
---|
| 646 | //EntryType |
---|
| 647 | def entryTypeInstance |
---|
| 648 | |
---|
[190] | 649 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
[149] | 650 | saveAndTest(entryTypeInstance) |
---|
| 651 | |
---|
[190] | 652 | entryTypeInstance = new EntryType(name:"Work Done") // #2 |
---|
[149] | 653 | saveAndTest(entryTypeInstance) |
---|
| 654 | |
---|
[190] | 655 | entryTypeInstance = new EntryType(name:"Production Note") // #3 |
---|
[149] | 656 | saveAndTest(entryTypeInstance) |
---|
| 657 | |
---|
[190] | 658 | entryTypeInstance = new EntryType(name:"Work Request") // #4 |
---|
[149] | 659 | saveAndTest(entryTypeInstance) |
---|
| 660 | } |
---|
| 661 | |
---|
| 662 | def createDemoEntries() { |
---|
| 663 | |
---|
[190] | 664 | def entryResult |
---|
| 665 | def p = [:] |
---|
[149] | 666 | |
---|
| 667 | //Entry #1 |
---|
[190] | 668 | p = [task: Task.get(1), |
---|
| 669 | entryType: EntryType.get(1), |
---|
| 670 | comment: "This level sensor is causing us trouble.", |
---|
| 671 | durationMinute: 20] |
---|
[149] | 672 | |
---|
[190] | 673 | entryResult = taskService.createEntry(p) |
---|
| 674 | |
---|
[149] | 675 | //Entry #2 |
---|
[190] | 676 | p = [task: Task.get(1), |
---|
| 677 | entryType: EntryType.get(2), |
---|
| 678 | comment: "Cleaned sensor, see how it goes.", |
---|
| 679 | durationMinute: 30] |
---|
[149] | 680 | |
---|
[190] | 681 | entryResult = taskService.createEntry(p) |
---|
| 682 | |
---|
[149] | 683 | //Entry #3 |
---|
[190] | 684 | p = [task: Task.get(1), |
---|
| 685 | entryType: EntryType.get(2), |
---|
| 686 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
| 687 | durationMinute: 20] |
---|
| 688 | |
---|
| 689 | entryResult = taskService.createEntry(p) |
---|
[149] | 690 | } |
---|
| 691 | |
---|
[242] | 692 | def createDemoAssignedGroups() { |
---|
| 693 | |
---|
[251] | 694 | def result |
---|
| 695 | def p = [:] |
---|
[242] | 696 | |
---|
| 697 | //AssignedGroup #1 |
---|
[251] | 698 | p = [personGroup: PersonGroup.get(1), |
---|
| 699 | task: Task.get(1), |
---|
| 700 | estimatedHour: 2, |
---|
| 701 | estimatedMinute: 30] |
---|
| 702 | result = assignedGroupService.save(p) |
---|
[242] | 703 | |
---|
| 704 | //AssignedGroup #2 |
---|
[251] | 705 | p = [personGroup: PersonGroup.get(2), |
---|
| 706 | task: Task.get(1), |
---|
| 707 | estimatedHour: 1, |
---|
| 708 | estimatedMinute: 0] |
---|
| 709 | result = assignedGroupService.save(p) |
---|
[242] | 710 | } |
---|
| 711 | |
---|
[241] | 712 | def createDemoAssignedPersons() { |
---|
[149] | 713 | |
---|
[251] | 714 | def result |
---|
| 715 | def p = [:] |
---|
[149] | 716 | |
---|
[241] | 717 | //AssignedPerson #1 |
---|
[251] | 718 | p = [person: Person.get(4), |
---|
| 719 | task: Task.get(1), |
---|
| 720 | estimatedHour: 1, |
---|
| 721 | estimatedMinute: 20] |
---|
| 722 | result = assignedPersonService.save(p) |
---|
[149] | 723 | |
---|
[241] | 724 | //AssignedPerson #2 |
---|
[251] | 725 | p = [person: Person.get(5), |
---|
| 726 | task: Task.get(1), |
---|
| 727 | estimatedHour: 3, |
---|
| 728 | estimatedMinute: 30] |
---|
| 729 | result = assignedPersonService.save(p) |
---|
[149] | 730 | } |
---|
| 731 | |
---|
| 732 | def createDemoTaskRecurringSchedules() { |
---|
| 733 | |
---|
| 734 | //TaskRecurringSchedule |
---|
| 735 | def taskRecurringScheduleInstance |
---|
| 736 | |
---|
| 737 | //TaskRecurringSchedule #1 |
---|
| 738 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
| 739 | recurEvery: 1, |
---|
[199] | 740 | recurPeriod: Period.get(2), |
---|
[210] | 741 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 742 | generateAhead: 1, |
---|
[199] | 743 | taskDuration: 2, |
---|
| 744 | taskDurationPeriod: Period.get(1), |
---|
| 745 | enabled: false) |
---|
[149] | 746 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 747 | |
---|
| 748 | //TaskRecurringSchedule #2 |
---|
[199] | 749 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6), |
---|
[149] | 750 | recurEvery: 1, |
---|
| 751 | recurPeriod: Period.get(1), |
---|
[210] | 752 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 753 | generateAhead: 1, |
---|
| 754 | taskDuration: 1, |
---|
[199] | 755 | taskDurationPeriod: Period.get(1), |
---|
| 756 | enabled: true) |
---|
[149] | 757 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | /************************* |
---|
| 761 | START OF INVENTORY |
---|
| 762 | **************************/ |
---|
| 763 | |
---|
| 764 | def createDemoInventoryStores() { |
---|
| 765 | |
---|
| 766 | //InventoryStore |
---|
| 767 | def inventoryStoreInstance |
---|
| 768 | |
---|
| 769 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 770 | saveAndTest(inventoryStoreInstance) |
---|
| 771 | |
---|
| 772 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 773 | saveAndTest(inventoryStoreInstance) |
---|
| 774 | } |
---|
| 775 | |
---|
[175] | 776 | def createDemoInventoryLocations() { |
---|
[149] | 777 | |
---|
[175] | 778 | // InventoryLocation |
---|
| 779 | def inventoryLocation |
---|
[149] | 780 | |
---|
[175] | 781 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 782 | saveAndTest(inventoryLocation) |
---|
[149] | 783 | |
---|
[175] | 784 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "C55") |
---|
| 785 | saveAndTest(inventoryLocation) |
---|
[149] | 786 | } |
---|
| 787 | |
---|
| 788 | def createDemoInventoryGroups() { |
---|
| 789 | |
---|
| 790 | //InventoryGroup |
---|
| 791 | def inventoryGroupInstance |
---|
| 792 | |
---|
| 793 | //InventoryGroup #1 |
---|
| 794 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 795 | saveAndTest(inventoryGroupInstance) |
---|
| 796 | |
---|
| 797 | //InventoryGroup #2 |
---|
| 798 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 799 | saveAndTest(inventoryGroupInstance) |
---|
| 800 | |
---|
| 801 | //InventoryGroup #3 |
---|
| 802 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 803 | saveAndTest(inventoryGroupInstance) |
---|
| 804 | |
---|
| 805 | //InventoryGroup #4 |
---|
| 806 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 807 | saveAndTest(inventoryGroupInstance) |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | def createBaseInventoryTypes() { |
---|
| 811 | |
---|
| 812 | //InventoryType |
---|
| 813 | def inventoryTypeInstance |
---|
| 814 | |
---|
| 815 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 816 | saveAndTest(inventoryTypeInstance) |
---|
| 817 | |
---|
| 818 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 819 | saveAndTest(inventoryTypeInstance) |
---|
| 820 | } |
---|
| 821 | |
---|
[175] | 822 | def createBaseInventoryMovementTypes() { |
---|
| 823 | |
---|
| 824 | // InventoryMovementType |
---|
| 825 | def inventoryMovementTypeInstance |
---|
| 826 | |
---|
| 827 | // InventoryMovementType #1 |
---|
[177] | 828 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 829 | incrementsInventory: false) |
---|
[175] | 830 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 831 | |
---|
| 832 | // InventoryMovementType #2 |
---|
[177] | 833 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 834 | incrementsInventory: true) |
---|
[175] | 835 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 836 | |
---|
| 837 | // InventoryMovementType #3 |
---|
[177] | 838 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 839 | incrementsInventory: true) |
---|
[175] | 840 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 841 | |
---|
| 842 | // InventoryMovementType #4 |
---|
| 843 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 844 | incrementsInventory: true) |
---|
| 845 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 846 | |
---|
| 847 | // InventoryMovementType #5 |
---|
| 848 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 849 | incrementsInventory: false) |
---|
| 850 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 851 | } |
---|
| 852 | |
---|
[149] | 853 | def createDemoInventoryItems() { |
---|
| 854 | |
---|
| 855 | //InventoryItem |
---|
| 856 | def inventoryItemInstance |
---|
| 857 | |
---|
| 858 | //InventoryItem #1 |
---|
| 859 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 860 | inventoryType: InventoryType.get(1), |
---|
| 861 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 862 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 863 | name: "Hemp rope", |
---|
| 864 | description: "Natural hemp rope.", |
---|
[175] | 865 | unitsInStock: 2, |
---|
[149] | 866 | reorderPoint: 0) |
---|
| 867 | saveAndTest(inventoryItemInstance) |
---|
| 868 | |
---|
| 869 | //InventoryItem #2 |
---|
| 870 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 871 | inventoryType: InventoryType.get(1), |
---|
| 872 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 873 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 874 | name: "Cotton Rope 12mm", |
---|
| 875 | description: "A soft natural rope made from cotton.", |
---|
[149] | 876 | alternateItems: InventoryItem.get(1), |
---|
[175] | 877 | unitsInStock: 2, |
---|
[149] | 878 | reorderPoint: 0) |
---|
| 879 | saveAndTest(inventoryItemInstance) |
---|
| 880 | |
---|
| 881 | //InventoryItem #3 |
---|
| 882 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 883 | inventoryType: InventoryType.get(1), |
---|
| 884 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 885 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 886 | name: "2305-2RS", |
---|
| 887 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[175] | 888 | unitsInStock: 3, |
---|
[149] | 889 | reorderPoint: 2) |
---|
| 890 | saveAndTest(inventoryItemInstance) |
---|
| 891 | |
---|
| 892 | //InventoryItem #4 |
---|
| 893 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 894 | inventoryType: InventoryType.get(1), |
---|
| 895 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 896 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 897 | name: "L1592-K10", |
---|
| 898 | description: "10kW contactor", |
---|
[175] | 899 | unitsInStock: 4, |
---|
[149] | 900 | reorderPoint: 0) |
---|
| 901 | saveAndTest(inventoryItemInstance) |
---|
| 902 | |
---|
| 903 | //InventoryItem #5 |
---|
| 904 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 905 | inventoryType: InventoryType.get(1), |
---|
| 906 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 907 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 908 | name: "6205-ZZ", |
---|
| 909 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[175] | 910 | unitsInStock: 5, |
---|
[149] | 911 | reorderPoint: 2) |
---|
| 912 | saveAndTest(inventoryItemInstance) |
---|
| 913 | } |
---|
| 914 | |
---|
| 915 | /******************* |
---|
| 916 | START OF ASSET |
---|
| 917 | *******************/ |
---|
| 918 | |
---|
| 919 | def createDemoLifePlan() { |
---|
| 920 | |
---|
| 921 | //LifePlan |
---|
| 922 | def lifeplanInstance |
---|
| 923 | |
---|
| 924 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 925 | saveAndTest(lifeplanInstance) |
---|
| 926 | } |
---|
| 927 | |
---|
[270] | 928 | def createBaseExtenededAttributeTypes() { |
---|
| 929 | |
---|
| 930 | //ExtendedAttributeType |
---|
| 931 | def extendedAttributeTypeInstance |
---|
| 932 | |
---|
| 933 | //ExtendedAttributeType #1 |
---|
| 934 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
| 935 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 936 | |
---|
| 937 | //ExtendedAttributeType #2 |
---|
| 938 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
| 939 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 940 | |
---|
| 941 | //ExtendedAttributeType #3 |
---|
| 942 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
| 943 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 944 | |
---|
| 945 | //ExtendedAttributeType #4 |
---|
| 946 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
| 947 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 948 | |
---|
| 949 | //ExtendedAttributeType #5 |
---|
| 950 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
| 951 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 952 | |
---|
| 953 | //ExtendedAttributeType #6 |
---|
| 954 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
| 955 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 956 | |
---|
| 957 | //ExtendedAttributeType #7 |
---|
| 958 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
| 959 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 960 | |
---|
| 961 | //ExtendedAttributeType #8 |
---|
| 962 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer's Number") |
---|
| 963 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 964 | |
---|
| 965 | //ExtendedAttributeType #9 |
---|
| 966 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Inventory Number") |
---|
| 967 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 968 | } |
---|
| 969 | |
---|
[149] | 970 | def createBaseMaintenancePolicies() { |
---|
| 971 | |
---|
| 972 | //MaintenancePolicy |
---|
| 973 | def maintenancePolicyInstance |
---|
| 974 | |
---|
| 975 | //MaintenancePolicy #1 |
---|
| 976 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 977 | saveAndTest(maintenancePolicyInstance) |
---|
| 978 | |
---|
| 979 | //MaintenancePolicy #2 |
---|
| 980 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 981 | saveAndTest(maintenancePolicyInstance) |
---|
| 982 | |
---|
| 983 | //MaintenancePolicy #3 |
---|
| 984 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 985 | saveAndTest(maintenancePolicyInstance) |
---|
| 986 | |
---|
| 987 | //MaintenancePolicy #4 |
---|
| 988 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 989 | saveAndTest(maintenancePolicyInstance) |
---|
| 990 | |
---|
| 991 | //MaintenancePolicy #5 |
---|
| 992 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 993 | saveAndTest(maintenancePolicyInstance) |
---|
[275] | 994 | |
---|
| 995 | //MaintenancePolicy #6 |
---|
| 996 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
| 997 | saveAndTest(maintenancePolicyInstance) |
---|
| 998 | |
---|
| 999 | //MaintenancePolicy #7 |
---|
| 1000 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
| 1001 | saveAndTest(maintenancePolicyInstance) |
---|
[149] | 1002 | } |
---|
| 1003 | |
---|
| 1004 | def createDemoTaskProcedure() { |
---|
| 1005 | |
---|
| 1006 | //TaskProcedure |
---|
| 1007 | def taskProcedureInstance |
---|
| 1008 | |
---|
| 1009 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 1010 | saveAndTest(taskProcedureInstance) |
---|
| 1011 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
| 1012 | } |
---|
| 1013 | |
---|
| 1014 | def createDemoMaintenanceActions() { |
---|
| 1015 | |
---|
| 1016 | //MaintenanceAction |
---|
| 1017 | def maintenanceActionInstance |
---|
| 1018 | |
---|
| 1019 | //MaintenanceAction #1 |
---|
| 1020 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 1021 | procedureStepNumber: 1, |
---|
| 1022 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1023 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1024 | saveAndTest(maintenanceActionInstance) |
---|
| 1025 | |
---|
| 1026 | //MaintenanceAction #2 |
---|
| 1027 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 1028 | procedureStepNumber: 2, |
---|
| 1029 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1030 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1031 | saveAndTest(maintenanceActionInstance) |
---|
| 1032 | |
---|
| 1033 | //MaintenanceAction #3 |
---|
| 1034 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 1035 | procedureStepNumber: 3, |
---|
| 1036 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1037 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1038 | saveAndTest(maintenanceActionInstance) |
---|
| 1039 | } |
---|
| 1040 | |
---|
[268] | 1041 | def createDemoSections() { |
---|
[149] | 1042 | |
---|
[268] | 1043 | //Section |
---|
| 1044 | def sectionInstance |
---|
[149] | 1045 | |
---|
[268] | 1046 | //Section #1 |
---|
| 1047 | sectionInstance = new Section(name: "Press Section", |
---|
[276] | 1048 | site: Site.get(3), |
---|
[162] | 1049 | department: Department.get(1)) |
---|
[268] | 1050 | saveAndTest(sectionInstance) |
---|
[149] | 1051 | |
---|
[268] | 1052 | //Section #2 |
---|
| 1053 | sectionInstance = new Section(name: "RO System", |
---|
[276] | 1054 | site: Site.get(1), |
---|
[162] | 1055 | department: Department.get(2)) |
---|
[268] | 1056 | saveAndTest(sectionInstance) |
---|
[149] | 1057 | |
---|
[268] | 1058 | //Section #3 |
---|
[276] | 1059 | sectionInstance = new Section(name: "Auxiliary Section", |
---|
[162] | 1060 | site: Site.get(1), |
---|
| 1061 | department: Department.get(1)) |
---|
[268] | 1062 | saveAndTest(sectionInstance) |
---|
[149] | 1063 | } |
---|
| 1064 | |
---|
[276] | 1065 | def createDemoAssetTree() { |
---|
[149] | 1066 | |
---|
[270] | 1067 | //Asset |
---|
| 1068 | def assetInstance |
---|
[149] | 1069 | |
---|
[270] | 1070 | //Asset #1 |
---|
[276] | 1071 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
| 1072 | section: Section.get(1)) |
---|
| 1073 | saveAndTest(assetInstance1) |
---|
[270] | 1074 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
[149] | 1075 | |
---|
[270] | 1076 | //Asset #2 |
---|
[276] | 1077 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
| 1078 | section: Section.get(1)) |
---|
| 1079 | saveAndTest(assetInstance2) |
---|
[149] | 1080 | |
---|
[270] | 1081 | //Asset #3 |
---|
[276] | 1082 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
| 1083 | section: Section.get(1)) |
---|
| 1084 | saveAndTest(assetInstance3) |
---|
[149] | 1085 | |
---|
[270] | 1086 | //Asset #4 |
---|
[276] | 1087 | def assetInstance4 = new Asset(name: "RO 1", |
---|
| 1088 | section: Section.get(2)) |
---|
| 1089 | saveAndTest(assetInstance4) |
---|
[149] | 1090 | |
---|
[270] | 1091 | //AssetSubItem |
---|
| 1092 | def assetSubItemInstance |
---|
[149] | 1093 | |
---|
[276] | 1094 | //AssetSubItem #1 Level1 |
---|
| 1095 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower") |
---|
| 1096 | saveAndTest(assetSubItemInstance1) |
---|
[149] | 1097 | |
---|
[276] | 1098 | // Add assetSubItemInstance1 to some assets. |
---|
| 1099 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1100 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1101 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1102 | |
---|
| 1103 | //AssetSubItem #2 Level1 |
---|
| 1104 | def assetSubItemInstance2 = new AssetSubItem(name: "Reactor Tower") |
---|
| 1105 | saveAndTest(assetSubItemInstance2) |
---|
| 1106 | |
---|
| 1107 | // Add assetSubItemInstance2 to some assets. |
---|
| 1108 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
| 1109 | |
---|
| 1110 | //AssetSubItem #3 Level1 |
---|
| 1111 | def assetSubItemInstance3 = new AssetSubItem(name: "Blower Tower") |
---|
| 1112 | saveAndTest(assetSubItemInstance3) |
---|
| 1113 | |
---|
| 1114 | // Add assetSubItemInstance3 to some assets. |
---|
| 1115 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
| 1116 | |
---|
| 1117 | //AssetSubItem #4 Level2 |
---|
[270] | 1118 | assetSubItemInstance = new AssetSubItem(name: "Print Unit Upper", |
---|
[276] | 1119 | parentItem: AssetSubItem.get(1)) |
---|
[270] | 1120 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1121 | |
---|
[276] | 1122 | //AssetSubItem #5 Level3 |
---|
| 1123 | assetSubItemInstance = new AssetSubItem(name: "Agitator", |
---|
| 1124 | parentItem: AssetSubItem.get(2)) |
---|
[270] | 1125 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1126 | |
---|
[276] | 1127 | //AssetSubItem #6 Level2 |
---|
| 1128 | assetSubItemInstance = new AssetSubItem(name: "Scraper", |
---|
| 1129 | parentItem: AssetSubItem.get(3)) |
---|
| 1130 | saveAndTest(assetSubItemInstance) |
---|
| 1131 | |
---|
| 1132 | //AssetSubItem #7 Level3 |
---|
| 1133 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
| 1134 | parentItem: AssetSubItem.get(5)) |
---|
| 1135 | saveAndTest(assetSubItemInstance) |
---|
| 1136 | |
---|
| 1137 | //AssetSubItem #8 Level3 |
---|
| 1138 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
| 1139 | parentItem: AssetSubItem.get(5)) |
---|
| 1140 | saveAndTest(assetSubItemInstance) |
---|
| 1141 | |
---|
| 1142 | //AssetSubItem #9 Level4 |
---|
| 1143 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
| 1144 | parentItem: AssetSubItem.get(7)) |
---|
| 1145 | saveAndTest(assetSubItemInstance) |
---|
| 1146 | |
---|
| 1147 | //AssetSubItem #10 Level4 |
---|
| 1148 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
| 1149 | parentItem: AssetSubItem.get(7)) |
---|
| 1150 | saveAndTest(assetSubItemInstance) |
---|
| 1151 | } // createDemoAssetTree() |
---|
| 1152 | |
---|
[149] | 1153 | def createDemoAssetExtenedAttributes() { |
---|
| 1154 | |
---|
[270] | 1155 | //AssetExtendedAttribute |
---|
| 1156 | def assetExtendedAttributeInstance |
---|
| 1157 | |
---|
| 1158 | //AssetExtendedAttribute #1 |
---|
| 1159 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 1160 | asset: Asset.get(1), |
---|
| 1161 | extendedAttributeType: ExtendedAttributeType.get(1)) |
---|
| 1162 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1163 | |
---|
| 1164 | //AssetExtendedAttribute #2 |
---|
| 1165 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1166 | asset: Asset.get(1), |
---|
| 1167 | extendedAttributeType: ExtendedAttributeType.get(5)) |
---|
| 1168 | saveAndTest(assetExtendedAttributeInstance) |
---|
[149] | 1169 | } |
---|
| 1170 | |
---|
| 1171 | |
---|
| 1172 | /**************************************** |
---|
| 1173 | Call this function instead of .save() |
---|
| 1174 | *****************************************/ |
---|
| 1175 | private boolean saveAndTest(object) { |
---|
| 1176 | if(!object.save()) { |
---|
| 1177 | // DemoDataSuccessful = false |
---|
[199] | 1178 | log.error "'${object}' failed to save!" |
---|
| 1179 | log.error object.errors |
---|
[149] | 1180 | return false |
---|
| 1181 | } |
---|
| 1182 | return true |
---|
| 1183 | } |
---|
| 1184 | } |
---|