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