[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) |
---|
[597] | 639 | |
---|
[441] | 640 | // InventoryItemPurchaseType #3 |
---|
| 641 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Received Complete", |
---|
| 642 | description: "Order has been partially received.") |
---|
| 643 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 644 | |
---|
| 645 | // InventoryItemPurchaseType #4 |
---|
| 646 | inventoryItemPurchaseTypeInstance = new InventoryItemPurchaseType(name: "Invoice Approved", |
---|
| 647 | description: "Invoice approved for payment.") |
---|
| 648 | saveAndTest(inventoryItemPurchaseTypeInstance) |
---|
| 649 | } |
---|
| 650 | |
---|
[175] | 651 | def createDemoSuppliers() { |
---|
| 652 | |
---|
| 653 | // Supplier |
---|
| 654 | def supplierInstance |
---|
| 655 | |
---|
| 656 | // Supplier #1 |
---|
| 657 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
[420] | 658 | supplierType: SupplierType.get(2)) |
---|
[175] | 659 | saveAndTest(supplierInstance) |
---|
| 660 | |
---|
| 661 | // Supplier #2 |
---|
| 662 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
[420] | 663 | supplierType: SupplierType.get(3)) |
---|
[175] | 664 | saveAndTest(supplierInstance) |
---|
| 665 | } |
---|
| 666 | |
---|
| 667 | def createDemoManufacturers() { |
---|
| 668 | |
---|
| 669 | // Manufacturer |
---|
| 670 | def manufacturerInstance |
---|
| 671 | |
---|
| 672 | // Manufacturer #1 |
---|
| 673 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
[420] | 674 | manufacturerType: ManufacturerType.get(2)) |
---|
[175] | 675 | saveAndTest(manufacturerInstance) |
---|
| 676 | |
---|
| 677 | // Manufacturer #2 |
---|
| 678 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
[420] | 679 | manufacturerType: ManufacturerType.get(3)) |
---|
[175] | 680 | saveAndTest(manufacturerInstance) |
---|
| 681 | } |
---|
| 682 | |
---|
[431] | 683 | def createDemoProductionReference() { |
---|
| 684 | |
---|
| 685 | // ProductionReference |
---|
| 686 | def productionReferenceInstance |
---|
| 687 | |
---|
| 688 | // ProductionReference #1 |
---|
| 689 | productionReferenceInstance = new ProductionReference(name: "Monday Production") |
---|
| 690 | saveAndTest(productionReferenceInstance) |
---|
| 691 | |
---|
| 692 | // ProductionReference #2 |
---|
| 693 | productionReferenceInstance = new ProductionReference(name: "Tuesday Production") |
---|
| 694 | saveAndTest(productionReferenceInstance) |
---|
| 695 | } |
---|
| 696 | |
---|
[441] | 697 | def createDemoCostCodes() { |
---|
| 698 | |
---|
| 699 | // CostCode |
---|
| 700 | def costCodeInstance |
---|
| 701 | |
---|
| 702 | // CostCode #1 |
---|
| 703 | costCodeInstance = new CostCode(name: "RM Reelstand") |
---|
| 704 | saveAndTest(costCodeInstance) |
---|
| 705 | |
---|
| 706 | // CostCode #2 |
---|
| 707 | costCodeInstance = new CostCode(name: "CAPEX Reelstand") |
---|
| 708 | saveAndTest(costCodeInstance) |
---|
| 709 | } |
---|
| 710 | |
---|
[149] | 711 | /********************* |
---|
| 712 | START OF TASK |
---|
| 713 | *********************/ |
---|
| 714 | |
---|
[180] | 715 | def createBaseTaskGroups() { |
---|
[149] | 716 | //TaskGroup |
---|
| 717 | def taskGroupInstance |
---|
| 718 | |
---|
[258] | 719 | //TaskGroup #1 |
---|
[149] | 720 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 721 | description:"Engineering daily activities") |
---|
| 722 | saveAndTest(taskGroupInstance) |
---|
| 723 | |
---|
[258] | 724 | //TaskGroup #2 |
---|
[149] | 725 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 726 | description:"Production daily activities") |
---|
| 727 | saveAndTest(taskGroupInstance) |
---|
| 728 | |
---|
[258] | 729 | //TaskGroup #3 |
---|
[149] | 730 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
[576] | 731 | description:"New site projects") |
---|
[149] | 732 | saveAndTest(taskGroupInstance) |
---|
[576] | 733 | |
---|
| 734 | //TaskGroup #4 |
---|
[587] | 735 | taskGroupInstance = new TaskGroup(name:"Electrical Dayshift", |
---|
[576] | 736 | description:"Group for dayshift electrical tasks") |
---|
| 737 | saveAndTest(taskGroupInstance) |
---|
| 738 | |
---|
| 739 | //TaskGroup #5 |
---|
[587] | 740 | taskGroupInstance = new TaskGroup(name:"Electrical Nightshift", |
---|
[576] | 741 | description:"Group for dayshift mechanical tasks") |
---|
| 742 | saveAndTest(taskGroupInstance) |
---|
| 743 | |
---|
| 744 | //TaskGroup #6 |
---|
[587] | 745 | taskGroupInstance = new TaskGroup(name:"Mechanical Dayshift", |
---|
[576] | 746 | description:"Group for nightshift electrical tasks") |
---|
| 747 | saveAndTest(taskGroupInstance) |
---|
| 748 | |
---|
| 749 | //TaskGroup #7 |
---|
[587] | 750 | taskGroupInstance = new TaskGroup(name:"Mechanical Nightshift", |
---|
[576] | 751 | description:"Group for nightshift mechanical tasks") |
---|
| 752 | saveAndTest(taskGroupInstance) |
---|
[149] | 753 | } |
---|
| 754 | |
---|
| 755 | def createBaseTaskStatus() { |
---|
| 756 | |
---|
| 757 | //TaskStatus |
---|
| 758 | def taskStatusInstance |
---|
| 759 | |
---|
[181] | 760 | taskStatusInstance = new TaskStatus(name:"Not Started") // #1 |
---|
[149] | 761 | saveAndTest(taskStatusInstance) |
---|
| 762 | |
---|
[181] | 763 | taskStatusInstance = new TaskStatus(name:"In Progress") // #2 |
---|
[149] | 764 | saveAndTest(taskStatusInstance) |
---|
| 765 | |
---|
[222] | 766 | taskStatusInstance = new TaskStatus(name:"Complete") // #3 |
---|
[149] | 767 | saveAndTest(taskStatusInstance) |
---|
| 768 | } |
---|
| 769 | |
---|
| 770 | def createBaseTaskPriorities() { |
---|
| 771 | |
---|
| 772 | //TaskPriority |
---|
| 773 | def taskPriorityInstance |
---|
| 774 | |
---|
[433] | 775 | taskPriorityInstance = new TaskPriority(name:"0 - Immediate") // #1 |
---|
[149] | 776 | saveAndTest(taskPriorityInstance) |
---|
| 777 | |
---|
[433] | 778 | taskPriorityInstance = new TaskPriority(name:"1 - Very High") // #2 |
---|
[149] | 779 | saveAndTest(taskPriorityInstance) |
---|
| 780 | |
---|
[433] | 781 | taskPriorityInstance = new TaskPriority(name:"2 - High") // #3 |
---|
[149] | 782 | saveAndTest(taskPriorityInstance) |
---|
| 783 | |
---|
[433] | 784 | taskPriorityInstance = new TaskPriority(name:"3 - Normal") // #4 |
---|
[149] | 785 | saveAndTest(taskPriorityInstance) |
---|
[433] | 786 | |
---|
| 787 | taskPriorityInstance = new TaskPriority(name:"4 - Low") // #5 |
---|
| 788 | saveAndTest(taskPriorityInstance) |
---|
| 789 | |
---|
| 790 | taskPriorityInstance = new TaskPriority(name:"5 - Minor") // #6 |
---|
| 791 | saveAndTest(taskPriorityInstance) |
---|
[149] | 792 | } |
---|
| 793 | |
---|
[252] | 794 | def createBaseTaskBudgetStatus() { |
---|
| 795 | |
---|
| 796 | //TaskBudgetStatus |
---|
| 797 | def taskBudgetStatusInstance |
---|
| 798 | |
---|
| 799 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Unplanned") // #1 |
---|
| 800 | saveAndTest(taskBudgetStatusInstance) |
---|
| 801 | |
---|
| 802 | taskBudgetStatusInstance = new TaskBudgetStatus(name:"Planned") // #2 |
---|
| 803 | saveAndTest(taskBudgetStatusInstance) |
---|
| 804 | } |
---|
| 805 | |
---|
[149] | 806 | def createBaseTaskTypes() { |
---|
| 807 | |
---|
| 808 | //TaskType |
---|
| 809 | def taskTypeInstance |
---|
| 810 | |
---|
[418] | 811 | taskTypeInstance = new TaskType(name:"Immediate Callout") // #1 |
---|
[149] | 812 | saveAndTest(taskTypeInstance) |
---|
| 813 | |
---|
[418] | 814 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") // #2 |
---|
[149] | 815 | saveAndTest(taskTypeInstance) |
---|
| 816 | |
---|
[418] | 817 | taskTypeInstance = new TaskType(name:"Scheduled") // #3 |
---|
[149] | 818 | saveAndTest(taskTypeInstance) |
---|
| 819 | |
---|
[418] | 820 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") // #4 |
---|
[149] | 821 | saveAndTest(taskTypeInstance) |
---|
| 822 | |
---|
[523] | 823 | taskTypeInstance = new TaskType(name:"Project") // #5 |
---|
[149] | 824 | saveAndTest(taskTypeInstance) |
---|
| 825 | } |
---|
| 826 | |
---|
[180] | 827 | def createBaseTaskModificationTypes() { |
---|
| 828 | |
---|
| 829 | //ModificationType |
---|
| 830 | def taskModificationTypeInstance |
---|
| 831 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() // #1 |
---|
| 832 | taskModificationTypeInstance = new TaskModificationType(name:"Started").save() // #2 |
---|
| 833 | taskModificationTypeInstance = new TaskModificationType(name:"Modified").save() // #3 |
---|
| 834 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() // #4 |
---|
| 835 | taskModificationTypeInstance = new TaskModificationType(name:"Reopened").save() // #5 |
---|
| 836 | taskModificationTypeInstance = new TaskModificationType(name:"Trashed").save() // #6 |
---|
| 837 | taskModificationTypeInstance = new TaskModificationType(name:"Restored").save() // #7 |
---|
| 838 | taskModificationTypeInstance = new TaskModificationType(name:"Approved").save() // #8 |
---|
| 839 | taskModificationTypeInstance = new TaskModificationType(name:"Renege approval").save() // #9 |
---|
[251] | 840 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Groups)").save() // #10 |
---|
| 841 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Assigned Persons)").save() // #11 |
---|
[418] | 842 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Flagged for attention)").save() // #12 |
---|
| 843 | taskModificationTypeInstance = new TaskModificationType(name:"Modified (Attention flag cleared)").save() // #13 |
---|
[180] | 844 | } |
---|
| 845 | |
---|
[149] | 846 | def createDemoTasks() { |
---|
| 847 | |
---|
[180] | 848 | def taskResult |
---|
| 849 | def p = [:] |
---|
[149] | 850 | |
---|
| 851 | //Task #1 |
---|
[180] | 852 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 853 | taskPriority:TaskPriority.get(2), |
---|
| 854 | taskType:TaskType.get(1), |
---|
| 855 | leadPerson:Person.get(2), |
---|
[534] | 856 | primaryAsset:Asset.get(4), |
---|
[418] | 857 | description:"Level sensor not working", |
---|
[180] | 858 | comment:"Has been noted as problematic, try recalibrating.", |
---|
[447] | 859 | targetStartDate: dateUtilService.today, |
---|
| 860 | targetCompletionDate: dateUtilService.today] |
---|
[149] | 861 | |
---|
[394] | 862 | taskResult = taskService.save(p) |
---|
[180] | 863 | |
---|
[149] | 864 | //Task #2 |
---|
[180] | 865 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 866 | taskPriority:TaskPriority.get(2), |
---|
[418] | 867 | taskType:TaskType.get(3), |
---|
[149] | 868 | leadPerson:Person.get(5), |
---|
[534] | 869 | primaryAsset:Asset.get(4), |
---|
[149] | 870 | description:"Some follow-up work", |
---|
| 871 | comment:"Some help required", |
---|
[210] | 872 | targetStartDate: dateUtilService.tomorrow, |
---|
[447] | 873 | targetCompletionDate: dateUtilService.tomorrow, |
---|
[529] | 874 | parentTask: Task.list()[0]] |
---|
[149] | 875 | |
---|
[394] | 876 | taskResult = taskService.save(p) |
---|
[180] | 877 | |
---|
[149] | 878 | //Task #3 |
---|
[180] | 879 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[149] | 880 | taskPriority:TaskPriority.get(2), |
---|
[418] | 881 | taskType:TaskType.get(3), |
---|
[149] | 882 | leadPerson:Person.get(5), |
---|
[534] | 883 | primaryAsset:Asset.get(4), |
---|
[418] | 884 | description:"A Sub Task can be created from the 'Sub Task' tab.", |
---|
[149] | 885 | comment:"Some help required", |
---|
[210] | 886 | targetStartDate: dateUtilService.yesterday, |
---|
[447] | 887 | targetCompletionDate: dateUtilService.yesterday, |
---|
[529] | 888 | parentTask: Task.list()[0]] |
---|
[149] | 889 | |
---|
[394] | 890 | taskResult = taskService.save(p) |
---|
[180] | 891 | |
---|
[149] | 892 | //Task #4 |
---|
[180] | 893 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[534] | 894 | taskPriority:TaskPriority.get(2), |
---|
| 895 | taskType:TaskType.get(2), |
---|
| 896 | leadPerson:Person.get(4), |
---|
| 897 | primaryAsset:Asset.get(4), |
---|
| 898 | description:"Please replace sensor at next available opportunity.", |
---|
| 899 | comment:"Nothing else has worked. So we now require the part to be replaced.", |
---|
[447] | 900 | targetStartDate: dateUtilService.today, |
---|
| 901 | targetCompletionDate: dateUtilService.oneWeekFromNow, |
---|
[529] | 902 | parentTask: Task.list()[0]] |
---|
[149] | 903 | |
---|
[394] | 904 | taskResult = taskService.save(p) |
---|
[180] | 905 | |
---|
[149] | 906 | //Task #5 |
---|
[180] | 907 | p = [taskGroup:TaskGroup.findByName("Production Activites"), |
---|
[534] | 908 | taskPriority:TaskPriority.get(2), |
---|
| 909 | taskType:TaskType.get(3), |
---|
| 910 | leadPerson:Person.get(6), |
---|
| 911 | primaryAsset:Asset.get(1), |
---|
| 912 | description:"Production Task", |
---|
| 913 | comment:"Production task for specific production run or shift", |
---|
[447] | 914 | targetStartDate: dateUtilService.today - 6, |
---|
| 915 | targetCompletionDate: dateUtilService.today - 6] |
---|
[149] | 916 | |
---|
[394] | 917 | taskResult = taskService.save(p) |
---|
[180] | 918 | |
---|
[149] | 919 | //Task #6 |
---|
[199] | 920 | p = [taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
[534] | 921 | taskPriority:TaskPriority.get(4), |
---|
| 922 | taskType:TaskType.get(4), |
---|
| 923 | leadPerson:Person.get(4), |
---|
| 924 | primaryAsset:Asset.get(2), |
---|
| 925 | description:"This is a recurring preventative maintenance task.", |
---|
| 926 | comment:"If there is a parent task specified then this is a generated sub task, if there is a recurring schedule specified then this is a parent task.", |
---|
[447] | 927 | targetStartDate: dateUtilService.today, |
---|
| 928 | targetCompletionDate: dateUtilService.today + 30] |
---|
[180] | 929 | |
---|
[394] | 930 | taskResult = taskService.save(p) |
---|
[534] | 931 | taskService.approve(taskResult.taskInstance) |
---|
[149] | 932 | } |
---|
| 933 | |
---|
| 934 | def createBaseEntryTypes() { |
---|
| 935 | |
---|
| 936 | //EntryType |
---|
| 937 | def entryTypeInstance |
---|
| 938 | |
---|
[190] | 939 | entryTypeInstance = new EntryType(name:"Fault") // #1 |
---|
[149] | 940 | saveAndTest(entryTypeInstance) |
---|
| 941 | |
---|
[418] | 942 | entryTypeInstance = new EntryType(name:"Cause") // #2 |
---|
[149] | 943 | saveAndTest(entryTypeInstance) |
---|
| 944 | |
---|
[418] | 945 | entryTypeInstance = new EntryType(name:"Work Done") // #3 |
---|
[149] | 946 | saveAndTest(entryTypeInstance) |
---|
| 947 | |
---|
[418] | 948 | entryTypeInstance = new EntryType(name:"Production Note") // #4 |
---|
[149] | 949 | saveAndTest(entryTypeInstance) |
---|
[418] | 950 | |
---|
| 951 | entryTypeInstance = new EntryType(name:"Work Request") // #5 |
---|
| 952 | saveAndTest(entryTypeInstance) |
---|
[149] | 953 | } |
---|
| 954 | |
---|
| 955 | def createDemoEntries() { |
---|
| 956 | |
---|
[190] | 957 | def entryResult |
---|
| 958 | def p = [:] |
---|
[149] | 959 | |
---|
| 960 | //Entry #1 |
---|
[529] | 961 | p = [task: Task.list()[0], |
---|
[190] | 962 | entryType: EntryType.get(1), |
---|
| 963 | comment: "This level sensor is causing us trouble.", |
---|
| 964 | durationMinute: 20] |
---|
[149] | 965 | |
---|
[394] | 966 | entryResult = taskService.saveEntry(p) |
---|
[190] | 967 | |
---|
[149] | 968 | //Entry #2 |
---|
[529] | 969 | p = [task: Task.list()[0], |
---|
[418] | 970 | entryType: EntryType.get(3), |
---|
[190] | 971 | comment: "Cleaned sensor, see how it goes.", |
---|
| 972 | durationMinute: 30] |
---|
[149] | 973 | |
---|
[394] | 974 | entryResult = taskService.saveEntry(p) |
---|
[190] | 975 | |
---|
[149] | 976 | //Entry #3 |
---|
[529] | 977 | p = [task: Task.list()[0], |
---|
[418] | 978 | entryType: EntryType.get(3), |
---|
[190] | 979 | comment: "Checked up on it later and sensor is dropping out intermittently, created sub task to replace sensor.", |
---|
| 980 | durationMinute: 20] |
---|
| 981 | |
---|
[394] | 982 | entryResult = taskService.saveEntry(p) |
---|
[534] | 983 | |
---|
| 984 | //Entry #4 |
---|
| 985 | p = [task: Task.list()[5], |
---|
| 986 | entryType: EntryType.get(3), |
---|
| 987 | comment: "Recurring work done as per procedure.", |
---|
| 988 | durationMinute: 55] |
---|
| 989 | |
---|
| 990 | entryResult = taskService.saveEntry(p) |
---|
[149] | 991 | } |
---|
| 992 | |
---|
[242] | 993 | def createDemoAssignedGroups() { |
---|
| 994 | |
---|
[251] | 995 | def result |
---|
| 996 | def p = [:] |
---|
[242] | 997 | |
---|
| 998 | //AssignedGroup #1 |
---|
[251] | 999 | p = [personGroup: PersonGroup.get(1), |
---|
[529] | 1000 | task: Task.list()[0], |
---|
[251] | 1001 | estimatedHour: 2, |
---|
| 1002 | estimatedMinute: 30] |
---|
| 1003 | result = assignedGroupService.save(p) |
---|
[242] | 1004 | |
---|
| 1005 | //AssignedGroup #2 |
---|
[251] | 1006 | p = [personGroup: PersonGroup.get(2), |
---|
[529] | 1007 | task: Task.list()[0], |
---|
[251] | 1008 | estimatedHour: 1, |
---|
| 1009 | estimatedMinute: 0] |
---|
| 1010 | result = assignedGroupService.save(p) |
---|
[242] | 1011 | } |
---|
| 1012 | |
---|
[241] | 1013 | def createDemoAssignedPersons() { |
---|
[149] | 1014 | |
---|
[251] | 1015 | def result |
---|
| 1016 | def p = [:] |
---|
[149] | 1017 | |
---|
[241] | 1018 | //AssignedPerson #1 |
---|
[534] | 1019 | p = [person: Person.get(3), // Demo Manager. |
---|
| 1020 | task: Task.list()[5], |
---|
[251] | 1021 | estimatedHour: 1, |
---|
| 1022 | estimatedMinute: 20] |
---|
| 1023 | result = assignedPersonService.save(p) |
---|
[149] | 1024 | |
---|
[241] | 1025 | //AssignedPerson #2 |
---|
[534] | 1026 | p = [person: Person.get(4), // Demo User. |
---|
[529] | 1027 | task: Task.list()[0], |
---|
[251] | 1028 | estimatedHour: 3, |
---|
| 1029 | estimatedMinute: 30] |
---|
| 1030 | result = assignedPersonService.save(p) |
---|
[149] | 1031 | } |
---|
| 1032 | |
---|
[534] | 1033 | def createBaseMaintenancePolicies() { |
---|
| 1034 | |
---|
| 1035 | //MaintenancePolicy |
---|
| 1036 | def maintenancePolicyInstance |
---|
| 1037 | |
---|
| 1038 | //MaintenancePolicy #1 |
---|
| 1039 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 1040 | saveAndTest(maintenancePolicyInstance) |
---|
| 1041 | |
---|
| 1042 | //MaintenancePolicy #2 |
---|
| 1043 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 1044 | saveAndTest(maintenancePolicyInstance) |
---|
| 1045 | |
---|
| 1046 | //MaintenancePolicy #3 |
---|
| 1047 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 1048 | saveAndTest(maintenancePolicyInstance) |
---|
| 1049 | |
---|
| 1050 | //MaintenancePolicy #4 |
---|
| 1051 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 1052 | saveAndTest(maintenancePolicyInstance) |
---|
| 1053 | |
---|
| 1054 | //MaintenancePolicy #5 |
---|
| 1055 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 1056 | saveAndTest(maintenancePolicyInstance) |
---|
| 1057 | |
---|
| 1058 | //MaintenancePolicy #6 |
---|
| 1059 | maintenancePolicyInstance = new MaintenancePolicy(name: "Regulatory Requirement") |
---|
| 1060 | saveAndTest(maintenancePolicyInstance) |
---|
| 1061 | |
---|
| 1062 | //MaintenancePolicy #7 |
---|
| 1063 | maintenancePolicyInstance = new MaintenancePolicy(name: "Hidden Function Test") |
---|
| 1064 | saveAndTest(maintenancePolicyInstance) |
---|
| 1065 | } |
---|
| 1066 | |
---|
| 1067 | def createDemoTaskProcedure() { |
---|
| 1068 | |
---|
| 1069 | //TaskProcedure |
---|
| 1070 | def taskProcedureInstance |
---|
| 1071 | |
---|
| 1072 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 1073 | saveAndTest(taskProcedureInstance) |
---|
| 1074 | taskProcedureInstance.addToTasks(Task.list()[0]) |
---|
| 1075 | } |
---|
| 1076 | |
---|
| 1077 | def createDemoMaintenanceActions() { |
---|
| 1078 | |
---|
| 1079 | //MaintenanceAction |
---|
| 1080 | def maintenanceActionInstance |
---|
| 1081 | |
---|
| 1082 | //MaintenanceAction #1 |
---|
| 1083 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 1084 | procedureStepNumber: 10, |
---|
| 1085 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1086 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1087 | saveAndTest(maintenanceActionInstance) |
---|
| 1088 | |
---|
| 1089 | //MaintenanceAction #2 |
---|
| 1090 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 1091 | procedureStepNumber: 20, |
---|
| 1092 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1093 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1094 | saveAndTest(maintenanceActionInstance) |
---|
| 1095 | |
---|
| 1096 | //MaintenanceAction #3 |
---|
| 1097 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 1098 | procedureStepNumber: 30, |
---|
| 1099 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 1100 | taskProcedure: TaskProcedure.get(1)) |
---|
| 1101 | saveAndTest(maintenanceActionInstance) |
---|
| 1102 | } |
---|
| 1103 | |
---|
[149] | 1104 | def createDemoTaskRecurringSchedules() { |
---|
| 1105 | |
---|
| 1106 | //TaskRecurringSchedule |
---|
| 1107 | def taskRecurringScheduleInstance |
---|
| 1108 | |
---|
| 1109 | //TaskRecurringSchedule #1 |
---|
[529] | 1110 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[0], |
---|
[149] | 1111 | recurEvery: 1, |
---|
[199] | 1112 | recurPeriod: Period.get(2), |
---|
[210] | 1113 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 1114 | generateAhead: 1, |
---|
[199] | 1115 | taskDuration: 2, |
---|
| 1116 | taskDurationPeriod: Period.get(1), |
---|
| 1117 | enabled: false) |
---|
[149] | 1118 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 1119 | |
---|
| 1120 | //TaskRecurringSchedule #2 |
---|
[534] | 1121 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.list()[5], |
---|
[149] | 1122 | recurEvery: 1, |
---|
| 1123 | recurPeriod: Period.get(1), |
---|
[210] | 1124 | nextTargetStartDate: dateUtilService.today, |
---|
[149] | 1125 | generateAhead: 1, |
---|
| 1126 | taskDuration: 1, |
---|
[199] | 1127 | taskDurationPeriod: Period.get(1), |
---|
| 1128 | enabled: true) |
---|
[149] | 1129 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 1130 | } |
---|
| 1131 | |
---|
| 1132 | /************************* |
---|
| 1133 | START OF INVENTORY |
---|
| 1134 | **************************/ |
---|
| 1135 | |
---|
| 1136 | def createDemoInventoryStores() { |
---|
| 1137 | |
---|
| 1138 | //InventoryStore |
---|
| 1139 | def inventoryStoreInstance |
---|
| 1140 | |
---|
| 1141 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 1142 | saveAndTest(inventoryStoreInstance) |
---|
| 1143 | |
---|
| 1144 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 1145 | saveAndTest(inventoryStoreInstance) |
---|
| 1146 | } |
---|
| 1147 | |
---|
[175] | 1148 | def createDemoInventoryLocations() { |
---|
[149] | 1149 | |
---|
[175] | 1150 | // InventoryLocation |
---|
| 1151 | def inventoryLocation |
---|
[149] | 1152 | |
---|
[175] | 1153 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 1154 | saveAndTest(inventoryLocation) |
---|
[149] | 1155 | |
---|
[418] | 1156 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(2), name: "C55") |
---|
[175] | 1157 | saveAndTest(inventoryLocation) |
---|
[149] | 1158 | } |
---|
| 1159 | |
---|
| 1160 | def createDemoInventoryGroups() { |
---|
| 1161 | |
---|
| 1162 | //InventoryGroup |
---|
| 1163 | def inventoryGroupInstance |
---|
| 1164 | |
---|
| 1165 | //InventoryGroup #1 |
---|
| 1166 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 1167 | saveAndTest(inventoryGroupInstance) |
---|
| 1168 | |
---|
| 1169 | //InventoryGroup #2 |
---|
| 1170 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 1171 | saveAndTest(inventoryGroupInstance) |
---|
| 1172 | |
---|
| 1173 | //InventoryGroup #3 |
---|
| 1174 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 1175 | saveAndTest(inventoryGroupInstance) |
---|
| 1176 | |
---|
| 1177 | //InventoryGroup #4 |
---|
| 1178 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 1179 | saveAndTest(inventoryGroupInstance) |
---|
| 1180 | } |
---|
| 1181 | |
---|
| 1182 | def createBaseInventoryTypes() { |
---|
| 1183 | |
---|
| 1184 | //InventoryType |
---|
| 1185 | def inventoryTypeInstance |
---|
| 1186 | |
---|
| 1187 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 1188 | saveAndTest(inventoryTypeInstance) |
---|
| 1189 | |
---|
| 1190 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 1191 | saveAndTest(inventoryTypeInstance) |
---|
| 1192 | } |
---|
| 1193 | |
---|
[175] | 1194 | def createBaseInventoryMovementTypes() { |
---|
| 1195 | |
---|
| 1196 | // InventoryMovementType |
---|
| 1197 | def inventoryMovementTypeInstance |
---|
| 1198 | |
---|
| 1199 | // InventoryMovementType #1 |
---|
[177] | 1200 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 1201 | incrementsInventory: false) |
---|
[175] | 1202 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1203 | |
---|
| 1204 | // InventoryMovementType #2 |
---|
[177] | 1205 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 1206 | incrementsInventory: true) |
---|
[175] | 1207 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1208 | |
---|
| 1209 | // InventoryMovementType #3 |
---|
[177] | 1210 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 1211 | incrementsInventory: true) |
---|
[175] | 1212 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 1213 | |
---|
| 1214 | // InventoryMovementType #4 |
---|
| 1215 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 1216 | incrementsInventory: true) |
---|
| 1217 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 1218 | |
---|
| 1219 | // InventoryMovementType #5 |
---|
| 1220 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 1221 | incrementsInventory: false) |
---|
| 1222 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 1223 | } |
---|
| 1224 | |
---|
[149] | 1225 | def createDemoInventoryItems() { |
---|
| 1226 | |
---|
| 1227 | //InventoryItem |
---|
| 1228 | def inventoryItemInstance |
---|
| 1229 | |
---|
[549] | 1230 | def pictureResource = grailsApplication.mainContext.getResource('images/logo.png') |
---|
| 1231 | |
---|
[149] | 1232 | //InventoryItem #1 |
---|
| 1233 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 1234 | inventoryType: InventoryType.get(1), |
---|
| 1235 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 1236 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 1237 | name: "Hemp rope", |
---|
| 1238 | description: "Natural hemp rope.", |
---|
[175] | 1239 | unitsInStock: 2, |
---|
[149] | 1240 | reorderPoint: 0) |
---|
| 1241 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1242 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1243 | |
---|
| 1244 | //InventoryItem #2 |
---|
| 1245 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 1246 | inventoryType: InventoryType.get(1), |
---|
| 1247 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 1248 | inventoryLocation: InventoryLocation.get(1), |
---|
[185] | 1249 | name: "Cotton Rope 12mm", |
---|
| 1250 | description: "A soft natural rope made from cotton.", |
---|
[149] | 1251 | alternateItems: InventoryItem.get(1), |
---|
[175] | 1252 | unitsInStock: 2, |
---|
[149] | 1253 | reorderPoint: 0) |
---|
| 1254 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1255 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1256 | |
---|
| 1257 | //InventoryItem #3 |
---|
| 1258 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 1259 | inventoryType: InventoryType.get(1), |
---|
| 1260 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1261 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1262 | name: "2305-2RS", |
---|
| 1263 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[175] | 1264 | unitsInStock: 3, |
---|
[149] | 1265 | reorderPoint: 2) |
---|
| 1266 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1267 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1268 | |
---|
| 1269 | //InventoryItem #4 |
---|
| 1270 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 1271 | inventoryType: InventoryType.get(1), |
---|
| 1272 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1273 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1274 | name: "L1592-K10", |
---|
| 1275 | description: "10kW contactor", |
---|
[175] | 1276 | unitsInStock: 4, |
---|
[149] | 1277 | reorderPoint: 0) |
---|
| 1278 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1279 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1280 | |
---|
| 1281 | //InventoryItem #5 |
---|
| 1282 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 1283 | inventoryType: InventoryType.get(1), |
---|
| 1284 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 1285 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 1286 | name: "6205-ZZ", |
---|
| 1287 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[175] | 1288 | unitsInStock: 5, |
---|
[149] | 1289 | reorderPoint: 2) |
---|
| 1290 | saveAndTest(inventoryItemInstance) |
---|
[549] | 1291 | inventoryItemService.savePicture(inventoryItemInstance, pictureResource) |
---|
[149] | 1292 | } |
---|
| 1293 | |
---|
| 1294 | /******************* |
---|
| 1295 | START OF ASSET |
---|
| 1296 | *******************/ |
---|
| 1297 | |
---|
| 1298 | def createDemoLifePlan() { |
---|
| 1299 | |
---|
| 1300 | //LifePlan |
---|
| 1301 | def lifeplanInstance |
---|
| 1302 | |
---|
| 1303 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 1304 | saveAndTest(lifeplanInstance) |
---|
| 1305 | } |
---|
| 1306 | |
---|
[270] | 1307 | def createBaseExtenededAttributeTypes() { |
---|
| 1308 | |
---|
| 1309 | //ExtendedAttributeType |
---|
| 1310 | def extendedAttributeTypeInstance |
---|
| 1311 | |
---|
| 1312 | //ExtendedAttributeType #1 |
---|
| 1313 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Model Number") |
---|
| 1314 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1315 | |
---|
| 1316 | //ExtendedAttributeType #2 |
---|
| 1317 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Purchase Cost") |
---|
| 1318 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1319 | |
---|
| 1320 | //ExtendedAttributeType #3 |
---|
| 1321 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Serial Number") |
---|
| 1322 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1323 | |
---|
| 1324 | //ExtendedAttributeType #4 |
---|
| 1325 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufactured Date") |
---|
| 1326 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1327 | |
---|
| 1328 | //ExtendedAttributeType #5 |
---|
| 1329 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Location Description") |
---|
| 1330 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1331 | |
---|
| 1332 | //ExtendedAttributeType #6 |
---|
| 1333 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Centre") |
---|
| 1334 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1335 | |
---|
| 1336 | //ExtendedAttributeType #7 |
---|
| 1337 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Cost Code") |
---|
| 1338 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1339 | |
---|
| 1340 | //ExtendedAttributeType #8 |
---|
| 1341 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Manufacturer's Number") |
---|
| 1342 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1343 | |
---|
| 1344 | //ExtendedAttributeType #9 |
---|
| 1345 | extendedAttributeTypeInstance = new ExtendedAttributeType(name: "Inventory Number") |
---|
| 1346 | saveAndTest(extendedAttributeTypeInstance) |
---|
| 1347 | } |
---|
| 1348 | |
---|
[268] | 1349 | def createDemoSections() { |
---|
[149] | 1350 | |
---|
[268] | 1351 | //Section |
---|
| 1352 | def sectionInstance |
---|
[149] | 1353 | |
---|
[268] | 1354 | //Section #1 |
---|
[314] | 1355 | sectionInstance = new Section(name: "Press", |
---|
| 1356 | description: "Press Section", |
---|
| 1357 | site: Site.get(3), |
---|
| 1358 | department: Department.get(1)) |
---|
[268] | 1359 | saveAndTest(sectionInstance) |
---|
[149] | 1360 | |
---|
[268] | 1361 | //Section #2 |
---|
[321] | 1362 | sectionInstance = new Section(name: "CSM-Delig", |
---|
[314] | 1363 | description: "Pulp Delignification", |
---|
| 1364 | site: Site.get(1), |
---|
| 1365 | department: Department.get(2)) |
---|
[268] | 1366 | saveAndTest(sectionInstance) |
---|
[149] | 1367 | |
---|
[268] | 1368 | //Section #3 |
---|
[321] | 1369 | sectionInstance = new Section(name: "CSM-Aux", |
---|
[314] | 1370 | description: "Auxilliary Section", |
---|
| 1371 | site: Site.get(1), |
---|
| 1372 | department: Department.get(1)) |
---|
[268] | 1373 | saveAndTest(sectionInstance) |
---|
[149] | 1374 | } |
---|
| 1375 | |
---|
[276] | 1376 | def createDemoAssetTree() { |
---|
[149] | 1377 | |
---|
[270] | 1378 | //Asset |
---|
| 1379 | def assetInstance |
---|
[149] | 1380 | |
---|
[270] | 1381 | //Asset #1 |
---|
[276] | 1382 | def assetInstance1 = new Asset(name: "Print Tower 22", |
---|
[314] | 1383 | description: "Complete Printing Asset #22", |
---|
| 1384 | section: Section.get(1)) |
---|
[276] | 1385 | saveAndTest(assetInstance1) |
---|
[270] | 1386 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
[149] | 1387 | |
---|
[270] | 1388 | //Asset #2 |
---|
[276] | 1389 | def assetInstance2 = new Asset(name: "Print Tower 21", |
---|
[314] | 1390 | description: "Complete Printing Asset #21", |
---|
| 1391 | section: Section.get(1)) |
---|
[276] | 1392 | saveAndTest(assetInstance2) |
---|
[149] | 1393 | |
---|
[270] | 1394 | //Asset #3 |
---|
[276] | 1395 | def assetInstance3 = new Asset(name: "Print Tower 23", |
---|
[314] | 1396 | description: "Complete Printing Asset #23", |
---|
| 1397 | section: Section.get(1)) |
---|
[276] | 1398 | saveAndTest(assetInstance3) |
---|
[149] | 1399 | |
---|
[270] | 1400 | //Asset #4 |
---|
[321] | 1401 | def assetInstance4 = new Asset(name: "C579", |
---|
[314] | 1402 | description: "RO #1", |
---|
| 1403 | section: Section.get(2)) |
---|
[276] | 1404 | saveAndTest(assetInstance4) |
---|
[149] | 1405 | |
---|
[270] | 1406 | //AssetSubItem |
---|
| 1407 | def assetSubItemInstance |
---|
[149] | 1408 | |
---|
[276] | 1409 | //AssetSubItem #1 Level1 |
---|
[314] | 1410 | def assetSubItemInstance1 = new AssetSubItem(name: "Print Tower", |
---|
| 1411 | description: "Common sub asset.") |
---|
[276] | 1412 | saveAndTest(assetSubItemInstance1) |
---|
[149] | 1413 | |
---|
[276] | 1414 | // Add assetSubItemInstance1 to some assets. |
---|
| 1415 | assetInstance1.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1416 | assetInstance2.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1417 | assetInstance3.addToAssetSubItems(assetSubItemInstance1) |
---|
| 1418 | |
---|
| 1419 | //AssetSubItem #2 Level1 |
---|
[321] | 1420 | def assetSubItemInstance2 = new AssetSubItem(name: "C579-44", |
---|
| 1421 | description: "Tanks and towers") |
---|
[276] | 1422 | saveAndTest(assetSubItemInstance2) |
---|
| 1423 | |
---|
| 1424 | // Add assetSubItemInstance2 to some assets. |
---|
| 1425 | assetInstance4.addToAssetSubItems(assetSubItemInstance2) |
---|
| 1426 | |
---|
| 1427 | //AssetSubItem #3 Level1 |
---|
[321] | 1428 | def assetSubItemInstance3 = new AssetSubItem(name: "C579-20", |
---|
| 1429 | description: "Control Loops") |
---|
[276] | 1430 | saveAndTest(assetSubItemInstance3) |
---|
| 1431 | |
---|
| 1432 | // Add assetSubItemInstance3 to some assets. |
---|
| 1433 | assetInstance4.addToAssetSubItems(assetSubItemInstance3) |
---|
| 1434 | |
---|
| 1435 | //AssetSubItem #4 Level2 |
---|
[321] | 1436 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0022", |
---|
| 1437 | description: "Blow Tank", |
---|
| 1438 | parentItem: AssetSubItem.get(2)) |
---|
| 1439 | saveAndTest(assetSubItemInstance) |
---|
| 1440 | |
---|
| 1441 | //AssetSubItem #5 Level2 |
---|
| 1442 | assetSubItemInstance = new AssetSubItem(name: "C579-TK-0023", |
---|
| 1443 | description: "Reactor Tower", |
---|
| 1444 | parentItem: AssetSubItem.get(2)) |
---|
| 1445 | saveAndTest(assetSubItemInstance) |
---|
| 1446 | |
---|
| 1447 | //AssetSubItem #6 Level2 |
---|
[314] | 1448 | assetSubItemInstance = new AssetSubItem(name: "Print Unit", |
---|
| 1449 | description: "Print Unit - Common Level 2 sub item.", |
---|
| 1450 | parentItem: AssetSubItem.get(1)) |
---|
[270] | 1451 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1452 | |
---|
[321] | 1453 | //AssetSubItem #7 Level2 |
---|
| 1454 | assetSubItemInstance = new AssetSubItem(name: "1925365", |
---|
| 1455 | description: "Agitator", |
---|
| 1456 | parentItem: AssetSubItem.get(4)) |
---|
[270] | 1457 | saveAndTest(assetSubItemInstance) |
---|
[149] | 1458 | |
---|
[321] | 1459 | //AssetSubItem #8 Level2 |
---|
| 1460 | assetSubItemInstance = new AssetSubItem(name: "1925366", |
---|
| 1461 | description: "Scraper", |
---|
| 1462 | parentItem: AssetSubItem.get(4)) |
---|
[276] | 1463 | saveAndTest(assetSubItemInstance) |
---|
| 1464 | |
---|
[321] | 1465 | //AssetSubItem #9 Level3 |
---|
[276] | 1466 | assetSubItemInstance = new AssetSubItem(name: "Motor", |
---|
[314] | 1467 | description: "Motor - Level 3 sub item", |
---|
[321] | 1468 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1469 | saveAndTest(assetSubItemInstance) |
---|
| 1470 | |
---|
[321] | 1471 | //AssetSubItem #10 Level3 |
---|
[276] | 1472 | assetSubItemInstance = new AssetSubItem(name: "Gearbox", |
---|
[314] | 1473 | description: "Gearbox - Level 3 sub item, gearbox", |
---|
[321] | 1474 | parentItem: AssetSubItem.get(6)) |
---|
[276] | 1475 | saveAndTest(assetSubItemInstance) |
---|
| 1476 | |
---|
[321] | 1477 | //AssetSubItem #11 Level4 |
---|
[276] | 1478 | assetSubItemInstance = new AssetSubItem(name: "DS Bearing", |
---|
[314] | 1479 | description: "Drive Side Bearing", |
---|
[321] | 1480 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1481 | saveAndTest(assetSubItemInstance) |
---|
| 1482 | |
---|
[321] | 1483 | //AssetSubItem #12 Level4 |
---|
[276] | 1484 | assetSubItemInstance = new AssetSubItem(name: "NDS Bearing", |
---|
[314] | 1485 | description: "Non Drive Side Bearing", |
---|
[321] | 1486 | parentItem: AssetSubItem.get(9)) |
---|
[276] | 1487 | saveAndTest(assetSubItemInstance) |
---|
[321] | 1488 | |
---|
| 1489 | //AssetSubItem #13 Level2 |
---|
| 1490 | assetSubItemInstance = new AssetSubItem(name: "C579-F-0001", |
---|
| 1491 | description: "Weak Caustic Flow", |
---|
| 1492 | parentItem: AssetSubItem.get(3)) |
---|
| 1493 | saveAndTest(assetSubItemInstance) |
---|
| 1494 | |
---|
| 1495 | //AssetSubItem #14 Level3 |
---|
| 1496 | assetSubItemInstance = new AssetSubItem(name: "C579-FT-0002", |
---|
| 1497 | description: "Weak Caustic Flow Transmitter", |
---|
| 1498 | parentItem: AssetSubItem.get(13)) |
---|
| 1499 | saveAndTest(assetSubItemInstance) |
---|
| 1500 | |
---|
| 1501 | //AssetSubItem #15 Level3 |
---|
| 1502 | assetSubItemInstance = new AssetSubItem(name: "C579-PT-0003", |
---|
| 1503 | description: "Weak Caustic Pressure Transmitter", |
---|
| 1504 | parentItem: AssetSubItem.get(13)) |
---|
| 1505 | saveAndTest(assetSubItemInstance) |
---|
[276] | 1506 | } // createDemoAssetTree() |
---|
| 1507 | |
---|
[149] | 1508 | def createDemoAssetExtenedAttributes() { |
---|
| 1509 | |
---|
[270] | 1510 | //AssetExtendedAttribute |
---|
| 1511 | def assetExtendedAttributeInstance |
---|
| 1512 | |
---|
| 1513 | //AssetExtendedAttribute #1 |
---|
| 1514 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 1515 | asset: Asset.get(1), |
---|
| 1516 | extendedAttributeType: ExtendedAttributeType.get(1)) |
---|
| 1517 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1518 | |
---|
| 1519 | //AssetExtendedAttribute #2 |
---|
| 1520 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1521 | asset: Asset.get(1), |
---|
| 1522 | extendedAttributeType: ExtendedAttributeType.get(5)) |
---|
| 1523 | saveAndTest(assetExtendedAttributeInstance) |
---|
[149] | 1524 | } |
---|
| 1525 | |
---|
[571] | 1526 | /** |
---|
| 1527 | * Lucene index and mirroring is disabled at startup. |
---|
[580] | 1528 | * Us this to start Lucene indexing after creating bootstrap data. |
---|
[571] | 1529 | * @param indexInNewThread Whether to run the index in a new thread, defaults to true. |
---|
| 1530 | */ |
---|
| 1531 | def startLucene(Boolean indexInNewThread = true) { |
---|
[580] | 1532 | log.info "Start mirroring Lucene index." |
---|
[571] | 1533 | searchableService.startMirroring() |
---|
| 1534 | if(indexInNewThread) { |
---|
| 1535 | Thread.start { |
---|
[580] | 1536 | log.info "Rebuilding Lucene index, bulkIndex (new thread)." |
---|
[571] | 1537 | searchableService.index() |
---|
[580] | 1538 | log.info "Rebuilding Lucene index, complete." |
---|
[571] | 1539 | } |
---|
| 1540 | } |
---|
| 1541 | else { |
---|
[580] | 1542 | log.info "Rebuilding Lucene index, bulkIndex." |
---|
[571] | 1543 | searchableService.index() |
---|
[580] | 1544 | log.info "Rebuilding Lucene index, complete." |
---|
[571] | 1545 | } |
---|
| 1546 | } |
---|
[149] | 1547 | |
---|
[571] | 1548 | /** |
---|
| 1549 | * Lucene index and mirroring during bulk data creation may be slow. |
---|
| 1550 | * Us this to stop lucene indexing and restart with startLucene() after data creation. |
---|
| 1551 | */ |
---|
| 1552 | def stopLucene() { |
---|
| 1553 | log.info "Stop mirroring lucene index." |
---|
| 1554 | searchableService.stopMirroring() |
---|
| 1555 | } |
---|
| 1556 | |
---|
| 1557 | /** |
---|
| 1558 | * Call this function instead of .save() |
---|
| 1559 | */ |
---|
[149] | 1560 | private boolean saveAndTest(object) { |
---|
| 1561 | if(!object.save()) { |
---|
| 1562 | // DemoDataSuccessful = false |
---|
[199] | 1563 | log.error "'${object}' failed to save!" |
---|
| 1564 | log.error object.errors |
---|
[149] | 1565 | return false |
---|
| 1566 | } |
---|
| 1567 | return true |
---|
| 1568 | } |
---|
[571] | 1569 | |
---|
[617] | 1570 | } // end of class |
---|