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