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