[149] | 1 | /** |
---|
| 2 | * Provides a data service to create base and demo data. |
---|
| 3 | */ |
---|
| 4 | class CreateDataService { |
---|
| 5 | |
---|
| 6 | def authenticateService |
---|
| 7 | boolean transactional = false |
---|
| 8 | |
---|
| 9 | /******************************************* |
---|
| 10 | Start of Group methods. |
---|
| 11 | Generally use these methods to create data. |
---|
| 12 | *******************************************/ |
---|
| 13 | |
---|
| 14 | /** |
---|
| 15 | * Always call this at startup to ensure admin access. |
---|
| 16 | */ |
---|
| 17 | def ensureAdminAccess() { |
---|
| 18 | if(!Authority.findByAuthority("ROLE_AppAdmin") ) { |
---|
| 19 | println "ROLE_AppAdmin not found, calling createAdminAuthority()." |
---|
| 20 | createAdminAuthority() |
---|
| 21 | } |
---|
| 22 | if(!Person.findByloginName("admin") ) { |
---|
| 23 | println "LoginName 'admin' not found, calling createAdminPerson()." |
---|
| 24 | createAdminPerson() |
---|
| 25 | } |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * Create the base data required for the application to function. |
---|
| 30 | */ |
---|
| 31 | def createBaseData() { |
---|
| 32 | println "Creating base data..." |
---|
| 33 | // Person and Utils |
---|
| 34 | createBaseAuthorities() |
---|
| 35 | createBasePersonGroups() |
---|
| 36 | createBasePersons() |
---|
| 37 | createBaseUnitsOfMeasure() |
---|
| 38 | createBasePeriods() |
---|
[175] | 39 | createBaseSupplierType() |
---|
| 40 | createBaseManufacturerType() |
---|
[149] | 41 | // Tasks |
---|
| 42 | createBaseTaskStatus() |
---|
| 43 | createBaseTaskPriorities() |
---|
| 44 | createBaseTaskTypes() |
---|
| 45 | createBaseEntryTypes() |
---|
| 46 | createBaseModificationTypes() |
---|
| 47 | // Inventory |
---|
| 48 | createBaseInventoryTypes() |
---|
[175] | 49 | createBaseInventoryMovementTypes() |
---|
[149] | 50 | createBaseMaintenancePolicies() |
---|
| 51 | // Assets |
---|
| 52 | createBaseAssetExtenededAttributeTypes() |
---|
| 53 | |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * Create demo data for some example sites. |
---|
| 58 | */ |
---|
| 59 | def createDemoData() { |
---|
| 60 | println "Creating demo data..." |
---|
| 61 | // Person and Utils |
---|
| 62 | createDemoPersons() |
---|
| 63 | createDemoSites() |
---|
[162] | 64 | createDemoDepartments() |
---|
[175] | 65 | createDemoSuppliers() |
---|
| 66 | createDemoManufacturers() |
---|
[149] | 67 | // Tasks |
---|
| 68 | createDemoTaskGroups() /// @todo: Perhaps this should be BaseData? |
---|
| 69 | createDemoTasks() |
---|
| 70 | createDemoEntries() |
---|
| 71 | createDemoAssignedPersons() |
---|
| 72 | createDemoTaskRecurringSchedules() |
---|
| 73 | // Inventory |
---|
| 74 | createDemoInventoryStores() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
[175] | 75 | createDemoInventoryLocations() |
---|
[149] | 76 | createDemoInventoryGroups() /// @todo: Perhaps a 'createQuickStartData' method? |
---|
| 77 | createDemoInventoryItems() |
---|
| 78 | // Assets |
---|
| 79 | createDemoLifePlan() |
---|
| 80 | createDemoTaskProcedure() |
---|
| 81 | createDemoMaintenanceActions() |
---|
| 82 | createDemoSystemSections() |
---|
| 83 | createDemoAssetTypes() |
---|
| 84 | createDemoAssemblies() |
---|
| 85 | createDemoSubAssemblies() |
---|
| 86 | createDemoComponentItems() |
---|
| 87 | createDemoAssets() |
---|
| 88 | createDemoAssetExtenedAttributes() |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | /****************** |
---|
| 92 | Start of Person |
---|
| 93 | *******************/ |
---|
| 94 | |
---|
| 95 | def createAdminAuthority() { |
---|
| 96 | def authInstance |
---|
| 97 | |
---|
| 98 | authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.", |
---|
| 99 | authority:"ROLE_AppAdmin") |
---|
| 100 | saveAndTest(authInstance) |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | def createBaseAuthorities() { |
---|
| 104 | |
---|
| 105 | def authInstance |
---|
| 106 | |
---|
| 107 | authInstance = new Authority(description:"Business manager, grants full management access.", |
---|
| 108 | authority:"ROLE_Manager") |
---|
| 109 | saveAndTest(authInstance) |
---|
| 110 | |
---|
| 111 | authInstance = new Authority(description:"Application User, all application users need this base role to allow login.", |
---|
| 112 | authority:"ROLE_AppUser") |
---|
| 113 | saveAndTest(authInstance) |
---|
| 114 | } |
---|
| 115 | |
---|
| 116 | void createBasePersonGroups() { |
---|
| 117 | //TypeOfPersonGroup |
---|
| 118 | def personGroupTypeInstance |
---|
[164] | 119 | personGroupTypeInstance = new PersonGroupType(name:"Team") |
---|
[149] | 120 | saveAndTest(personGroupTypeInstance) |
---|
| 121 | personGroupTypeInstance = new PersonGroupType(name:"Contractor") |
---|
| 122 | saveAndTest(personGroupTypeInstance) |
---|
| 123 | personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam") |
---|
| 124 | saveAndTest(personGroupTypeInstance) |
---|
| 125 | |
---|
| 126 | //PersonGroup |
---|
| 127 | def personGroupInstance |
---|
[164] | 128 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 129 | name:"Electrical") |
---|
| 130 | saveAndTest(personGroupInstance) |
---|
[164] | 131 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 132 | name:"Mechanical") |
---|
| 133 | saveAndTest(personGroupInstance) |
---|
[164] | 134 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(1), |
---|
[149] | 135 | name:"Production") |
---|
| 136 | saveAndTest(personGroupInstance) |
---|
| 137 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2), |
---|
| 138 | name:"Kewl AirCon Guys") |
---|
| 139 | saveAndTest(personGroupInstance) |
---|
| 140 | personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3), |
---|
| 141 | name:"gnuMims") |
---|
| 142 | saveAndTest(personGroupInstance) |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | def createAdminPerson() { |
---|
| 146 | //Person |
---|
| 147 | def passClearText = "pass" |
---|
| 148 | def passwordEncoded = authenticateService.encodePassword(passClearText) |
---|
| 149 | def personInstance |
---|
| 150 | |
---|
| 151 | //Person #1 |
---|
| 152 | personInstance = new Person(loginName:"admin", |
---|
| 153 | firstName:"Admin", |
---|
| 154 | lastName:"Powers", |
---|
| 155 | pass:passClearText, |
---|
| 156 | password:passwordEncoded, |
---|
| 157 | email:"admin@example.com") |
---|
| 158 | saveAndTest(personInstance) |
---|
| 159 | personInstance.addToAuthorities(Authority.get(1)) |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | def createBasePersons() { |
---|
| 163 | //Person |
---|
| 164 | def passClearText = "pass" |
---|
| 165 | def passwordEncoded = authenticateService.encodePassword(passClearText) |
---|
| 166 | def personInstance |
---|
| 167 | |
---|
| 168 | //Person #1 is admin. |
---|
| 169 | |
---|
| 170 | //Person #2 |
---|
| 171 | personInstance = new Person(loginName:"manager", |
---|
| 172 | firstName:"Demo", |
---|
| 173 | lastName:"Manager", |
---|
| 174 | pass:passClearText, |
---|
| 175 | password:passwordEncoded, |
---|
| 176 | email:"manager@example.com") |
---|
| 177 | saveAndTest(personInstance) |
---|
| 178 | personInstance.addToAuthorities(Authority.get(2)) |
---|
| 179 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 180 | personInstance.addToPersonGroups(PersonGroup.get(5)) |
---|
[149] | 181 | |
---|
| 182 | //Person #3 |
---|
| 183 | personInstance = new Person(loginName:"user", |
---|
| 184 | firstName:"Demo", |
---|
| 185 | lastName:"User", |
---|
| 186 | pass:passClearText, |
---|
| 187 | password:passwordEncoded, |
---|
| 188 | email:"user@example.com") |
---|
| 189 | saveAndTest(personInstance) |
---|
| 190 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 191 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 192 | } |
---|
| 193 | |
---|
| 194 | def createDemoPersons() { |
---|
| 195 | //Person |
---|
| 196 | def passClearText = "pass" |
---|
| 197 | def passwordEncoded = authenticateService.encodePassword(passClearText) |
---|
| 198 | def personInstance |
---|
| 199 | |
---|
| 200 | //Person #4 |
---|
| 201 | personInstance = new Person(loginName:"craig", |
---|
| 202 | firstName:"Craig", |
---|
| 203 | lastName:"SuperSparky", |
---|
| 204 | pass:passClearText, |
---|
| 205 | password:passwordEncoded, |
---|
| 206 | email:"user@example.com") |
---|
| 207 | saveAndTest(personInstance) |
---|
| 208 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 209 | personInstance.addToPersonGroups(PersonGroup.get(1)) |
---|
[149] | 210 | |
---|
| 211 | //Person #5 |
---|
| 212 | personInstance = new Person(loginName:"john", |
---|
| 213 | firstName:"John", |
---|
| 214 | lastName:"SuperFitter", |
---|
| 215 | pass:passClearText, |
---|
| 216 | password:passwordEncoded, |
---|
| 217 | email:"user@example.com") |
---|
| 218 | saveAndTest(personInstance) |
---|
| 219 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 220 | personInstance.addToPersonGroups(PersonGroup.get(2)) |
---|
[149] | 221 | |
---|
| 222 | //Person #6 |
---|
| 223 | personInstance = new Person(loginName:"mann", |
---|
| 224 | firstName:"Production", |
---|
| 225 | lastName:"Mann", |
---|
| 226 | pass:passClearText, |
---|
| 227 | password:passwordEncoded, |
---|
| 228 | email:"user@example.com") |
---|
| 229 | saveAndTest(personInstance) |
---|
| 230 | personInstance.addToAuthorities(Authority.get(3)) |
---|
[164] | 231 | personInstance.addToPersonGroups(PersonGroup.get(3)) |
---|
[149] | 232 | } |
---|
| 233 | |
---|
| 234 | /*********************** |
---|
| 235 | START OF UTILITIES |
---|
| 236 | ***********************/ |
---|
| 237 | |
---|
| 238 | def createDemoSites() { |
---|
| 239 | //Site |
---|
| 240 | def siteInstance |
---|
| 241 | |
---|
| 242 | siteInstance = new Site(name: "Creek Mill") |
---|
| 243 | saveAndTest(siteInstance) |
---|
| 244 | |
---|
| 245 | siteInstance = new Site(name: "Jasper Street Depot") |
---|
| 246 | saveAndTest(siteInstance) |
---|
[162] | 247 | |
---|
| 248 | siteInstance = new Site(name: "River Press") |
---|
| 249 | saveAndTest(siteInstance) |
---|
[149] | 250 | } |
---|
| 251 | |
---|
[162] | 252 | def createDemoDepartments() { |
---|
| 253 | |
---|
| 254 | //Department |
---|
| 255 | def departmentInstance |
---|
| 256 | |
---|
| 257 | //Department #1 |
---|
| 258 | departmentInstance = new Department(name: "Print Centre", |
---|
| 259 | site: Site.get(1)) |
---|
| 260 | saveAndTest(departmentInstance) |
---|
| 261 | |
---|
| 262 | //Department #2 |
---|
| 263 | departmentInstance = new Department(name: "Pulp Mill 2", |
---|
| 264 | site: Site.get(2)) |
---|
| 265 | saveAndTest(departmentInstance) |
---|
| 266 | } |
---|
| 267 | |
---|
[149] | 268 | def createBaseUnitsOfMeasure() { |
---|
| 269 | |
---|
| 270 | //UnitOfMeasure |
---|
| 271 | def unitOfMeasureInstance |
---|
| 272 | |
---|
| 273 | //UnitOfMeasure #1 |
---|
| 274 | unitOfMeasureInstance = new UnitOfMeasure(name: "each") |
---|
| 275 | saveAndTest(unitOfMeasureInstance) |
---|
| 276 | |
---|
| 277 | //UnitOfMeasure #2 |
---|
| 278 | unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)") |
---|
| 279 | saveAndTest(unitOfMeasureInstance) |
---|
| 280 | |
---|
| 281 | //UnitOfMeasure #3 |
---|
| 282 | unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)") |
---|
| 283 | saveAndTest(unitOfMeasureInstance) |
---|
| 284 | |
---|
| 285 | //UnitOfMeasure #4 |
---|
| 286 | unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)") |
---|
| 287 | saveAndTest(unitOfMeasureInstance) |
---|
| 288 | |
---|
| 289 | //UnitOfMeasure #5 |
---|
| 290 | unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)") |
---|
| 291 | saveAndTest(unitOfMeasureInstance) |
---|
| 292 | } |
---|
| 293 | |
---|
| 294 | def createBasePeriods() { |
---|
| 295 | |
---|
| 296 | //Period |
---|
| 297 | def periodInstance |
---|
| 298 | |
---|
| 299 | //Period #1 |
---|
| 300 | periodInstance = new Period(period: "Day(s)") |
---|
| 301 | saveAndTest(periodInstance) |
---|
| 302 | |
---|
| 303 | //Period #2 |
---|
| 304 | periodInstance = new Period(period: "Week(s)") |
---|
| 305 | saveAndTest(periodInstance) |
---|
| 306 | |
---|
| 307 | //Period #3 |
---|
| 308 | periodInstance = new Period(period: "Month(s)") |
---|
| 309 | saveAndTest(periodInstance) |
---|
| 310 | |
---|
| 311 | //Period #4 |
---|
| 312 | periodInstance = new Period(period: "Year(s)") |
---|
| 313 | saveAndTest(periodInstance) |
---|
| 314 | } |
---|
| 315 | |
---|
[175] | 316 | def createBaseSupplierType() { |
---|
| 317 | |
---|
| 318 | // SupplierType |
---|
| 319 | def supplierTypeInstance |
---|
| 320 | |
---|
| 321 | // SupplierType #1 |
---|
| 322 | supplierTypeInstance = new SupplierType(name: "OEM", |
---|
| 323 | description: "Original equipment supplier") |
---|
| 324 | saveAndTest(supplierTypeInstance) |
---|
| 325 | |
---|
| 326 | // SupplierType #2 |
---|
| 327 | supplierTypeInstance = new SupplierType(name: "Local", |
---|
| 328 | description: "Local supplier") |
---|
| 329 | saveAndTest(supplierTypeInstance) |
---|
| 330 | } |
---|
| 331 | |
---|
| 332 | def createBaseManufacturerType() { |
---|
| 333 | |
---|
| 334 | // ManufacturerType |
---|
| 335 | def manufacturerTypeInstance |
---|
| 336 | |
---|
| 337 | // ManufacturerType #1 |
---|
| 338 | manufacturerTypeInstance = new ManufacturerType(name: "OEM", |
---|
| 339 | description: "Original equipment manufacturer") |
---|
| 340 | saveAndTest(manufacturerTypeInstance) |
---|
| 341 | |
---|
| 342 | // ManufacturerType #2 |
---|
| 343 | manufacturerTypeInstance = new ManufacturerType(name: "Alternate", |
---|
| 344 | description: "Not original equipment manufacturer") |
---|
| 345 | saveAndTest(manufacturerTypeInstance) |
---|
| 346 | |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | def createDemoSuppliers() { |
---|
| 350 | |
---|
| 351 | // Supplier |
---|
| 352 | def supplierInstance |
---|
| 353 | |
---|
| 354 | // Supplier #1 |
---|
| 355 | supplierInstance = new Supplier(name: "OEM Distributors", |
---|
| 356 | supplierType: SupplierType.get(1)) |
---|
| 357 | saveAndTest(supplierInstance) |
---|
| 358 | |
---|
| 359 | // Supplier #2 |
---|
| 360 | supplierInstance = new Supplier(name: "Mex Holdings", |
---|
| 361 | supplierType: SupplierType.get(2)) |
---|
| 362 | saveAndTest(supplierInstance) |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | def createDemoManufacturers() { |
---|
| 366 | |
---|
| 367 | // Manufacturer |
---|
| 368 | def manufacturerInstance |
---|
| 369 | |
---|
| 370 | // Manufacturer #1 |
---|
| 371 | manufacturerInstance = new Manufacturer(name: "OEM Manufacturer", |
---|
| 372 | manufacturerType: ManufacturerType.get(1)) |
---|
| 373 | saveAndTest(manufacturerInstance) |
---|
| 374 | |
---|
| 375 | // Manufacturer #2 |
---|
| 376 | manufacturerInstance = new Manufacturer(name: "Laser Cutting Services Pty", |
---|
| 377 | manufacturerType: ManufacturerType.get(2)) |
---|
| 378 | saveAndTest(manufacturerInstance) |
---|
| 379 | } |
---|
| 380 | |
---|
[149] | 381 | /********************* |
---|
| 382 | START OF TASK |
---|
| 383 | *********************/ |
---|
| 384 | |
---|
| 385 | def createDemoTaskGroups() { |
---|
| 386 | //TaskGroup |
---|
| 387 | def taskGroupInstance |
---|
| 388 | |
---|
| 389 | taskGroupInstance = new TaskGroup(name:"Engineering Activites", |
---|
| 390 | description:"Engineering daily activities") |
---|
| 391 | saveAndTest(taskGroupInstance) |
---|
| 392 | |
---|
| 393 | taskGroupInstance = new TaskGroup(name:"Production Activites", |
---|
| 394 | description:"Production daily activities") |
---|
| 395 | saveAndTest(taskGroupInstance) |
---|
| 396 | |
---|
| 397 | taskGroupInstance = new TaskGroup(name:"New Projects", |
---|
| 398 | description:" ") |
---|
| 399 | saveAndTest(taskGroupInstance) |
---|
| 400 | } |
---|
| 401 | |
---|
| 402 | def createBaseTaskStatus() { |
---|
| 403 | |
---|
| 404 | //TaskStatus |
---|
| 405 | def taskStatusInstance |
---|
| 406 | |
---|
| 407 | taskStatusInstance = new TaskStatus(name:"Not Started") |
---|
| 408 | saveAndTest(taskStatusInstance) |
---|
| 409 | |
---|
| 410 | taskStatusInstance = new TaskStatus(name:"In Progress") |
---|
| 411 | saveAndTest(taskStatusInstance) |
---|
| 412 | |
---|
| 413 | taskStatusInstance = new TaskStatus(name:"Completed") |
---|
| 414 | saveAndTest(taskStatusInstance) |
---|
| 415 | } |
---|
| 416 | |
---|
| 417 | def createBaseTaskPriorities() { |
---|
| 418 | |
---|
| 419 | //TaskPriority |
---|
| 420 | def taskPriorityInstance |
---|
| 421 | |
---|
| 422 | taskPriorityInstance = new TaskPriority(name:"Normal") |
---|
| 423 | saveAndTest(taskPriorityInstance) |
---|
| 424 | |
---|
| 425 | taskPriorityInstance = new TaskPriority(name:"Low") |
---|
| 426 | saveAndTest(taskPriorityInstance) |
---|
| 427 | |
---|
| 428 | taskPriorityInstance = new TaskPriority(name:"High") |
---|
| 429 | saveAndTest(taskPriorityInstance) |
---|
| 430 | |
---|
| 431 | taskPriorityInstance = new TaskPriority(name:"Immediate") |
---|
| 432 | saveAndTest(taskPriorityInstance) |
---|
| 433 | } |
---|
| 434 | |
---|
| 435 | def createBaseTaskTypes() { |
---|
| 436 | |
---|
| 437 | //TaskType |
---|
| 438 | def taskTypeInstance |
---|
| 439 | |
---|
| 440 | taskTypeInstance = new TaskType(name:"Unscheduled Breakin") |
---|
| 441 | saveAndTest(taskTypeInstance) |
---|
| 442 | |
---|
| 443 | taskTypeInstance = new TaskType(name:"Preventative Maintenance") |
---|
| 444 | saveAndTest(taskTypeInstance) |
---|
| 445 | |
---|
| 446 | taskTypeInstance = new TaskType(name:"Project") |
---|
| 447 | saveAndTest(taskTypeInstance) |
---|
| 448 | |
---|
| 449 | taskTypeInstance = new TaskType(name:"Turnaround") |
---|
| 450 | saveAndTest(taskTypeInstance) |
---|
| 451 | |
---|
| 452 | taskTypeInstance = new TaskType(name:"Production Run") |
---|
| 453 | saveAndTest(taskTypeInstance) |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | def createDemoTasks() { |
---|
| 457 | |
---|
| 458 | //Task |
---|
| 459 | def taskInstance |
---|
| 460 | |
---|
| 461 | //Task #1 |
---|
| 462 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 463 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 464 | taskPriority:TaskPriority.get(2), |
---|
| 465 | taskType:TaskType.get(1), |
---|
| 466 | leadPerson:Person.get(2), |
---|
| 467 | description:"Check specific level sensor", |
---|
| 468 | comment:"Has been noted as problematic, try recalibrating.", |
---|
| 469 | targetStartDate:new Date()) |
---|
| 470 | saveAndTest(taskInstance) |
---|
| 471 | |
---|
| 472 | //Task #2 |
---|
| 473 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 474 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 475 | taskPriority:TaskPriority.get(2), |
---|
| 476 | taskType:TaskType.get(1), |
---|
| 477 | leadPerson:Person.get(5), |
---|
| 478 | description:"Some follow-up work", |
---|
| 479 | comment:"Some help required", |
---|
| 480 | targetStartDate:new Date()+1, |
---|
| 481 | parentTask: Task.get(1)) |
---|
| 482 | saveAndTest(taskInstance) |
---|
| 483 | |
---|
| 484 | //Task #3 |
---|
| 485 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 486 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 487 | taskPriority:TaskPriority.get(2), |
---|
| 488 | taskType:TaskType.get(1), |
---|
| 489 | leadPerson:Person.get(5), |
---|
| 490 | description:"A Sub Task can be created by setting the Parent Task value", |
---|
| 491 | comment:"Some help required", |
---|
| 492 | targetStartDate:new Date()-1, |
---|
| 493 | parentTask: Task.get(1)) |
---|
| 494 | saveAndTest(taskInstance) |
---|
| 495 | |
---|
| 496 | //Task #4 |
---|
| 497 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"), |
---|
| 498 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 499 | taskPriority:TaskPriority.get(2), |
---|
| 500 | taskType:TaskType.get(1), |
---|
| 501 | leadPerson:Person.get(4), |
---|
| 502 | description:"Replace sensor at next opportunity.", |
---|
| 503 | comment:"Nothing else has worked.", |
---|
| 504 | targetStartDate:new Date()+7, |
---|
| 505 | parentTask: Task.get(1)) |
---|
| 506 | saveAndTest(taskInstance) |
---|
| 507 | |
---|
| 508 | //Task #5 |
---|
| 509 | taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"), |
---|
| 510 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 511 | taskPriority:TaskPriority.get(2), |
---|
| 512 | taskType:TaskType.get(5), |
---|
| 513 | leadPerson:Person.get(6), |
---|
| 514 | description:"Production Report", |
---|
| 515 | comment:"Production report for specific production run or shift", |
---|
| 516 | targetStartDate:new Date()-7) |
---|
| 517 | saveAndTest(taskInstance) |
---|
| 518 | |
---|
| 519 | //Task #6 |
---|
| 520 | taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"), |
---|
| 521 | taskStatus:TaskStatus.findByName("Not Started"), |
---|
| 522 | taskPriority:TaskPriority.get(2), |
---|
| 523 | taskType:TaskType.get(3), |
---|
| 524 | leadPerson:Person.get(1), |
---|
| 525 | description:"Make killer CMMS app", |
---|
| 526 | comment:"Use Grails and get a move on!", |
---|
| 527 | targetStartDate:new Date()-6) |
---|
| 528 | saveAndTest(taskInstance) |
---|
| 529 | } |
---|
| 530 | |
---|
| 531 | def createBaseEntryTypes() { |
---|
| 532 | |
---|
| 533 | //EntryType |
---|
| 534 | def entryTypeInstance |
---|
| 535 | |
---|
| 536 | entryTypeInstance = new EntryType(name:"Fault") |
---|
| 537 | saveAndTest(entryTypeInstance) |
---|
| 538 | |
---|
| 539 | entryTypeInstance = new EntryType(name:"WorkDone") |
---|
| 540 | saveAndTest(entryTypeInstance) |
---|
| 541 | |
---|
| 542 | entryTypeInstance = new EntryType(name:"Production Note") |
---|
| 543 | saveAndTest(entryTypeInstance) |
---|
| 544 | |
---|
| 545 | entryTypeInstance = new EntryType(name:"Work Request") |
---|
| 546 | saveAndTest(entryTypeInstance) |
---|
| 547 | } |
---|
| 548 | |
---|
| 549 | def createDemoEntries() { |
---|
| 550 | |
---|
| 551 | //Entry |
---|
| 552 | def entryInstance |
---|
| 553 | |
---|
| 554 | //Entry #1 |
---|
| 555 | entryInstance = new Entry(enteredBy: Person.get(3), |
---|
| 556 | task: Task.get(1), |
---|
| 557 | entryType: EntryType.findByName("Fault"), |
---|
| 558 | comment: "This level sensor is causing us trouble.", |
---|
| 559 | durationMinute: 20) |
---|
| 560 | saveAndTest(entryInstance) |
---|
| 561 | |
---|
| 562 | //Entry #2 |
---|
| 563 | entryInstance = new Entry(enteredBy: Person.get(4), |
---|
| 564 | task: Task.get(1), |
---|
| 565 | entryType: EntryType.findByName("WorkDone"), |
---|
| 566 | comment: "Cleaned sensor, see how it goes.", |
---|
| 567 | durationMinute: 30) |
---|
| 568 | saveAndTest(entryInstance) |
---|
| 569 | |
---|
| 570 | //Entry #3 |
---|
| 571 | entryInstance = new Entry(enteredBy: Person.get(4), |
---|
| 572 | task: Task.get(1), |
---|
| 573 | entryType: EntryType.findByName("WorkDone"), |
---|
| 574 | comment: "Checked up on it later and sensor is dropping out intermittently, created subTask to replace sensor.", |
---|
| 575 | durationMinute: 20) |
---|
| 576 | saveAndTest(entryInstance) |
---|
| 577 | } |
---|
| 578 | |
---|
| 579 | def createBaseModificationTypes() { |
---|
| 580 | |
---|
| 581 | //ModificationType |
---|
| 582 | def taskModificationTypeInstance |
---|
| 583 | taskModificationTypeInstance = new TaskModificationType(name:"Created").save() |
---|
| 584 | taskModificationTypeInstance = new TaskModificationType(name:"Completed").save() |
---|
| 585 | taskModificationTypeInstance = new TaskModificationType(name:"Closed").save() |
---|
| 586 | taskModificationTypeInstance = new TaskModificationType(name:"Altered").save() |
---|
| 587 | taskModificationTypeInstance = new TaskModificationType(name:"TargetDateModified").save() |
---|
| 588 | taskModificationTypeInstance = new TaskModificationType(name:"ScheduledDateModified").save() |
---|
| 589 | taskModificationTypeInstance = new TaskModificationType(name:"DescriptionModified").save() |
---|
| 590 | taskModificationTypeInstance = new TaskModificationType(name:"AssignedToModified").save() |
---|
| 591 | taskModificationTypeInstance = new TaskModificationType(name:"NameModified").save() |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | def createDemoAssignedPersons() { |
---|
| 595 | |
---|
| 596 | //AssignedPerson |
---|
| 597 | def assignedPersonInstance |
---|
| 598 | |
---|
| 599 | //AssignedPerson #1 |
---|
| 600 | assignedPersonInstance = new AssignedPerson(person: Person.get(4), |
---|
| 601 | task: Task.get(1), |
---|
| 602 | estimatedHour: 1, |
---|
| 603 | estimatedMinute: 20) |
---|
| 604 | saveAndTest(assignedPersonInstance) |
---|
| 605 | |
---|
| 606 | //AssignedPerson #2 |
---|
| 607 | assignedPersonInstance = new AssignedPerson(person: Person.get(5), |
---|
| 608 | task: Task.get(1), |
---|
| 609 | estimatedHour: 3, |
---|
| 610 | estimatedMinute: 30) |
---|
| 611 | saveAndTest(assignedPersonInstance) |
---|
| 612 | } |
---|
| 613 | |
---|
| 614 | def createDemoTaskRecurringSchedules() { |
---|
| 615 | |
---|
| 616 | //TaskRecurringSchedule |
---|
| 617 | def taskRecurringScheduleInstance |
---|
| 618 | |
---|
| 619 | //TaskRecurringSchedule #1 |
---|
| 620 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1), |
---|
| 621 | recurEvery: 1, |
---|
| 622 | recurPeriod: Period.get(1), |
---|
| 623 | startDate: new Date(), |
---|
| 624 | generateAhead: 1, |
---|
| 625 | generateAheadPeriod: Period.get(1), |
---|
| 626 | taskDuration: 1, |
---|
| 627 | taskDurationPeriod: Period.get(1)) |
---|
| 628 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 629 | |
---|
| 630 | //TaskRecurringSchedule #2 |
---|
| 631 | taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(2), |
---|
| 632 | recurEvery: 1, |
---|
| 633 | recurPeriod: Period.get(1), |
---|
| 634 | startDate: new Date(), |
---|
| 635 | generateAhead: 1, |
---|
| 636 | generateAheadPeriod: Period.get(1), |
---|
| 637 | taskDuration: 1, |
---|
| 638 | taskDurationPeriod: Period.get(1)) |
---|
| 639 | saveAndTest(taskRecurringScheduleInstance) |
---|
| 640 | } |
---|
| 641 | |
---|
| 642 | /************************* |
---|
| 643 | START OF INVENTORY |
---|
| 644 | **************************/ |
---|
| 645 | |
---|
| 646 | def createDemoInventoryStores() { |
---|
| 647 | |
---|
| 648 | //InventoryStore |
---|
| 649 | def inventoryStoreInstance |
---|
| 650 | |
---|
| 651 | inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1") |
---|
| 652 | saveAndTest(inventoryStoreInstance) |
---|
| 653 | |
---|
| 654 | inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2") |
---|
| 655 | saveAndTest(inventoryStoreInstance) |
---|
| 656 | } |
---|
| 657 | |
---|
[175] | 658 | def createDemoInventoryLocations() { |
---|
[149] | 659 | |
---|
[175] | 660 | // InventoryLocation |
---|
| 661 | def inventoryLocation |
---|
[149] | 662 | |
---|
[175] | 663 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "A1-2") |
---|
| 664 | saveAndTest(inventoryLocation) |
---|
[149] | 665 | |
---|
[175] | 666 | inventoryLocation = new InventoryLocation(inventoryStore: InventoryStore.get(1), name: "C55") |
---|
| 667 | saveAndTest(inventoryLocation) |
---|
[149] | 668 | } |
---|
| 669 | |
---|
| 670 | def createDemoInventoryGroups() { |
---|
| 671 | |
---|
| 672 | //InventoryGroup |
---|
| 673 | def inventoryGroupInstance |
---|
| 674 | |
---|
| 675 | //InventoryGroup #1 |
---|
| 676 | inventoryGroupInstance = new InventoryGroup(name: "Misc") |
---|
| 677 | saveAndTest(inventoryGroupInstance) |
---|
| 678 | |
---|
| 679 | //InventoryGroup #2 |
---|
| 680 | inventoryGroupInstance = new InventoryGroup(name: "Electrical") |
---|
| 681 | saveAndTest(inventoryGroupInstance) |
---|
| 682 | |
---|
| 683 | //InventoryGroup #3 |
---|
| 684 | inventoryGroupInstance = new InventoryGroup(name: "Mechanical") |
---|
| 685 | saveAndTest(inventoryGroupInstance) |
---|
| 686 | |
---|
| 687 | //InventoryGroup #4 |
---|
| 688 | inventoryGroupInstance = new InventoryGroup(name: "Production") |
---|
| 689 | saveAndTest(inventoryGroupInstance) |
---|
| 690 | } |
---|
| 691 | |
---|
| 692 | def createBaseInventoryTypes() { |
---|
| 693 | |
---|
| 694 | //InventoryType |
---|
| 695 | def inventoryTypeInstance |
---|
| 696 | |
---|
| 697 | inventoryTypeInstance = new InventoryType(name: "Consumable") |
---|
| 698 | saveAndTest(inventoryTypeInstance) |
---|
| 699 | |
---|
| 700 | inventoryTypeInstance = new InventoryType(name: "Repairable") |
---|
| 701 | saveAndTest(inventoryTypeInstance) |
---|
| 702 | } |
---|
| 703 | |
---|
[175] | 704 | def createBaseInventoryMovementTypes() { |
---|
| 705 | |
---|
| 706 | // InventoryMovementType |
---|
| 707 | def inventoryMovementTypeInstance |
---|
| 708 | |
---|
| 709 | // InventoryMovementType #1 |
---|
[177] | 710 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Used", |
---|
| 711 | incrementsInventory: false) |
---|
[175] | 712 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 713 | |
---|
| 714 | // InventoryMovementType #2 |
---|
[177] | 715 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Repaired", |
---|
| 716 | incrementsInventory: true) |
---|
[175] | 717 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 718 | |
---|
| 719 | // InventoryMovementType #3 |
---|
[177] | 720 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Purchase Received", |
---|
| 721 | incrementsInventory: true) |
---|
[175] | 722 | saveAndTest(inventoryMovementTypeInstance) |
---|
[177] | 723 | |
---|
| 724 | // InventoryMovementType #4 |
---|
| 725 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Increase", |
---|
| 726 | incrementsInventory: true) |
---|
| 727 | saveAndTest(inventoryMovementTypeInstance) |
---|
| 728 | |
---|
| 729 | // InventoryMovementType #5 |
---|
| 730 | inventoryMovementTypeInstance = new InventoryMovementType(name: "Correction Decrease", |
---|
| 731 | incrementsInventory: false) |
---|
| 732 | saveAndTest(inventoryMovementTypeInstance) |
---|
[175] | 733 | } |
---|
| 734 | |
---|
[149] | 735 | def createDemoInventoryItems() { |
---|
| 736 | |
---|
| 737 | //InventoryItem |
---|
| 738 | def inventoryItemInstance |
---|
| 739 | |
---|
| 740 | //InventoryItem #1 |
---|
| 741 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 742 | inventoryType: InventoryType.get(1), |
---|
| 743 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 744 | inventoryLocation: InventoryLocation.get(1), |
---|
[149] | 745 | name: "J-Rope", |
---|
| 746 | description: "Twine wound J-Rope", |
---|
[175] | 747 | unitsInStock: 2, |
---|
[149] | 748 | reorderPoint: 0) |
---|
| 749 | saveAndTest(inventoryItemInstance) |
---|
| 750 | |
---|
| 751 | //InventoryItem #2 |
---|
| 752 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1), |
---|
| 753 | inventoryType: InventoryType.get(1), |
---|
| 754 | unitOfMeasure: UnitOfMeasure.get(2), |
---|
[175] | 755 | inventoryLocation: InventoryLocation.get(1), |
---|
[149] | 756 | name: "L-Rope", |
---|
| 757 | description: "Twine wound L-Rope", |
---|
| 758 | alternateItems: InventoryItem.get(1), |
---|
[175] | 759 | unitsInStock: 2, |
---|
[149] | 760 | reorderPoint: 0) |
---|
| 761 | saveAndTest(inventoryItemInstance) |
---|
| 762 | |
---|
| 763 | //InventoryItem #3 |
---|
| 764 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 765 | inventoryType: InventoryType.get(1), |
---|
| 766 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 767 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 768 | name: "2305-2RS", |
---|
| 769 | description: "Bearing 25x62x24mm double row self aligning ball", |
---|
[175] | 770 | unitsInStock: 3, |
---|
[149] | 771 | reorderPoint: 2) |
---|
| 772 | saveAndTest(inventoryItemInstance) |
---|
| 773 | |
---|
| 774 | //InventoryItem #4 |
---|
| 775 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2), |
---|
| 776 | inventoryType: InventoryType.get(1), |
---|
| 777 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 778 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 779 | name: "L1592-K10", |
---|
| 780 | description: "10kW contactor", |
---|
[175] | 781 | unitsInStock: 4, |
---|
[149] | 782 | reorderPoint: 0) |
---|
| 783 | saveAndTest(inventoryItemInstance) |
---|
| 784 | |
---|
| 785 | //InventoryItem #5 |
---|
| 786 | inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3), |
---|
| 787 | inventoryType: InventoryType.get(1), |
---|
| 788 | unitOfMeasure: UnitOfMeasure.get(1), |
---|
[175] | 789 | inventoryLocation: InventoryLocation.get(2), |
---|
[149] | 790 | name: "6205-ZZ", |
---|
| 791 | description: "Bearing 25x52x15mm single row ball shielded", |
---|
[175] | 792 | unitsInStock: 5, |
---|
[149] | 793 | reorderPoint: 2) |
---|
| 794 | saveAndTest(inventoryItemInstance) |
---|
| 795 | } |
---|
| 796 | |
---|
| 797 | /******************* |
---|
| 798 | START OF ASSET |
---|
| 799 | *******************/ |
---|
| 800 | |
---|
| 801 | def createDemoLifePlan() { |
---|
| 802 | |
---|
| 803 | //LifePlan |
---|
| 804 | def lifeplanInstance |
---|
| 805 | |
---|
| 806 | lifeplanInstance = new LifePlan(name: "Initial Plan") |
---|
| 807 | saveAndTest(lifeplanInstance) |
---|
| 808 | } |
---|
| 809 | |
---|
| 810 | def createBaseMaintenancePolicies() { |
---|
| 811 | |
---|
| 812 | //MaintenancePolicy |
---|
| 813 | def maintenancePolicyInstance |
---|
| 814 | |
---|
| 815 | //MaintenancePolicy #1 |
---|
| 816 | maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time") |
---|
| 817 | saveAndTest(maintenancePolicyInstance) |
---|
| 818 | |
---|
| 819 | //MaintenancePolicy #2 |
---|
| 820 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online") |
---|
| 821 | saveAndTest(maintenancePolicyInstance) |
---|
| 822 | |
---|
| 823 | //MaintenancePolicy #3 |
---|
| 824 | maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline") |
---|
| 825 | saveAndTest(maintenancePolicyInstance) |
---|
| 826 | |
---|
| 827 | //MaintenancePolicy #4 |
---|
| 828 | maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out") |
---|
| 829 | saveAndTest(maintenancePolicyInstance) |
---|
| 830 | |
---|
| 831 | //MaintenancePolicy #5 |
---|
| 832 | maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure") |
---|
| 833 | saveAndTest(maintenancePolicyInstance) |
---|
| 834 | } |
---|
| 835 | |
---|
| 836 | def createDemoTaskProcedure() { |
---|
| 837 | |
---|
| 838 | //TaskProcedure |
---|
| 839 | def taskProcedureInstance |
---|
| 840 | |
---|
| 841 | taskProcedureInstance = new TaskProcedure(name: "Daily check") |
---|
| 842 | saveAndTest(taskProcedureInstance) |
---|
| 843 | taskProcedureInstance.addToTasks(Task.get(1)) |
---|
| 844 | } |
---|
| 845 | |
---|
| 846 | def createDemoMaintenanceActions() { |
---|
| 847 | |
---|
| 848 | //MaintenanceAction |
---|
| 849 | def maintenanceActionInstance |
---|
| 850 | |
---|
| 851 | //MaintenanceAction #1 |
---|
| 852 | maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run", |
---|
| 853 | procedureStepNumber: 1, |
---|
| 854 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 855 | taskProcedure: TaskProcedure.get(1)) |
---|
| 856 | saveAndTest(maintenanceActionInstance) |
---|
| 857 | |
---|
| 858 | //MaintenanceAction #2 |
---|
| 859 | maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups", |
---|
| 860 | procedureStepNumber: 2, |
---|
| 861 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 862 | taskProcedure: TaskProcedure.get(1)) |
---|
| 863 | saveAndTest(maintenanceActionInstance) |
---|
| 864 | |
---|
| 865 | //MaintenanceAction #3 |
---|
| 866 | maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup", |
---|
| 867 | procedureStepNumber: 3, |
---|
| 868 | maintenancePolicy: MaintenancePolicy.get(1), |
---|
| 869 | taskProcedure: TaskProcedure.get(1)) |
---|
| 870 | saveAndTest(maintenanceActionInstance) |
---|
| 871 | } |
---|
| 872 | |
---|
| 873 | def createDemoSystemSections() { |
---|
| 874 | |
---|
| 875 | //SystemSection |
---|
| 876 | def systemSectionInstance |
---|
| 877 | |
---|
| 878 | //SystemSection #1 |
---|
| 879 | systemSectionInstance = new SystemSection(name: "Press Section", |
---|
[162] | 880 | site: Site.get(1), |
---|
| 881 | department: Department.get(1)) |
---|
[149] | 882 | saveAndTest(systemSectionInstance) |
---|
| 883 | |
---|
| 884 | //SystemSection #2 |
---|
| 885 | systemSectionInstance = new SystemSection(name: "RO System", |
---|
[162] | 886 | site: Site.get(2), |
---|
| 887 | department: Department.get(2)) |
---|
[149] | 888 | saveAndTest(systemSectionInstance) |
---|
| 889 | |
---|
| 890 | //SystemSection #3 |
---|
| 891 | systemSectionInstance = new SystemSection(name: "Auxilliray Section", |
---|
[162] | 892 | site: Site.get(1), |
---|
| 893 | department: Department.get(1)) |
---|
[149] | 894 | saveAndTest(systemSectionInstance) |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | def createDemoAssetTypes() { |
---|
| 898 | |
---|
| 899 | //AssetType |
---|
| 900 | def assetTypeInstance |
---|
| 901 | |
---|
| 902 | //AssetType #1 |
---|
| 903 | assetTypeInstance = new AssetType(name: "Print Unit") |
---|
| 904 | saveAndTest(assetTypeInstance) |
---|
| 905 | |
---|
| 906 | //AssetType #2 |
---|
| 907 | assetTypeInstance = new AssetType(name: "Reactor Tower") |
---|
| 908 | saveAndTest(assetTypeInstance) |
---|
| 909 | } |
---|
| 910 | |
---|
| 911 | def createDemoAssemblies() { |
---|
| 912 | |
---|
| 913 | //Assembly |
---|
| 914 | def assemblyInstance |
---|
| 915 | |
---|
| 916 | //Assembly #1 |
---|
| 917 | assemblyInstance = new Assembly(name: "Print Couple", |
---|
| 918 | assetType: AssetType.get(1)) |
---|
| 919 | saveAndTest(assemblyInstance) |
---|
| 920 | // assemblyInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
| 921 | |
---|
| 922 | //Assembly #2 |
---|
| 923 | assemblyInstance = new Assembly(name: "Agitator", |
---|
| 924 | assetType: AssetType.get(2)) |
---|
| 925 | saveAndTest(assemblyInstance) |
---|
| 926 | } |
---|
| 927 | |
---|
| 928 | def createDemoSubAssemblies() { |
---|
| 929 | |
---|
| 930 | //SubAssembly |
---|
| 931 | def subAssemblyInstance |
---|
| 932 | |
---|
| 933 | //SubAssembly #1 |
---|
| 934 | subAssemblyInstance = new SubAssembly(name: "Cylinder", |
---|
| 935 | assembly: Assembly.get(1)) |
---|
| 936 | saveAndTest(subAssemblyInstance) |
---|
| 937 | |
---|
| 938 | //SubAssembly #2 |
---|
| 939 | subAssemblyInstance = new SubAssembly(name: "Gearmotor", |
---|
| 940 | assembly: Assembly.get(2)) |
---|
| 941 | saveAndTest(subAssemblyInstance) |
---|
| 942 | } |
---|
| 943 | |
---|
| 944 | def createDemoComponentItems() { |
---|
| 945 | |
---|
| 946 | //ComponentItem |
---|
| 947 | def componentItemInstance |
---|
| 948 | |
---|
| 949 | //ComponentItem #1 |
---|
| 950 | componentItemInstance = new ComponentItem(name: "Bearing", |
---|
| 951 | subAssembly: SubAssembly.get(1)) |
---|
| 952 | saveAndTest(componentItemInstance) |
---|
| 953 | |
---|
| 954 | //ComponentItem #2 |
---|
| 955 | componentItemInstance = new ComponentItem(name: "Drive shaft oil seal", |
---|
| 956 | subAssembly: SubAssembly.get(2)) |
---|
| 957 | saveAndTest(componentItemInstance) |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | def createDemoAssets() { |
---|
| 961 | |
---|
| 962 | //Asset |
---|
| 963 | def assetInstance |
---|
| 964 | |
---|
| 965 | //Asset #1 |
---|
| 966 | assetInstance = new Asset(name: "Print Unit 22", |
---|
| 967 | assetType: AssetType.get(1), |
---|
| 968 | systemSection: SystemSection.get(1)) |
---|
| 969 | saveAndTest(assetInstance) |
---|
| 970 | // assetInstance.addToMaintenanceActions(MaintenanceAction.get(1)) |
---|
| 971 | |
---|
| 972 | //Asset #2 |
---|
| 973 | assetInstance = new Asset(name: "Print Unit 21", |
---|
| 974 | assetType: AssetType.get(1), |
---|
| 975 | systemSection: SystemSection.get(1)) |
---|
| 976 | saveAndTest(assetInstance) |
---|
| 977 | |
---|
| 978 | //Asset #3 |
---|
| 979 | assetInstance = new Asset(name: "Print Unit 23", |
---|
| 980 | assetType: AssetType.get(1), |
---|
| 981 | systemSection: SystemSection.get(1)) |
---|
| 982 | saveAndTest(assetInstance) |
---|
| 983 | |
---|
| 984 | //Asset #4 |
---|
| 985 | assetInstance = new Asset(name: "RO 1", |
---|
| 986 | assetType: AssetType.get(2), |
---|
| 987 | systemSection: SystemSection.get(2)) |
---|
| 988 | saveAndTest(assetInstance) |
---|
| 989 | } |
---|
| 990 | |
---|
| 991 | def createBaseAssetExtenededAttributeTypes() { |
---|
| 992 | |
---|
| 993 | //AssetExtendedAttributeType |
---|
| 994 | def assetExtendedAttributeInstanceType |
---|
| 995 | |
---|
| 996 | //AssetExtendedAttributeType #1 |
---|
| 997 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Model Number") |
---|
| 998 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 999 | |
---|
| 1000 | //AssetExtendedAttributeType #2 |
---|
| 1001 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Purchase Cost") |
---|
| 1002 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1003 | |
---|
| 1004 | //AssetExtendedAttributeType #3 |
---|
| 1005 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Serial Number") |
---|
| 1006 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1007 | |
---|
| 1008 | //AssetExtendedAttributeType #4 |
---|
| 1009 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Manufactured Date") |
---|
| 1010 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1011 | |
---|
| 1012 | //AssetExtendedAttributeType #5 |
---|
| 1013 | assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Location Description") |
---|
| 1014 | saveAndTest(assetExtendedAttributeInstanceType) |
---|
| 1015 | } |
---|
| 1016 | |
---|
| 1017 | def createDemoAssetExtenedAttributes() { |
---|
| 1018 | |
---|
| 1019 | //AssetExtendedAttribute |
---|
| 1020 | def assetExtendedAttributeInstance |
---|
| 1021 | |
---|
| 1022 | //AssetExtendedAttribute #1 |
---|
| 1023 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2", |
---|
| 1024 | asset: Asset.get(1), |
---|
| 1025 | assetExtendedAttributeType: AssetExtendedAttributeType.get(1)) |
---|
| 1026 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1027 | |
---|
| 1028 | //AssetExtendedAttribute #2 |
---|
| 1029 | assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5", |
---|
| 1030 | asset: Asset.get(1), |
---|
| 1031 | assetExtendedAttributeType: AssetExtendedAttributeType.get(5)) |
---|
| 1032 | saveAndTest(assetExtendedAttributeInstance) |
---|
| 1033 | } |
---|
| 1034 | |
---|
| 1035 | |
---|
| 1036 | /**************************************** |
---|
| 1037 | Call this function instead of .save() |
---|
| 1038 | *****************************************/ |
---|
| 1039 | private boolean saveAndTest(object) { |
---|
| 1040 | if(!object.save()) { |
---|
| 1041 | // DemoDataSuccessful = false |
---|
| 1042 | println "'${object}' failed to save!" |
---|
| 1043 | println object.errors |
---|
| 1044 | return false |
---|
| 1045 | } |
---|
| 1046 | return true |
---|
| 1047 | } |
---|
| 1048 | } |
---|