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