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