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