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