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