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