source: trunk/grails-app/conf/BootStrap.groovy @ 145

Last change on this file since 145 was 145, checked in by gav, 15 years ago

Minor bootstrap change, adjust security to accept all /plugin/ urls.
Tested every dateChooser under the sun only to come back to RichUI, only needs to support "EEE, dd-MMM-yyyy" format and have dropdowns for year and month and it would be perfect.
Placed a dateChooser on Task Create view.

File size: 36.7 KB
RevLine 
[58]1import grails.util.GrailsUtil
[55]2
[58]3class BootStrap 
4{
5    //Required to be right here for Acegi plugin.
6    def authenticateService
7    Boolean BootStrapDemoDataSuccessful = true
8
9    def init = { servletContext ->
10
11    println "**** BootStrap GrailsUtil.environment = ${GrailsUtil.environment}"
12   
13        switch (GrailsUtil.environment)
14        {
15            case "development":
16                        bootStrapDemoData()
17                        break
18            case "test":
19                        break
20            case "production":
21                        bootStrapDemoData()
22                        break 
23        }
24   
25    }
26
27    def destroy = {
28    }
29
30    //Insert some demo/startup data.
31    void bootStrapDemoData()
32    {
33        println "BootStrapping demo data..."
[136]34        3.times{println it}
[118]35
[122]36/***********************
37START OF UTILITIES
38***********************/
[118]39
[122]40//Site
41        def siteInstance
[118]42
[122]43        siteInstance = new Site(name: "Creek Mill")
44        BootStrapSaveAndTest(siteInstance)
45
46        siteInstance = new Site(name: "Jasper Street Depot")
47        BootStrapSaveAndTest(siteInstance)
48
49//UnitOfMeasure
50        def unitOfMeasureInstance
51
52        //UnitOfMeasure #1
53        unitOfMeasureInstance = new UnitOfMeasure(name: "each")
54        BootStrapSaveAndTest(unitOfMeasureInstance)
55
56        //UnitOfMeasure #2
57        unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)")
58        BootStrapSaveAndTest(unitOfMeasureInstance)
59
60        //UnitOfMeasure #3
61        unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)")
62        BootStrapSaveAndTest(unitOfMeasureInstance)
63
64        //UnitOfMeasure #4
65        unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)")
66        BootStrapSaveAndTest(unitOfMeasureInstance)
67
68        //UnitOfMeasure #5
69        unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)")
70        BootStrapSaveAndTest(unitOfMeasureInstance)
71
72//Period
73        def periodInstance
74
75        //Period #1
76        periodInstance = new Period(period: "Day(s)")
77        BootStrapSaveAndTest(periodInstance)
78
79        //Period #2
80        periodInstance = new Period(period: "Week(s)")
81        BootStrapSaveAndTest(periodInstance)
82
83        //Period #3
84        periodInstance = new Period(period: "Month(s)")
85        BootStrapSaveAndTest(periodInstance)
86
87        //Period #4
88        periodInstance = new Period(period: "Year(s)")
89        BootStrapSaveAndTest(periodInstance)
90
91/*********************
92START OF PERSON
93*********************/
94
[116]95//TypeOfPersonGroup
[64]96        def personGroupTypeInstance
97        personGroupTypeInstance = new PersonGroupType(name:"Department")
98        BootStrapSaveAndTest(personGroupTypeInstance)
99        personGroupTypeInstance = new PersonGroupType(name:"Contractor")
100        BootStrapSaveAndTest(personGroupTypeInstance)
101        personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam")
102        BootStrapSaveAndTest(personGroupTypeInstance)
[58]103   
[116]104//PersonGroup
[64]105        def personGroupInstance
106        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
107                        name:"Electrical")
108        BootStrapSaveAndTest(personGroupInstance)
109        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
110                        name:"Mechanical")
111        BootStrapSaveAndTest(personGroupInstance)
112        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
113                        name:"Production")
114        BootStrapSaveAndTest(personGroupInstance)
115        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2),
116                        name:"Kewl AirCon Guys")
117        BootStrapSaveAndTest(personGroupInstance)
118        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3),
119                        name:"gnuMims")
120        BootStrapSaveAndTest(personGroupInstance)
[58]121
[116]122//Authority
[59]123        def authInstance
124
[102]125        authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.",
[71]126                                        authority:"ROLE_AppAdmin")
[59]127        BootStrapSaveAndTest(authInstance)
128
[91]129        authInstance = new Authority(description:"Business manager, grants full management access.",
130                                        authority:"ROLE_Manager")
131        BootStrapSaveAndTest(authInstance)
132
133        authInstance = new Authority(description:"Application User, all application users need this base role to allow login.",
[71]134                                        authority:"ROLE_AppUser")
[59]135        BootStrapSaveAndTest(authInstance)
[58]136           
[116]137//Person
[73]138        def passClearText = "pass"
139        def passwordEncoded = authenticateService.encodePassword(passClearText)
[59]140        def personInstance
[58]141
[102]142        //Person #1
[59]143        personInstance = new Person(loginName:"admin",
[58]144                                    firstName:"Admin",
145                                    lastName:"Powers",
[73]146                                    pass:passClearText,
[59]147                                    password:passwordEncoded,
[58]148                                    email:"admin@example.com")
149        BootStrapSaveAndTest(personInstance)
[59]150        personInstance.addToAuthorities(Authority.get(1))
151        personInstance.addToAuthorities(Authority.get(2))
[91]152        personInstance.addToAuthorities(Authority.get(3))
[66]153        personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims"))
[58]154
[102]155        //Person #2
[91]156        personInstance = new Person(loginName:"manager",
[145]157                                    firstName:"Demo",
[91]158                                    lastName:"Manager",
[73]159                                    pass:passClearText,
160                                    password:passwordEncoded,
[91]161                                    email:"manager@example.com")
[73]162        BootStrapSaveAndTest(personInstance)
163        personInstance.addToAuthorities(Authority.get(2))
[91]164        personInstance.addToAuthorities(Authority.get(3))
[73]165        personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims"))
166
[102]167        //Person #3
[59]168        personInstance = new Person(loginName:"user",
169                                    firstName:"Demo",
[102]170                                    lastName:"User",
[73]171                                    pass:passClearText,
[59]172                                    password:passwordEncoded,
173                                    email:"user@example.com")
174        BootStrapSaveAndTest(personInstance)
[91]175        personInstance.addToAuthorities(Authority.get(3))
[66]176        personInstance.addToPersonGroups(PersonGroup.findByName("Electrical"))
[58]177
[102]178        //Person #4
[59]179        personInstance = new Person(loginName:"craig",
180                                    firstName:"Craig",
[102]181                                    lastName:"SuperSparky",
[73]182                                    pass:passClearText,
[59]183                                    password:passwordEncoded,
184                                    email:"user@example.com")
185        BootStrapSaveAndTest(personInstance)
[91]186        personInstance.addToAuthorities(Authority.get(3))
[66]187        personInstance.addToPersonGroups(PersonGroup.findByName("Electrical"))
[58]188
[102]189        //Person #5
[73]190        personInstance = new Person(loginName:"john",
191                                    firstName:"John",
[102]192                                    lastName:"SuperFitter",
[73]193                                    pass:passClearText,
[59]194                                    password:passwordEncoded,
195                                    email:"user@example.com")
196        BootStrapSaveAndTest(personInstance)
[91]197        personInstance.addToAuthorities(Authority.get(3))
[66]198        personInstance.addToPersonGroups(PersonGroup.findByName("Mechanical"))
[58]199
[102]200        //Person #6
[59]201        personInstance = new Person(loginName:"mann",
202                                    firstName:"Production",
203                                    lastName:"Mann",
[73]204                                    pass:passClearText,
[59]205                                    password:passwordEncoded,
206                                    email:"user@example.com")
207        BootStrapSaveAndTest(personInstance)
[91]208        personInstance.addToAuthorities(Authority.get(3))
[66]209        personInstance.addToPersonGroups(PersonGroup.findByName("Production"))
210
[122]211/*********************
212START OF TASK
213*********************/
214
[116]215//TaskGroup
[69]216        def taskGroupInstance
217
218        taskGroupInstance = new TaskGroup(name:"Engineering Activites",
[131]219                                                                            description:"Engineering daily activities")
[69]220        BootStrapSaveAndTest(taskGroupInstance)
221
222        taskGroupInstance = new TaskGroup(name:"Production Activites",
[131]223                                                                            description:"Production daily activities")
[69]224        BootStrapSaveAndTest(taskGroupInstance)
225
226        taskGroupInstance = new TaskGroup(name:"New Projects",
[131]227                                                                            description:" ")
[69]228        BootStrapSaveAndTest(taskGroupInstance)
229
[116]230//TaskStatus
[66]231        def taskStatusInstance
232   
233        taskStatusInstance = new TaskStatus(name:"Not Started")
234        BootStrapSaveAndTest(taskStatusInstance)
235
236        taskStatusInstance = new TaskStatus(name:"In Progress")
237        BootStrapSaveAndTest(taskStatusInstance)
238
239        taskStatusInstance = new TaskStatus(name:"Completed")
240        BootStrapSaveAndTest(taskStatusInstance)
241
[116]242//TaskPriority
[69]243        def taskPriorityInstance
[66]244
[127]245        taskPriorityInstance = new TaskPriority(name:"Normal")
[69]246        BootStrapSaveAndTest(taskPriorityInstance)
[66]247
[127]248        taskPriorityInstance = new TaskPriority(name:"Low")
[69]249        BootStrapSaveAndTest(taskPriorityInstance)
[66]250
[69]251        taskPriorityInstance = new TaskPriority(name:"High")
252        BootStrapSaveAndTest(taskPriorityInstance)
[66]253
[69]254        taskPriorityInstance = new TaskPriority(name:"Immediate")
255        BootStrapSaveAndTest(taskPriorityInstance)
256
[116]257//TaskType
[69]258        def taskTypeInstance
259
260        taskTypeInstance = new TaskType(name:"Unscheduled Breakin")
261        BootStrapSaveAndTest(taskTypeInstance)
262
[131]263        taskTypeInstance = new TaskType(name:"Preventative Maintenance")
[69]264        BootStrapSaveAndTest(taskTypeInstance)
265
266        taskTypeInstance = new TaskType(name:"Project")
267        BootStrapSaveAndTest(taskTypeInstance)
268
269        taskTypeInstance = new TaskType(name:"Turnaround")
270        BootStrapSaveAndTest(taskTypeInstance)
271
272        taskTypeInstance = new TaskType(name:"Production Run")
273        BootStrapSaveAndTest(taskTypeInstance)
274
[116]275//Task
[66]276        def taskInstance
[58]277
[116]278        //Task #1
[66]279        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
280                 taskStatus:TaskStatus.findByName("Not Started"),
[69]281                 taskPriority:TaskPriority.get(2),
282                 taskType:TaskType.get(1),
[140]283                 leadPerson:Person.get(2),
[66]284                 description:"Check specific level sensor",
[142]285                 comment:"Has been noted as problematic, try recalibrating.",
286                targetStartDate:new Date())
[66]287        BootStrapSaveAndTest(taskInstance)
288
[116]289        //Task #2
[114]290        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
291                taskStatus:TaskStatus.findByName("Not Started"),
292                taskPriority:TaskPriority.get(2),
293                taskType:TaskType.get(1),
294                leadPerson:Person.get(5),
295                description:"Some follow-up work",
296                comment:"Some help required",
[142]297                targetStartDate:new Date()+1,
[114]298                parentTask: Task.get(1))
299        BootStrapSaveAndTest(taskInstance)
[69]300
[116]301        //Task #3
[114]302        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
303                taskStatus:TaskStatus.findByName("Not Started"),
304                taskPriority:TaskPriority.get(2),
305                taskType:TaskType.get(1),
306                leadPerson:Person.get(5),
307                description:"A Sub Task can be created by setting the Parent Task value",
308                comment:"Some help required",
[142]309                targetStartDate:new Date()-1,
[114]310                parentTask: Task.get(1))
311        BootStrapSaveAndTest(taskInstance)
312
[116]313        //Task #4
[114]314        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
[84]315                 taskStatus:TaskStatus.findByName("Not Started"),
316                 taskPriority:TaskPriority.get(2),
317                 taskType:TaskType.get(1),
[102]318                 leadPerson:Person.get(4),
[84]319                 description:"Replace sensor at next opportunity.",
[114]320                 comment:"Nothing else has worked.",
[142]321                targetStartDate:new Date()+7,
[114]322                parentTask: Task.get(1))
323        BootStrapSaveAndTest(taskInstance)
[84]324
[116]325        //Task #5
[66]326        taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"),
327                 taskStatus:TaskStatus.findByName("Not Started"),
[69]328                 taskPriority:TaskPriority.get(2),
329                 taskType:TaskType.get(5),
[102]330                 leadPerson:Person.get(6),
[66]331                 description:"Production Report",
[142]332                 comment:"Production report for specific production run or shift",
333                targetStartDate:new Date()-7)
[66]334        BootStrapSaveAndTest(taskInstance)
335
[116]336        //Task #6
[69]337        taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"),
[66]338                 taskStatus:TaskStatus.findByName("Not Started"),
[69]339                 taskPriority:TaskPriority.get(2),
340                 taskType:TaskType.get(3),
[66]341                 leadPerson:Person.get(1),
342                 description:"Make killer CMMS app",
[142]343                 comment:"Use Grails and get a move on!",
344                targetStartDate:new Date()-6)
[66]345        BootStrapSaveAndTest(taskInstance)
346
[116]347//EntryType
[66]348        def entryTypeInstance
[58]349
[66]350        entryTypeInstance = new EntryType(name:"Fault")
351        BootStrapSaveAndTest(entryTypeInstance)
352
353        entryTypeInstance = new EntryType(name:"WorkDone")
354        BootStrapSaveAndTest(entryTypeInstance)
355
[69]356        entryTypeInstance = new EntryType(name:"Production Note")
[66]357        BootStrapSaveAndTest(entryTypeInstance)
358
359        entryTypeInstance = new EntryType(name:"Work Request")
360        BootStrapSaveAndTest(entryTypeInstance)
361
[116]362//Entry
[84]363        def entryInstance
364
[116]365        //Entry #1
[137]366        entryInstance = new Entry(enteredBy: Person.get(3),
[84]367                                                    task: Task.get(1),
368                                                    entryType: EntryType.findByName("Fault"),
369                                                    comment: "This level sensor is causing us trouble.",
370                                                    durationMinute: 20)
371        BootStrapSaveAndTest(entryInstance)
372
[116]373        //Entry #2
[84]374        entryInstance = new Entry(enteredBy: Person.get(4),
375                                                    task: Task.get(1),
376                                                    entryType: EntryType.findByName("WorkDone"),
377                                                    comment: "Cleaned sensor, see how it goes.",
378                                                    durationMinute: 30)
379        BootStrapSaveAndTest(entryInstance)
380
[116]381        //Entry #3
[84]382        entryInstance = new Entry(enteredBy: Person.get(4),
383                                                    task: Task.get(1),
384                                                    entryType: EntryType.findByName("WorkDone"),
385                                                    comment: "Checked up on it later and sensor is dropping out intermittently, created subTask to replace sensor.",
386                                                    durationMinute: 20)
387        BootStrapSaveAndTest(entryInstance)
388
[116]389//ModificationType
[93]390        def taskModificationTypeInstance
391        taskModificationTypeInstance = new TaskModificationType(name:"Created").save()
392        taskModificationTypeInstance = new TaskModificationType(name:"Completed").save()
393        taskModificationTypeInstance = new TaskModificationType(name:"Closed").save()
394        taskModificationTypeInstance = new TaskModificationType(name:"Altered").save()
395        taskModificationTypeInstance = new TaskModificationType(name:"TargetDateModified").save()
396        taskModificationTypeInstance = new TaskModificationType(name:"ScheduledDateModified").save()
397        taskModificationTypeInstance = new TaskModificationType(name:"DescriptionModified").save()
398        taskModificationTypeInstance = new TaskModificationType(name:"AssignedToModified").save()
399        taskModificationTypeInstance = new TaskModificationType(name:"NameModified").save()
[96]400   
[116]401//AssignedPerson
[96]402        def assignedPersonInstance
403
[116]404        //AssignedPerson #1
[96]405        assignedPersonInstance = new AssignedPerson(person: Person.get(4),
406                                                                                        task: Task.get(1),
407                                                                                        estimatedHour: 1,
408                                                                                        estimatedMinute: 20)
409        BootStrapSaveAndTest(assignedPersonInstance)
410
[116]411        //AssignedPerson #2
[96]412        assignedPersonInstance = new AssignedPerson(person: Person.get(5),
413                                                                                        task: Task.get(1),
414                                                                                        estimatedHour: 3,
415                                                                                        estimatedMinute: 30)
416        BootStrapSaveAndTest(assignedPersonInstance)
417
[131]418//TaskRecurringSchedule
419        def taskRecurringScheduleInstance
[118]420
[131]421        //TaskRecurringSchedule #1
422        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(1),
423                                                                                                    recurEvery: 1,
[136]424                                                                                                    recurPeriod: Period.get(1),
425                                                                                                    startDate: new Date(),
426                                                                                                    generateAhead: 1,
427                                                                                                    generateAheadPeriod: Period.get(1),
428                                                                                                    taskDuration: 1,
429                                                                                                    taskDurationPeriod: Period.get(1))
[131]430        BootStrapSaveAndTest(taskRecurringScheduleInstance)
[118]431
[131]432        //TaskRecurringSchedule #2
433        taskRecurringScheduleInstance = new TaskRecurringSchedule(task: Task.get(2),
434                                                                                                    recurEvery: 1,
[136]435                                                                                                    recurPeriod: Period.get(1),
436                                                                                                    startDate: new Date(),
437                                                                                                    generateAhead: 1,
438                                                                                                    generateAheadPeriod: Period.get(1),
439                                                                                                    taskDuration: 1,
440                                                                                                    taskDurationPeriod: Period.get(1))
[131]441        BootStrapSaveAndTest(taskRecurringScheduleInstance)
[124]442
[122]443/*************************
444START OF INVENTORY
445**************************/
[96]446
[116]447//InventoryStore
[124]448        def inventoryStoreInstance
[117]449
450        inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1")
[116]451        BootStrapSaveAndTest(inventoryStoreInstance)
452
[117]453        inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2")
454        BootStrapSaveAndTest(inventoryStoreInstance)
455
[116]456//StoreLocation
[117]457        def storeLocation
458       
459        storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "A1-2")
[116]460        BootStrapSaveAndTest(storeLocation)
461
[117]462        storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "C55")
463        BootStrapSaveAndTest(storeLocation)
464
[116]465//InventoryGroup
466        def inventoryGroupInstance
467
[117]468        //InventoryGroup #1
[116]469        inventoryGroupInstance = new InventoryGroup(name: "Misc")
470        BootStrapSaveAndTest(inventoryGroupInstance)
471
[117]472        //InventoryGroup #2
473        inventoryGroupInstance = new InventoryGroup(name: "Electrical")
474        BootStrapSaveAndTest(inventoryGroupInstance)
475
476        //InventoryGroup #3
477        inventoryGroupInstance = new InventoryGroup(name: "Mechanical")
478        BootStrapSaveAndTest(inventoryGroupInstance)
479
480        //InventoryGroup #4
481        inventoryGroupInstance = new InventoryGroup(name: "Production")
482        BootStrapSaveAndTest(inventoryGroupInstance)
483
[116]484//InventoryType
485        def inventoryTypeInstance
486
487        inventoryTypeInstance = new InventoryType(name: "Consumable")
488        BootStrapSaveAndTest(inventoryTypeInstance)
489
490        inventoryTypeInstance = new InventoryType(name: "Repairable")
491        BootStrapSaveAndTest(inventoryTypeInstance)
492
493//InventoryItem
494        def inventoryItemInstance
495
[117]496        //InventoryItem #1
[116]497        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1),
498                                                                                    inventoryType: InventoryType.get(1),
[117]499                                                                                    unitOfMeasure: UnitOfMeasure.get(2),
500                                                                                    name: "J-Rope",
501                                                                                    description: "Twine wound J-Rope",
502                                                                                    reorderPoint: 0)
503        BootStrapSaveAndTest(inventoryItemInstance)
504
505        //InventoryItem #2
506        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1),
507                                                                                    inventoryType: InventoryType.get(1),
508                                                                                    unitOfMeasure: UnitOfMeasure.get(2),
509                                                                                    name: "L-Rope",
510                                                                                    description: "Twine wound L-Rope",
511                                                                                    alternateItems: InventoryItem.get(1),
512                                                                                    reorderPoint: 0)
513        BootStrapSaveAndTest(inventoryItemInstance)
514
515        //InventoryItem #3
516        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3),
517                                                                                    inventoryType: InventoryType.get(1),
[116]518                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
[117]519                                                                                    name: "2305-2RS",
520                                                                                    description: "Bearing 25x62x24mm double row self aligning ball",
521                                                                                    reorderPoint: 2)
522        BootStrapSaveAndTest(inventoryItemInstance)
523
524        //InventoryItem #4
525        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2),
526                                                                                    inventoryType: InventoryType.get(1),
527                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
528                                                                                    name: "L1592-K10",
529                                                                                    description: "10kW contactor",
[116]530                                                                                    reorderPoint: 0)
531        BootStrapSaveAndTest(inventoryItemInstance)
532
[117]533        //InventoryItem #5
534        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3),
535                                                                                    inventoryType: InventoryType.get(1),
536                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
537                                                                                    name: "6205-ZZ",
538                                                                                    description: "Bearing 25x52x15mm single row ball shielded",
539                                                                                    reorderPoint: 2)
540        BootStrapSaveAndTest(inventoryItemInstance)
541
[116]542//StoredItem
543        def storedItemInstance
544
[117]545        //StoredItem #1
[116]546        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1),
547                                                                            storeLocation: StoreLocation.get(1),
548                                                                            quantity: 8)
549        BootStrapSaveAndTest(storedItemInstance)
550
[117]551        //StoredItem #2
552        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1),
553                                                                            storeLocation: StoreLocation.get(2),
554                                                                            quantity: 4)
555        BootStrapSaveAndTest(storedItemInstance)
556
557        //StoredItem #3
558        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(2),
559                                                                            storeLocation: StoreLocation.get(1),
560                                                                            quantity: 2)
561        BootStrapSaveAndTest(storedItemInstance)
562
563        //StoredItem #4
564        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(3),
565                                                                            storeLocation: StoreLocation.get(1),
566                                                                            quantity: 2)
567        BootStrapSaveAndTest(storedItemInstance)
568
569        //StoredItem #5
570        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(4),
571                                                                            storeLocation: StoreLocation.get(1),
572                                                                            quantity: 30)
573        BootStrapSaveAndTest(storedItemInstance)
574
[118]575/*******************
576START OF ASSET
577*******************/
578
[122]579//LifePlan
580        def lifeplanInstance
[118]581
[122]582        lifeplanInstance = new LifePlan(name: "Initial Plan")
583        BootStrapSaveAndTest(lifeplanInstance)
[118]584
[122]585//MaintenancePolicy
[124]586        def maintenancePolicyInstance
[118]587
[122]588        //MaintenancePolicy #1
589        maintenancePolicyInstance = new MaintenancePolicy(name: "Fixed Time")
590        BootStrapSaveAndTest(maintenancePolicyInstance)
[118]591
[124]592        //MaintenancePolicy #2
593        maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Online")
594        BootStrapSaveAndTest(maintenancePolicyInstance)
595
596        //MaintenancePolicy #3
597        maintenancePolicyInstance = new MaintenancePolicy(name: "Condition Based Offline")
598        BootStrapSaveAndTest(maintenancePolicyInstance)
599
600        //MaintenancePolicy #4
601        maintenancePolicyInstance = new MaintenancePolicy(name: "Design Out")
602        BootStrapSaveAndTest(maintenancePolicyInstance)
603
604        //MaintenancePolicy #5
605        maintenancePolicyInstance = new MaintenancePolicy(name: "Operate To Failure")
606        BootStrapSaveAndTest(maintenancePolicyInstance)
607
[131]608//TaskProcedure
609        def taskProcedureInstance
[118]610
[131]611        taskProcedureInstance = new TaskProcedure(name: "Daily check")
612        BootStrapSaveAndTest(taskProcedureInstance)
613        taskProcedureInstance.addToTasks(Task.get(1))
[118]614
[122]615//MaintenanceAction
616        def maintenanceActionInstance
[118]617
[124]618        //MaintenanceAction #1
[137]619        maintenanceActionInstance = new MaintenanceAction(description: "Check all E-stops, activate E-stops S1-S12 and ensure machine cannot run",
[131]620                                                                                                        procedureStepNumber: 1,
[122]621                                                                                                        maintenancePolicy: MaintenancePolicy.get(1),
[131]622                                                                                                        taskProcedure: TaskProcedure.get(1))
[122]623        BootStrapSaveAndTest(maintenanceActionInstance)
[124]624
625        //MaintenanceAction #2
[131]626        maintenanceActionInstance = new MaintenanceAction(description: "Do more pushups",
627                                                                                                        procedureStepNumber: 2,
[124]628                                                                                                        maintenancePolicy: MaintenancePolicy.get(1),
[131]629                                                                                                        taskProcedure: TaskProcedure.get(1))
[124]630        BootStrapSaveAndTest(maintenanceActionInstance)
631
632        //MaintenanceAction #3
[131]633        maintenanceActionInstance = new MaintenanceAction(description: "Ok just one more pushup",
634                                                                                                        procedureStepNumber: 3,
[124]635                                                                                                        maintenancePolicy: MaintenancePolicy.get(1),
[131]636                                                                                                        taskProcedure: TaskProcedure.get(1))
[124]637        BootStrapSaveAndTest(maintenanceActionInstance)
[122]638                                                                                                   
[118]639//SystemSection
[124]640    def systemSectionInstance
[118]641
[124]642    //SystemSection #1
[118]643    systemSectionInstance = new SystemSection(name: "Press Section",
[122]644                                                                                   site: Site.get(1))
[118]645    BootStrapSaveAndTest(systemSectionInstance)
646
[124]647    //SystemSection #2
648    systemSectionInstance = new SystemSection(name: "RO System",
649                                                                                   site: Site.get(2))
650    BootStrapSaveAndTest(systemSectionInstance)
651
652    //SystemSection #3
653    systemSectionInstance = new SystemSection(name: "Auxilliray Section",
654                                                                                   site: Site.get(1))
655    BootStrapSaveAndTest(systemSectionInstance)
656
[118]657//AssetType
658        def assetTypeInstance
[122]659
660        //AssetType #1
[124]661        assetTypeInstance = new AssetType(name: "Print Unit")
[118]662        BootStrapSaveAndTest(assetTypeInstance)
663
[122]664        //AssetType #2
[124]665        assetTypeInstance = new AssetType(name: "Reactor Tower")
[118]666        BootStrapSaveAndTest(assetTypeInstance)
667   
668//Assembly
669        def assemblyInstance
[122]670
671        //Assembly #1
[131]672        assemblyInstance = new Assembly(name: "Print Couple",
673                                                                        assetType: AssetType.get(1))
[118]674        BootStrapSaveAndTest(assemblyInstance)
[122]675//        assemblyInstance.addToMaintenanceActions(MaintenanceAction.get(1))
676       
677        //Assembly #2
[124]678        assemblyInstance = new Assembly(name: "Agitator",
[131]679                                                                        assetType: AssetType.get(2))
[118]680        BootStrapSaveAndTest(assemblyInstance)
681
682//SubAssembly
683        def subAssemblyInstance
[122]684
685        //SubAssembly #1
[131]686        subAssemblyInstance = new SubAssembly(name: "Cylinder",
687                                                                                    assembly: Assembly.get(1))
[118]688        BootStrapSaveAndTest(subAssemblyInstance)
[122]689 
690         //SubAssembly #2
[131]691        subAssemblyInstance = new SubAssembly(name: "Gearmotor",
692                                                                                    assembly: Assembly.get(2))
[118]693        BootStrapSaveAndTest(subAssemblyInstance)
694
695//ComponentItem
[122]696        def componentItemInstance
697   
698        //ComponentItem #1
[131]699        componentItemInstance = new ComponentItem(name: "Bearing",
700                                                                                            subAssembly: SubAssembly.get(1))
[122]701        BootStrapSaveAndTest(componentItemInstance)
[118]702
[122]703         //ComponentItem #2
[131]704        componentItemInstance = new ComponentItem(name: "Drive shaft oil seal",
705                                                                                            subAssembly: SubAssembly.get(2))
[122]706        BootStrapSaveAndTest(componentItemInstance)
[118]707
708//Asset
709        def assetInstance
710
711        //Asset #1
[124]712        assetInstance = new Asset(name: "Print Unit 22",
713                                                        assetType: AssetType.get(1),
714                                                        systemSection: SystemSection.get(1))
715        BootStrapSaveAndTest(assetInstance)
716//        assetInstance.addToMaintenanceActions(MaintenanceAction.get(1))
717
718        //Asset #2
719        assetInstance = new Asset(name: "Print Unit 21",
720                                                        assetType: AssetType.get(1),
721                                                        systemSection: SystemSection.get(1))
722        BootStrapSaveAndTest(assetInstance)
723
724        //Asset #3
[118]725        assetInstance = new Asset(name: "Print Unit 23",
726                                                        assetType: AssetType.get(1),
[122]727                                                        systemSection: SystemSection.get(1))
[118]728        BootStrapSaveAndTest(assetInstance)
729
[124]730        //Asset #4
731        assetInstance = new Asset(name: "RO 1",
732                                                        assetType: AssetType.get(2),
733                                                        systemSection: SystemSection.get(2))
734        BootStrapSaveAndTest(assetInstance)
735
736//AssetExtendedAttributeType
737        def assetExtendedAttributeInstanceType
738
739        //AssetExtendedAttributeType #1
740        assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Model Number")
741        BootStrapSaveAndTest(assetExtendedAttributeInstanceType)
742
743        //AssetExtendedAttributeType #2
744        assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Purchase Cost")
745        BootStrapSaveAndTest(assetExtendedAttributeInstanceType)
746
747        //AssetExtendedAttributeType #3
748        assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Serial Number")
749        BootStrapSaveAndTest(assetExtendedAttributeInstanceType)
750
751        //AssetExtendedAttributeType #4
752        assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Manufactured Date")
753        BootStrapSaveAndTest(assetExtendedAttributeInstanceType)
754
755        //AssetExtendedAttributeType #5
756        assetExtendedAttributeInstanceType = new AssetExtendedAttributeType(name: "Location Description")
757        BootStrapSaveAndTest(assetExtendedAttributeInstanceType)
758
759//AssetExtendedAttribute
760        def assetExtendedAttributeInstance
761
762        //AssetExtendedAttribute #1
763        assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "PU Mark 2",
764                                                                                                                    asset: Asset.get(1),
765                                                                                                                    assetExtendedAttributeType: AssetExtendedAttributeType.get(1))
766        BootStrapSaveAndTest(assetExtendedAttributeInstance)
767
768        //AssetExtendedAttribute #2
769        assetExtendedAttributeInstance = new AssetExtendedAttribute(value: "On the far side of Tank 5",
770                                                                                                                    asset: Asset.get(1),
771                                                                                                                    assetExtendedAttributeType: AssetExtendedAttributeType.get(5))
772        BootStrapSaveAndTest(assetExtendedAttributeInstance)
773
774/*************************
775Finally did it all work.
776**************************/       
[58]777        if(BootStrapDemoDataSuccessful) {
778            println "BootStrapping demo data...successful."
779        }
780        else println "BootStrapping demo data...failed."
781    }
[116]782
[124]783/****************************************
784Call this function instead of .save()
785*****************************************/   
[58]786    void BootStrapSaveAndTest(object) {
787        if(!object.save()) {
788            BootStrapDemoDataSuccessful = false
789            println "'${object}' failed to save!"
790            println object.errors
791
792        }
793    } 
794}
Note: See TracBrowser for help on using the repository browser.