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