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