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