[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 | |
---|
[321] | 380 | siteInstance = new Site(name: "CSM", |
---|
[314] | 381 | description: "Creek Side Mill") |
---|
[149] | 382 | saveAndTest(siteInstance) |
---|
| 383 | |
---|
[314] | 384 | siteInstance = new Site(name: "Jasper Street Depot", |
---|
| 385 | description: "Storage depot on Jasper Street.") |
---|
[149] | 386 | saveAndTest(siteInstance) |
---|
[162] | 387 | |
---|
[314] | 388 | siteInstance = new Site(name: "River Press", |
---|
| 389 | description: "Printing press site") |
---|
[162] | 390 | saveAndTest(siteInstance) |
---|
[149] | 391 | } |
---|
| 392 | |
---|
[162] | 393 | def createDemoDepartments() { |
---|
| 394 | |
---|
| 395 | //Department |
---|
| 396 | def departmentInstance |
---|
| 397 | |
---|
| 398 | //Department #1 |
---|
| 399 | departmentInstance = new Department(name: "Print Centre", |
---|
[314] | 400 | description: "Printing Department", |
---|
| 401 | site: Site.get(1)) |
---|
[162] | 402 | saveAndTest(departmentInstance) |
---|
| 403 | |
---|
| 404 | //Department #2 |
---|
[321] | 405 | departmentInstance = new Department(name: "Pulp Mill", |
---|
| 406 | description: "Business Department", |
---|
[314] | 407 | site: Site.get(2)) |
---|
[162] | 408 | saveAndTest(departmentInstance) |
---|
| 409 | } |
---|
| 410 | |
---|
[149] | 411 | def createBaseUnitsOfMeasure() { |
---|
| 412 | |
---|
| 413 | //UnitOfMeasure |
---|
| 414 | def unitOfMeasureInstance |
---|
| 415 | |
---|
| 416 | //UnitOfMeasure #1 |
---|
| 417 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 418 | saveAndTest(unitOfMeasureInstance) |
---|
| 419 | |
---|
| 420 | //UnitOfMeasure #2 |
---|
| 421 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 422 | saveAndTest(unitOfMeasureInstance) |
---|
| 423 | |
---|
| 424 | //UnitOfMeasure #3 |
---|
| 425 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 426 | saveAndTest(unitOfMeasureInstance) |
---|
| 427 | |
---|
| 428 | //UnitOfMeasure #4 |
---|
| 429 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 430 | saveAndTest(unitOfMeasureInstance) |
---|
| 431 | |
---|
| 432 | //UnitOfMeasure #5 |
---|
| 433 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 434 | saveAndTest(unitOfMeasureInstance) |
---|
| 435 | } |
---|
| 436 | |
---|
| 437 | def createBasePeriods() { |
---|
| 438 | |
---|
| 439 | //Period |
---|
| 440 | def periodInstance |
---|
| 441 | |
---|
| 442 | //Period #1 |
---|
| 443 | periodInstance = new Period(period: "Day(s)") |
---|
| 444 | saveAndTest(periodInstance) |
---|
| 445 | |
---|
| 446 | //Period #2 |
---|
| 447 | periodInstance = new Period(period: "Week(s)") |
---|
| 448 | saveAndTest(periodInstance) |
---|
| 449 | |
---|
| 450 | //Period #3 |
---|
| 451 | periodInstance = new Period(period: "Month(s)") |
---|
| 452 | saveAndTest(periodInstance) |
---|
| 453 | |
---|
| 454 | //Period #4 |
---|
| 455 | periodInstance = new Period(period: "Year(s)") |
---|
| 456 | saveAndTest(periodInstance) |
---|
| 457 | } |
---|
| 458 | |
---|
[175] | 459 | def createBaseSupplierType() { |
---|
| 460 | |
---|
| 461 | // SupplierType |
---|
| 462 | def supplierTypeInstance |
---|
| 463 | |
---|
| 464 | // SupplierType #1 |
---|
| 465 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
| 466 | description: "Original equipment supplier") |
---|
| 467 | saveAndTest(supplierTypeInstance) |
---|
| 468 | |
---|
| 469 | // SupplierType #2 |
---|
| 470 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
| 471 | description: "Local supplier") |
---|
| 472 | saveAndTest(supplierTypeInstance) |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | def createBaseManufacturerType() { |
---|
| 476 | |
---|
| 477 | // ManufacturerType |
---|
| 478 | def manufacturerTypeInstance |
---|
| 479 | |
---|
| 480 | // ManufacturerType #1 |
---|
| 481 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
| 482 | description: "Original equipment manufacturer") |
---|
| 483 | saveAndTest(manufacturerTypeInstance) |
---|
| 484 | |
---|
| 485 | // ManufacturerType #2 |
---|
| 486 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
| 487 | description: "Not original equipment manufacturer") |
---|
| 488 | saveAndTest(manufacturerTypeInstance) |
---|
| 489 | |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | def createDemoSuppliers() { |
---|
| 493 | |
---|
| 494 | // Supplier |
---|
| 495 | def supplierInstance |
---|
| 496 | |
---|
| 497 | // Supplier #1 |
---|
| 498 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
| 499 | supplierType: SupplierType.get(1)) |
---|
| 500 | saveAndTest(supplierInstance) |
---|
| 501 | |
---|
| 502 | // Supplier #2 |
---|
| 503 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
| 504 | supplierType: SupplierType.get(2)) |
---|
| 505 | saveAndTest(supplierInstance) |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | def createDemoManufacturers() { |
---|
| 509 | |
---|
| 510 | // Manufacturer |
---|
| 511 | def manufacturerInstance |
---|
| 512 | |
---|
| 513 | // Manufacturer #1 |
---|
| 514 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
| 515 | manufacturerType: ManufacturerType.get(1)) |
---|
| 516 | saveAndTest(manufacturerInstance) |
---|
| 517 | |
---|
| 518 | // Manufacturer #2 |
---|
| 519 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
| 520 | manufacturerType: ManufacturerType.get(2)) |
---|
| 521 | saveAndTest(manufacturerInstance) |
---|
| 522 | } |
---|
| 523 | |
---|
[149] | 524 | /********************* |
---|
| 525 | START OF TASK |
---|
| 526 | *********************/ |
---|
| 527 | |
---|
[180] | 528 | def createBaseTaskGroups() { |
---|
[149] | 529 | //TaskGroup |
---|
| 530 | def taskGroupInstance |
---|
| 531 | |
---|
[258] | 532 | //TaskGroup #1 |
---|
[149] | 533 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 534 | description:"Engineering daily activities") |
---|
| 535 | saveAndTest(taskGroupInstance) |
---|
| 536 | |
---|
[258] | 537 | //TaskGroup #2 |
---|
[149] | 538 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 539 | description:"Production daily activities") |
---|
| 540 | saveAndTest(taskGroupInstance) |
---|
| 541 | |
---|
[258] | 542 | //TaskGroup #3 |
---|
[149] | 543 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
| 544 | description:" ") |
---|
| 545 | saveAndTest(taskGroupInstance) |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | def createBaseTaskStatus() { |
---|
| 549 | |
---|
| 550 | //TaskStatus |
---|
| 551 | def taskStatusInstance |
---|
| 552 | |
---|
[181] | 553 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
[149] | 554 | saveAndTest(taskStatusInstance) |
---|
| 555 | |
---|
[181] | 556 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
[149] | 557 | saveAndTest(taskStatusInstance) |
---|
| 558 | |
---|
[222] | 559 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
[149] | 560 | saveAndTest(taskStatusInstance) |
---|
| 561 | } |
---|
| 562 | |
---|
| 563 | def createBaseTaskPriorities() { |
---|
| 564 | |
---|
| 565 | //TaskPriority |
---|
| 566 | def taskPriorityInstance |
---|
| 567 | |
---|
[199] | 568 | taskPriorityInstance = new TaskPriority(name:"Normal") // #1 |
---|
[149] | 569 | saveAndTest(taskPriorityInstance) |
---|
| 570 | |
---|
[199] | 571 | taskPriorityInstance = new TaskPriority(name:"Low") // #2 |
---|
[149] | 572 | saveAndTest(taskPriorityInstance) |
---|
| 573 | |
---|
[199] | 574 | taskPriorityInstance = new TaskPriority(name:"High") // #3 |
---|
[149] | 575 | saveAndTest(taskPriorityInstance) |
---|
| 576 | |
---|
[199] | 577 | taskPriorityInstance = new TaskPriority(name:"Immediate") // #4 |
---|
[149] | 578 | saveAndTest(taskPriorityInstance) |
---|
| 579 | } |
---|
| 580 | |
---|
[252] | 581 | def createBaseTaskBudgetStatus() { |
---|
| 582 | |
---|
| 583 | //TaskBudgetStatus |
---|
| 584 | def taskBudgetStatusInstance |
---|
| 585 | |
---|
| 586 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
| 587 | saveAndTest(taskBudgetStatusInstance) |
---|
| 588 | |
---|
| 589 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
| 590 | saveAndTest(taskBudgetStatusInstance) |
---|
| 591 | } |
---|
| 592 | |
---|
[149] | 593 | def createBaseTaskTypes() { |
---|
| 594 | |
---|
| 595 | //TaskType |
---|
| 596 | def taskTypeInstance |
---|
| 597 | |
---|
[199] | 598 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #1 |
---|
[149] | 599 | saveAndTest(taskTypeInstance) |
---|
| 600 | |
---|
[199] | 601 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #2 |
---|
[149] | 602 | saveAndTest(taskTypeInstance) |
---|
| 603 | |
---|
[199] | 604 | taskTypeInstance = new TaskType(name:"Project") // #3 |
---|
[149] | 605 | saveAndTest(taskTypeInstance) |
---|
| 606 | |
---|
[199] | 607 | taskTypeInstance = new TaskType(name:"Turnaround") // #4 |
---|
[149] | 608 | saveAndTest(taskTypeInstance) |
---|
| 609 | |
---|
[199] | 610 | taskTypeInstance = new TaskType(name:"Production Run") // #5 |
---|
[149] | 611 | saveAndTest(taskTypeInstance) |
---|
| 612 | } |
---|
| 613 | |
---|
[180] | 614 | def createBaseTaskModificationTypes() { |
---|
| 615 | |
---|
| 616 | //ModificationType |
---|
| 617 | def taskModificationTypeInstance |
---|
| 618 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
| 619 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
| 620 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
| 621 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
| 622 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
| 623 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
| 624 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
| 625 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
| 626 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
[251] | 627 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
| 628 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
[180] | 629 | } |
---|
| 630 | |
---|
[149] | 631 | def createDemoTasks() { |
---|
| 632 | |
---|
[180] | 633 | def taskResult |
---|
| 634 | def p = [:] |
---|
[149] | 635 | |
---|
| 636 | //Task #1 |
---|
[180] | 637 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 638 | taskPriority:TaskPriority.get(2), |
---|
| 639 | taskType:TaskType.get(1), |
---|
| 640 | leadPerson:Person.get(2), |
---|
| 641 | description:"Check specific level sensor", |
---|
| 642 | comment:"Has been noted as problematic, try recalibrating.", |
---|
[210] | 643 | targetStartDate: dateUtilService.today] |
---|
[149] | 644 | |
---|
[180] | 645 | taskResult = taskService.create(p) |
---|
| 646 | |
---|
[149] | 647 | //Task #2 |
---|
[180] | 648 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 649 | taskPriority:TaskPriority.get(2), |
---|
| 650 | taskType:TaskType.get(1), |
---|
| 651 | leadPerson:Person.get(5), |
---|
| 652 | description:"Some follow-up work", |
---|
| 653 | comment:"Some help required", |
---|
[210] | 654 | targetStartDate: dateUtilService.tomorrow, |
---|
[180] | 655 | parentTask: Task.get(1)] |
---|
[149] | 656 | |
---|
[180] | 657 | taskResult = taskService.create(p) |
---|
| 658 | |
---|
[149] | 659 | //Task #3 |
---|
[180] | 660 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 661 | taskPriority:TaskPriority.get(2), |
---|
| 662 | taskType:TaskType.get(1), |
---|
| 663 | leadPerson:Person.get(5), |
---|
[314] | 664 | description:"A Sub Task can be created from the Sub Task's tab.", |
---|
[149] | 665 | comment:"Some help required", |
---|
[210] | 666 | targetStartDate: dateUtilService.yesterday, |
---|
[180] | 667 | parentTask: Task.get(1)] |
---|
[149] | 668 | |
---|
[180] | 669 | taskResult = taskService.create(p) |
---|
| 670 | |
---|
[149] | 671 | //Task #4 |
---|
[180] | 672 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 673 | taskPriority:TaskPriority.get(2), |
---|
| 674 | taskType:TaskType.get(1), |
---|
| 675 | leadPerson:Person.get(4), |
---|
| 676 | description:"Replace sensor at next opportunity.", |
---|
| 677 | comment:"Nothing else has worked.", |
---|
[210] | 678 | targetStartDate: dateUtilService.oneWeekFromNow, |
---|
[180] | 679 | parentTask: Task.get(1)] |
---|
[149] | 680 | |
---|
[180] | 681 | taskResult = taskService.create(p) |
---|
| 682 | |
---|
[149] | 683 | //Task #5 |
---|
[180] | 684 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
[149] | 685 | taskPriority:TaskPriority.get(2), |
---|
| 686 | taskType:TaskType.get(5), |
---|
| 687 | leadPerson:Person.get(6), |
---|
| 688 | description:"Production Report", |
---|
| 689 | comment:"Production report for specific production run or shift", |
---|
[210] | 690 | targetStartDate: dateUtilService.today - 6] |
---|
[149] | 691 | |
---|
[180] | 692 | taskResult = taskService.create(p) |
---|
| 693 | |
---|
[149] | 694 | //Task #6 |
---|
[199] | 695 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 696 | taskPriority:TaskPriority.get(1), |
---|
| 697 | taskType:TaskType.get(2), |
---|
| 698 | leadPerson:Person.get(4), |
---|
| 699 | description:"This is a recurring task", |
---|
| 700 | 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] | 701 | targetStartDate: dateUtilService.today] |
---|
[180] | 702 | |
---|
| 703 | taskResult = taskService.create(p) |
---|
[149] | 704 | } |
---|
| 705 | |
---|
| 706 | def createBaseEntryTypes() { |
---|
| 707 | |
---|
| 708 | //EntryType |
---|
| 709 | def entryTypeInstance |
---|
| 710 | |
---|
[190] | 711 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
[149] | 712 | saveAndTest(entryTypeInstance) |
---|
| 713 | |
---|
[190] | 714 | entryTypeInstance = new EntryType(name:"Work Done") // #2 |
---|
[149] | 715 | saveAndTest(entryTypeInstance) |
---|
| 716 | |
---|
[190] | 717 | entryTypeInstance = new EntryType(name:"Production Note") // #3 |
---|
[149] | 718 | saveAndTest(entryTypeInstance) |
---|
| 719 | |
---|
[190] | 720 | entryTypeInstance = new EntryType(name:"Work Request") // #4 |
---|
[149] | 721 | saveAndTest(entryTypeInstance) |
---|
| 722 | } |
---|
| 723 | |
---|
| 724 | def createDemoEntries() { |
---|
| 725 | |
---|
[190] | 726 | def entryResult |
---|
| 727 | def p = [:] |
---|
[149] | 728 | |
---|
| 729 | //Entry #1 |
---|
[190] | 730 | p = [task: Task.get(1), |
---|
| 731 | entryType: EntryType.get(1), |
---|
| 732 | comment: "This level sensor is causing us trouble.", |
---|
| 733 | durationMinute: 20] |
---|
[149] | 734 | |
---|
[190] | 735 | entryResult = taskService.createEntry(p) |
---|
| 736 | |
---|
[149] | 737 | //Entry #2 |
---|
[190] | 738 | p = [task: Task.get(1), |
---|
| 739 | entryType: EntryType.get(2), |
---|
| 740 | comment: "Cleaned sensor, see how it goes.", |
---|
| 741 | durationMinute: 30] |
---|
[149] | 742 | |
---|
[190] | 743 | entryResult = taskService.createEntry(p) |
---|
| 744 | |
---|
[149] | 745 | //Entry #3 |
---|
[190] | 746 | p = [task: Task.get(1), |
---|
| 747 | entryType: EntryType.get(2), |
---|
| 748 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
| 749 | durationMinute: 20] |
---|
| 750 | |
---|
| 751 | entryResult = taskService.createEntry(p) |
---|
[149] | 752 | } |
---|
| 753 | |
---|
[242] | 754 | def createDemoAssignedGroups() { |
---|
| 755 | |
---|
[251] | 756 | def result |
---|
| 757 | def p = [:] |
---|
[242] | 758 | |
---|
| 759 | //AssignedGroup #1 |
---|
[251] | 760 | p = [personGroup: PersonGroup.get(1), |
---|
| 761 | task: Task.get(1), |
---|
| 762 | estimatedHour: 2, |
---|
| 763 | estimatedMinute: 30] |
---|
| 764 | result = assignedGroupService.save(p) |
---|
[242] | 765 | |
---|
| 766 | //AssignedGroup #2 |
---|
[251] | 767 | p = [personGroup: PersonGroup.get(2), |
---|
| 768 | task: Task.get(1), |
---|
| 769 | estimatedHour: 1, |
---|
| 770 | estimatedMinute: 0] |
---|
| 771 | result = assignedGroupService.save(p) |
---|
[242] | 772 | } |
---|
| 773 | |
---|
[241] | 774 | def createDemoAssignedPersons() { |
---|
[149] | 775 | |
---|
[251] | 776 | def result |
---|
| 777 | def p = [:] |
---|
[149] | 778 | |
---|
[241] | 779 | //AssignedPerson #1 |
---|
[251] | 780 | p = [person: Person.get(4), |
---|
| 781 | task: Task.get(1), |
---|
| 782 | estimatedHour: 1, |
---|
| 783 | estimatedMinute: 20] |
---|
| 784 | result = assignedPersonService.save(p) |
---|
[149] | 785 | |
---|
[241] | 786 | //AssignedPerson #2 |
---|
[251] | 787 | p = [person: Person.get(5), |
---|
| 788 | task: Task.get(1), |
---|
| 789 | estimatedHour: 3, |
---|
| 790 | estimatedMinute: 30] |
---|
| 791 | result = assignedPersonService.save(p) |
---|
[149] | 792 | } |
---|
| 793 | |
---|
| 794 | def createDemoTaskRecurringSchedules() { |
---|
| 795 | |
---|
| 796 | //TaskRecurringSchedule |
---|
| 797 | def taskRecurringScheduleInstance |
---|
| 798 | |
---|
| 799 | //TaskRecurringSchedule #1 |
---|
| 800 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
| 801 | recurEvery: 1, |
---|
[199] | 802 | recurPeriod: Period.get(2), |
---|
[210] | 803 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 804 | generateAhead: 1, |
---|
[199] | 805 | taskDuration: 2, |
---|
| 806 | taskDurationPeriod: Period.get(1), |
---|
| 807 | enabled: false) |
---|
[149] | 808 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 809 | |
---|
| 810 | //TaskRecurringSchedule #2 |
---|
[199] | 811 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6), |
---|
[149] | 812 | recurEvery: 1, |
---|
| 813 | recurPeriod: Period.get(1), |
---|
[210] | 814 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 815 | generateAhead: 1, |
---|
| 816 | taskDuration: 1, |
---|
[199] | 817 | taskDurationPeriod: Period.get(1), |
---|
| 818 | enabled: true) |
---|
[149] | 819 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 820 | } |
---|
| 821 | |
---|
| 822 | /************************* |
---|
| 823 | START OF INVENTORY |
---|
| 824 | **************************/ |
---|
| 825 | |
---|
| 826 | def createDemoInventoryStores() { |
---|
| 827 | |
---|
| 828 | //InventoryStore |
---|
| 829 | def inventoryStoreInstance |
---|
| 830 | |
---|
| 831 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 832 | saveAndTest(inventoryStoreInstance) |
---|
| 833 | |
---|
| 834 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 835 | saveAndTest(inventoryStoreInstance) |
---|
| 836 | } |
---|
| 837 | |
---|
[175] | 838 | def createDemoInventoryLocations() { |
---|
[149] | 839 | |
---|
[175] | 840 | // InventoryLocation |
---|
| 841 | def inventoryLocation |
---|
[149] | 842 | |
---|
[175] | 843 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 844 | saveAndTest(inventoryLocation) |
---|
[149] | 845 | |
---|
[175] | 846 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "C55") |
---|
| 847 | saveAndTest(inventoryLocation) |
---|
[149] | 848 | } |
---|
| 849 | |
---|
| 850 | def createDemoInventoryGroups() { |
---|
| 851 | |
---|
| 852 | //InventoryGroup |
---|
| 853 | def inventoryGroupInstance |
---|
| 854 | |
---|
| 855 | //InventoryGroup #1 |
---|
| 856 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 857 | saveAndTest(inventoryGroupInstance) |
---|
| 858 | |
---|
| 859 | //InventoryGroup #2 |
---|
| 860 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 861 | saveAndTest(inventoryGroupInstance) |
---|
| 862 | |
---|
| 863 | //InventoryGroup #3 |
---|
| 864 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 865 | saveAndTest(inventoryGroupInstance) |
---|
| 866 | |
---|
| 867 | //InventoryGroup #4 |
---|
| 868 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 869 | saveAndTest(inventoryGroupInstance) |
---|
| 870 | } |
---|
| 871 | |
---|
| 872 | def createBaseInventoryTypes() { |
---|
| 873 | |
---|
| 874 | //InventoryType |
---|
| 875 | def inventoryTypeInstance |
---|
| 876 | |
---|
| 877 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 878 | saveAndTest(inventoryTypeInstance) |
---|
| 879 | |
---|
| 880 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 881 | saveAndTest(inventoryTypeInstance) |
---|
| 882 | } |
---|
| 883 | |
---|
[175] | 884 | def createBaseInventoryMovementTypes() { |
---|
| 885 | |
---|
| 886 | // InventoryMovementType |
---|
| 887 | def inventoryMovementTypeInstance |
---|
| 888 | |
---|
| 889 | // InventoryMovementType #1 |
---|
[177] | 890 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 891 | incrementsInventory: false) |
---|
[175] | 892 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 893 | |
---|
| 894 | // InventoryMovementType #2 |
---|
[177] | 895 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 896 | incrementsInventory: true) |
---|
[175] | 897 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 898 | |
---|
| 899 | // InventoryMovementType #3 |
---|
[177] | 900 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 901 | incrementsInventory: true) |
---|
[175] | 902 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 903 | |
---|
| 904 | // InventoryMovementType #4 |
---|
| 905 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 906 | incrementsInventory: true) |
---|
| 907 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 908 | |
---|
| 909 | // InventoryMovementType #5 |
---|
| 910 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 911 | incrementsInventory: false) |
---|
| 912 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 913 | } |
---|
| 914 | |
---|
[149] | 915 | def createDemoInventoryItems() { |
---|
| 916 | |
---|
| 917 | //InventoryItem |
---|
| 918 | def inventoryItemInstance |
---|
| 919 | |
---|
| 920 | //InventoryItem #1 |
---|
| 921 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 922 | inventoryType: InventoryType.get(1), |
---|
| 923 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 924 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 925 | name: "Hemp rope", |
---|
| 926 | description: "Natural hemp rope.", |
---|
[175] | 927 | unitsInStock: 2, |
---|
[149] | 928 | reorderPoint: 0) |
---|
| 929 | saveAndTest(inventoryItemInstance) |
---|
| 930 | |
---|
| 931 | //InventoryItem #2 |
---|
| 932 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 933 | inventoryType: InventoryType.get(1), |
---|
| 934 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 935 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 936 | name: "Cotton Rope 12mm", |
---|
| 937 | description: "A soft natural rope made from cotton.", |
---|
[149] | 938 | alternateItems: InventoryItem.get(1), |
---|
[175] | 939 | unitsInStock: 2, |
---|
[149] | 940 | reorderPoint: 0) |
---|
| 941 | saveAndTest(inventoryItemInstance) |
---|
| 942 | |
---|
| 943 | //InventoryItem #3 |
---|
| 944 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 945 | inventoryType: InventoryType.get(1), |
---|
| 946 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 947 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 948 | name: "2305-2RS", |
---|
| 949 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[175] | 950 | unitsInStock: 3, |
---|
[149] | 951 | reorderPoint: 2) |
---|
| 952 | saveAndTest(inventoryItemInstance) |
---|
| 953 | |
---|
| 954 | //InventoryItem #4 |
---|
| 955 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 956 | inventoryType: InventoryType.get(1), |
---|
| 957 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 958 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 959 | name: "L1592-K10", |
---|
| 960 | description: "10kW contactor", |
---|
[175] | 961 | unitsInStock: 4, |
---|
[149] | 962 | reorderPoint: 0) |
---|
| 963 | saveAndTest(inventoryItemInstance) |
---|
| 964 | |
---|
| 965 | //InventoryItem #5 |
---|
| 966 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 967 | inventoryType: InventoryType.get(1), |
---|
| 968 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 969 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 970 | name: "6205-ZZ", |
---|
| 971 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[175] | 972 | unitsInStock: 5, |
---|
[149] | 973 | reorderPoint: 2) |
---|
| 974 | saveAndTest(inventoryItemInstance) |
---|
| 975 | } |
---|
| 976 | |
---|
| 977 | /******************* |
---|
| 978 | START OF ASSET |
---|
| 979 | *******************/ |
---|
| 980 | |
---|
| 981 | def createDemoLifePlan() { |
---|
| 982 | |
---|
| 983 | //LifePlan |
---|
| 984 | def lifeplanInstance |
---|
| 985 | |
---|
| 986 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 987 | saveAndTest(lifeplanInstance) |
---|
| 988 | } |
---|
| 989 | |
---|
[270] | 990 | def createBaseExtenededAttributeTypes() { |
---|
| 991 | |
---|
| 992 | //ExtendedAttributeType |
---|
| 993 | def extendedAttributeTypeInstance |
---|
| 994 | |
---|
| 995 | //ExtendedAttributeType #1 |
---|
| 996 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
| 997 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 998 | |
---|
| 999 | //ExtendedAttributeType #2 |
---|
| 1000 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
| 1001 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1002 | |
---|
| 1003 | //ExtendedAttributeType #3 |
---|
| 1004 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
| 1005 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1006 | |
---|
| 1007 | //ExtendedAttributeType #4 |
---|
| 1008 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
| 1009 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1010 | |
---|
| 1011 | //ExtendedAttributeType #5 |
---|
| 1012 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
| 1013 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1014 | |
---|
| 1015 | //ExtendedAttributeType #6 |
---|
| 1016 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
| 1017 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1018 | |
---|
| 1019 | //ExtendedAttributeType #7 |
---|
| 1020 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
| 1021 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1022 | |
---|
| 1023 | //ExtendedAttributeType #8 |
---|
| 1024 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer's Number") |
---|
| 1025 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1026 | |
---|
| 1027 | //ExtendedAttributeType #9 |
---|
| 1028 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Inventory Number") |
---|
| 1029 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1030 | } |
---|
| 1031 | |
---|
[149] | 1032 | def createBaseMaintenancePolicies() { |
---|
| 1033 | |
---|
| 1034 | //MaintenancePolicy |
---|
| 1035 | def maintenancePolicyInstance |
---|
| 1036 | |
---|
| 1037 | //MaintenancePolicy #1 |
---|
| 1038 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 1039 | saveAndTest(maintenancePolicyInstance) |
---|
| 1040 | |
---|
| 1041 | //MaintenancePolicy #2 |
---|
| 1042 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 1043 | saveAndTest(maintenancePolicyInstance) |
---|
| 1044 | |
---|
| 1045 | //MaintenancePolicy #3 |
---|
| 1046 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 1047 | saveAndTest(maintenancePolicyInstance) |
---|
| 1048 | |
---|
| 1049 | //MaintenancePolicy #4 |
---|
| 1050 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 1051 | saveAndTest(maintenancePolicyInstance) |
---|
| 1052 | |
---|
| 1053 | //MaintenancePolicy #5 |
---|
| 1054 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 1055 | saveAndTest(maintenancePolicyInstance) |
---|
[275] | 1056 | |
---|
| 1057 | //MaintenancePolicy #6 |
---|
| 1058 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
| 1059 | saveAndTest(maintenancePolicyInstance) |
---|
| 1060 | |
---|
| 1061 | //MaintenancePolicy #7 |
---|
| 1062 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
| 1063 | saveAndTest(maintenancePolicyInstance) |
---|
[149] | 1064 | } |
---|
| 1065 | |
---|
| 1066 | def createDemoTaskProcedure() { |
---|
| 1067 | |
---|
| 1068 | //TaskProcedure |
---|
| 1069 | def taskProcedureInstance |
---|
| 1070 | |
---|
| 1071 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 1072 | saveAndTest(taskProcedureInstance) |
---|
| 1073 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
| 1074 | } |
---|
| 1075 | |
---|
| 1076 | def createDemoMaintenanceActions() { |
---|
| 1077 | |
---|
| 1078 | //MaintenanceAction |
---|
| 1079 | def maintenanceActionInstance |
---|
| 1080 | |
---|
| 1081 | //MaintenanceAction #1 |
---|
| 1082 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 1083 | procedureStepNumber: 1, |
---|
| 1084 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1085 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1086 | saveAndTest(maintenanceActionInstance) |
---|
| 1087 | |
---|
| 1088 | //MaintenanceAction #2 |
---|
| 1089 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 1090 | procedureStepNumber: 2, |
---|
| 1091 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1092 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1093 | saveAndTest(maintenanceActionInstance) |
---|
| 1094 | |
---|
| 1095 | //MaintenanceAction #3 |
---|
| 1096 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 1097 | procedureStepNumber: 3, |
---|
| 1098 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1099 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1100 | saveAndTest(maintenanceActionInstance) |
---|
| 1101 | } |
---|
| 1102 | |
---|
[268] | 1103 | def createDemoSections() { |
---|
[149] | 1104 | |
---|
[268] | 1105 | //Section |
---|
| 1106 | def sectionInstance |
---|
[149] | 1107 | |
---|
[268] | 1108 | //Section #1 |
---|
[314] | 1109 | sectionInstance = new Section(name: "Press", |
---|
| 1110 | description: "Press Section", |
---|
| 1111 | site: Site.get(3), |
---|
| 1112 | department: Department.get(1)) |
---|
[268] | 1113 | saveAndTest(sectionInstance) |
---|
[149] | 1114 | |
---|
[268] | 1115 | //Section #2 |
---|
[321] | 1116 | sectionInstance = new Section(name: "CSM-Delig", |
---|
[314] | 1117 | description: "Pulp Delignification", |
---|
| 1118 | site: Site.get(1), |
---|
| 1119 | department: Department.get(2)) |
---|
[268] | 1120 | saveAndTest(sectionInstance) |
---|
[149] | 1121 | |
---|
[268] | 1122 | //Section #3 |
---|
[321] | 1123 | sectionInstance = new Section(name: "CSM-Aux", |
---|
[314] | 1124 | description: "Auxilliary Section", |
---|
| 1125 | site: Site.get(1), |
---|
| 1126 | department: Department.get(1)) |
---|
[268] | 1127 | saveAndTest(sectionInstance) |
---|
[149] | 1128 | } |
---|
| 1129 | |
---|
[276] | 1130 | def createDemoAssetTree() { |
---|
[149] | 1131 | |
---|
[270] | 1132 | //Asset |
---|
| 1133 | def assetInstance |
---|
[149] | 1134 | |
---|
[270] | 1135 | //Asset #1 |
---|
[276] | 1136 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
[314] | 1137 | description: "Complete Printing Asset #22", |
---|
| 1138 | section: Section.get(1)) |
---|
[276] | 1139 | saveAndTest(assetInstance1) |
---|
[270] | 1140 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
[149] | 1141 | |
---|
[270] | 1142 | //Asset #2 |
---|
[276] | 1143 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
[314] | 1144 | description: "Complete Printing Asset #21", |
---|
| 1145 | section: Section.get(1)) |
---|
[276] | 1146 | saveAndTest(assetInstance2) |
---|
[149] | 1147 | |
---|
[270] | 1148 | //Asset #3 |
---|
[276] | 1149 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
[314] | 1150 | description: "Complete Printing Asset #23", |
---|
| 1151 | section: Section.get(1)) |
---|
[276] | 1152 | saveAndTest(assetInstance3) |
---|
[149] | 1153 | |
---|
[270] | 1154 | //Asset #4 |
---|
[321] | 1155 | def assetInstance4 = new Asset(name: "C579", |
---|
[314] | 1156 | description: "RO #1", |
---|
| 1157 | section: Section.get(2)) |
---|
[276] | 1158 | saveAndTest(assetInstance4) |
---|
[149] | 1159 | |
---|
[270] | 1160 | //AssetSubItem |
---|
| 1161 | def assetSubItemInstance |
---|
[149] | 1162 | |
---|
[276] | 1163 | //AssetSubItem #1 Level1 |
---|
[314] | 1164 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower", |
---|
| 1165 | description: "Common sub asset.") |
---|
[276] | 1166 | saveAndTest(assetSubItemInstance1) |
---|
[149] | 1167 | |
---|
[276] | 1168 | // Add assetSubItemInstance1 to some assets. |
---|
| 1169 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1170 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1171 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1172 | |
---|
| 1173 | //AssetSubItem #2 Level1 |
---|
[321] | 1174 | def assetSubItemInstance2 = new AssetSubItem(name: "C579-44", |
---|
| 1175 | description: "Tanks and towers") |
---|
[276] | 1176 | saveAndTest(assetSubItemInstance2) |
---|
| 1177 | |
---|
| 1178 | // Add assetSubItemInstance2 to some assets. |
---|
| 1179 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
| 1180 | |
---|
| 1181 | //AssetSubItem #3 Level1 |
---|
[321] | 1182 | def assetSubItemInstance3 = new AssetSubItem(name: "C579-20", |
---|
| 1183 | description: "Control Loops") |
---|
[276] | 1184 | saveAndTest(assetSubItemInstance3) |
---|
| 1185 | |
---|
| 1186 | // Add assetSubItemInstance3 to some assets. |
---|
| 1187 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
| 1188 | |
---|
| 1189 | //AssetSubItem #4 Level2 |
---|
[321] | 1190 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0022", |
---|
| 1191 | description: "Blow Tank", |
---|
| 1192 | parentItem: AssetSubItem.get(2)) |
---|
| 1193 | saveAndTest(assetSubItemInstance) |
---|
| 1194 | |
---|
| 1195 | //AssetSubItem #5 Level2 |
---|
| 1196 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0023", |
---|
| 1197 | description: "Reactor Tower", |
---|
| 1198 | parentItem: AssetSubItem.get(2)) |
---|
| 1199 | saveAndTest(assetSubItemInstance) |
---|
| 1200 | |
---|
| 1201 | //AssetSubItem #6 Level2 |
---|
[314] | 1202 | assetSubItemInstance = new AssetSubItem(name: "Print Unit", |
---|
| 1203 | description: "Print Unit - Common Level 2 sub item.", |
---|
| 1204 | parentItem: AssetSubItem.get(1)) |
---|
[270] | 1205 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1206 | |
---|
[321] | 1207 | //AssetSubItem #7 Level2 |
---|
| 1208 | assetSubItemInstance = new AssetSubItem(name: "1925365", |
---|
| 1209 | description: "Agitator", |
---|
| 1210 | parentItem: AssetSubItem.get(4)) |
---|
[270] | 1211 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1212 | |
---|
[321] | 1213 | //AssetSubItem #8 Level2 |
---|
| 1214 | assetSubItemInstance = new AssetSubItem(name: "1925366", |
---|
| 1215 | description: "Scraper", |
---|
| 1216 | parentItem: AssetSubItem.get(4)) |
---|
[276] | 1217 | saveAndTest(assetSubItemInstance) |
---|
| 1218 | |
---|
[321] | 1219 | //AssetSubItem #9 Level3 |
---|
[276] | 1220 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
[314] | 1221 | description: "Motor - Level 3 sub item", |
---|
[321] | 1222 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1223 | saveAndTest(assetSubItemInstance) |
---|
| 1224 | |
---|
[321] | 1225 | //AssetSubItem #10 Level3 |
---|
[276] | 1226 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
[314] | 1227 | description: "Gearbox - Level 3 sub item, gearbox", |
---|
[321] | 1228 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1229 | saveAndTest(assetSubItemInstance) |
---|
| 1230 | |
---|
[321] | 1231 | //AssetSubItem #11 Level4 |
---|
[276] | 1232 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
[314] | 1233 | description: "Drive Side Bearing", |
---|
[321] | 1234 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1235 | saveAndTest(assetSubItemInstance) |
---|
| 1236 | |
---|
[321] | 1237 | //AssetSubItem #12 Level4 |
---|
[276] | 1238 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
[314] | 1239 | description: "Non Drive Side Bearing", |
---|
[321] | 1240 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1241 | saveAndTest(assetSubItemInstance) |
---|
[321] | 1242 | |
---|
| 1243 | //AssetSubItem #13 Level2 |
---|
| 1244 | assetSubItemInstance = new AssetSubItem(name: "C579-F-0001", |
---|
| 1245 | description: "Weak Caustic Flow", |
---|
| 1246 | parentItem: AssetSubItem.get(3)) |
---|
| 1247 | saveAndTest(assetSubItemInstance) |
---|
| 1248 | |
---|
| 1249 | //AssetSubItem #14 Level3 |
---|
| 1250 | assetSubItemInstance = new AssetSubItem(name: "C579-FT-0002", |
---|
| 1251 | description: "Weak Caustic Flow Transmitter", |
---|
| 1252 | parentItem: AssetSubItem.get(13)) |
---|
| 1253 | saveAndTest(assetSubItemInstance) |
---|
| 1254 | |
---|
| 1255 | //AssetSubItem #15 Level3 |
---|
| 1256 | assetSubItemInstance = new AssetSubItem(name: "C579-PT-0003", |
---|
| 1257 | description: "Weak Caustic Pressure Transmitter", |
---|
| 1258 | parentItem: AssetSubItem.get(13)) |
---|
| 1259 | saveAndTest(assetSubItemInstance) |
---|
[276] | 1260 | } // createDemoAssetTree() |
---|
| 1261 | |
---|
[149] | 1262 | def createDemoAssetExtenedAttributes() { |
---|
| 1263 | |
---|
[270] | 1264 | //AssetExtendedAttribute |
---|
| 1265 | def assetExtendedAttributeInstance |
---|
| 1266 | |
---|
| 1267 | //AssetExtendedAttribute #1 |
---|
| 1268 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 1269 | asset: Asset.get(1), |
---|
| 1270 | extendedAttributeType: ExtendedAttributeType.get(1)) |
---|
| 1271 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1272 | |
---|
| 1273 | //AssetExtendedAttribute #2 |
---|
| 1274 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1275 | asset: Asset.get(1), |
---|
| 1276 | extendedAttributeType: ExtendedAttributeType.get(5)) |
---|
| 1277 | saveAndTest(assetExtendedAttributeInstance) |
---|
[149] | 1278 | } |
---|
| 1279 | |
---|
| 1280 | |
---|
| 1281 | /**************************************** |
---|
| 1282 | Call this function instead of .save() |
---|
| 1283 | *****************************************/ |
---|
| 1284 | private boolean saveAndTest(object) { |
---|
| 1285 | if(!object.save()) { |
---|
| 1286 | // DemoDataSuccessful = false |
---|
[199] | 1287 | log.error "'${object}' failed to save!" |
---|
| 1288 | log.error object.errors |
---|
[149] | 1289 | return false |
---|
| 1290 | } |
---|
| 1291 | return true |
---|
| 1292 | } |
---|
| 1293 | } |
---|