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