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