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