[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() |
---|
[397] | 60 | createBaseSupplierTypes() |
---|
| 61 | createBaseManufacturerTypes() |
---|
| 62 | createBaseAddressTypes() |
---|
[402] | 63 | createBaseContactTypes() |
---|
[441] | 64 | createBaseInventoryItemPurchaseTypes() |
---|
[237] | 65 | |
---|
[149] | 66 | // Tasks |
---|
[180] | 67 | createBaseTaskGroups() |
---|
[149] | 68 | createBaseTaskStatus() |
---|
| 69 | createBaseTaskPriorities() |
---|
[252] | 70 | createBaseTaskBudgetStatus() |
---|
[149] | 71 | createBaseTaskTypes() |
---|
[180] | 72 | createBaseTaskModificationTypes() |
---|
[149] | 73 | createBaseEntryTypes() |
---|
[237] | 74 | |
---|
[149] | 75 | // Inventory |
---|
| 76 | createBaseInventoryTypes() |
---|
[175] | 77 | createBaseInventoryMovementTypes() |
---|
[237] | 78 | |
---|
[149] | 79 | // Assets |
---|
[270] | 80 | createBaseExtenededAttributeTypes() |
---|
| 81 | createBaseMaintenancePolicies() |
---|
[149] | 82 | |
---|
[237] | 83 | // Record that data has been created. |
---|
| 84 | appConfigService.set("baseDataCreated") |
---|
[149] | 85 | } |
---|
| 86 | |
---|
| 87 | /** |
---|
| 88 | * Create demo data for some example sites. |
---|
| 89 | */ |
---|
| 90 | def createDemoData() { |
---|
[237] | 91 | |
---|
| 92 | if(!appConfigService.exists("baseDataCreated")) { |
---|
| 93 | log.error "Demo data cannot be created until base data has been created." |
---|
| 94 | return false |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | if(appConfigService.exists("demoDataCreated")) { |
---|
| 98 | log.error "Demo data has already been created, will NOT recreate." |
---|
| 99 | return false |
---|
| 100 | } |
---|
| 101 | |
---|
| 102 | if(appConfigService.exists("demoDataCreationDisabled")) { |
---|
| 103 | log.error "Demo data creation has been disabled, will NOT create." |
---|
| 104 | return false |
---|
| 105 | } |
---|
| 106 | |
---|
[199] | 107 | log.info "Creating demo data..." |
---|
[237] | 108 | |
---|
[149] | 109 | // Person and Utils |
---|
| 110 | createDemoPersons() |
---|
| 111 | createDemoSites() |
---|
[162] | 112 | createDemoDepartments() |
---|
[175] | 113 | createDemoSuppliers() |
---|
| 114 | createDemoManufacturers() |
---|
[431] | 115 | createDemoProductionReference() |
---|
[441] | 116 | createDemoCostCodes() |
---|
[237] | 117 | |
---|
[149] | 118 | // Tasks |
---|
| 119 | createDemoTasks() |
---|
| 120 | createDemoEntries() |
---|
[242] | 121 | createDemoAssignedGroups() |
---|
[241] | 122 | createDemoAssignedPersons() |
---|
[149] | 123 | createDemoTaskRecurringSchedules() |
---|
[237] | 124 | |
---|
[149] | 125 | // Inventory |
---|
| 126 | createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
[175] | 127 | createDemoInventoryLocations() |
---|
[149] | 128 | createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
| 129 | createDemoInventoryItems() |
---|
[237] | 130 | |
---|
[149] | 131 | // Assets |
---|
| 132 | createDemoLifePlan() |
---|
| 133 | createDemoTaskProcedure() |
---|
| 134 | createDemoMaintenanceActions() |
---|
[268] | 135 | createDemoSections() |
---|
[276] | 136 | createDemoAssetTree() |
---|
[149] | 137 | createDemoAssetExtenedAttributes() |
---|
[237] | 138 | |
---|
| 139 | // Record that data has been created. |
---|
| 140 | appConfigService.set("demoDataCreated") |
---|
[149] | 141 | } |
---|
| 142 | |
---|
| 143 | /****************** |
---|
| 144 | Start of Person |
---|
| 145 | *******************/ |
---|
| 146 | |
---|
| 147 | def createAdminAuthority() { |
---|
| 148 | def authInstance |
---|
| 149 | |
---|
[294] | 150 | // Authority #1 |
---|
[431] | 151 | authInstance = new Authority(description:"Application Admin, not required for daily use! \ |
---|
| 152 | Grants full admin access to the application.", |
---|
[149] | 153 | authority:"ROLE_AppAdmin") |
---|
| 154 | saveAndTest(authInstance) |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | def createBaseAuthorities() { |
---|
| 158 | |
---|
| 159 | def authInstance |
---|
| 160 | |
---|
[294] | 161 | // Authority #2 |
---|
[296] | 162 | authInstance = new Authority(description:"Business Manager, grants full management access.", |
---|
[431] | 163 | authority:"ROLE_Manager") |
---|
[149] | 164 | saveAndTest(authInstance) |
---|
| 165 | |
---|
[294] | 166 | // Authority #3 |
---|
[431] | 167 | authInstance = new Authority(description:"Application User, all application users need this base role \ |
---|
| 168 | to allow login.", |
---|
| 169 | authority:"ROLE_AppUser") |
---|
[149] | 170 | saveAndTest(authInstance) |
---|
[296] | 171 | |
---|
| 172 | // Authority #4 |
---|
| 173 | authInstance = new Authority(description:"Task Manager", |
---|
[431] | 174 | authority:"ROLE_TaskManager") |
---|
[296] | 175 | saveAndTest(authInstance) |
---|
| 176 | |
---|
| 177 | // Authority #5 |
---|
| 178 | authInstance = new Authority(description:"Task User", |
---|
[431] | 179 | authority:"ROLE_TaskUser") |
---|
[296] | 180 | saveAndTest(authInstance) |
---|
| 181 | |
---|
| 182 | // Authority #6 |
---|
| 183 | authInstance = new Authority(description:"Inventory Manager", |
---|
[431] | 184 | authority:"ROLE_InventoryManager") |
---|
[296] | 185 | saveAndTest(authInstance) |
---|
| 186 | |
---|
| 187 | // Authority #7 |
---|
| 188 | authInstance = new Authority(description:"Inventory User", |
---|
[431] | 189 | authority:"ROLE_InventoryUser") |
---|
[296] | 190 | saveAndTest(authInstance) |
---|
| 191 | |
---|
| 192 | // Authority #8 |
---|
| 193 | authInstance = new Authority(description:"Asset Manager", |
---|
[431] | 194 | authority:"ROLE_AssetManager") |
---|
[296] | 195 | saveAndTest(authInstance) |
---|
| 196 | |
---|
| 197 | // Authority #9 |
---|
| 198 | authInstance = new Authority(description:"Asset User", |
---|
[431] | 199 | authority:"ROLE_AssetUser") |
---|
[296] | 200 | saveAndTest(authInstance) |
---|
[431] | 201 | |
---|
| 202 | // Authority #10 |
---|
| 203 | authInstance = new Authority(description:"Production Manager", |
---|
| 204 | authority:"ROLE_ProductionManager") |
---|
| 205 | saveAndTest(authInstance) |
---|
| 206 | |
---|
| 207 | // Authority #11 |
---|
| 208 | authInstance = new Authority(description:"Production User", |
---|
| 209 | authority:"ROLE_ProductionUser") |
---|
| 210 | saveAndTest(authInstance) |
---|
[149] | 211 | } |
---|
| 212 | |
---|
| 213 | void createBasePersonGroups() { |
---|
| 214 | //TypeOfPersonGroup |
---|
| 215 | def personGroupTypeInstance |
---|
[164] | 216 | personGroupTypeInstance = new PersonGroupType(name:"Team") |
---|
[149] | 217 | saveAndTest(personGroupTypeInstance) |
---|
| 218 | personGroupTypeInstance = new PersonGroupType(name:"Contractor") |
---|
| 219 | saveAndTest(personGroupTypeInstance) |
---|
| 220 | personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam") |
---|
| 221 | saveAndTest(personGroupTypeInstance) |
---|
| 222 | |
---|
| 223 | //PersonGroup |
---|
| 224 | def personGroupInstance |
---|
[164] | 225 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 226 | name:"Electrical") |
---|
| 227 | saveAndTest(personGroupInstance) |
---|
[164] | 228 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 229 | name:"Mechanical") |
---|
| 230 | saveAndTest(personGroupInstance) |
---|
[164] | 231 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 232 | name:"Production") |
---|
| 233 | saveAndTest(personGroupInstance) |
---|
| 234 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
| 235 | name:"Kewl AirCon Guys") |
---|
| 236 | saveAndTest(personGroupInstance) |
---|
| 237 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
| 238 | name:"gnuMims") |
---|
| 239 | saveAndTest(personGroupInstance) |
---|
| 240 | } |
---|
| 241 | |
---|
[199] | 242 | def createSystemPerson() { |
---|
| 243 | //Person |
---|
| 244 | def passClearText = "pass" |
---|
[291] | 245 | def passwordEncoded = authService.encodePassword(passClearText) |
---|
[199] | 246 | def personInstance |
---|
| 247 | |
---|
| 248 | //Person #1 |
---|
| 249 | personInstance = new Person(loginName:"system", |
---|
| 250 | firstName:"gnuMims", |
---|
| 251 | lastName:"System", |
---|
| 252 | description:'''This is a pseudo person that the application uses to insert data. DO NOT |
---|
| 253 | assign login authorities or change the details of this person.''', |
---|
| 254 | pass:passClearText, |
---|
[399] | 255 | password:passwordEncoded) |
---|
[199] | 256 | saveAndTest(personInstance) |
---|
| 257 | } |
---|
| 258 | |
---|
[149] | 259 | def createAdminPerson() { |
---|
| 260 | //Person |
---|
| 261 | def passClearText = "pass" |
---|
[291] | 262 | def passwordEncoded = authService.encodePassword(passClearText) |
---|
[149] | 263 | def personInstance |
---|
| 264 | |
---|
[199] | 265 | //Person #2 |
---|
[149] | 266 | personInstance = new Person(loginName:"admin", |
---|
| 267 | firstName:"Admin", |
---|
| 268 | lastName:"Powers", |
---|
[199] | 269 | description:'''Every time the application starts it ensures that the 'admin' login name is available. |
---|
| 270 | DO update the password and other details but keep the login name as 'admin'. ''', |
---|
[149] | 271 | pass:passClearText, |
---|
[399] | 272 | password:passwordEncoded) |
---|
[149] | 273 | saveAndTest(personInstance) |
---|
| 274 | personInstance.addToAuthorities(Authority.get(1)) |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | def createBasePersons() { |
---|
[199] | 278 | } |
---|
| 279 | |
---|
| 280 | def createDemoPersons() { |
---|
[149] | 281 | //Person |
---|
| 282 | def passClearText = "pass" |
---|
[291] | 283 | def passwordEncoded = authService.encodePassword(passClearText) |
---|
[149] | 284 | def personInstance |
---|
| 285 | |
---|
[199] | 286 | //Person #1 is system. |
---|
| 287 | //Person #2 is admin. |
---|
[149] | 288 | |
---|
[199] | 289 | //Person #3 |
---|
[149] | 290 | personInstance = new Person(loginName:"manager", |
---|
| 291 | firstName:"Demo", |
---|
| 292 | lastName:"Manager", |
---|
| 293 | pass:passClearText, |
---|
[399] | 294 | password:passwordEncoded) |
---|
[149] | 295 | saveAndTest(personInstance) |
---|
[431] | 296 | personInstance.addToAuthorities(Authority.get(2)) // ROLE_Manager. |
---|
| 297 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
[149] | 298 | |
---|
[199] | 299 | //Person #4 |
---|
[149] | 300 | personInstance = new Person(loginName:"user", |
---|
| 301 | firstName:"Demo", |
---|
| 302 | lastName:"User", |
---|
| 303 | pass:passClearText, |
---|
[399] | 304 | password:passwordEncoded) |
---|
[149] | 305 | saveAndTest(personInstance) |
---|
[431] | 306 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 307 | personInstance.addToAuthorities(Authority.get(5)) // ROLE_TaskManager. |
---|
| 308 | personInstance.addToAuthorities(Authority.get(7)) // ROLE_InventoryUser. |
---|
| 309 | personInstance.addToAuthorities(Authority.get(9)) // ROLE_AssetUser. |
---|
[164] | 310 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 311 | |
---|
[199] | 312 | //Person #5 |
---|
[149] | 313 | personInstance = new Person(loginName:"craig", |
---|
| 314 | firstName:"Craig", |
---|
| 315 | lastName:"SuperSparky", |
---|
| 316 | pass:passClearText, |
---|
[399] | 317 | password:passwordEncoded) |
---|
[149] | 318 | saveAndTest(personInstance) |
---|
| 319 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[296] | 320 | personInstance.addToAuthorities(Authority.get(5)) |
---|
| 321 | personInstance.addToAuthorities(Authority.get(7)) |
---|
| 322 | personInstance.addToAuthorities(Authority.get(9)) |
---|
[164] | 323 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 324 | |
---|
[199] | 325 | //Person #6 |
---|
[149] | 326 | personInstance = new Person(loginName:"john", |
---|
| 327 | firstName:"John", |
---|
| 328 | lastName:"SuperFitter", |
---|
| 329 | pass:passClearText, |
---|
[399] | 330 | password:passwordEncoded) |
---|
[149] | 331 | saveAndTest(personInstance) |
---|
| 332 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[296] | 333 | personInstance.addToAuthorities(Authority.get(5)) |
---|
| 334 | personInstance.addToAuthorities(Authority.get(7)) |
---|
| 335 | personInstance.addToAuthorities(Authority.get(9)) |
---|
[164] | 336 | personInstance.addToPersonGroups(PersonGroup.get(2)) |
---|
[149] | 337 | |
---|
[199] | 338 | //Person #7 |
---|
[431] | 339 | personInstance = new Person(loginName:"production manager", |
---|
[149] | 340 | firstName:"Production", |
---|
[431] | 341 | lastName:"Manager", |
---|
[149] | 342 | pass:passClearText, |
---|
[399] | 343 | password:passwordEncoded) |
---|
[149] | 344 | saveAndTest(personInstance) |
---|
[431] | 345 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 346 | personInstance.addToAuthorities(Authority.get(10)) // ROLE_ProductionManager. |
---|
[164] | 347 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
[296] | 348 | |
---|
[431] | 349 | //Person #8 |
---|
| 350 | personInstance = new Person(loginName:"production", |
---|
| 351 | firstName:"Production", |
---|
| 352 | lastName:"User", |
---|
| 353 | pass:passClearText, |
---|
| 354 | password:passwordEncoded) |
---|
| 355 | saveAndTest(personInstance) |
---|
| 356 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 357 | personInstance.addToAuthorities(Authority.get(11)) // ROLE_ProductionUser. |
---|
| 358 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
| 359 | |
---|
| 360 | //Person #9 |
---|
[296] | 361 | personInstance = new Person(loginName:"testmanager", |
---|
| 362 | firstName:"Test", |
---|
| 363 | lastName:"Manager", |
---|
| 364 | pass:passClearText, |
---|
[399] | 365 | password:passwordEncoded) |
---|
[296] | 366 | saveAndTest(personInstance) |
---|
[431] | 367 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 368 | personInstance.addToAuthorities(Authority.get(4)) // ROLE_TaskManager. |
---|
| 369 | personInstance.addToAuthorities(Authority.get(6)) // ROLE_InventoryManager. |
---|
| 370 | personInstance.addToAuthorities(Authority.get(8)) // ROLE_AssetManager. |
---|
[296] | 371 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
[149] | 372 | } |
---|
| 373 | |
---|
| 374 | /*********************** |
---|
| 375 | START OF UTILITIES |
---|
| 376 | ***********************/ |
---|
| 377 | |
---|
[265] | 378 | //These can redefined by the site at deployment time. |
---|
[266] | 379 | /// @todo: build an admin view so that only the value (definition) can be changed. |
---|
[265] | 380 | def createBaseDefinitions() { |
---|
| 381 | appConfigService.set("Department Definition", "A department as recongised by accounting.") |
---|
[393] | 382 | appConfigService.set("Site Definition", "The plant, work or production site.") |
---|
| 383 | appConfigService.set("Section Definition", "A logical grouping of assets, which may be an area, system or process \ |
---|
| 384 | as determined by design.") |
---|
| 385 | appConfigService.set("Asset Definition", |
---|
| 386 | "The complete asset as it is known on the site. \ |
---|
| 387 | Often purchased as a whole with the primary purpose of returning value by performing a function. \ |
---|
| 388 | An asset is made up of 1 or more sub assets and performs a complete function as specified by the designer.") |
---|
| 389 | appConfigService.set("Asset Sub Item 1 Name", |
---|
| 390 | "Sub Asset") |
---|
| 391 | appConfigService.set("Asset Sub Item 1 Definition", |
---|
| 392 | "A machine that performs part of a complete asset's function and often has a model number.") |
---|
| 393 | appConfigService.set("Asset Sub Item 2 Name", |
---|
| 394 | "Functional Assembly") |
---|
| 395 | appConfigService.set("Asset Sub Item 2 Definition", |
---|
| 396 | "Functional Assemblies are taken from the designer's functional list for the sub asset and are made up of sub \ |
---|
| 397 | assemblies that together perform that function.") |
---|
| 398 | appConfigService.set("Asset Sub Item 3 Name", |
---|
| 399 | "Sub Assembly Group") |
---|
| 400 | appConfigService.set("Asset Sub Item 3 Definition", |
---|
| 401 | "Group or type of part.") |
---|
| 402 | appConfigService.set("Asset Sub Item 4 Name", |
---|
| 403 | "Component Item") |
---|
| 404 | appConfigService.set("Asset Sub Item 4 Definition", |
---|
| 405 | "The smallest part that would be analysed for failure.") |
---|
[265] | 406 | } |
---|
| 407 | |
---|
[149] | 408 | def createDemoSites() { |
---|
| 409 | //Site |
---|
| 410 | def siteInstance |
---|
| 411 | |
---|
[321] | 412 | siteInstance = new Site(name: "CSM", |
---|
[314] | 413 | description: "Creek Side Mill") |
---|
[149] | 414 | saveAndTest(siteInstance) |
---|
| 415 | |
---|
[314] | 416 | siteInstance = new Site(name: "Jasper Street Depot", |
---|
| 417 | description: "Storage depot on Jasper Street.") |
---|
[149] | 418 | saveAndTest(siteInstance) |
---|
[162] | 419 | |
---|
[314] | 420 | siteInstance = new Site(name: "River Press", |
---|
| 421 | description: "Printing press site") |
---|
[162] | 422 | saveAndTest(siteInstance) |
---|
[149] | 423 | } |
---|
| 424 | |
---|
[162] | 425 | def createDemoDepartments() { |
---|
| 426 | |
---|
| 427 | //Department |
---|
| 428 | def departmentInstance |
---|
| 429 | |
---|
| 430 | //Department #1 |
---|
| 431 | departmentInstance = new Department(name: "Print Centre", |
---|
[314] | 432 | description: "Printing Department", |
---|
| 433 | site: Site.get(1)) |
---|
[162] | 434 | saveAndTest(departmentInstance) |
---|
| 435 | |
---|
| 436 | //Department #2 |
---|
[321] | 437 | departmentInstance = new Department(name: "Pulp Mill", |
---|
| 438 | description: "Business Department", |
---|
[314] | 439 | site: Site.get(2)) |
---|
[162] | 440 | saveAndTest(departmentInstance) |
---|
| 441 | } |
---|
| 442 | |
---|
[149] | 443 | def createBaseUnitsOfMeasure() { |
---|
| 444 | |
---|
| 445 | //UnitOfMeasure |
---|
| 446 | def unitOfMeasureInstance |
---|
| 447 | |
---|
| 448 | //UnitOfMeasure #1 |
---|
| 449 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 450 | saveAndTest(unitOfMeasureInstance) |
---|
| 451 | |
---|
| 452 | //UnitOfMeasure #2 |
---|
| 453 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 454 | saveAndTest(unitOfMeasureInstance) |
---|
| 455 | |
---|
| 456 | //UnitOfMeasure #3 |
---|
| 457 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 458 | saveAndTest(unitOfMeasureInstance) |
---|
| 459 | |
---|
| 460 | //UnitOfMeasure #4 |
---|
| 461 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 462 | saveAndTest(unitOfMeasureInstance) |
---|
| 463 | |
---|
| 464 | //UnitOfMeasure #5 |
---|
| 465 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 466 | saveAndTest(unitOfMeasureInstance) |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | def createBasePeriods() { |
---|
| 470 | |
---|
| 471 | //Period |
---|
| 472 | def periodInstance |
---|
| 473 | |
---|
| 474 | //Period #1 |
---|
| 475 | periodInstance = new Period(period: "Day(s)") |
---|
| 476 | saveAndTest(periodInstance) |
---|
| 477 | |
---|
| 478 | //Period #2 |
---|
| 479 | periodInstance = new Period(period: "Week(s)") |
---|
| 480 | saveAndTest(periodInstance) |
---|
| 481 | |
---|
| 482 | //Period #3 |
---|
| 483 | periodInstance = new Period(period: "Month(s)") |
---|
| 484 | saveAndTest(periodInstance) |
---|
| 485 | |
---|
| 486 | //Period #4 |
---|
| 487 | periodInstance = new Period(period: "Year(s)") |
---|
| 488 | saveAndTest(periodInstance) |
---|
| 489 | } |
---|
| 490 | |
---|
[397] | 491 | def createBaseSupplierTypes() { |
---|
[175] | 492 | |
---|
| 493 | // SupplierType |
---|
| 494 | def supplierTypeInstance |
---|
| 495 | |
---|
| 496 | // SupplierType #1 |
---|
[420] | 497 | supplierTypeInstance = new SupplierType(name: "Unknown", |
---|
| 498 | description: "Unknown supplier type") |
---|
| 499 | saveAndTest(supplierTypeInstance) |
---|
| 500 | |
---|
| 501 | // SupplierType #2 |
---|
[175] | 502 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
| 503 | description: "Original equipment supplier") |
---|
| 504 | saveAndTest(supplierTypeInstance) |
---|
| 505 | |
---|
[420] | 506 | // SupplierType #3 |
---|
[175] | 507 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
| 508 | description: "Local supplier") |
---|
| 509 | saveAndTest(supplierTypeInstance) |
---|
| 510 | } |
---|
| 511 | |
---|
[397] | 512 | def createBaseManufacturerTypes() { |
---|
[175] | 513 | |
---|
| 514 | // ManufacturerType |
---|
| 515 | def manufacturerTypeInstance |
---|
| 516 | |
---|
| 517 | // ManufacturerType #1 |
---|
[420] | 518 | manufacturerTypeInstance = new ManufacturerType(name: "Unknown", |
---|
| 519 | description: "Unknown manufacturer type") |
---|
| 520 | saveAndTest(manufacturerTypeInstance) |
---|
| 521 | |
---|
| 522 | // ManufacturerType #2 |
---|
[175] | 523 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
| 524 | description: "Original equipment manufacturer") |
---|
| 525 | saveAndTest(manufacturerTypeInstance) |
---|
| 526 | |
---|
[420] | 527 | // ManufacturerType #3 |
---|
[175] | 528 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
| 529 | description: "Not original equipment manufacturer") |
---|
| 530 | saveAndTest(manufacturerTypeInstance) |
---|
| 531 | |
---|
| 532 | } |
---|
| 533 | |
---|
[397] | 534 | def createBaseAddressTypes() { |
---|
| 535 | |
---|
| 536 | // AddressType |
---|
| 537 | def addressTypeInstance |
---|
| 538 | |
---|
| 539 | // AddressType #1 |
---|
| 540 | addressTypeInstance = new AddressType(name: "Postal", |
---|
| 541 | description: "A postal address.") |
---|
| 542 | saveAndTest(addressTypeInstance) |
---|
| 543 | |
---|
| 544 | // AddressType #2 |
---|
| 545 | addressTypeInstance = new AddressType(name: "Physical", |
---|
| 546 | description: "A physical address.") |
---|
| 547 | saveAndTest(addressTypeInstance) |
---|
| 548 | |
---|
| 549 | // AddressType #3 |
---|
| 550 | addressTypeInstance = new AddressType(name: "Postal & Physical", |
---|
| 551 | description: "An address that is both the postal and physical address.") |
---|
| 552 | saveAndTest(addressTypeInstance) |
---|
| 553 | |
---|
| 554 | // AddressType #4 |
---|
| 555 | addressTypeInstance = new AddressType(name: "Invoice", |
---|
| 556 | description: "An address to send invoices to.") |
---|
| 557 | saveAndTest(addressTypeInstance) |
---|
| 558 | |
---|
| 559 | // AddressType #5 |
---|
| 560 | addressTypeInstance = new AddressType(name: "Delivery", |
---|
| 561 | description: "An address to send deliveries to.") |
---|
| 562 | saveAndTest(addressTypeInstance) |
---|
| 563 | } |
---|
| 564 | |
---|
[402] | 565 | def createBaseContactTypes() { |
---|
| 566 | |
---|
| 567 | // ContactType |
---|
| 568 | def contactTypeInstance |
---|
| 569 | |
---|
| 570 | // ContactType #1 |
---|
| 571 | contactTypeInstance = new ContactType(name: "Email", |
---|
| 572 | description: "Email address.") |
---|
| 573 | saveAndTest(contactTypeInstance) |
---|
| 574 | |
---|
| 575 | // ContactType #2 |
---|
| 576 | contactTypeInstance = new ContactType(name: "Alternate Email", |
---|
| 577 | description: "Alternate email address.") |
---|
| 578 | saveAndTest(contactTypeInstance) |
---|
| 579 | |
---|
| 580 | // ContactType #3 |
---|
| 581 | contactTypeInstance = new ContactType(name: "Mobile", |
---|
| 582 | description: "Modile phone number.") |
---|
| 583 | saveAndTest(contactTypeInstance) |
---|
| 584 | |
---|
| 585 | // ContactType #4 |
---|
| 586 | contactTypeInstance = new ContactType(name: "Work Phone", |
---|
| 587 | description: "Work phone number.") |
---|
| 588 | saveAndTest(contactTypeInstance) |
---|
| 589 | |
---|
| 590 | // ContactType #5 |
---|
| 591 | contactTypeInstance = new ContactType(name: "Home Phone", |
---|
| 592 | description: "Home phone number.") |
---|
| 593 | saveAndTest(contactTypeInstance) |
---|
| 594 | |
---|
| 595 | // ContactType #6 |
---|
| 596 | contactTypeInstance = new ContactType(name: "Work Fax", |
---|
| 597 | description: "Work fax number.") |
---|
| 598 | saveAndTest(contactTypeInstance) |
---|
| 599 | |
---|
| 600 | // ContactType #7 |
---|
| 601 | contactTypeInstance = new ContactType(name: "Home Fax", |
---|
| 602 | description: "Home fax number.") |
---|
| 603 | saveAndTest(contactTypeInstance) |
---|
| 604 | |
---|
| 605 | // ContactType #8 |
---|
| 606 | contactTypeInstance = new ContactType(name: "Web Site", |
---|
| 607 | description: "Web site address.") |
---|
| 608 | saveAndTest(contactTypeInstance) |
---|
| 609 | |
---|
| 610 | // ContactType #9 |
---|
| 611 | contactTypeInstance = new ContactType(name: "Person", |
---|
| 612 | description: "Contact person.") |
---|
| 613 | saveAndTest(contactTypeInstance) |
---|
| 614 | } |
---|
| 615 | |
---|
[441] | 616 | def createBaseInventoryItemPurchaseTypes() { |
---|
| 617 | |
---|
| 618 | // InventoryItemPurchaseType |
---|
| 619 | def inventoryItemPurchaseTypeInstance |
---|
| 620 | |
---|
| 621 | // InventoryItemPurchaseType #1 |
---|
| 622 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Order Placed", |
---|
| 623 | description: "Order has been placed.") |
---|
| 624 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 625 | |
---|
| 626 | // InventoryItemPurchaseType #2 |
---|
| 627 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Received B/order To Come", |
---|
| 628 | description: "Order has been partially received.") |
---|
| 629 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 630 | // InventoryItemPurchaseType #3 |
---|
| 631 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Received Complete", |
---|
| 632 | description: "Order has been partially received.") |
---|
| 633 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 634 | |
---|
| 635 | // InventoryItemPurchaseType #4 |
---|
| 636 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Invoice Approved", |
---|
| 637 | description: "Invoice approved for payment.") |
---|
| 638 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 639 | } |
---|
| 640 | |
---|
[175] | 641 | def createDemoSuppliers() { |
---|
| 642 | |
---|
| 643 | // Supplier |
---|
| 644 | def supplierInstance |
---|
| 645 | |
---|
| 646 | // Supplier #1 |
---|
| 647 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
[420] | 648 | supplierType: SupplierType.get(2)) |
---|
[175] | 649 | saveAndTest(supplierInstance) |
---|
| 650 | |
---|
| 651 | // Supplier #2 |
---|
| 652 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
[420] | 653 | supplierType: SupplierType.get(3)) |
---|
[175] | 654 | saveAndTest(supplierInstance) |
---|
| 655 | } |
---|
| 656 | |
---|
| 657 | def createDemoManufacturers() { |
---|
| 658 | |
---|
| 659 | // Manufacturer |
---|
| 660 | def manufacturerInstance |
---|
| 661 | |
---|
| 662 | // Manufacturer #1 |
---|
| 663 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
[420] | 664 | manufacturerType: ManufacturerType.get(2)) |
---|
[175] | 665 | saveAndTest(manufacturerInstance) |
---|
| 666 | |
---|
| 667 | // Manufacturer #2 |
---|
| 668 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
[420] | 669 | manufacturerType: ManufacturerType.get(3)) |
---|
[175] | 670 | saveAndTest(manufacturerInstance) |
---|
| 671 | } |
---|
| 672 | |
---|
[431] | 673 | def createDemoProductionReference() { |
---|
| 674 | |
---|
| 675 | // ProductionReference |
---|
| 676 | def productionReferenceInstance |
---|
| 677 | |
---|
| 678 | // ProductionReference #1 |
---|
| 679 | productionReferenceInstance = new ProductionReference(name: "Monday Production") |
---|
| 680 | saveAndTest(productionReferenceInstance) |
---|
| 681 | |
---|
| 682 | // ProductionReference #2 |
---|
| 683 | productionReferenceInstance = new ProductionReference(name: "Tuesday Production") |
---|
| 684 | saveAndTest(productionReferenceInstance) |
---|
| 685 | } |
---|
| 686 | |
---|
[441] | 687 | def createDemoCostCodes() { |
---|
| 688 | |
---|
| 689 | // CostCode |
---|
| 690 | def costCodeInstance |
---|
| 691 | |
---|
| 692 | // CostCode #1 |
---|
| 693 | costCodeInstance = new CostCode(name: "RM Reelstand") |
---|
| 694 | saveAndTest(costCodeInstance) |
---|
| 695 | |
---|
| 696 | // CostCode #2 |
---|
| 697 | costCodeInstance = new CostCode(name: "CAPEX Reelstand") |
---|
| 698 | saveAndTest(costCodeInstance) |
---|
| 699 | } |
---|
| 700 | |
---|
[149] | 701 | /********************* |
---|
| 702 | START OF TASK |
---|
| 703 | *********************/ |
---|
| 704 | |
---|
[180] | 705 | def createBaseTaskGroups() { |
---|
[149] | 706 | //TaskGroup |
---|
| 707 | def taskGroupInstance |
---|
| 708 | |
---|
[258] | 709 | //TaskGroup #1 |
---|
[149] | 710 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 711 | description:"Engineering daily activities") |
---|
| 712 | saveAndTest(taskGroupInstance) |
---|
| 713 | |
---|
[258] | 714 | //TaskGroup #2 |
---|
[149] | 715 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 716 | description:"Production daily activities") |
---|
| 717 | saveAndTest(taskGroupInstance) |
---|
| 718 | |
---|
[258] | 719 | //TaskGroup #3 |
---|
[149] | 720 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
| 721 | description:" ") |
---|
| 722 | saveAndTest(taskGroupInstance) |
---|
| 723 | } |
---|
| 724 | |
---|
| 725 | def createBaseTaskStatus() { |
---|
| 726 | |
---|
| 727 | //TaskStatus |
---|
| 728 | def taskStatusInstance |
---|
| 729 | |
---|
[181] | 730 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
[149] | 731 | saveAndTest(taskStatusInstance) |
---|
| 732 | |
---|
[181] | 733 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
[149] | 734 | saveAndTest(taskStatusInstance) |
---|
| 735 | |
---|
[222] | 736 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
[149] | 737 | saveAndTest(taskStatusInstance) |
---|
| 738 | } |
---|
| 739 | |
---|
| 740 | def createBaseTaskPriorities() { |
---|
| 741 | |
---|
| 742 | //TaskPriority |
---|
| 743 | def taskPriorityInstance |
---|
| 744 | |
---|
[433] | 745 | taskPriorityInstance = new TaskPriority(name:"0 - Immediate") // #1 |
---|
[149] | 746 | saveAndTest(taskPriorityInstance) |
---|
| 747 | |
---|
[433] | 748 | taskPriorityInstance = new TaskPriority(name:"1 - Very High") // #2 |
---|
[149] | 749 | saveAndTest(taskPriorityInstance) |
---|
| 750 | |
---|
[433] | 751 | taskPriorityInstance = new TaskPriority(name:"2 - High") // #3 |
---|
[149] | 752 | saveAndTest(taskPriorityInstance) |
---|
| 753 | |
---|
[433] | 754 | taskPriorityInstance = new TaskPriority(name:"3 - Normal") // #4 |
---|
[149] | 755 | saveAndTest(taskPriorityInstance) |
---|
[433] | 756 | |
---|
| 757 | taskPriorityInstance = new TaskPriority(name:"4 - Low") // #5 |
---|
| 758 | saveAndTest(taskPriorityInstance) |
---|
| 759 | |
---|
| 760 | taskPriorityInstance = new TaskPriority(name:"5 - Minor") // #6 |
---|
| 761 | saveAndTest(taskPriorityInstance) |
---|
[149] | 762 | } |
---|
| 763 | |
---|
[252] | 764 | def createBaseTaskBudgetStatus() { |
---|
| 765 | |
---|
| 766 | //TaskBudgetStatus |
---|
| 767 | def taskBudgetStatusInstance |
---|
| 768 | |
---|
| 769 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
| 770 | saveAndTest(taskBudgetStatusInstance) |
---|
| 771 | |
---|
| 772 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
| 773 | saveAndTest(taskBudgetStatusInstance) |
---|
| 774 | } |
---|
| 775 | |
---|
[149] | 776 | def createBaseTaskTypes() { |
---|
| 777 | |
---|
| 778 | //TaskType |
---|
| 779 | def taskTypeInstance |
---|
| 780 | |
---|
[418] | 781 | taskTypeInstance = new TaskType(name:"Immediate Callout") // #1 |
---|
[149] | 782 | saveAndTest(taskTypeInstance) |
---|
| 783 | |
---|
[418] | 784 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #2 |
---|
[149] | 785 | saveAndTest(taskTypeInstance) |
---|
| 786 | |
---|
[418] | 787 | taskTypeInstance = new TaskType(name:"Scheduled") // #3 |
---|
[149] | 788 | saveAndTest(taskTypeInstance) |
---|
| 789 | |
---|
[418] | 790 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #4 |
---|
[149] | 791 | saveAndTest(taskTypeInstance) |
---|
| 792 | |
---|
[418] | 793 | taskTypeInstance = new TaskType(name:"Predictive Maintenance") // #5 |
---|
[149] | 794 | saveAndTest(taskTypeInstance) |
---|
[418] | 795 | |
---|
| 796 | taskTypeInstance = new TaskType(name:"Project") // #6 |
---|
| 797 | saveAndTest(taskTypeInstance) |
---|
[149] | 798 | } |
---|
| 799 | |
---|
[180] | 800 | def createBaseTaskModificationTypes() { |
---|
| 801 | |
---|
| 802 | //ModificationType |
---|
| 803 | def taskModificationTypeInstance |
---|
| 804 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
| 805 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
| 806 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
| 807 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
| 808 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
| 809 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
| 810 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
| 811 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
| 812 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
[251] | 813 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
| 814 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
[418] | 815 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Flagged for attention)").save() // #12 |
---|
| 816 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Attention flag cleared)").save() // #13 |
---|
[180] | 817 | } |
---|
| 818 | |
---|
[149] | 819 | def createDemoTasks() { |
---|
| 820 | |
---|
[180] | 821 | def taskResult |
---|
| 822 | def p = [:] |
---|
[149] | 823 | |
---|
| 824 | //Task #1 |
---|
[180] | 825 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 826 | taskPriority:TaskPriority.get(2), |
---|
| 827 | taskType:TaskType.get(1), |
---|
| 828 | leadPerson:Person.get(2), |
---|
[418] | 829 | description:"Level sensor not working", |
---|
[180] | 830 | comment:"Has been noted as problematic, try recalibrating.", |
---|
[447] | 831 | targetStartDate: dateUtilService.today, |
---|
| 832 | targetCompletionDate: dateUtilService.today] |
---|
[149] | 833 | |
---|
[394] | 834 | taskResult = taskService.save(p) |
---|
[180] | 835 | |
---|
[149] | 836 | //Task #2 |
---|
[180] | 837 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 838 | taskPriority:TaskPriority.get(2), |
---|
[418] | 839 | taskType:TaskType.get(3), |
---|
[149] | 840 | leadPerson:Person.get(5), |
---|
| 841 | description:"Some follow-up work", |
---|
| 842 | comment:"Some help required", |
---|
[210] | 843 | targetStartDate: dateUtilService.tomorrow, |
---|
[447] | 844 | targetCompletionDate: dateUtilService.tomorrow, |
---|
[180] | 845 | parentTask: Task.get(1)] |
---|
[149] | 846 | |
---|
[394] | 847 | taskResult = taskService.save(p) |
---|
[180] | 848 | |
---|
[149] | 849 | //Task #3 |
---|
[180] | 850 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 851 | taskPriority:TaskPriority.get(2), |
---|
[418] | 852 | taskType:TaskType.get(3), |
---|
[149] | 853 | leadPerson:Person.get(5), |
---|
[418] | 854 | description:"A Sub Task can be created from the 'Sub Task' tab.", |
---|
[149] | 855 | comment:"Some help required", |
---|
[210] | 856 | targetStartDate: dateUtilService.yesterday, |
---|
[447] | 857 | targetCompletionDate: dateUtilService.yesterday, |
---|
[180] | 858 | parentTask: Task.get(1)] |
---|
[149] | 859 | |
---|
[394] | 860 | taskResult = taskService.save(p) |
---|
[180] | 861 | |
---|
[149] | 862 | //Task #4 |
---|
[180] | 863 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 864 | taskPriority:TaskPriority.get(2), |
---|
[418] | 865 | taskType:TaskType.get(2), |
---|
[149] | 866 | leadPerson:Person.get(4), |
---|
[418] | 867 | description:"Please replace sensor at next available opportunity.", |
---|
| 868 | comment:"Nothing else has worked. So we now require the part to be replaced.", |
---|
[447] | 869 | targetStartDate: dateUtilService.today, |
---|
| 870 | targetCompletionDate: dateUtilService.oneWeekFromNow, |
---|
[180] | 871 | parentTask: Task.get(1)] |
---|
[149] | 872 | |
---|
[394] | 873 | taskResult = taskService.save(p) |
---|
[180] | 874 | |
---|
[149] | 875 | //Task #5 |
---|
[180] | 876 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
[149] | 877 | taskPriority:TaskPriority.get(2), |
---|
[418] | 878 | taskType:TaskType.get(3), |
---|
[149] | 879 | leadPerson:Person.get(6), |
---|
[418] | 880 | description:"Production Task", |
---|
| 881 | comment:"Production task for specific production run or shift", |
---|
[447] | 882 | targetStartDate: dateUtilService.today - 6, |
---|
| 883 | targetCompletionDate: dateUtilService.today - 6] |
---|
[149] | 884 | |
---|
[394] | 885 | taskResult = taskService.save(p) |
---|
[180] | 886 | |
---|
[149] | 887 | //Task #6 |
---|
[199] | 888 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[418] | 889 | taskPriority:TaskPriority.get(4), |
---|
| 890 | taskType:TaskType.get(3), |
---|
[199] | 891 | leadPerson:Person.get(4), |
---|
[418] | 892 | description:"This is a recurring preventative maintenance task.", |
---|
[199] | 893 | 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.", |
---|
[447] | 894 | targetStartDate: dateUtilService.today, |
---|
| 895 | targetCompletionDate: dateUtilService.today + 30] |
---|
[180] | 896 | |
---|
[394] | 897 | taskResult = taskService.save(p) |
---|
[149] | 898 | } |
---|
| 899 | |
---|
| 900 | def createBaseEntryTypes() { |
---|
| 901 | |
---|
| 902 | //EntryType |
---|
| 903 | def entryTypeInstance |
---|
| 904 | |
---|
[190] | 905 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
[149] | 906 | saveAndTest(entryTypeInstance) |
---|
| 907 | |
---|
[418] | 908 | entryTypeInstance = new EntryType(name:"Cause") // #2 |
---|
[149] | 909 | saveAndTest(entryTypeInstance) |
---|
| 910 | |
---|
[418] | 911 | entryTypeInstance = new EntryType(name:"Work Done") // #3 |
---|
[149] | 912 | saveAndTest(entryTypeInstance) |
---|
| 913 | |
---|
[418] | 914 | entryTypeInstance = new EntryType(name:"Production Note") // #4 |
---|
[149] | 915 | saveAndTest(entryTypeInstance) |
---|
[418] | 916 | |
---|
| 917 | entryTypeInstance = new EntryType(name:"Work Request") // #5 |
---|
| 918 | saveAndTest(entryTypeInstance) |
---|
[149] | 919 | } |
---|
| 920 | |
---|
| 921 | def createDemoEntries() { |
---|
| 922 | |
---|
[190] | 923 | def entryResult |
---|
| 924 | def p = [:] |
---|
[149] | 925 | |
---|
| 926 | //Entry #1 |
---|
[190] | 927 | p = [task: Task.get(1), |
---|
| 928 | entryType: EntryType.get(1), |
---|
| 929 | comment: "This level sensor is causing us trouble.", |
---|
| 930 | durationMinute: 20] |
---|
[149] | 931 | |
---|
[394] | 932 | entryResult = taskService.saveEntry(p) |
---|
[190] | 933 | |
---|
[149] | 934 | //Entry #2 |
---|
[190] | 935 | p = [task: Task.get(1), |
---|
[418] | 936 | entryType: EntryType.get(3), |
---|
[190] | 937 | comment: "Cleaned sensor, see how it goes.", |
---|
| 938 | durationMinute: 30] |
---|
[149] | 939 | |
---|
[394] | 940 | entryResult = taskService.saveEntry(p) |
---|
[190] | 941 | |
---|
[149] | 942 | //Entry #3 |
---|
[190] | 943 | p = [task: Task.get(1), |
---|
[418] | 944 | entryType: EntryType.get(3), |
---|
[190] | 945 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
| 946 | durationMinute: 20] |
---|
| 947 | |
---|
[394] | 948 | entryResult = taskService.saveEntry(p) |
---|
[149] | 949 | } |
---|
| 950 | |
---|
[242] | 951 | def createDemoAssignedGroups() { |
---|
| 952 | |
---|
[251] | 953 | def result |
---|
| 954 | def p = [:] |
---|
[242] | 955 | |
---|
| 956 | //AssignedGroup #1 |
---|
[251] | 957 | p = [personGroup: PersonGroup.get(1), |
---|
| 958 | task: Task.get(1), |
---|
| 959 | estimatedHour: 2, |
---|
| 960 | estimatedMinute: 30] |
---|
| 961 | result = assignedGroupService.save(p) |
---|
[242] | 962 | |
---|
| 963 | //AssignedGroup #2 |
---|
[251] | 964 | p = [personGroup: PersonGroup.get(2), |
---|
| 965 | task: Task.get(1), |
---|
| 966 | estimatedHour: 1, |
---|
| 967 | estimatedMinute: 0] |
---|
| 968 | result = assignedGroupService.save(p) |
---|
[242] | 969 | } |
---|
| 970 | |
---|
[241] | 971 | def createDemoAssignedPersons() { |
---|
[149] | 972 | |
---|
[251] | 973 | def result |
---|
| 974 | def p = [:] |
---|
[149] | 975 | |
---|
[241] | 976 | //AssignedPerson #1 |
---|
[251] | 977 | p = [person: Person.get(4), |
---|
| 978 | task: Task.get(1), |
---|
| 979 | estimatedHour: 1, |
---|
| 980 | estimatedMinute: 20] |
---|
| 981 | result = assignedPersonService.save(p) |
---|
[149] | 982 | |
---|
[241] | 983 | //AssignedPerson #2 |
---|
[251] | 984 | p = [person: Person.get(5), |
---|
| 985 | task: Task.get(1), |
---|
| 986 | estimatedHour: 3, |
---|
| 987 | estimatedMinute: 30] |
---|
| 988 | result = assignedPersonService.save(p) |
---|
[149] | 989 | } |
---|
| 990 | |
---|
| 991 | def createDemoTaskRecurringSchedules() { |
---|
| 992 | |
---|
| 993 | //TaskRecurringSchedule |
---|
| 994 | def taskRecurringScheduleInstance |
---|
| 995 | |
---|
| 996 | //TaskRecurringSchedule #1 |
---|
| 997 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
| 998 | recurEvery: 1, |
---|
[199] | 999 | recurPeriod: Period.get(2), |
---|
[210] | 1000 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 1001 | generateAhead: 1, |
---|
[199] | 1002 | taskDuration: 2, |
---|
| 1003 | taskDurationPeriod: Period.get(1), |
---|
| 1004 | enabled: false) |
---|
[149] | 1005 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 1006 | |
---|
| 1007 | //TaskRecurringSchedule #2 |
---|
[199] | 1008 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(6), |
---|
[149] | 1009 | recurEvery: 1, |
---|
| 1010 | recurPeriod: Period.get(1), |
---|
[210] | 1011 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 1012 | generateAhead: 1, |
---|
| 1013 | taskDuration: 1, |
---|
[199] | 1014 | taskDurationPeriod: Period.get(1), |
---|
| 1015 | enabled: true) |
---|
[149] | 1016 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 1017 | } |
---|
| 1018 | |
---|
| 1019 | /************************* |
---|
| 1020 | START OF INVENTORY |
---|
| 1021 | **************************/ |
---|
| 1022 | |
---|
| 1023 | def createDemoInventoryStores() { |
---|
| 1024 | |
---|
| 1025 | //InventoryStore |
---|
| 1026 | def inventoryStoreInstance |
---|
| 1027 | |
---|
| 1028 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 1029 | saveAndTest(inventoryStoreInstance) |
---|
| 1030 | |
---|
| 1031 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 1032 | saveAndTest(inventoryStoreInstance) |
---|
| 1033 | } |
---|
| 1034 | |
---|
[175] | 1035 | def createDemoInventoryLocations() { |
---|
[149] | 1036 | |
---|
[175] | 1037 | // InventoryLocation |
---|
| 1038 | def inventoryLocation |
---|
[149] | 1039 | |
---|
[175] | 1040 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 1041 | saveAndTest(inventoryLocation) |
---|
[149] | 1042 | |
---|
[418] | 1043 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(2), name: "C55") |
---|
[175] | 1044 | saveAndTest(inventoryLocation) |
---|
[149] | 1045 | } |
---|
| 1046 | |
---|
| 1047 | def createDemoInventoryGroups() { |
---|
| 1048 | |
---|
| 1049 | //InventoryGroup |
---|
| 1050 | def inventoryGroupInstance |
---|
| 1051 | |
---|
| 1052 | //InventoryGroup #1 |
---|
| 1053 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 1054 | saveAndTest(inventoryGroupInstance) |
---|
| 1055 | |
---|
| 1056 | //InventoryGroup #2 |
---|
| 1057 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 1058 | saveAndTest(inventoryGroupInstance) |
---|
| 1059 | |
---|
| 1060 | //InventoryGroup #3 |
---|
| 1061 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 1062 | saveAndTest(inventoryGroupInstance) |
---|
| 1063 | |
---|
| 1064 | //InventoryGroup #4 |
---|
| 1065 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 1066 | saveAndTest(inventoryGroupInstance) |
---|
| 1067 | } |
---|
| 1068 | |
---|
| 1069 | def createBaseInventoryTypes() { |
---|
| 1070 | |
---|
| 1071 | //InventoryType |
---|
| 1072 | def inventoryTypeInstance |
---|
| 1073 | |
---|
| 1074 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 1075 | saveAndTest(inventoryTypeInstance) |
---|
| 1076 | |
---|
| 1077 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 1078 | saveAndTest(inventoryTypeInstance) |
---|
| 1079 | } |
---|
| 1080 | |
---|
[175] | 1081 | def createBaseInventoryMovementTypes() { |
---|
| 1082 | |
---|
| 1083 | // InventoryMovementType |
---|
| 1084 | def inventoryMovementTypeInstance |
---|
| 1085 | |
---|
| 1086 | // InventoryMovementType #1 |
---|
[177] | 1087 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 1088 | incrementsInventory: false) |
---|
[175] | 1089 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1090 | |
---|
| 1091 | // InventoryMovementType #2 |
---|
[177] | 1092 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 1093 | incrementsInventory: true) |
---|
[175] | 1094 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1095 | |
---|
| 1096 | // InventoryMovementType #3 |
---|
[177] | 1097 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 1098 | incrementsInventory: true) |
---|
[175] | 1099 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 1100 | |
---|
| 1101 | // InventoryMovementType #4 |
---|
| 1102 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 1103 | incrementsInventory: true) |
---|
| 1104 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1105 | |
---|
| 1106 | // InventoryMovementType #5 |
---|
| 1107 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 1108 | incrementsInventory: false) |
---|
| 1109 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 1110 | } |
---|
| 1111 | |
---|
[149] | 1112 | def createDemoInventoryItems() { |
---|
| 1113 | |
---|
| 1114 | //InventoryItem |
---|
| 1115 | def inventoryItemInstance |
---|
| 1116 | |
---|
| 1117 | //InventoryItem #1 |
---|
| 1118 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 1119 | inventoryType: InventoryType.get(1), |
---|
| 1120 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 1121 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 1122 | name: "Hemp rope", |
---|
| 1123 | description: "Natural hemp rope.", |
---|
[175] | 1124 | unitsInStock: 2, |
---|
[149] | 1125 | reorderPoint: 0) |
---|
| 1126 | saveAndTest(inventoryItemInstance) |
---|
| 1127 | |
---|
| 1128 | //InventoryItem #2 |
---|
| 1129 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 1130 | inventoryType: InventoryType.get(1), |
---|
| 1131 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 1132 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 1133 | name: "Cotton Rope 12mm", |
---|
| 1134 | description: "A soft natural rope made from cotton.", |
---|
[149] | 1135 | alternateItems: InventoryItem.get(1), |
---|
[175] | 1136 | unitsInStock: 2, |
---|
[149] | 1137 | reorderPoint: 0) |
---|
| 1138 | saveAndTest(inventoryItemInstance) |
---|
| 1139 | |
---|
| 1140 | //InventoryItem #3 |
---|
| 1141 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 1142 | inventoryType: InventoryType.get(1), |
---|
| 1143 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1144 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1145 | name: "2305-2RS", |
---|
| 1146 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[175] | 1147 | unitsInStock: 3, |
---|
[149] | 1148 | reorderPoint: 2) |
---|
| 1149 | saveAndTest(inventoryItemInstance) |
---|
| 1150 | |
---|
| 1151 | //InventoryItem #4 |
---|
| 1152 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 1153 | inventoryType: InventoryType.get(1), |
---|
| 1154 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1155 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1156 | name: "L1592-K10", |
---|
| 1157 | description: "10kW contactor", |
---|
[175] | 1158 | unitsInStock: 4, |
---|
[149] | 1159 | reorderPoint: 0) |
---|
| 1160 | saveAndTest(inventoryItemInstance) |
---|
| 1161 | |
---|
| 1162 | //InventoryItem #5 |
---|
| 1163 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 1164 | inventoryType: InventoryType.get(1), |
---|
| 1165 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1166 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1167 | name: "6205-ZZ", |
---|
| 1168 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[175] | 1169 | unitsInStock: 5, |
---|
[149] | 1170 | reorderPoint: 2) |
---|
| 1171 | saveAndTest(inventoryItemInstance) |
---|
| 1172 | } |
---|
| 1173 | |
---|
| 1174 | /******************* |
---|
| 1175 | START OF ASSET |
---|
| 1176 | *******************/ |
---|
| 1177 | |
---|
| 1178 | def createDemoLifePlan() { |
---|
| 1179 | |
---|
| 1180 | //LifePlan |
---|
| 1181 | def lifeplanInstance |
---|
| 1182 | |
---|
| 1183 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 1184 | saveAndTest(lifeplanInstance) |
---|
| 1185 | } |
---|
| 1186 | |
---|
[270] | 1187 | def createBaseExtenededAttributeTypes() { |
---|
| 1188 | |
---|
| 1189 | //ExtendedAttributeType |
---|
| 1190 | def extendedAttributeTypeInstance |
---|
| 1191 | |
---|
| 1192 | //ExtendedAttributeType #1 |
---|
| 1193 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
| 1194 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1195 | |
---|
| 1196 | //ExtendedAttributeType #2 |
---|
| 1197 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
| 1198 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1199 | |
---|
| 1200 | //ExtendedAttributeType #3 |
---|
| 1201 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
| 1202 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1203 | |
---|
| 1204 | //ExtendedAttributeType #4 |
---|
| 1205 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
| 1206 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1207 | |
---|
| 1208 | //ExtendedAttributeType #5 |
---|
| 1209 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
| 1210 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1211 | |
---|
| 1212 | //ExtendedAttributeType #6 |
---|
| 1213 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
| 1214 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1215 | |
---|
| 1216 | //ExtendedAttributeType #7 |
---|
| 1217 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
| 1218 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1219 | |
---|
| 1220 | //ExtendedAttributeType #8 |
---|
| 1221 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer's Number") |
---|
| 1222 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1223 | |
---|
| 1224 | //ExtendedAttributeType #9 |
---|
| 1225 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Inventory Number") |
---|
| 1226 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1227 | } |
---|
| 1228 | |
---|
[149] | 1229 | def createBaseMaintenancePolicies() { |
---|
| 1230 | |
---|
| 1231 | //MaintenancePolicy |
---|
| 1232 | def maintenancePolicyInstance |
---|
| 1233 | |
---|
| 1234 | //MaintenancePolicy #1 |
---|
| 1235 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 1236 | saveAndTest(maintenancePolicyInstance) |
---|
| 1237 | |
---|
| 1238 | //MaintenancePolicy #2 |
---|
| 1239 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 1240 | saveAndTest(maintenancePolicyInstance) |
---|
| 1241 | |
---|
| 1242 | //MaintenancePolicy #3 |
---|
| 1243 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 1244 | saveAndTest(maintenancePolicyInstance) |
---|
| 1245 | |
---|
| 1246 | //MaintenancePolicy #4 |
---|
| 1247 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 1248 | saveAndTest(maintenancePolicyInstance) |
---|
| 1249 | |
---|
| 1250 | //MaintenancePolicy #5 |
---|
| 1251 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 1252 | saveAndTest(maintenancePolicyInstance) |
---|
[275] | 1253 | |
---|
| 1254 | //MaintenancePolicy #6 |
---|
| 1255 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
| 1256 | saveAndTest(maintenancePolicyInstance) |
---|
| 1257 | |
---|
| 1258 | //MaintenancePolicy #7 |
---|
| 1259 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
| 1260 | saveAndTest(maintenancePolicyInstance) |
---|
[149] | 1261 | } |
---|
| 1262 | |
---|
| 1263 | def createDemoTaskProcedure() { |
---|
| 1264 | |
---|
| 1265 | //TaskProcedure |
---|
| 1266 | def taskProcedureInstance |
---|
| 1267 | |
---|
| 1268 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 1269 | saveAndTest(taskProcedureInstance) |
---|
| 1270 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
| 1271 | } |
---|
| 1272 | |
---|
| 1273 | def createDemoMaintenanceActions() { |
---|
| 1274 | |
---|
| 1275 | //MaintenanceAction |
---|
| 1276 | def maintenanceActionInstance |
---|
| 1277 | |
---|
| 1278 | //MaintenanceAction #1 |
---|
| 1279 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 1280 | procedureStepNumber: 1, |
---|
| 1281 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1282 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1283 | saveAndTest(maintenanceActionInstance) |
---|
| 1284 | |
---|
| 1285 | //MaintenanceAction #2 |
---|
| 1286 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 1287 | procedureStepNumber: 2, |
---|
| 1288 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1289 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1290 | saveAndTest(maintenanceActionInstance) |
---|
| 1291 | |
---|
| 1292 | //MaintenanceAction #3 |
---|
| 1293 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 1294 | procedureStepNumber: 3, |
---|
| 1295 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1296 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1297 | saveAndTest(maintenanceActionInstance) |
---|
| 1298 | } |
---|
| 1299 | |
---|
[268] | 1300 | def createDemoSections() { |
---|
[149] | 1301 | |
---|
[268] | 1302 | //Section |
---|
| 1303 | def sectionInstance |
---|
[149] | 1304 | |
---|
[268] | 1305 | //Section #1 |
---|
[314] | 1306 | sectionInstance = new Section(name: "Press", |
---|
| 1307 | description: "Press Section", |
---|
| 1308 | site: Site.get(3), |
---|
| 1309 | department: Department.get(1)) |
---|
[268] | 1310 | saveAndTest(sectionInstance) |
---|
[149] | 1311 | |
---|
[268] | 1312 | //Section #2 |
---|
[321] | 1313 | sectionInstance = new Section(name: "CSM-Delig", |
---|
[314] | 1314 | description: "Pulp Delignification", |
---|
| 1315 | site: Site.get(1), |
---|
| 1316 | department: Department.get(2)) |
---|
[268] | 1317 | saveAndTest(sectionInstance) |
---|
[149] | 1318 | |
---|
[268] | 1319 | //Section #3 |
---|
[321] | 1320 | sectionInstance = new Section(name: "CSM-Aux", |
---|
[314] | 1321 | description: "Auxilliary Section", |
---|
| 1322 | site: Site.get(1), |
---|
| 1323 | department: Department.get(1)) |
---|
[268] | 1324 | saveAndTest(sectionInstance) |
---|
[149] | 1325 | } |
---|
| 1326 | |
---|
[276] | 1327 | def createDemoAssetTree() { |
---|
[149] | 1328 | |
---|
[270] | 1329 | //Asset |
---|
| 1330 | def assetInstance |
---|
[149] | 1331 | |
---|
[270] | 1332 | //Asset #1 |
---|
[276] | 1333 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
[314] | 1334 | description: "Complete Printing Asset #22", |
---|
| 1335 | section: Section.get(1)) |
---|
[276] | 1336 | saveAndTest(assetInstance1) |
---|
[270] | 1337 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
[149] | 1338 | |
---|
[270] | 1339 | //Asset #2 |
---|
[276] | 1340 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
[314] | 1341 | description: "Complete Printing Asset #21", |
---|
| 1342 | section: Section.get(1)) |
---|
[276] | 1343 | saveAndTest(assetInstance2) |
---|
[149] | 1344 | |
---|
[270] | 1345 | //Asset #3 |
---|
[276] | 1346 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
[314] | 1347 | description: "Complete Printing Asset #23", |
---|
| 1348 | section: Section.get(1)) |
---|
[276] | 1349 | saveAndTest(assetInstance3) |
---|
[149] | 1350 | |
---|
[270] | 1351 | //Asset #4 |
---|
[321] | 1352 | def assetInstance4 = new Asset(name: "C579", |
---|
[314] | 1353 | description: "RO #1", |
---|
| 1354 | section: Section.get(2)) |
---|
[276] | 1355 | saveAndTest(assetInstance4) |
---|
[149] | 1356 | |
---|
[270] | 1357 | //AssetSubItem |
---|
| 1358 | def assetSubItemInstance |
---|
[149] | 1359 | |
---|
[276] | 1360 | //AssetSubItem #1 Level1 |
---|
[314] | 1361 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower", |
---|
| 1362 | description: "Common sub asset.") |
---|
[276] | 1363 | saveAndTest(assetSubItemInstance1) |
---|
[149] | 1364 | |
---|
[276] | 1365 | // Add assetSubItemInstance1 to some assets. |
---|
| 1366 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1367 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1368 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1369 | |
---|
| 1370 | //AssetSubItem #2 Level1 |
---|
[321] | 1371 | def assetSubItemInstance2 = new AssetSubItem(name: "C579-44", |
---|
| 1372 | description: "Tanks and towers") |
---|
[276] | 1373 | saveAndTest(assetSubItemInstance2) |
---|
| 1374 | |
---|
| 1375 | // Add assetSubItemInstance2 to some assets. |
---|
| 1376 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
| 1377 | |
---|
| 1378 | //AssetSubItem #3 Level1 |
---|
[321] | 1379 | def assetSubItemInstance3 = new AssetSubItem(name: "C579-20", |
---|
| 1380 | description: "Control Loops") |
---|
[276] | 1381 | saveAndTest(assetSubItemInstance3) |
---|
| 1382 | |
---|
| 1383 | // Add assetSubItemInstance3 to some assets. |
---|
| 1384 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
| 1385 | |
---|
| 1386 | //AssetSubItem #4 Level2 |
---|
[321] | 1387 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0022", |
---|
| 1388 | description: "Blow Tank", |
---|
| 1389 | parentItem: AssetSubItem.get(2)) |
---|
| 1390 | saveAndTest(assetSubItemInstance) |
---|
| 1391 | |
---|
| 1392 | //AssetSubItem #5 Level2 |
---|
| 1393 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0023", |
---|
| 1394 | description: "Reactor Tower", |
---|
| 1395 | parentItem: AssetSubItem.get(2)) |
---|
| 1396 | saveAndTest(assetSubItemInstance) |
---|
| 1397 | |
---|
| 1398 | //AssetSubItem #6 Level2 |
---|
[314] | 1399 | assetSubItemInstance = new AssetSubItem(name: "Print Unit", |
---|
| 1400 | description: "Print Unit - Common Level 2 sub item.", |
---|
| 1401 | parentItem: AssetSubItem.get(1)) |
---|
[270] | 1402 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1403 | |
---|
[321] | 1404 | //AssetSubItem #7 Level2 |
---|
| 1405 | assetSubItemInstance = new AssetSubItem(name: "1925365", |
---|
| 1406 | description: "Agitator", |
---|
| 1407 | parentItem: AssetSubItem.get(4)) |
---|
[270] | 1408 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1409 | |
---|
[321] | 1410 | //AssetSubItem #8 Level2 |
---|
| 1411 | assetSubItemInstance = new AssetSubItem(name: "1925366", |
---|
| 1412 | description: "Scraper", |
---|
| 1413 | parentItem: AssetSubItem.get(4)) |
---|
[276] | 1414 | saveAndTest(assetSubItemInstance) |
---|
| 1415 | |
---|
[321] | 1416 | //AssetSubItem #9 Level3 |
---|
[276] | 1417 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
[314] | 1418 | description: "Motor - Level 3 sub item", |
---|
[321] | 1419 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1420 | saveAndTest(assetSubItemInstance) |
---|
| 1421 | |
---|
[321] | 1422 | //AssetSubItem #10 Level3 |
---|
[276] | 1423 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
[314] | 1424 | description: "Gearbox - Level 3 sub item, gearbox", |
---|
[321] | 1425 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1426 | saveAndTest(assetSubItemInstance) |
---|
| 1427 | |
---|
[321] | 1428 | //AssetSubItem #11 Level4 |
---|
[276] | 1429 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
[314] | 1430 | description: "Drive Side Bearing", |
---|
[321] | 1431 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1432 | saveAndTest(assetSubItemInstance) |
---|
| 1433 | |
---|
[321] | 1434 | //AssetSubItem #12 Level4 |
---|
[276] | 1435 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
[314] | 1436 | description: "Non Drive Side Bearing", |
---|
[321] | 1437 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1438 | saveAndTest(assetSubItemInstance) |
---|
[321] | 1439 | |
---|
| 1440 | //AssetSubItem #13 Level2 |
---|
| 1441 | assetSubItemInstance = new AssetSubItem(name: "C579-F-0001", |
---|
| 1442 | description: "Weak Caustic Flow", |
---|
| 1443 | parentItem: AssetSubItem.get(3)) |
---|
| 1444 | saveAndTest(assetSubItemInstance) |
---|
| 1445 | |
---|
| 1446 | //AssetSubItem #14 Level3 |
---|
| 1447 | assetSubItemInstance = new AssetSubItem(name: "C579-FT-0002", |
---|
| 1448 | description: "Weak Caustic Flow Transmitter", |
---|
| 1449 | parentItem: AssetSubItem.get(13)) |
---|
| 1450 | saveAndTest(assetSubItemInstance) |
---|
| 1451 | |
---|
| 1452 | //AssetSubItem #15 Level3 |
---|
| 1453 | assetSubItemInstance = new AssetSubItem(name: "C579-PT-0003", |
---|
| 1454 | description: "Weak Caustic Pressure Transmitter", |
---|
| 1455 | parentItem: AssetSubItem.get(13)) |
---|
| 1456 | saveAndTest(assetSubItemInstance) |
---|
[276] | 1457 | } // createDemoAssetTree() |
---|
| 1458 | |
---|
[149] | 1459 | def createDemoAssetExtenedAttributes() { |
---|
| 1460 | |
---|
[270] | 1461 | //AssetExtendedAttribute |
---|
| 1462 | def assetExtendedAttributeInstance |
---|
| 1463 | |
---|
| 1464 | //AssetExtendedAttribute #1 |
---|
| 1465 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 1466 | asset: Asset.get(1), |
---|
| 1467 | extendedAttributeType: ExtendedAttributeType.get(1)) |
---|
| 1468 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1469 | |
---|
| 1470 | //AssetExtendedAttribute #2 |
---|
| 1471 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1472 | asset: Asset.get(1), |
---|
| 1473 | extendedAttributeType: ExtendedAttributeType.get(5)) |
---|
| 1474 | saveAndTest(assetExtendedAttributeInstance) |
---|
[149] | 1475 | } |
---|
| 1476 | |
---|
| 1477 | |
---|
| 1478 | /**************************************** |
---|
| 1479 | Call this function instead of .save() |
---|
| 1480 | *****************************************/ |
---|
| 1481 | private boolean saveAndTest(object) { |
---|
| 1482 | if(!object.save()) { |
---|
| 1483 | // DemoDataSuccessful = false |
---|
[199] | 1484 | log.error "'${object}' failed to save!" |
---|
| 1485 | log.error object.errors |
---|
[149] | 1486 | return false |
---|
| 1487 | } |
---|
| 1488 | return true |
---|
| 1489 | } |
---|
| 1490 | } |
---|