[622] | 1 | import org.codehaus.groovy.grails.commons.ConfigurationHolder |
---|
| 2 | |
---|
[149] | 3 | /** |
---|
| 4 | * Provides a data service to create base and demo data. |
---|
[798] | 5 | * Beware that most, if not all, BASE data is referenced by "Id" throughout the program. |
---|
[180] | 6 | * This allows changing the text of the 'name' property to something of the same meaning. |
---|
| 7 | * But be sure to maintain the correct Id during creation, indicated by #1, #2 etc. |
---|
[798] | 8 | * Task.list()[0] is used to allow integration testing with DEMO data, where Id's may change due to create-delete. |
---|
[149] | 9 | */ |
---|
| 10 | class CreateDataService { |
---|
| 11 | |
---|
| 12 | boolean transactional = false |
---|
| 13 | |
---|
[291] | 14 | def authService |
---|
[180] | 15 | def taskService |
---|
[210] | 16 | def dateUtilService |
---|
[237] | 17 | def appConfigService |
---|
[571] | 18 | def searchableService |
---|
[549] | 19 | def inventoryItemService |
---|
[251] | 20 | def assignedGroupService |
---|
| 21 | def assignedPersonService |
---|
[180] | 22 | |
---|
[549] | 23 | def grailsApplication |
---|
| 24 | |
---|
[149] | 25 | /******************************************* |
---|
| 26 | Start of Group methods. |
---|
| 27 | Generally use these methods to create data. |
---|
| 28 | *******************************************/ |
---|
| 29 | |
---|
| 30 | /** |
---|
[199] | 31 | * Always call this at startup to ensure that we have admin access |
---|
| 32 | * and that the system pseudo person is available. |
---|
[149] | 33 | */ |
---|
[199] | 34 | def ensureSystemAndAdminAccess() { |
---|
[149] | 35 | if(!Authority.findByAuthority("ROLE_AppAdmin") ) { |
---|
[199] | 36 | log.warn "ROLE_AppAdmin not found, calling createAdminAuthority()." |
---|
[149] | 37 | createAdminAuthority() |
---|
| 38 | } |
---|
[703] | 39 | if(!Person.findByLoginName("system") ) { |
---|
[199] | 40 | log.warn "LoginName 'system' not found, calling createSystemPerson()." |
---|
| 41 | createSystemPerson() |
---|
| 42 | } |
---|
[703] | 43 | if(!Person.findByLoginName("admin") ) { |
---|
[199] | 44 | log.warn "LoginName 'admin' not found, calling createAdminPerson()." |
---|
[149] | 45 | createAdminPerson() |
---|
| 46 | } |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | /** |
---|
| 50 | * Create the base data required for the application to function. |
---|
| 51 | */ |
---|
| 52 | def createBaseData() { |
---|
[237] | 53 | |
---|
| 54 | if(appConfigService.exists("baseDataCreated")) { |
---|
[506] | 55 | log.info "Base data previously created." |
---|
[237] | 56 | return false |
---|
| 57 | } |
---|
| 58 | |
---|
[506] | 59 | log.info "Creating base data." |
---|
[237] | 60 | |
---|
[149] | 61 | // Person and Utils |
---|
| 62 | createBaseAuthorities() |
---|
[506] | 63 | createBasePersonGroupTypes() |
---|
[149] | 64 | createBasePersonGroups() |
---|
[265] | 65 | createBaseDefinitions() |
---|
[149] | 66 | createBaseUnitsOfMeasure() |
---|
| 67 | createBasePeriods() |
---|
[397] | 68 | createBaseSupplierTypes() |
---|
| 69 | createBaseAddressTypes() |
---|
[402] | 70 | createBaseContactTypes() |
---|
[534] | 71 | createBaseMaintenancePolicies() |
---|
[441] | 72 | createBaseInventoryItemPurchaseTypes() |
---|
[821] | 73 | createBaseConditionSeverity() |
---|
[237] | 74 | |
---|
[534] | 75 | // Assets |
---|
| 76 | createBaseExtenededAttributeTypes() |
---|
| 77 | |
---|
| 78 | // Inventory |
---|
| 79 | createBaseInventoryTypes() |
---|
| 80 | createBaseInventoryMovementTypes() |
---|
| 81 | |
---|
[149] | 82 | // Tasks |
---|
[180] | 83 | createBaseTaskGroups() |
---|
[149] | 84 | createBaseTaskStatus() |
---|
| 85 | createBaseTaskPriorities() |
---|
[252] | 86 | createBaseTaskBudgetStatus() |
---|
[149] | 87 | createBaseTaskTypes() |
---|
[180] | 88 | createBaseTaskModificationTypes() |
---|
[149] | 89 | createBaseEntryTypes() |
---|
[237] | 90 | |
---|
| 91 | // Record that data has been created. |
---|
| 92 | appConfigService.set("baseDataCreated") |
---|
[149] | 93 | } |
---|
| 94 | |
---|
| 95 | /** |
---|
| 96 | * Create demo data for some example sites. |
---|
| 97 | */ |
---|
| 98 | def createDemoData() { |
---|
[237] | 99 | |
---|
| 100 | if(!appConfigService.exists("baseDataCreated")) { |
---|
| 101 | log.error "Demo data cannot be created until base data has been created." |
---|
| 102 | return false |
---|
| 103 | } |
---|
| 104 | |
---|
| 105 | if(appConfigService.exists("demoDataCreated")) { |
---|
| 106 | log.error "Demo data has already been created, will NOT recreate." |
---|
| 107 | return false |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | if(appConfigService.exists("demoDataCreationDisabled")) { |
---|
| 111 | log.error "Demo data creation has been disabled, will NOT create." |
---|
| 112 | return false |
---|
| 113 | } |
---|
| 114 | |
---|
[199] | 115 | log.info "Creating demo data..." |
---|
[237] | 116 | |
---|
[149] | 117 | // Person and Utils |
---|
| 118 | createDemoSites() |
---|
[162] | 119 | createDemoDepartments() |
---|
[175] | 120 | createDemoSuppliers() |
---|
[431] | 121 | createDemoProductionReference() |
---|
[633] | 122 | createDemoPurchasingGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
[441] | 123 | createDemoCostCodes() |
---|
[633] | 124 | createDemoPersons() |
---|
[237] | 125 | |
---|
[534] | 126 | // Assets |
---|
| 127 | createDemoSections() |
---|
| 128 | createDemoAssetTree() |
---|
[685] | 129 | createDemoAssetExtendedAttributes() |
---|
| 130 | createDemoAssetSubItemExtendedAttributes() |
---|
[237] | 131 | |
---|
[149] | 132 | // Inventory |
---|
| 133 | createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
[175] | 134 | createDemoInventoryLocations() |
---|
[149] | 135 | createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
| 136 | createDemoInventoryItems() |
---|
[237] | 137 | |
---|
[534] | 138 | // Tasks |
---|
| 139 | createDemoTasks() |
---|
| 140 | createDemoEntries() |
---|
| 141 | createDemoAssignedGroups() |
---|
| 142 | createDemoAssignedPersons() |
---|
[809] | 143 | // createDemoTaskProcedure() |
---|
| 144 | // createDemoMaintenanceActions() |
---|
[534] | 145 | createDemoTaskRecurringSchedules() |
---|
[237] | 146 | |
---|
| 147 | // Record that data has been created. |
---|
| 148 | appConfigService.set("demoDataCreated") |
---|
[149] | 149 | } |
---|
| 150 | |
---|
| 151 | /****************** |
---|
| 152 | Start of Person |
---|
| 153 | *******************/ |
---|
| 154 | |
---|
| 155 | def createAdminAuthority() { |
---|
| 156 | def authInstance |
---|
| 157 | |
---|
[294] | 158 | // Authority #1 |
---|
[431] | 159 | authInstance = new Authority(description:"Application Admin, not required for daily use! \ |
---|
| 160 | Grants full admin access to the application.", |
---|
[149] | 161 | authority:"ROLE_AppAdmin") |
---|
| 162 | saveAndTest(authInstance) |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | def createBaseAuthorities() { |
---|
| 166 | |
---|
| 167 | def authInstance |
---|
| 168 | |
---|
[294] | 169 | // Authority #2 |
---|
[296] | 170 | authInstance = new Authority(description:"Business Manager, grants full management access.", |
---|
[431] | 171 | authority:"ROLE_Manager") |
---|
[149] | 172 | saveAndTest(authInstance) |
---|
| 173 | |
---|
[294] | 174 | // Authority #3 |
---|
[431] | 175 | authInstance = new Authority(description:"Application User, all application users need this base role \ |
---|
| 176 | to allow login.", |
---|
| 177 | authority:"ROLE_AppUser") |
---|
[149] | 178 | saveAndTest(authInstance) |
---|
[296] | 179 | |
---|
| 180 | // Authority #4 |
---|
| 181 | authInstance = new Authority(description:"Task Manager", |
---|
[431] | 182 | authority:"ROLE_TaskManager") |
---|
[296] | 183 | saveAndTest(authInstance) |
---|
| 184 | |
---|
| 185 | // Authority #5 |
---|
| 186 | authInstance = new Authority(description:"Task User", |
---|
[431] | 187 | authority:"ROLE_TaskUser") |
---|
[296] | 188 | saveAndTest(authInstance) |
---|
| 189 | |
---|
| 190 | // Authority #6 |
---|
| 191 | authInstance = new Authority(description:"Inventory Manager", |
---|
[431] | 192 | authority:"ROLE_InventoryManager") |
---|
[296] | 193 | saveAndTest(authInstance) |
---|
| 194 | |
---|
| 195 | // Authority #7 |
---|
| 196 | authInstance = new Authority(description:"Inventory User", |
---|
[431] | 197 | authority:"ROLE_InventoryUser") |
---|
[296] | 198 | saveAndTest(authInstance) |
---|
| 199 | |
---|
| 200 | // Authority #8 |
---|
| 201 | authInstance = new Authority(description:"Asset Manager", |
---|
[431] | 202 | authority:"ROLE_AssetManager") |
---|
[296] | 203 | saveAndTest(authInstance) |
---|
| 204 | |
---|
| 205 | // Authority #9 |
---|
| 206 | authInstance = new Authority(description:"Asset User", |
---|
[431] | 207 | authority:"ROLE_AssetUser") |
---|
[296] | 208 | saveAndTest(authInstance) |
---|
[431] | 209 | |
---|
| 210 | // Authority #10 |
---|
| 211 | authInstance = new Authority(description:"Production Manager", |
---|
| 212 | authority:"ROLE_ProductionManager") |
---|
| 213 | saveAndTest(authInstance) |
---|
| 214 | |
---|
| 215 | // Authority #11 |
---|
| 216 | authInstance = new Authority(description:"Production User", |
---|
| 217 | authority:"ROLE_ProductionUser") |
---|
| 218 | saveAndTest(authInstance) |
---|
[149] | 219 | } |
---|
| 220 | |
---|
[506] | 221 | void createBasePersonGroupTypes() { |
---|
| 222 | |
---|
| 223 | //PersonGroupType. |
---|
[149] | 224 | def personGroupTypeInstance |
---|
[506] | 225 | personGroupTypeInstance = new PersonGroupType(name:"Team") |
---|
[149] | 226 | saveAndTest(personGroupTypeInstance) |
---|
[506] | 227 | personGroupTypeInstance = new PersonGroupType(name:"Contractor") |
---|
[149] | 228 | saveAndTest(personGroupTypeInstance) |
---|
[506] | 229 | personGroupTypeInstance = new PersonGroupType(name:"Project Team") |
---|
[149] | 230 | saveAndTest(personGroupTypeInstance) |
---|
[506] | 231 | } |
---|
[149] | 232 | |
---|
[506] | 233 | void createBasePersonGroups() { |
---|
| 234 | |
---|
[149] | 235 | //PersonGroup |
---|
| 236 | def personGroupInstance |
---|
[506] | 237 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
| 238 | name:"Electrical - General") |
---|
[149] | 239 | saveAndTest(personGroupInstance) |
---|
[506] | 240 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
| 241 | name:"Mechanical - General") |
---|
[149] | 242 | saveAndTest(personGroupInstance) |
---|
[506] | 243 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
| 244 | name:"Production") |
---|
[149] | 245 | saveAndTest(personGroupInstance) |
---|
[506] | 246 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
| 247 | name:"AirCon Contractor") |
---|
[149] | 248 | saveAndTest(personGroupInstance) |
---|
[506] | 249 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
| 250 | name:"gnuMims") |
---|
[149] | 251 | saveAndTest(personGroupInstance) |
---|
| 252 | } |
---|
| 253 | |
---|
[199] | 254 | def createSystemPerson() { |
---|
| 255 | //Person |
---|
| 256 | def passClearText = "pass" |
---|
[291] | 257 | def passwordEncoded = authService.encodePassword(passClearText) |
---|
[199] | 258 | def personInstance |
---|
| 259 | |
---|
| 260 | //Person #1 |
---|
| 261 | personInstance = new Person(loginName:"system", |
---|
| 262 | firstName:"gnuMims", |
---|
| 263 | lastName:"System", |
---|
| 264 | description:'''This is a pseudo person that the application uses to insert data. DO NOT |
---|
| 265 | assign login authorities or change the details of this person.''', |
---|
| 266 | pass:passClearText, |
---|
[399] | 267 | password:passwordEncoded) |
---|
[199] | 268 | saveAndTest(personInstance) |
---|
| 269 | } |
---|
| 270 | |
---|
[149] | 271 | def createAdminPerson() { |
---|
| 272 | //Person |
---|
| 273 | def passClearText = "pass" |
---|
[291] | 274 | def passwordEncoded = authService.encodePassword(passClearText) |
---|
[149] | 275 | def personInstance |
---|
| 276 | |
---|
[199] | 277 | //Person #2 |
---|
[149] | 278 | personInstance = new Person(loginName:"admin", |
---|
| 279 | firstName:"Admin", |
---|
| 280 | lastName:"Powers", |
---|
[199] | 281 | description:'''Every time the application starts it ensures that the 'admin' login name is available. |
---|
| 282 | DO update the password and other details but keep the login name as 'admin'. ''', |
---|
[149] | 283 | pass:passClearText, |
---|
[399] | 284 | password:passwordEncoded) |
---|
[149] | 285 | saveAndTest(personInstance) |
---|
| 286 | personInstance.addToAuthorities(Authority.get(1)) |
---|
| 287 | } |
---|
| 288 | |
---|
| 289 | def createBasePersons() { |
---|
[199] | 290 | } |
---|
| 291 | |
---|
| 292 | def createDemoPersons() { |
---|
[149] | 293 | //Person |
---|
| 294 | def passClearText = "pass" |
---|
[291] | 295 | def passwordEncoded = authService.encodePassword(passClearText) |
---|
[149] | 296 | def personInstance |
---|
| 297 | |
---|
[199] | 298 | //Person #1 is system. |
---|
| 299 | //Person #2 is admin. |
---|
[149] | 300 | |
---|
[199] | 301 | //Person #3 |
---|
[149] | 302 | personInstance = new Person(loginName:"manager", |
---|
| 303 | firstName:"Demo", |
---|
| 304 | lastName:"Manager", |
---|
| 305 | pass:passClearText, |
---|
[399] | 306 | password:passwordEncoded) |
---|
[149] | 307 | saveAndTest(personInstance) |
---|
[431] | 308 | personInstance.addToAuthorities(Authority.get(2)) // ROLE_Manager. |
---|
| 309 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
[633] | 310 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
| 311 | personInstance.addToPurchasingGroups(PurchasingGroup.get(1)) |
---|
| 312 | personInstance.addToPurchasingGroups(PurchasingGroup.get(2)) |
---|
[149] | 313 | |
---|
[199] | 314 | //Person #4 |
---|
[149] | 315 | personInstance = new Person(loginName:"user", |
---|
| 316 | firstName:"Demo", |
---|
| 317 | lastName:"User", |
---|
| 318 | pass:passClearText, |
---|
[399] | 319 | password:passwordEncoded) |
---|
[149] | 320 | saveAndTest(personInstance) |
---|
[431] | 321 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 322 | personInstance.addToAuthorities(Authority.get(5)) // ROLE_TaskManager. |
---|
| 323 | personInstance.addToAuthorities(Authority.get(7)) // ROLE_InventoryUser. |
---|
| 324 | personInstance.addToAuthorities(Authority.get(9)) // ROLE_AssetUser. |
---|
[164] | 325 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 326 | |
---|
[199] | 327 | //Person #5 |
---|
[149] | 328 | personInstance = new Person(loginName:"craig", |
---|
| 329 | firstName:"Craig", |
---|
| 330 | lastName:"SuperSparky", |
---|
| 331 | pass:passClearText, |
---|
[399] | 332 | password:passwordEncoded) |
---|
[149] | 333 | saveAndTest(personInstance) |
---|
| 334 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[296] | 335 | personInstance.addToAuthorities(Authority.get(5)) |
---|
| 336 | personInstance.addToAuthorities(Authority.get(7)) |
---|
| 337 | personInstance.addToAuthorities(Authority.get(9)) |
---|
[164] | 338 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 339 | |
---|
[199] | 340 | //Person #6 |
---|
[149] | 341 | personInstance = new Person(loginName:"john", |
---|
| 342 | firstName:"John", |
---|
| 343 | lastName:"SuperFitter", |
---|
| 344 | pass:passClearText, |
---|
[399] | 345 | password:passwordEncoded) |
---|
[149] | 346 | saveAndTest(personInstance) |
---|
| 347 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[296] | 348 | personInstance.addToAuthorities(Authority.get(5)) |
---|
| 349 | personInstance.addToAuthorities(Authority.get(7)) |
---|
| 350 | personInstance.addToAuthorities(Authority.get(9)) |
---|
[164] | 351 | personInstance.addToPersonGroups(PersonGroup.get(2)) |
---|
[149] | 352 | |
---|
[199] | 353 | //Person #7 |
---|
[431] | 354 | personInstance = new Person(loginName:"production manager", |
---|
[149] | 355 | firstName:"Production", |
---|
[431] | 356 | lastName:"Manager", |
---|
[149] | 357 | pass:passClearText, |
---|
[399] | 358 | password:passwordEncoded) |
---|
[149] | 359 | saveAndTest(personInstance) |
---|
[431] | 360 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 361 | personInstance.addToAuthorities(Authority.get(10)) // ROLE_ProductionManager. |
---|
[164] | 362 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
[296] | 363 | |
---|
[431] | 364 | //Person #8 |
---|
| 365 | personInstance = new Person(loginName:"production", |
---|
| 366 | firstName:"Production", |
---|
| 367 | lastName:"User", |
---|
| 368 | pass:passClearText, |
---|
| 369 | password:passwordEncoded) |
---|
| 370 | saveAndTest(personInstance) |
---|
| 371 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 372 | personInstance.addToAuthorities(Authority.get(11)) // ROLE_ProductionUser. |
---|
| 373 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
| 374 | |
---|
| 375 | //Person #9 |
---|
[296] | 376 | personInstance = new Person(loginName:"testmanager", |
---|
| 377 | firstName:"Test", |
---|
| 378 | lastName:"Manager", |
---|
| 379 | pass:passClearText, |
---|
[399] | 380 | password:passwordEncoded) |
---|
[296] | 381 | saveAndTest(personInstance) |
---|
[431] | 382 | personInstance.addToAuthorities(Authority.get(3)) // ROLE_AppUser. |
---|
| 383 | personInstance.addToAuthorities(Authority.get(4)) // ROLE_TaskManager. |
---|
| 384 | personInstance.addToAuthorities(Authority.get(6)) // ROLE_InventoryManager. |
---|
| 385 | personInstance.addToAuthorities(Authority.get(8)) // ROLE_AssetManager. |
---|
[296] | 386 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
[149] | 387 | } |
---|
| 388 | |
---|
| 389 | /*********************** |
---|
| 390 | START OF UTILITIES |
---|
| 391 | ***********************/ |
---|
| 392 | |
---|
[265] | 393 | //These can redefined by the site at deployment time. |
---|
[266] | 394 | /// @todo: build an admin view so that only the value (definition) can be changed. |
---|
[265] | 395 | def createBaseDefinitions() { |
---|
| 396 | appConfigService.set("Department Definition", "A department as recongised by accounting.") |
---|
[393] | 397 | appConfigService.set("Site Definition", "The plant, work or production site.") |
---|
| 398 | appConfigService.set("Section Definition", "A logical grouping of assets, which may be an area, system or process \ |
---|
| 399 | as determined by design.") |
---|
| 400 | appConfigService.set("Asset Definition", |
---|
| 401 | "The complete asset as it is known on the site. \ |
---|
| 402 | Often purchased as a whole with the primary purpose of returning value by performing a function. \ |
---|
| 403 | An asset is made up of 1 or more sub assets and performs a complete function as specified by the designer.") |
---|
| 404 | appConfigService.set("Asset Sub Item 1 Name", |
---|
| 405 | "Sub Asset") |
---|
| 406 | appConfigService.set("Asset Sub Item 1 Definition", |
---|
| 407 | "A machine that performs part of a complete asset's function and often has a model number.") |
---|
| 408 | appConfigService.set("Asset Sub Item 2 Name", |
---|
| 409 | "Functional Assembly") |
---|
| 410 | appConfigService.set("Asset Sub Item 2 Definition", |
---|
| 411 | "Functional Assemblies are taken from the designer's functional list for the sub asset and are made up of sub \ |
---|
| 412 | assemblies that together perform that function.") |
---|
| 413 | appConfigService.set("Asset Sub Item 3 Name", |
---|
| 414 | "Sub Assembly Group") |
---|
| 415 | appConfigService.set("Asset Sub Item 3 Definition", |
---|
| 416 | "Group or type of part.") |
---|
| 417 | appConfigService.set("Asset Sub Item 4 Name", |
---|
| 418 | "Component Item") |
---|
| 419 | appConfigService.set("Asset Sub Item 4 Definition", |
---|
| 420 | "The smallest part that would be analysed for failure.") |
---|
[265] | 421 | } |
---|
| 422 | |
---|
[149] | 423 | def createDemoSites() { |
---|
| 424 | //Site |
---|
| 425 | def siteInstance |
---|
| 426 | |
---|
[321] | 427 | siteInstance = new Site(name: "CSM", |
---|
[314] | 428 | description: "Creek Side Mill") |
---|
[149] | 429 | saveAndTest(siteInstance) |
---|
| 430 | |
---|
[314] | 431 | siteInstance = new Site(name: "Jasper Street Depot", |
---|
| 432 | description: "Storage depot on Jasper Street.") |
---|
[149] | 433 | saveAndTest(siteInstance) |
---|
[162] | 434 | |
---|
[314] | 435 | siteInstance = new Site(name: "River Press", |
---|
| 436 | description: "Printing press site") |
---|
[162] | 437 | saveAndTest(siteInstance) |
---|
[149] | 438 | } |
---|
| 439 | |
---|
[162] | 440 | def createDemoDepartments() { |
---|
| 441 | |
---|
| 442 | //Department |
---|
| 443 | def departmentInstance |
---|
| 444 | |
---|
| 445 | //Department #1 |
---|
| 446 | departmentInstance = new Department(name: "Print Centre", |
---|
[314] | 447 | description: "Printing Department", |
---|
| 448 | site: Site.get(1)) |
---|
[162] | 449 | saveAndTest(departmentInstance) |
---|
| 450 | |
---|
| 451 | //Department #2 |
---|
[321] | 452 | departmentInstance = new Department(name: "Pulp Mill", |
---|
| 453 | description: "Business Department", |
---|
[314] | 454 | site: Site.get(2)) |
---|
[162] | 455 | saveAndTest(departmentInstance) |
---|
| 456 | } |
---|
| 457 | |
---|
[149] | 458 | def createBaseUnitsOfMeasure() { |
---|
| 459 | |
---|
| 460 | //UnitOfMeasure |
---|
| 461 | def unitOfMeasureInstance |
---|
| 462 | |
---|
| 463 | //UnitOfMeasure #1 |
---|
| 464 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 465 | saveAndTest(unitOfMeasureInstance) |
---|
| 466 | |
---|
| 467 | //UnitOfMeasure #2 |
---|
| 468 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 469 | saveAndTest(unitOfMeasureInstance) |
---|
| 470 | |
---|
| 471 | //UnitOfMeasure #3 |
---|
| 472 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 473 | saveAndTest(unitOfMeasureInstance) |
---|
| 474 | |
---|
| 475 | //UnitOfMeasure #4 |
---|
| 476 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 477 | saveAndTest(unitOfMeasureInstance) |
---|
| 478 | |
---|
| 479 | //UnitOfMeasure #5 |
---|
| 480 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 481 | saveAndTest(unitOfMeasureInstance) |
---|
[739] | 482 | |
---|
| 483 | //UnitOfMeasure #6 |
---|
| 484 | unitOfMeasureInstance = new UnitOfMeasure(name: "gram(s)") |
---|
| 485 | saveAndTest(unitOfMeasureInstance) |
---|
[149] | 486 | } |
---|
| 487 | |
---|
| 488 | def createBasePeriods() { |
---|
| 489 | |
---|
| 490 | //Period |
---|
| 491 | def periodInstance |
---|
| 492 | |
---|
| 493 | //Period #1 |
---|
| 494 | periodInstance = new Period(period: "Day(s)") |
---|
| 495 | saveAndTest(periodInstance) |
---|
| 496 | |
---|
| 497 | //Period #2 |
---|
| 498 | periodInstance = new Period(period: "Week(s)") |
---|
| 499 | saveAndTest(periodInstance) |
---|
| 500 | |
---|
| 501 | //Period #3 |
---|
| 502 | periodInstance = new Period(period: "Month(s)") |
---|
| 503 | saveAndTest(periodInstance) |
---|
| 504 | |
---|
| 505 | //Period #4 |
---|
| 506 | periodInstance = new Period(period: "Year(s)") |
---|
| 507 | saveAndTest(periodInstance) |
---|
| 508 | } |
---|
| 509 | |
---|
[397] | 510 | def createBaseSupplierTypes() { |
---|
[175] | 511 | |
---|
| 512 | // SupplierType |
---|
| 513 | def supplierTypeInstance |
---|
| 514 | |
---|
| 515 | // SupplierType #1 |
---|
[420] | 516 | supplierTypeInstance = new SupplierType(name: "Unknown", |
---|
| 517 | description: "Unknown supplier type") |
---|
| 518 | saveAndTest(supplierTypeInstance) |
---|
| 519 | |
---|
| 520 | // SupplierType #2 |
---|
[175] | 521 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
| 522 | description: "Original equipment supplier") |
---|
| 523 | saveAndTest(supplierTypeInstance) |
---|
| 524 | |
---|
[420] | 525 | // SupplierType #3 |
---|
[175] | 526 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
| 527 | description: "Local supplier") |
---|
| 528 | saveAndTest(supplierTypeInstance) |
---|
| 529 | } |
---|
| 530 | |
---|
[397] | 531 | def createBaseAddressTypes() { |
---|
| 532 | |
---|
| 533 | // AddressType |
---|
| 534 | def addressTypeInstance |
---|
| 535 | |
---|
| 536 | // AddressType #1 |
---|
| 537 | addressTypeInstance = new AddressType(name: "Postal", |
---|
| 538 | description: "A postal address.") |
---|
| 539 | saveAndTest(addressTypeInstance) |
---|
| 540 | |
---|
| 541 | // AddressType #2 |
---|
| 542 | addressTypeInstance = new AddressType(name: "Physical", |
---|
| 543 | description: "A physical address.") |
---|
| 544 | saveAndTest(addressTypeInstance) |
---|
| 545 | |
---|
| 546 | // AddressType #3 |
---|
| 547 | addressTypeInstance = new AddressType(name: "Postal & Physical", |
---|
| 548 | description: "An address that is both the postal and physical address.") |
---|
| 549 | saveAndTest(addressTypeInstance) |
---|
| 550 | |
---|
| 551 | // AddressType #4 |
---|
| 552 | addressTypeInstance = new AddressType(name: "Invoice", |
---|
| 553 | description: "An address to send invoices to.") |
---|
| 554 | saveAndTest(addressTypeInstance) |
---|
| 555 | |
---|
| 556 | // AddressType #5 |
---|
| 557 | addressTypeInstance = new AddressType(name: "Delivery", |
---|
| 558 | description: "An address to send deliveries to.") |
---|
| 559 | saveAndTest(addressTypeInstance) |
---|
| 560 | } |
---|
| 561 | |
---|
[402] | 562 | def createBaseContactTypes() { |
---|
| 563 | |
---|
| 564 | // ContactType |
---|
| 565 | def contactTypeInstance |
---|
| 566 | |
---|
| 567 | // ContactType #1 |
---|
| 568 | contactTypeInstance = new ContactType(name: "Email", |
---|
| 569 | description: "Email address.") |
---|
| 570 | saveAndTest(contactTypeInstance) |
---|
| 571 | |
---|
| 572 | // ContactType #2 |
---|
| 573 | contactTypeInstance = new ContactType(name: "Alternate Email", |
---|
| 574 | description: "Alternate email address.") |
---|
| 575 | saveAndTest(contactTypeInstance) |
---|
| 576 | |
---|
| 577 | // ContactType #3 |
---|
| 578 | contactTypeInstance = new ContactType(name: "Mobile", |
---|
| 579 | description: "Modile phone number.") |
---|
| 580 | saveAndTest(contactTypeInstance) |
---|
| 581 | |
---|
| 582 | // ContactType #4 |
---|
| 583 | contactTypeInstance = new ContactType(name: "Work Phone", |
---|
| 584 | description: "Work phone number.") |
---|
| 585 | saveAndTest(contactTypeInstance) |
---|
| 586 | |
---|
| 587 | // ContactType #5 |
---|
| 588 | contactTypeInstance = new ContactType(name: "Home Phone", |
---|
| 589 | description: "Home phone number.") |
---|
| 590 | saveAndTest(contactTypeInstance) |
---|
| 591 | |
---|
| 592 | // ContactType #6 |
---|
| 593 | contactTypeInstance = new ContactType(name: "Work Fax", |
---|
| 594 | description: "Work fax number.") |
---|
| 595 | saveAndTest(contactTypeInstance) |
---|
| 596 | |
---|
| 597 | // ContactType #7 |
---|
| 598 | contactTypeInstance = new ContactType(name: "Home Fax", |
---|
| 599 | description: "Home fax number.") |
---|
| 600 | saveAndTest(contactTypeInstance) |
---|
| 601 | |
---|
| 602 | // ContactType #8 |
---|
| 603 | contactTypeInstance = new ContactType(name: "Web Site", |
---|
| 604 | description: "Web site address.") |
---|
| 605 | saveAndTest(contactTypeInstance) |
---|
| 606 | |
---|
| 607 | // ContactType #9 |
---|
| 608 | contactTypeInstance = new ContactType(name: "Person", |
---|
| 609 | description: "Contact person.") |
---|
| 610 | saveAndTest(contactTypeInstance) |
---|
| 611 | } |
---|
| 612 | |
---|
[441] | 613 | def createBaseInventoryItemPurchaseTypes() { |
---|
| 614 | |
---|
| 615 | // InventoryItemPurchaseType |
---|
| 616 | def inventoryItemPurchaseTypeInstance |
---|
| 617 | |
---|
| 618 | // InventoryItemPurchaseType #1 |
---|
| 619 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Order Placed", |
---|
| 620 | description: "Order has been placed.") |
---|
| 621 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 622 | |
---|
| 623 | // InventoryItemPurchaseType #2 |
---|
| 624 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Received B/order To Come", |
---|
| 625 | description: "Order has been partially received.") |
---|
| 626 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
[597] | 627 | |
---|
[441] | 628 | // InventoryItemPurchaseType #3 |
---|
| 629 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Received Complete", |
---|
| 630 | description: "Order has been partially received.") |
---|
| 631 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 632 | |
---|
| 633 | // InventoryItemPurchaseType #4 |
---|
| 634 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Invoice Approved", |
---|
| 635 | description: "Invoice approved for payment.") |
---|
| 636 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 637 | } |
---|
| 638 | |
---|
[821] | 639 | def createBaseConditionSeverity() { |
---|
| 640 | |
---|
| 641 | // ConditionSeverity |
---|
| 642 | def conditionSeverity |
---|
| 643 | |
---|
| 644 | // ConditionSeverity #1 |
---|
| 645 | conditionSeverity = new ConditionSeverity(code: 'A', |
---|
| 646 | recommendation: 'Normal Monitoring').save(failOnError:true) |
---|
| 647 | |
---|
| 648 | // ConditionSeverity #2 |
---|
| 649 | conditionSeverity = new ConditionSeverity(code: 'B', |
---|
[847] | 650 | recommendation: 'Restored To Normal').save(failOnError:true) |
---|
[821] | 651 | |
---|
| 652 | // ConditionSeverity #3 |
---|
| 653 | conditionSeverity = new ConditionSeverity(code: 'C', |
---|
[847] | 654 | recommendation: 'Increase Monitoring').save(failOnError:true) |
---|
[821] | 655 | |
---|
| 656 | // ConditionSeverity #4 |
---|
| 657 | conditionSeverity = new ConditionSeverity(code: 'D', |
---|
[848] | 658 | recommendation: 'Schedule Followup').save(failOnError:true) |
---|
[847] | 659 | |
---|
| 660 | // ConditionSeverity #5 |
---|
| 661 | conditionSeverity = new ConditionSeverity(code: 'E', |
---|
[848] | 662 | recommendation: 'Schedule 2-4 weeks').save(failOnError:true) |
---|
[821] | 663 | } |
---|
| 664 | |
---|
[175] | 665 | def createDemoSuppliers() { |
---|
| 666 | |
---|
| 667 | // Supplier |
---|
| 668 | def supplierInstance |
---|
| 669 | |
---|
| 670 | // Supplier #1 |
---|
| 671 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
[420] | 672 | supplierType: SupplierType.get(2)) |
---|
[175] | 673 | saveAndTest(supplierInstance) |
---|
| 674 | |
---|
| 675 | // Supplier #2 |
---|
| 676 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
[420] | 677 | supplierType: SupplierType.get(3)) |
---|
[175] | 678 | saveAndTest(supplierInstance) |
---|
| 679 | } |
---|
| 680 | |
---|
[431] | 681 | def createDemoProductionReference() { |
---|
| 682 | |
---|
| 683 | // ProductionReference |
---|
| 684 | def productionReferenceInstance |
---|
| 685 | |
---|
| 686 | // ProductionReference #1 |
---|
| 687 | productionReferenceInstance = new ProductionReference(name: "Monday Production") |
---|
| 688 | saveAndTest(productionReferenceInstance) |
---|
| 689 | |
---|
| 690 | // ProductionReference #2 |
---|
| 691 | productionReferenceInstance = new ProductionReference(name: "Tuesday Production") |
---|
| 692 | saveAndTest(productionReferenceInstance) |
---|
| 693 | } |
---|
| 694 | |
---|
[633] | 695 | void createDemoPurchasingGroups() { |
---|
| 696 | |
---|
| 697 | // PurchasingGroup |
---|
| 698 | def purchasingGroupInstance |
---|
| 699 | |
---|
| 700 | purchasingGroupInstance = new PurchasingGroup(name:"R&M") |
---|
| 701 | saveAndTest(purchasingGroupInstance) |
---|
| 702 | |
---|
| 703 | purchasingGroupInstance = new PurchasingGroup(name:"Raw Materials") |
---|
| 704 | saveAndTest(purchasingGroupInstance) |
---|
| 705 | |
---|
| 706 | purchasingGroupInstance = new PurchasingGroup(name:"Safety") |
---|
| 707 | saveAndTest(purchasingGroupInstance) |
---|
| 708 | } |
---|
| 709 | |
---|
[441] | 710 | def createDemoCostCodes() { |
---|
| 711 | |
---|
| 712 | // CostCode |
---|
| 713 | def costCodeInstance |
---|
| 714 | |
---|
| 715 | // CostCode #1 |
---|
[633] | 716 | costCodeInstance = new CostCode(name: "Reelstand.172", |
---|
| 717 | purchasingGroup: PurchasingGroup.get(1)) |
---|
[441] | 718 | saveAndTest(costCodeInstance) |
---|
| 719 | |
---|
| 720 | // CostCode #2 |
---|
[633] | 721 | costCodeInstance = new CostCode(name: "Reelstand.CAPEX", |
---|
| 722 | purchasingGroup: PurchasingGroup.get(1)) |
---|
[441] | 723 | saveAndTest(costCodeInstance) |
---|
[633] | 724 | |
---|
| 725 | // CostCode #2 |
---|
| 726 | costCodeInstance = new CostCode(name: "PrintUnit.123", |
---|
| 727 | purchasingGroup: PurchasingGroup.get(3)) |
---|
| 728 | saveAndTest(costCodeInstance) |
---|
[441] | 729 | } |
---|
| 730 | |
---|
[149] | 731 | /********************* |
---|
| 732 | START OF TASK |
---|
| 733 | *********************/ |
---|
| 734 | |
---|
[180] | 735 | def createBaseTaskGroups() { |
---|
[149] | 736 | //TaskGroup |
---|
| 737 | def taskGroupInstance |
---|
| 738 | |
---|
[258] | 739 | //TaskGroup #1 |
---|
[149] | 740 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 741 | description:"Engineering daily activities") |
---|
| 742 | saveAndTest(taskGroupInstance) |
---|
| 743 | |
---|
[258] | 744 | //TaskGroup #2 |
---|
[149] | 745 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 746 | description:"Production daily activities") |
---|
| 747 | saveAndTest(taskGroupInstance) |
---|
| 748 | |
---|
[258] | 749 | //TaskGroup #3 |
---|
[149] | 750 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
[576] | 751 | description:"New site projects") |
---|
[149] | 752 | saveAndTest(taskGroupInstance) |
---|
[576] | 753 | |
---|
| 754 | //TaskGroup #4 |
---|
[587] | 755 | taskGroupInstance = new TaskGroup(name:"Electrical Dayshift", |
---|
[576] | 756 | description:"Group for dayshift electrical tasks") |
---|
| 757 | saveAndTest(taskGroupInstance) |
---|
| 758 | |
---|
| 759 | //TaskGroup #5 |
---|
[587] | 760 | taskGroupInstance = new TaskGroup(name:"Electrical Nightshift", |
---|
[576] | 761 | description:"Group for dayshift mechanical tasks") |
---|
| 762 | saveAndTest(taskGroupInstance) |
---|
| 763 | |
---|
| 764 | //TaskGroup #6 |
---|
[587] | 765 | taskGroupInstance = new TaskGroup(name:"Mechanical Dayshift", |
---|
[576] | 766 | description:"Group for nightshift electrical tasks") |
---|
| 767 | saveAndTest(taskGroupInstance) |
---|
| 768 | |
---|
| 769 | //TaskGroup #7 |
---|
[587] | 770 | taskGroupInstance = new TaskGroup(name:"Mechanical Nightshift", |
---|
[576] | 771 | description:"Group for nightshift mechanical tasks") |
---|
| 772 | saveAndTest(taskGroupInstance) |
---|
[149] | 773 | } |
---|
| 774 | |
---|
| 775 | def createBaseTaskStatus() { |
---|
| 776 | |
---|
| 777 | //TaskStatus |
---|
| 778 | def taskStatusInstance |
---|
| 779 | |
---|
[181] | 780 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
[149] | 781 | saveAndTest(taskStatusInstance) |
---|
| 782 | |
---|
[181] | 783 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
[149] | 784 | saveAndTest(taskStatusInstance) |
---|
| 785 | |
---|
[222] | 786 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
[149] | 787 | saveAndTest(taskStatusInstance) |
---|
| 788 | } |
---|
| 789 | |
---|
| 790 | def createBaseTaskPriorities() { |
---|
| 791 | |
---|
| 792 | //TaskPriority |
---|
| 793 | def taskPriorityInstance |
---|
| 794 | |
---|
[433] | 795 | taskPriorityInstance = new TaskPriority(name:"0 - Immediate") // #1 |
---|
[149] | 796 | saveAndTest(taskPriorityInstance) |
---|
| 797 | |
---|
[433] | 798 | taskPriorityInstance = new TaskPriority(name:"1 - Very High") // #2 |
---|
[149] | 799 | saveAndTest(taskPriorityInstance) |
---|
| 800 | |
---|
[433] | 801 | taskPriorityInstance = new TaskPriority(name:"2 - High") // #3 |
---|
[149] | 802 | saveAndTest(taskPriorityInstance) |
---|
| 803 | |
---|
[433] | 804 | taskPriorityInstance = new TaskPriority(name:"3 - Normal") // #4 |
---|
[149] | 805 | saveAndTest(taskPriorityInstance) |
---|
[433] | 806 | |
---|
| 807 | taskPriorityInstance = new TaskPriority(name:"4 - Low") // #5 |
---|
| 808 | saveAndTest(taskPriorityInstance) |
---|
| 809 | |
---|
| 810 | taskPriorityInstance = new TaskPriority(name:"5 - Minor") // #6 |
---|
| 811 | saveAndTest(taskPriorityInstance) |
---|
[149] | 812 | } |
---|
| 813 | |
---|
[252] | 814 | def createBaseTaskBudgetStatus() { |
---|
| 815 | |
---|
| 816 | //TaskBudgetStatus |
---|
| 817 | def taskBudgetStatusInstance |
---|
| 818 | |
---|
| 819 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
| 820 | saveAndTest(taskBudgetStatusInstance) |
---|
| 821 | |
---|
| 822 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
| 823 | saveAndTest(taskBudgetStatusInstance) |
---|
| 824 | } |
---|
| 825 | |
---|
[149] | 826 | def createBaseTaskTypes() { |
---|
| 827 | |
---|
| 828 | //TaskType |
---|
| 829 | def taskTypeInstance |
---|
| 830 | |
---|
[418] | 831 | taskTypeInstance = new TaskType(name:"Immediate Callout") // #1 |
---|
[149] | 832 | saveAndTest(taskTypeInstance) |
---|
| 833 | |
---|
[418] | 834 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #2 |
---|
[149] | 835 | saveAndTest(taskTypeInstance) |
---|
| 836 | |
---|
[418] | 837 | taskTypeInstance = new TaskType(name:"Scheduled") // #3 |
---|
[149] | 838 | saveAndTest(taskTypeInstance) |
---|
| 839 | |
---|
[418] | 840 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #4 |
---|
[149] | 841 | saveAndTest(taskTypeInstance) |
---|
| 842 | |
---|
[523] | 843 | taskTypeInstance = new TaskType(name:"Project") // #5 |
---|
[149] | 844 | saveAndTest(taskTypeInstance) |
---|
[749] | 845 | |
---|
| 846 | taskTypeInstance = new TaskType(name:"Parent PM") // #6 |
---|
| 847 | saveAndTest(taskTypeInstance) |
---|
[149] | 848 | } |
---|
| 849 | |
---|
[180] | 850 | def createBaseTaskModificationTypes() { |
---|
| 851 | |
---|
| 852 | //ModificationType |
---|
| 853 | def taskModificationTypeInstance |
---|
| 854 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
| 855 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
| 856 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
| 857 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
| 858 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
| 859 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
| 860 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
| 861 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
| 862 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
[251] | 863 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
| 864 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
[418] | 865 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Flagged for attention)").save() // #12 |
---|
| 866 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Attention flag cleared)").save() // #13 |
---|
[180] | 867 | } |
---|
| 868 | |
---|
[149] | 869 | def createDemoTasks() { |
---|
| 870 | |
---|
[180] | 871 | def taskResult |
---|
| 872 | def p = [:] |
---|
[149] | 873 | |
---|
| 874 | //Task #1 |
---|
[180] | 875 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[798] | 876 | taskPriority:TaskPriority.get(1), |
---|
[180] | 877 | taskType:TaskType.get(1), |
---|
| 878 | leadPerson:Person.get(2), |
---|
[534] | 879 | primaryAsset:Asset.get(4), |
---|
[418] | 880 | description:"Level sensor not working", |
---|
[180] | 881 | comment:"Has been noted as problematic, try recalibrating.", |
---|
[447] | 882 | targetStartDate: dateUtilService.today, |
---|
| 883 | targetCompletionDate: dateUtilService.today] |
---|
[149] | 884 | |
---|
[394] | 885 | taskResult = taskService.save(p) |
---|
[750] | 886 | taskService.approve(taskResult.taskInstance) |
---|
[180] | 887 | |
---|
[149] | 888 | //Task #2 |
---|
[180] | 889 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 890 | taskPriority:TaskPriority.get(2), |
---|
[418] | 891 | taskType:TaskType.get(3), |
---|
[149] | 892 | leadPerson:Person.get(5), |
---|
[534] | 893 | primaryAsset:Asset.get(4), |
---|
[149] | 894 | description:"Some follow-up work", |
---|
| 895 | comment:"Some help required", |
---|
[210] | 896 | targetStartDate: dateUtilService.tomorrow, |
---|
[447] | 897 | targetCompletionDate: dateUtilService.tomorrow, |
---|
[529] | 898 | parentTask: Task.list()[0]] |
---|
[149] | 899 | |
---|
[394] | 900 | taskResult = taskService.save(p) |
---|
[750] | 901 | taskService.approve(taskResult.taskInstance) |
---|
[180] | 902 | |
---|
[149] | 903 | //Task #3 |
---|
[180] | 904 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 905 | taskPriority:TaskPriority.get(2), |
---|
[418] | 906 | taskType:TaskType.get(3), |
---|
[149] | 907 | leadPerson:Person.get(5), |
---|
[534] | 908 | primaryAsset:Asset.get(4), |
---|
[418] | 909 | description:"A Sub Task can be created from the 'Sub Task' tab.", |
---|
[149] | 910 | comment:"Some help required", |
---|
[210] | 911 | targetStartDate: dateUtilService.yesterday, |
---|
[447] | 912 | targetCompletionDate: dateUtilService.yesterday, |
---|
[529] | 913 | parentTask: Task.list()[0]] |
---|
[149] | 914 | |
---|
[394] | 915 | taskResult = taskService.save(p) |
---|
[750] | 916 | taskService.approve(taskResult.taskInstance) |
---|
[180] | 917 | |
---|
[149] | 918 | //Task #4 |
---|
[180] | 919 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[534] | 920 | taskPriority:TaskPriority.get(2), |
---|
| 921 | taskType:TaskType.get(2), |
---|
| 922 | leadPerson:Person.get(4), |
---|
| 923 | primaryAsset:Asset.get(4), |
---|
| 924 | description:"Please replace sensor at next available opportunity.", |
---|
| 925 | comment:"Nothing else has worked. So we now require the part to be replaced.", |
---|
[447] | 926 | targetStartDate: dateUtilService.today, |
---|
| 927 | targetCompletionDate: dateUtilService.oneWeekFromNow, |
---|
[529] | 928 | parentTask: Task.list()[0]] |
---|
[149] | 929 | |
---|
[394] | 930 | taskResult = taskService.save(p) |
---|
[750] | 931 | taskService.approve(taskResult.taskInstance) |
---|
[180] | 932 | |
---|
[149] | 933 | //Task #5 |
---|
[180] | 934 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
[534] | 935 | taskPriority:TaskPriority.get(2), |
---|
| 936 | taskType:TaskType.get(3), |
---|
| 937 | leadPerson:Person.get(6), |
---|
| 938 | primaryAsset:Asset.get(1), |
---|
| 939 | description:"Production Task", |
---|
| 940 | comment:"Production task for specific production run or shift", |
---|
[447] | 941 | targetStartDate: dateUtilService.today - 6, |
---|
| 942 | targetCompletionDate: dateUtilService.today - 6] |
---|
[149] | 943 | |
---|
[394] | 944 | taskResult = taskService.save(p) |
---|
[750] | 945 | taskService.approve(taskResult.taskInstance) |
---|
[180] | 946 | |
---|
[149] | 947 | //Task #6 |
---|
[199] | 948 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[534] | 949 | taskPriority:TaskPriority.get(4), |
---|
[750] | 950 | taskType:TaskType.get(6), |
---|
[534] | 951 | leadPerson:Person.get(4), |
---|
| 952 | primaryAsset:Asset.get(2), |
---|
| 953 | description:"This is a recurring preventative maintenance task.", |
---|
| 954 | comment:"If there is a parent task specified then this is a generated sub task, if there is a recurring schedule specified then this is a parent task.", |
---|
[447] | 955 | targetStartDate: dateUtilService.today, |
---|
| 956 | targetCompletionDate: dateUtilService.today + 30] |
---|
[180] | 957 | |
---|
[394] | 958 | taskResult = taskService.save(p) |
---|
[534] | 959 | taskService.approve(taskResult.taskInstance) |
---|
[750] | 960 | |
---|
| 961 | //Task #7 |
---|
| 962 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 963 | taskPriority:TaskPriority.get(4), |
---|
| 964 | taskType:TaskType.get(6), |
---|
| 965 | leadPerson:Person.get(4), |
---|
| 966 | primaryAsset:Asset.get(2), |
---|
| 967 | description:"100hr Service.", |
---|
| 968 | comment:"Based on OEM service.", |
---|
| 969 | targetStartDate: dateUtilService.today, |
---|
| 970 | targetCompletionDate: dateUtilService.today + 1] |
---|
| 971 | |
---|
| 972 | taskResult = taskService.save(p) |
---|
| 973 | taskService.approve(taskResult.taskInstance) |
---|
[149] | 974 | } |
---|
| 975 | |
---|
| 976 | def createBaseEntryTypes() { |
---|
| 977 | |
---|
| 978 | //EntryType |
---|
| 979 | def entryTypeInstance |
---|
| 980 | |
---|
[190] | 981 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
[149] | 982 | saveAndTest(entryTypeInstance) |
---|
| 983 | |
---|
[418] | 984 | entryTypeInstance = new EntryType(name:"Cause") // #2 |
---|
[149] | 985 | saveAndTest(entryTypeInstance) |
---|
| 986 | |
---|
[418] | 987 | entryTypeInstance = new EntryType(name:"Work Done") // #3 |
---|
[149] | 988 | saveAndTest(entryTypeInstance) |
---|
| 989 | |
---|
[418] | 990 | entryTypeInstance = new EntryType(name:"Production Note") // #4 |
---|
[149] | 991 | saveAndTest(entryTypeInstance) |
---|
[418] | 992 | |
---|
| 993 | entryTypeInstance = new EntryType(name:"Work Request") // #5 |
---|
| 994 | saveAndTest(entryTypeInstance) |
---|
[826] | 995 | |
---|
| 996 | entryTypeInstance = new EntryType(name:"PM Entry") // #6 |
---|
| 997 | saveAndTest(entryTypeInstance) |
---|
[149] | 998 | } |
---|
| 999 | |
---|
| 1000 | def createDemoEntries() { |
---|
| 1001 | |
---|
[190] | 1002 | def entryResult |
---|
| 1003 | def p = [:] |
---|
[149] | 1004 | |
---|
| 1005 | //Entry #1 |
---|
[529] | 1006 | p = [task: Task.list()[0], |
---|
[190] | 1007 | entryType: EntryType.get(1), |
---|
| 1008 | comment: "This level sensor is causing us trouble.", |
---|
| 1009 | durationMinute: 20] |
---|
[149] | 1010 | |
---|
[394] | 1011 | entryResult = taskService.saveEntry(p) |
---|
[190] | 1012 | |
---|
[149] | 1013 | //Entry #2 |
---|
[529] | 1014 | p = [task: Task.list()[0], |
---|
[418] | 1015 | entryType: EntryType.get(3), |
---|
[190] | 1016 | comment: "Cleaned sensor, see how it goes.", |
---|
| 1017 | durationMinute: 30] |
---|
[149] | 1018 | |
---|
[394] | 1019 | entryResult = taskService.saveEntry(p) |
---|
[190] | 1020 | |
---|
[149] | 1021 | //Entry #3 |
---|
[529] | 1022 | p = [task: Task.list()[0], |
---|
[418] | 1023 | entryType: EntryType.get(3), |
---|
[190] | 1024 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
| 1025 | durationMinute: 20] |
---|
| 1026 | |
---|
[394] | 1027 | entryResult = taskService.saveEntry(p) |
---|
[534] | 1028 | |
---|
| 1029 | //Entry #4 |
---|
[750] | 1030 | p = [task: Task.list()[4], |
---|
[534] | 1031 | entryType: EntryType.get(3), |
---|
[750] | 1032 | comment: "Work done as per procedure.", |
---|
[534] | 1033 | durationMinute: 55] |
---|
| 1034 | |
---|
| 1035 | entryResult = taskService.saveEntry(p) |
---|
[149] | 1036 | } |
---|
| 1037 | |
---|
[242] | 1038 | def createDemoAssignedGroups() { |
---|
| 1039 | |
---|
[251] | 1040 | def result |
---|
| 1041 | def p = [:] |
---|
[242] | 1042 | |
---|
| 1043 | //AssignedGroup #1 |
---|
[251] | 1044 | p = [personGroup: PersonGroup.get(1), |
---|
[529] | 1045 | task: Task.list()[0], |
---|
[251] | 1046 | estimatedHour: 2, |
---|
| 1047 | estimatedMinute: 30] |
---|
| 1048 | result = assignedGroupService.save(p) |
---|
[242] | 1049 | |
---|
| 1050 | //AssignedGroup #2 |
---|
[251] | 1051 | p = [personGroup: PersonGroup.get(2), |
---|
[529] | 1052 | task: Task.list()[0], |
---|
[251] | 1053 | estimatedHour: 1, |
---|
| 1054 | estimatedMinute: 0] |
---|
| 1055 | result = assignedGroupService.save(p) |
---|
[242] | 1056 | } |
---|
| 1057 | |
---|
[241] | 1058 | def createDemoAssignedPersons() { |
---|
[149] | 1059 | |
---|
[251] | 1060 | def result |
---|
| 1061 | def p = [:] |
---|
[149] | 1062 | |
---|
[241] | 1063 | //AssignedPerson #1 |
---|
[534] | 1064 | p = [person: Person.get(3), // Demo Manager. |
---|
| 1065 | task: Task.list()[5], |
---|
[251] | 1066 | estimatedHour: 1, |
---|
| 1067 | estimatedMinute: 20] |
---|
| 1068 | result = assignedPersonService.save(p) |
---|
[149] | 1069 | |
---|
[241] | 1070 | //AssignedPerson #2 |
---|
[534] | 1071 | p = [person: Person.get(4), // Demo User. |
---|
[750] | 1072 | task: Task.list()[5], |
---|
| 1073 | estimatedHour: 1, |
---|
| 1074 | estimatedMinute: 20] |
---|
| 1075 | result = assignedPersonService.save(p) |
---|
| 1076 | |
---|
| 1077 | //AssignedPerson #3 |
---|
| 1078 | p = [person: Person.get(3), // Demo Manager. |
---|
| 1079 | task: Task.list()[6], |
---|
[251] | 1080 | estimatedHour: 3, |
---|
| 1081 | estimatedMinute: 30] |
---|
| 1082 | result = assignedPersonService.save(p) |
---|
[750] | 1083 | |
---|
| 1084 | //AssignedPerson #4 |
---|
| 1085 | p = [person: Person.get(4), // Demo User. |
---|
| 1086 | task: Task.list()[6], |
---|
| 1087 | estimatedHour: 3, |
---|
| 1088 | estimatedMinute: 30] |
---|
| 1089 | result = assignedPersonService.save(p) |
---|
[149] | 1090 | } |
---|
| 1091 | |
---|
[534] | 1092 | def createBaseMaintenancePolicies() { |
---|
| 1093 | |
---|
| 1094 | //MaintenancePolicy |
---|
| 1095 | def maintenancePolicyInstance |
---|
| 1096 | |
---|
| 1097 | //MaintenancePolicy #1 |
---|
| 1098 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 1099 | saveAndTest(maintenancePolicyInstance) |
---|
| 1100 | |
---|
| 1101 | //MaintenancePolicy #2 |
---|
| 1102 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 1103 | saveAndTest(maintenancePolicyInstance) |
---|
| 1104 | |
---|
| 1105 | //MaintenancePolicy #3 |
---|
| 1106 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 1107 | saveAndTest(maintenancePolicyInstance) |
---|
| 1108 | |
---|
| 1109 | //MaintenancePolicy #4 |
---|
| 1110 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 1111 | saveAndTest(maintenancePolicyInstance) |
---|
| 1112 | |
---|
| 1113 | //MaintenancePolicy #5 |
---|
| 1114 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 1115 | saveAndTest(maintenancePolicyInstance) |
---|
| 1116 | |
---|
| 1117 | //MaintenancePolicy #6 |
---|
| 1118 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
| 1119 | saveAndTest(maintenancePolicyInstance) |
---|
| 1120 | |
---|
| 1121 | //MaintenancePolicy #7 |
---|
| 1122 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
| 1123 | saveAndTest(maintenancePolicyInstance) |
---|
| 1124 | } |
---|
| 1125 | |
---|
| 1126 | def createDemoTaskProcedure() { |
---|
| 1127 | |
---|
| 1128 | //TaskProcedure |
---|
| 1129 | def taskProcedureInstance |
---|
[798] | 1130 | def taskInstance |
---|
| 1131 | def person = Person.get(3) |
---|
[534] | 1132 | |
---|
[798] | 1133 | taskInstance = Task.list()[6] |
---|
| 1134 | taskProcedureInstance = new TaskProcedure(linkedTask: taskInstance, |
---|
| 1135 | createdBy: person, |
---|
| 1136 | lastUpdatedBy: person) |
---|
[534] | 1137 | saveAndTest(taskProcedureInstance) |
---|
[798] | 1138 | taskProcedureInstance.addToTasks(taskInstance) |
---|
[750] | 1139 | |
---|
[798] | 1140 | taskInstance = Task.list()[4] |
---|
| 1141 | taskProcedureInstance = new TaskProcedure(linkedTask: taskInstance, |
---|
| 1142 | createdBy: person, |
---|
| 1143 | lastUpdatedBy: person) |
---|
[750] | 1144 | saveAndTest(taskProcedureInstance) |
---|
[798] | 1145 | taskProcedureInstance.addToTasks(taskInstance) |
---|
[534] | 1146 | } |
---|
| 1147 | |
---|
| 1148 | def createDemoMaintenanceActions() { |
---|
| 1149 | |
---|
| 1150 | //MaintenanceAction |
---|
| 1151 | def maintenanceActionInstance |
---|
[798] | 1152 | def taskProcedure = TaskProcedure.get(1) |
---|
| 1153 | def assetSubItem = AssetSubItem.get(6) |
---|
[534] | 1154 | |
---|
| 1155 | //MaintenanceAction #1 |
---|
| 1156 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 1157 | procedureStepNumber: 10, |
---|
[798] | 1158 | assetSubItem: assetSubItem, |
---|
| 1159 | taskProcedure: taskProcedure) |
---|
| 1160 | taskProcedure.addToMaintenanceActions(maintenanceActionInstance) |
---|
[534] | 1161 | |
---|
| 1162 | //MaintenanceAction #2 |
---|
| 1163 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 1164 | procedureStepNumber: 20, |
---|
[798] | 1165 | assetSubItem: assetSubItem, |
---|
| 1166 | taskProcedure: taskProcedure) |
---|
| 1167 | taskProcedure.addToMaintenanceActions(maintenanceActionInstance) |
---|
[534] | 1168 | |
---|
| 1169 | //MaintenanceAction #3 |
---|
| 1170 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 1171 | procedureStepNumber: 30, |
---|
[798] | 1172 | assetSubItem: assetSubItem, |
---|
| 1173 | taskProcedure: taskProcedure) |
---|
| 1174 | taskProcedure.addToMaintenanceActions(maintenanceActionInstance) |
---|
| 1175 | |
---|
| 1176 | saveAndTest(taskProcedure) |
---|
[534] | 1177 | } |
---|
| 1178 | |
---|
[149] | 1179 | def createDemoTaskRecurringSchedules() { |
---|
| 1180 | |
---|
| 1181 | //TaskRecurringSchedule |
---|
| 1182 | def taskRecurringScheduleInstance |
---|
| 1183 | |
---|
| 1184 | //TaskRecurringSchedule #1 |
---|
[529] | 1185 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0], |
---|
[149] | 1186 | recurEvery: 1, |
---|
[199] | 1187 | recurPeriod: Period.get(2), |
---|
[210] | 1188 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 1189 | generateAhead: 1, |
---|
[199] | 1190 | taskDuration: 2, |
---|
| 1191 | taskDurationPeriod: Period.get(1), |
---|
| 1192 | enabled: false) |
---|
[149] | 1193 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 1194 | |
---|
| 1195 | //TaskRecurringSchedule #2 |
---|
[534] | 1196 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[5], |
---|
[149] | 1197 | recurEvery: 1, |
---|
| 1198 | recurPeriod: Period.get(1), |
---|
[210] | 1199 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 1200 | generateAhead: 1, |
---|
| 1201 | taskDuration: 1, |
---|
[199] | 1202 | taskDurationPeriod: Period.get(1), |
---|
| 1203 | enabled: true) |
---|
[149] | 1204 | saveAndTest(taskRecurringScheduleInstance) |
---|
[750] | 1205 | |
---|
| 1206 | //TaskRecurringSchedule #3 |
---|
| 1207 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[6], |
---|
| 1208 | recurEvery: 1, |
---|
| 1209 | recurPeriod: Period.get(1), |
---|
| 1210 | nextTargetStartDate: dateUtilService.today, |
---|
| 1211 | generateAhead: 1, |
---|
| 1212 | taskDuration: 1, |
---|
| 1213 | taskDurationPeriod: Period.get(1), |
---|
| 1214 | enabled: true) |
---|
| 1215 | saveAndTest(taskRecurringScheduleInstance) |
---|
[149] | 1216 | } |
---|
| 1217 | |
---|
| 1218 | /************************* |
---|
| 1219 | START OF INVENTORY |
---|
| 1220 | **************************/ |
---|
| 1221 | |
---|
| 1222 | def createDemoInventoryStores() { |
---|
| 1223 | |
---|
| 1224 | //InventoryStore |
---|
| 1225 | def inventoryStoreInstance |
---|
| 1226 | |
---|
| 1227 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 1228 | saveAndTest(inventoryStoreInstance) |
---|
| 1229 | |
---|
| 1230 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 1231 | saveAndTest(inventoryStoreInstance) |
---|
| 1232 | } |
---|
| 1233 | |
---|
[175] | 1234 | def createDemoInventoryLocations() { |
---|
[149] | 1235 | |
---|
[175] | 1236 | // InventoryLocation |
---|
| 1237 | def inventoryLocation |
---|
[149] | 1238 | |
---|
[175] | 1239 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 1240 | saveAndTest(inventoryLocation) |
---|
[149] | 1241 | |
---|
[418] | 1242 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(2), name: "C55") |
---|
[175] | 1243 | saveAndTest(inventoryLocation) |
---|
[149] | 1244 | } |
---|
| 1245 | |
---|
| 1246 | def createDemoInventoryGroups() { |
---|
| 1247 | |
---|
| 1248 | //InventoryGroup |
---|
| 1249 | def inventoryGroupInstance |
---|
| 1250 | |
---|
| 1251 | //InventoryGroup #1 |
---|
| 1252 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 1253 | saveAndTest(inventoryGroupInstance) |
---|
| 1254 | |
---|
| 1255 | //InventoryGroup #2 |
---|
| 1256 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 1257 | saveAndTest(inventoryGroupInstance) |
---|
| 1258 | |
---|
| 1259 | //InventoryGroup #3 |
---|
| 1260 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 1261 | saveAndTest(inventoryGroupInstance) |
---|
| 1262 | |
---|
| 1263 | //InventoryGroup #4 |
---|
| 1264 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 1265 | saveAndTest(inventoryGroupInstance) |
---|
| 1266 | } |
---|
| 1267 | |
---|
| 1268 | def createBaseInventoryTypes() { |
---|
| 1269 | |
---|
| 1270 | //InventoryType |
---|
| 1271 | def inventoryTypeInstance |
---|
| 1272 | |
---|
[694] | 1273 | //InventoryType #1 |
---|
| 1274 | inventoryTypeInstance = new InventoryType(name: "Consumable", |
---|
| 1275 | description: "Standard inventory items that are received as new.") |
---|
[149] | 1276 | saveAndTest(inventoryTypeInstance) |
---|
| 1277 | |
---|
[694] | 1278 | //InventoryType #2 |
---|
| 1279 | inventoryTypeInstance = new InventoryType(name: "Rotable", |
---|
| 1280 | description: "Repairable inventory items that are to be tracked as rotables.") |
---|
[149] | 1281 | saveAndTest(inventoryTypeInstance) |
---|
[694] | 1282 | |
---|
| 1283 | //InventoryType #3 |
---|
| 1284 | inventoryTypeInstance = new InventoryType(name: "Service", |
---|
| 1285 | description: "Provided services from contractors etc.") |
---|
| 1286 | saveAndTest(inventoryTypeInstance) |
---|
| 1287 | |
---|
| 1288 | //InventoryType #4 |
---|
| 1289 | inventoryTypeInstance = new InventoryType(name: "Tool", |
---|
| 1290 | description: "Tools that are held as inventory.") |
---|
| 1291 | saveAndTest(inventoryTypeInstance) |
---|
[149] | 1292 | } |
---|
| 1293 | |
---|
[175] | 1294 | def createBaseInventoryMovementTypes() { |
---|
| 1295 | |
---|
| 1296 | // InventoryMovementType |
---|
| 1297 | def inventoryMovementTypeInstance |
---|
| 1298 | |
---|
| 1299 | // InventoryMovementType #1 |
---|
[177] | 1300 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 1301 | incrementsInventory: false) |
---|
[175] | 1302 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1303 | |
---|
| 1304 | // InventoryMovementType #2 |
---|
[177] | 1305 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 1306 | incrementsInventory: true) |
---|
[175] | 1307 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1308 | |
---|
| 1309 | // InventoryMovementType #3 |
---|
[177] | 1310 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 1311 | incrementsInventory: true) |
---|
[175] | 1312 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 1313 | |
---|
| 1314 | // InventoryMovementType #4 |
---|
| 1315 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 1316 | incrementsInventory: true) |
---|
| 1317 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1318 | |
---|
| 1319 | // InventoryMovementType #5 |
---|
| 1320 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 1321 | incrementsInventory: false) |
---|
| 1322 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 1323 | } |
---|
| 1324 | |
---|
[149] | 1325 | def createDemoInventoryItems() { |
---|
| 1326 | |
---|
| 1327 | //InventoryItem |
---|
| 1328 | def inventoryItemInstance |
---|
[665] | 1329 | def currency = Currency.getInstance('AUD') |
---|
[149] | 1330 | |
---|
[549] | 1331 | def pictureResource = grailsApplication.mainContext.getResource('images/logo.png') |
---|
| 1332 | |
---|
[149] | 1333 | //InventoryItem #1 |
---|
| 1334 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 1335 | inventoryType: InventoryType.get(1), |
---|
| 1336 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 1337 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 1338 | name: "Hemp rope", |
---|
| 1339 | description: "Natural hemp rope.", |
---|
[665] | 1340 | estimatedUnitPriceAmount: 1.23, |
---|
| 1341 | estimatedUnitPriceCurrency: currency, |
---|
[175] | 1342 | unitsInStock: 2, |
---|
[149] | 1343 | reorderPoint: 0) |
---|
| 1344 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1345 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1346 | |
---|
| 1347 | //InventoryItem #2 |
---|
| 1348 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 1349 | inventoryType: InventoryType.get(1), |
---|
| 1350 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 1351 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 1352 | name: "Cotton Rope 12mm", |
---|
| 1353 | description: "A soft natural rope made from cotton.", |
---|
[665] | 1354 | estimatedUnitPriceAmount: 2.50, |
---|
| 1355 | estimatedUnitPriceCurrency: currency, |
---|
[175] | 1356 | unitsInStock: 2, |
---|
[149] | 1357 | reorderPoint: 0) |
---|
| 1358 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1359 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1360 | |
---|
| 1361 | //InventoryItem #3 |
---|
| 1362 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 1363 | inventoryType: InventoryType.get(1), |
---|
| 1364 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1365 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1366 | name: "2305-2RS", |
---|
| 1367 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[665] | 1368 | estimatedUnitPriceAmount: 5, |
---|
| 1369 | estimatedUnitPriceCurrency: currency, |
---|
[175] | 1370 | unitsInStock: 3, |
---|
[149] | 1371 | reorderPoint: 2) |
---|
| 1372 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1373 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1374 | |
---|
| 1375 | //InventoryItem #4 |
---|
| 1376 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 1377 | inventoryType: InventoryType.get(1), |
---|
| 1378 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1379 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1380 | name: "L1592-K10", |
---|
| 1381 | description: "10kW contactor", |
---|
[665] | 1382 | estimatedUnitPriceAmount: 180, |
---|
| 1383 | estimatedUnitPriceCurrency: currency, |
---|
[175] | 1384 | unitsInStock: 4, |
---|
[149] | 1385 | reorderPoint: 0) |
---|
| 1386 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1387 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1388 | |
---|
| 1389 | //InventoryItem #5 |
---|
| 1390 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 1391 | inventoryType: InventoryType.get(1), |
---|
| 1392 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1393 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1394 | name: "6205-ZZ", |
---|
| 1395 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[665] | 1396 | estimatedUnitPriceAmount: 3.45, |
---|
| 1397 | estimatedUnitPriceCurrency: currency, |
---|
[175] | 1398 | unitsInStock: 5, |
---|
[149] | 1399 | reorderPoint: 2) |
---|
| 1400 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1401 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1402 | } |
---|
| 1403 | |
---|
| 1404 | /******************* |
---|
| 1405 | START OF ASSET |
---|
| 1406 | *******************/ |
---|
| 1407 | |
---|
[270] | 1408 | def createBaseExtenededAttributeTypes() { |
---|
| 1409 | |
---|
| 1410 | //ExtendedAttributeType |
---|
| 1411 | def extendedAttributeTypeInstance |
---|
| 1412 | |
---|
| 1413 | //ExtendedAttributeType #1 |
---|
| 1414 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
| 1415 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1416 | |
---|
| 1417 | //ExtendedAttributeType #2 |
---|
| 1418 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
| 1419 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1420 | |
---|
| 1421 | //ExtendedAttributeType #3 |
---|
| 1422 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
| 1423 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1424 | |
---|
| 1425 | //ExtendedAttributeType #4 |
---|
| 1426 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
| 1427 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1428 | |
---|
| 1429 | //ExtendedAttributeType #5 |
---|
| 1430 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
| 1431 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1432 | |
---|
| 1433 | //ExtendedAttributeType #6 |
---|
| 1434 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
| 1435 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1436 | |
---|
| 1437 | //ExtendedAttributeType #7 |
---|
| 1438 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
| 1439 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1440 | |
---|
| 1441 | //ExtendedAttributeType #8 |
---|
[650] | 1442 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer") |
---|
[270] | 1443 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1444 | |
---|
| 1445 | //ExtendedAttributeType #9 |
---|
[678] | 1446 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "ecr") |
---|
[270] | 1447 | saveAndTest(extendedAttributeTypeInstance) |
---|
[650] | 1448 | |
---|
| 1449 | //ExtendedAttributeType #10 |
---|
[678] | 1450 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Risk Level") |
---|
[650] | 1451 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1452 | |
---|
| 1453 | //ExtendedAttributeType #11 |
---|
| 1454 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Safe Work Procedure") |
---|
| 1455 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1456 | |
---|
| 1457 | //ExtendedAttributeType #12 |
---|
[678] | 1458 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Regulatory Requirement") |
---|
[650] | 1459 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1460 | |
---|
| 1461 | //ExtendedAttributeType #13 |
---|
[678] | 1462 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Maintenance % Completion") |
---|
[650] | 1463 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1464 | |
---|
| 1465 | //ExtendedAttributeType #14 |
---|
| 1466 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Registration Required") |
---|
| 1467 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1468 | |
---|
| 1469 | //ExtendedAttributeType #15 |
---|
| 1470 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Registration Expiry Date") |
---|
| 1471 | saveAndTest(extendedAttributeTypeInstance) |
---|
[685] | 1472 | |
---|
| 1473 | //ExtendedAttributeType #16 |
---|
| 1474 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Asset Condition") |
---|
| 1475 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1476 | |
---|
| 1477 | //ExtendedAttributeType #17 |
---|
| 1478 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Asset Number") |
---|
| 1479 | saveAndTest(extendedAttributeTypeInstance) |
---|
[270] | 1480 | } |
---|
| 1481 | |
---|
[268] | 1482 | def createDemoSections() { |
---|
[149] | 1483 | |
---|
[268] | 1484 | //Section |
---|
| 1485 | def sectionInstance |
---|
[149] | 1486 | |
---|
[268] | 1487 | //Section #1 |
---|
[688] | 1488 | sectionInstance = new Section(name: "A-Press", |
---|
[314] | 1489 | description: "Press Section", |
---|
| 1490 | site: Site.get(3), |
---|
| 1491 | department: Department.get(1)) |
---|
[268] | 1492 | saveAndTest(sectionInstance) |
---|
[149] | 1493 | |
---|
[268] | 1494 | //Section #2 |
---|
[321] | 1495 | sectionInstance = new Section(name: "CSM-Delig", |
---|
[314] | 1496 | description: "Pulp Delignification", |
---|
| 1497 | site: Site.get(1), |
---|
| 1498 | department: Department.get(2)) |
---|
[268] | 1499 | saveAndTest(sectionInstance) |
---|
[149] | 1500 | |
---|
[268] | 1501 | //Section #3 |
---|
[321] | 1502 | sectionInstance = new Section(name: "CSM-Aux", |
---|
[314] | 1503 | description: "Auxilliary Section", |
---|
| 1504 | site: Site.get(1), |
---|
| 1505 | department: Department.get(1)) |
---|
[268] | 1506 | saveAndTest(sectionInstance) |
---|
[149] | 1507 | } |
---|
| 1508 | |
---|
[276] | 1509 | def createDemoAssetTree() { |
---|
[149] | 1510 | |
---|
[270] | 1511 | //Asset |
---|
| 1512 | def assetInstance |
---|
[149] | 1513 | |
---|
[270] | 1514 | //Asset #1 |
---|
[276] | 1515 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
[314] | 1516 | description: "Complete Printing Asset #22", |
---|
[650] | 1517 | comment: "Includes everthing directly attached to the tower.", |
---|
[314] | 1518 | section: Section.get(1)) |
---|
[276] | 1519 | saveAndTest(assetInstance1) |
---|
[149] | 1520 | |
---|
[270] | 1521 | //Asset #2 |
---|
[276] | 1522 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
[314] | 1523 | description: "Complete Printing Asset #21", |
---|
| 1524 | section: Section.get(1)) |
---|
[276] | 1525 | saveAndTest(assetInstance2) |
---|
[149] | 1526 | |
---|
[270] | 1527 | //Asset #3 |
---|
[276] | 1528 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
[314] | 1529 | description: "Complete Printing Asset #23", |
---|
| 1530 | section: Section.get(1)) |
---|
[276] | 1531 | saveAndTest(assetInstance3) |
---|
[149] | 1532 | |
---|
[270] | 1533 | //Asset #4 |
---|
[321] | 1534 | def assetInstance4 = new Asset(name: "C579", |
---|
[314] | 1535 | description: "RO #1", |
---|
| 1536 | section: Section.get(2)) |
---|
[276] | 1537 | saveAndTest(assetInstance4) |
---|
[149] | 1538 | |
---|
[270] | 1539 | //AssetSubItem |
---|
| 1540 | def assetSubItemInstance |
---|
[149] | 1541 | |
---|
[276] | 1542 | //AssetSubItem #1 Level1 |
---|
[314] | 1543 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower", |
---|
| 1544 | description: "Common sub asset.") |
---|
[276] | 1545 | saveAndTest(assetSubItemInstance1) |
---|
[149] | 1546 | |
---|
[276] | 1547 | // Add assetSubItemInstance1 to some assets. |
---|
| 1548 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1549 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1550 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1551 | |
---|
| 1552 | //AssetSubItem #2 Level1 |
---|
[321] | 1553 | def assetSubItemInstance2 = new AssetSubItem(name: "C579-44", |
---|
| 1554 | description: "Tanks and towers") |
---|
[276] | 1555 | saveAndTest(assetSubItemInstance2) |
---|
| 1556 | |
---|
| 1557 | // Add assetSubItemInstance2 to some assets. |
---|
| 1558 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
| 1559 | |
---|
| 1560 | //AssetSubItem #3 Level1 |
---|
[321] | 1561 | def assetSubItemInstance3 = new AssetSubItem(name: "C579-20", |
---|
| 1562 | description: "Control Loops") |
---|
[276] | 1563 | saveAndTest(assetSubItemInstance3) |
---|
| 1564 | |
---|
| 1565 | // Add assetSubItemInstance3 to some assets. |
---|
| 1566 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
| 1567 | |
---|
| 1568 | //AssetSubItem #4 Level2 |
---|
[321] | 1569 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0022", |
---|
| 1570 | description: "Blow Tank", |
---|
| 1571 | parentItem: AssetSubItem.get(2)) |
---|
| 1572 | saveAndTest(assetSubItemInstance) |
---|
| 1573 | |
---|
| 1574 | //AssetSubItem #5 Level2 |
---|
| 1575 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0023", |
---|
| 1576 | description: "Reactor Tower", |
---|
| 1577 | parentItem: AssetSubItem.get(2)) |
---|
| 1578 | saveAndTest(assetSubItemInstance) |
---|
| 1579 | |
---|
| 1580 | //AssetSubItem #6 Level2 |
---|
[314] | 1581 | assetSubItemInstance = new AssetSubItem(name: "Print Unit", |
---|
| 1582 | description: "Print Unit - Common Level 2 sub item.", |
---|
| 1583 | parentItem: AssetSubItem.get(1)) |
---|
[270] | 1584 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1585 | |
---|
[321] | 1586 | //AssetSubItem #7 Level2 |
---|
| 1587 | assetSubItemInstance = new AssetSubItem(name: "1925365", |
---|
| 1588 | description: "Agitator", |
---|
| 1589 | parentItem: AssetSubItem.get(4)) |
---|
[270] | 1590 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1591 | |
---|
[321] | 1592 | //AssetSubItem #8 Level2 |
---|
| 1593 | assetSubItemInstance = new AssetSubItem(name: "1925366", |
---|
| 1594 | description: "Scraper", |
---|
| 1595 | parentItem: AssetSubItem.get(4)) |
---|
[276] | 1596 | saveAndTest(assetSubItemInstance) |
---|
| 1597 | |
---|
[321] | 1598 | //AssetSubItem #9 Level3 |
---|
[276] | 1599 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
[314] | 1600 | description: "Motor - Level 3 sub item", |
---|
[321] | 1601 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1602 | saveAndTest(assetSubItemInstance) |
---|
| 1603 | |
---|
[321] | 1604 | //AssetSubItem #10 Level3 |
---|
[276] | 1605 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
[314] | 1606 | description: "Gearbox - Level 3 sub item, gearbox", |
---|
[321] | 1607 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1608 | saveAndTest(assetSubItemInstance) |
---|
| 1609 | |
---|
[321] | 1610 | //AssetSubItem #11 Level4 |
---|
[276] | 1611 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
[314] | 1612 | description: "Drive Side Bearing", |
---|
[321] | 1613 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1614 | saveAndTest(assetSubItemInstance) |
---|
| 1615 | |
---|
[321] | 1616 | //AssetSubItem #12 Level4 |
---|
[276] | 1617 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
[314] | 1618 | description: "Non Drive Side Bearing", |
---|
[321] | 1619 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1620 | saveAndTest(assetSubItemInstance) |
---|
[321] | 1621 | |
---|
| 1622 | //AssetSubItem #13 Level2 |
---|
| 1623 | assetSubItemInstance = new AssetSubItem(name: "C579-F-0001", |
---|
| 1624 | description: "Weak Caustic Flow", |
---|
| 1625 | parentItem: AssetSubItem.get(3)) |
---|
| 1626 | saveAndTest(assetSubItemInstance) |
---|
| 1627 | |
---|
| 1628 | //AssetSubItem #14 Level3 |
---|
| 1629 | assetSubItemInstance = new AssetSubItem(name: "C579-FT-0002", |
---|
| 1630 | description: "Weak Caustic Flow Transmitter", |
---|
| 1631 | parentItem: AssetSubItem.get(13)) |
---|
| 1632 | saveAndTest(assetSubItemInstance) |
---|
| 1633 | |
---|
| 1634 | //AssetSubItem #15 Level3 |
---|
| 1635 | assetSubItemInstance = new AssetSubItem(name: "C579-PT-0003", |
---|
| 1636 | description: "Weak Caustic Pressure Transmitter", |
---|
| 1637 | parentItem: AssetSubItem.get(13)) |
---|
| 1638 | saveAndTest(assetSubItemInstance) |
---|
[276] | 1639 | } // createDemoAssetTree() |
---|
| 1640 | |
---|
[685] | 1641 | def createDemoAssetSubItemExtendedAttributes() { |
---|
[149] | 1642 | |
---|
[685] | 1643 | //AssetSubItemExtendedAttribute |
---|
| 1644 | def assetSubItemExtendedAttributeInstance |
---|
| 1645 | |
---|
| 1646 | //AssetSubItemExtendedAttribute #1 |
---|
| 1647 | assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "United Press", |
---|
| 1648 | assetSubItem: AssetSubItem.get(1), |
---|
| 1649 | extendedAttributeType: ExtendedAttributeType.get(8)) // Manufacturer. |
---|
| 1650 | saveAndTest(assetSubItemExtendedAttributeInstance) |
---|
| 1651 | |
---|
| 1652 | //AssetSubItemExtendedAttribute #2 |
---|
| 1653 | assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "PU Mark 2", |
---|
| 1654 | assetSubItem: AssetSubItem.get(1), |
---|
| 1655 | extendedAttributeType: ExtendedAttributeType.get(1)) // Model Number. |
---|
| 1656 | saveAndTest(assetSubItemExtendedAttributeInstance) |
---|
| 1657 | |
---|
| 1658 | //AssetSubItemExtendedAttribute #3 |
---|
| 1659 | assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "765895", |
---|
| 1660 | assetSubItem: AssetSubItem.get(1), |
---|
| 1661 | extendedAttributeType: ExtendedAttributeType.get(3)) // Serial Number. |
---|
| 1662 | saveAndTest(assetSubItemExtendedAttributeInstance) |
---|
| 1663 | |
---|
| 1664 | //AssetSubItemExtendedAttribute #4 |
---|
| 1665 | assetSubItemExtendedAttributeInstance = new AssetSubItemExtendedAttribute(value: "Jan-2003", |
---|
| 1666 | assetSubItem: AssetSubItem.get(1), |
---|
| 1667 | extendedAttributeType: ExtendedAttributeType.get(4)) // Manufactured Date. |
---|
| 1668 | saveAndTest(assetSubItemExtendedAttributeInstance) |
---|
| 1669 | |
---|
| 1670 | } |
---|
| 1671 | |
---|
| 1672 | def createDemoAssetExtendedAttributes() { |
---|
| 1673 | |
---|
[270] | 1674 | //AssetExtendedAttribute |
---|
| 1675 | def assetExtendedAttributeInstance |
---|
| 1676 | |
---|
| 1677 | //AssetExtendedAttribute #1 |
---|
[685] | 1678 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1679 | asset: Asset.get(1), |
---|
| 1680 | extendedAttributeType: ExtendedAttributeType.get(5)) // Location Description. |
---|
[650] | 1681 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1682 | |
---|
| 1683 | //AssetExtendedAttribute #2 |
---|
[685] | 1684 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "3", |
---|
| 1685 | asset: Asset.get(1), |
---|
| 1686 | extendedAttributeType: ExtendedAttributeType.get(9)) // ecr. |
---|
[270] | 1687 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1688 | |
---|
[650] | 1689 | //AssetExtendedAttribute #3 |
---|
[685] | 1690 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "RP-001", |
---|
| 1691 | asset: Asset.get(1), |
---|
| 1692 | extendedAttributeType: ExtendedAttributeType.get(17)) // Asset Number. |
---|
[270] | 1693 | saveAndTest(assetExtendedAttributeInstance) |
---|
[650] | 1694 | |
---|
| 1695 | //AssetExtendedAttribute #4 |
---|
[685] | 1696 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Good", |
---|
| 1697 | asset: Asset.get(1), |
---|
| 1698 | extendedAttributeType: ExtendedAttributeType.get(16)) // Asset Condition. |
---|
[650] | 1699 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1700 | |
---|
| 1701 | //AssetExtendedAttribute #5 |
---|
[685] | 1702 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "TBA", |
---|
| 1703 | asset: Asset.get(1), |
---|
| 1704 | extendedAttributeType: ExtendedAttributeType.get(13)) // Maintenance % Completion. |
---|
[650] | 1705 | saveAndTest(assetExtendedAttributeInstance) |
---|
[685] | 1706 | |
---|
| 1707 | //AssetExtendedAttribute #6 |
---|
| 1708 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Y", |
---|
| 1709 | asset: Asset.get(1), |
---|
| 1710 | extendedAttributeType: ExtendedAttributeType.get(14)) // Registration Required. |
---|
| 1711 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1712 | |
---|
| 1713 | //AssetExtendedAttribute #7 |
---|
| 1714 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Feb-2009", |
---|
| 1715 | asset: Asset.get(1), |
---|
| 1716 | extendedAttributeType: ExtendedAttributeType.get(15)) // Registration Expiry Date. |
---|
| 1717 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1718 | |
---|
| 1719 | //AssetExtendedAttribute #8 |
---|
| 1720 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "N", |
---|
| 1721 | asset: Asset.get(1), |
---|
| 1722 | extendedAttributeType: ExtendedAttributeType.get(12)) // Regulatory Requirement. |
---|
| 1723 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1724 | |
---|
| 1725 | //AssetExtendedAttribute #9 |
---|
| 1726 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "Med", |
---|
| 1727 | asset: Asset.get(1), |
---|
| 1728 | extendedAttributeType: ExtendedAttributeType.get(10)) // Risk Level. |
---|
| 1729 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1730 | |
---|
| 1731 | //AssetExtendedAttribute #10 |
---|
| 1732 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "WP-003", |
---|
| 1733 | asset: Asset.get(1), |
---|
| 1734 | extendedAttributeType: ExtendedAttributeType.get(11)) // Safe Work Procedure. |
---|
| 1735 | saveAndTest(assetExtendedAttributeInstance) |
---|
[149] | 1736 | } |
---|
| 1737 | |
---|
[571] | 1738 | /** |
---|
[622] | 1739 | * SearchableIndex and mirroring is disabled at startup. |
---|
| 1740 | * Use this to start indexing after creating bootstrap data. |
---|
[571] | 1741 | * @param indexInNewThread Whether to run the index in a new thread, defaults to true. |
---|
| 1742 | */ |
---|
[622] | 1743 | def startSearchableIndex(Boolean indexInNewThread = true) { |
---|
| 1744 | log.info "Start mirroring searchable index." |
---|
| 1745 | ConfigurationHolder.config.appSearchable.cascadeOnUpdate = true |
---|
[571] | 1746 | searchableService.startMirroring() |
---|
| 1747 | if(indexInNewThread) { |
---|
| 1748 | Thread.start { |
---|
[622] | 1749 | log.info "Rebuilding searchable index, bulkIndex (new thread)." |
---|
[571] | 1750 | searchableService.index() |
---|
[622] | 1751 | log.info "Rebuilding searchable index, complete." |
---|
[571] | 1752 | } |
---|
| 1753 | } |
---|
| 1754 | else { |
---|
[622] | 1755 | log.info "Rebuilding searchable index, bulkIndex." |
---|
[571] | 1756 | searchableService.index() |
---|
[622] | 1757 | log.info "Rebuilding searchable index, complete." |
---|
[571] | 1758 | } |
---|
| 1759 | } |
---|
[149] | 1760 | |
---|
[571] | 1761 | /** |
---|
[622] | 1762 | * Searchable index and mirroring during bulk data creation may be slow. |
---|
| 1763 | * Use this to stop indexing and restart with startSearchableIndex() after data creation. |
---|
[571] | 1764 | */ |
---|
[622] | 1765 | def stopSearchableIndex() { |
---|
| 1766 | log.info "Stop mirroring searchable index." |
---|
| 1767 | ConfigurationHolder.config.appSearchable.cascadeOnUpdate = false |
---|
[571] | 1768 | searchableService.stopMirroring() |
---|
| 1769 | } |
---|
| 1770 | |
---|
| 1771 | /** |
---|
| 1772 | * Call this function instead of .save() |
---|
| 1773 | */ |
---|
[149] | 1774 | private boolean saveAndTest(object) { |
---|
| 1775 | if(!object.save()) { |
---|
| 1776 | // DemoDataSuccessful = false |
---|
[199] | 1777 | log.error "'${object}' failed to save!" |
---|
| 1778 | log.error object.errors |
---|
[149] | 1779 | return false |
---|
| 1780 | } |
---|
| 1781 | return true |
---|
| 1782 | } |
---|
[571] | 1783 | |
---|
[617] | 1784 | } // end of class |
---|