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

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

Delete ERD_Schema.odt and dataModel.png as no longer required.
Massive revision of ERD.
Slight tweak to BootStrap?.

File size: 27.5 KB
Line 
1import grails.util.GrailsUtil
2
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..."
34
35/*******************
36START OF TASK
37
38*******************/
39
40//TypeOfPersonGroup
41        def personGroupTypeInstance
42        personGroupTypeInstance = new PersonGroupType(name:"Department")
43        BootStrapSaveAndTest(personGroupTypeInstance)
44        personGroupTypeInstance = new PersonGroupType(name:"Contractor")
45        BootStrapSaveAndTest(personGroupTypeInstance)
46        personGroupTypeInstance = new PersonGroupType(name:"ProjectTeam")
47        BootStrapSaveAndTest(personGroupTypeInstance)
48   
49//PersonGroup
50        def personGroupInstance
51        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
52                        name:"Electrical")
53        BootStrapSaveAndTest(personGroupInstance)
54        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
55                        name:"Mechanical")
56        BootStrapSaveAndTest(personGroupInstance)
57        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
58                        name:"Production")
59        BootStrapSaveAndTest(personGroupInstance)
60        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(2),
61                        name:"Kewl AirCon Guys")
62        BootStrapSaveAndTest(personGroupInstance)
63        personGroupInstance = new PersonGroup(personGroupType:PersonGroupType.get(3),
64                        name:"gnuMims")
65        BootStrapSaveAndTest(personGroupInstance)
66
67//Authority
68        def authInstance
69
70        authInstance = new Authority(description:"Application Admin, not required for daily use! Grants full admin access to the application.",
71                                        authority:"ROLE_AppAdmin")
72        BootStrapSaveAndTest(authInstance)
73
74        authInstance = new Authority(description:"Business manager, grants full management access.",
75                                        authority:"ROLE_Manager")
76        BootStrapSaveAndTest(authInstance)
77
78        authInstance = new Authority(description:"Application User, all application users need this base role to allow login.",
79                                        authority:"ROLE_AppUser")
80        BootStrapSaveAndTest(authInstance)
81           
82//Person
83        def passClearText = "pass"
84        def passwordEncoded = authenticateService.encodePassword(passClearText)
85        def personInstance
86
87        //Person #1
88        personInstance = new Person(loginName:"admin",
89                                    firstName:"Admin",
90                                    lastName:"Powers",
91                                    pass:passClearText,
92                                    password:passwordEncoded,
93                                    email:"admin@example.com")
94        BootStrapSaveAndTest(personInstance)
95        personInstance.addToAuthorities(Authority.get(1))
96        personInstance.addToAuthorities(Authority.get(2))
97        personInstance.addToAuthorities(Authority.get(3))
98        personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims"))
99
100        //Person #2
101        personInstance = new Person(loginName:"manager",
102                                    firstName:"Meca",
103                                    lastName:"Manager",
104                                    pass:passClearText,
105                                    password:passwordEncoded,
106                                    email:"manager@example.com")
107        BootStrapSaveAndTest(personInstance)
108        personInstance.addToAuthorities(Authority.get(2))
109        personInstance.addToAuthorities(Authority.get(3))
110        personInstance.addToPersonGroups(PersonGroup.findByName("gnuMims"))
111
112        //Person #3
113        personInstance = new Person(loginName:"user",
114                                    firstName:"Demo",
115                                    lastName:"User",
116                                    pass:passClearText,
117                                    password:passwordEncoded,
118                                    email:"user@example.com")
119        BootStrapSaveAndTest(personInstance)
120        personInstance.addToAuthorities(Authority.get(3))
121        personInstance.addToPersonGroups(PersonGroup.findByName("Electrical"))
122
123        //Person #4
124        personInstance = new Person(loginName:"craig",
125                                    firstName:"Craig",
126                                    lastName:"SuperSparky",
127                                    pass:passClearText,
128                                    password:passwordEncoded,
129                                    email:"user@example.com")
130        BootStrapSaveAndTest(personInstance)
131        personInstance.addToAuthorities(Authority.get(3))
132        personInstance.addToPersonGroups(PersonGroup.findByName("Electrical"))
133
134        //Person #5
135        personInstance = new Person(loginName:"john",
136                                    firstName:"John",
137                                    lastName:"SuperFitter",
138                                    pass:passClearText,
139                                    password:passwordEncoded,
140                                    email:"user@example.com")
141        BootStrapSaveAndTest(personInstance)
142        personInstance.addToAuthorities(Authority.get(3))
143        personInstance.addToPersonGroups(PersonGroup.findByName("Mechanical"))
144
145        //Person #6
146        personInstance = new Person(loginName:"mann",
147                                    firstName:"Production",
148                                    lastName:"Mann",
149                                    pass:passClearText,
150                                    password:passwordEncoded,
151                                    email:"user@example.com")
152        BootStrapSaveAndTest(personInstance)
153        personInstance.addToAuthorities(Authority.get(3))
154        personInstance.addToPersonGroups(PersonGroup.findByName("Production"))
155
156//TaskGroup
157        def taskGroupInstance
158
159        taskGroupInstance = new TaskGroup(name:"Engineering Activites",
160                      description:"Engineering daily activities")
161        BootStrapSaveAndTest(taskGroupInstance)
162
163        taskGroupInstance = new TaskGroup(name:"Production Activites",
164                      description:"Production daily activities")
165        BootStrapSaveAndTest(taskGroupInstance)
166
167        taskGroupInstance = new TaskGroup(name:"New Projects",
168                      description:" ")
169        BootStrapSaveAndTest(taskGroupInstance)
170
171//TaskStatus
172        def taskStatusInstance
173   
174        taskStatusInstance = new TaskStatus(name:"Not Started")
175        BootStrapSaveAndTest(taskStatusInstance)
176
177        taskStatusInstance = new TaskStatus(name:"In Progress")
178        BootStrapSaveAndTest(taskStatusInstance)
179
180        taskStatusInstance = new TaskStatus(name:"Completed")
181        BootStrapSaveAndTest(taskStatusInstance)
182
183//TaskPriority
184        def taskPriorityInstance
185
186        taskPriorityInstance = new TaskPriority(name:"Low")
187        BootStrapSaveAndTest(taskPriorityInstance)
188
189        taskPriorityInstance = new TaskPriority(name:"Normal")
190        BootStrapSaveAndTest(taskPriorityInstance)
191
192        taskPriorityInstance = new TaskPriority(name:"High")
193        BootStrapSaveAndTest(taskPriorityInstance)
194
195        taskPriorityInstance = new TaskPriority(name:"Immediate")
196        BootStrapSaveAndTest(taskPriorityInstance)
197
198//TaskType
199        def taskTypeInstance
200
201        taskTypeInstance = new TaskType(name:"Unscheduled Breakin")
202        BootStrapSaveAndTest(taskTypeInstance)
203
204        taskTypeInstance = new TaskType(name:"Planned Maintenance")
205        BootStrapSaveAndTest(taskTypeInstance)
206
207        taskTypeInstance = new TaskType(name:"Project")
208        BootStrapSaveAndTest(taskTypeInstance)
209
210        taskTypeInstance = new TaskType(name:"Turnaround")
211        BootStrapSaveAndTest(taskTypeInstance)
212
213        taskTypeInstance = new TaskType(name:"Production Run")
214        BootStrapSaveAndTest(taskTypeInstance)
215
216//Task
217        def taskInstance
218
219        //Task #1
220        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
221                 taskStatus:TaskStatus.findByName("Not Started"),
222                 taskPriority:TaskPriority.get(2),
223                 taskType:TaskType.get(1),
224                 leadPerson:Person.get(3),
225                 description:"Check specific level sensor",
226                 comment:"Has been noted as problematic, try recallibrating")
227        BootStrapSaveAndTest(taskInstance)
228
229        //Task #2
230        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
231                taskStatus:TaskStatus.findByName("Not Started"),
232                taskPriority:TaskPriority.get(2),
233                taskType:TaskType.get(1),
234                leadPerson:Person.get(5),
235                description:"Some follow-up work",
236                comment:"Some help required",
237                parentTask: Task.get(1))
238        BootStrapSaveAndTest(taskInstance)
239
240        //Task #3
241        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
242                taskStatus:TaskStatus.findByName("Not Started"),
243                taskPriority:TaskPriority.get(2),
244                taskType:TaskType.get(1),
245                leadPerson:Person.get(5),
246                description:"A Sub Task can be created by setting the Parent Task value",
247                comment:"Some help required",
248                parentTask: Task.get(1))
249        BootStrapSaveAndTest(taskInstance)
250
251        //Task #4
252        taskInstance = new Task(taskGroup:TaskGroup.findByName("Engineering Activites"),
253                 taskStatus:TaskStatus.findByName("Not Started"),
254                 taskPriority:TaskPriority.get(2),
255                 taskType:TaskType.get(1),
256                 leadPerson:Person.get(4),
257                 description:"Replace sensor at next opportunity.",
258                 comment:"Nothing else has worked.",
259                parentTask: Task.get(1))
260        BootStrapSaveAndTest(taskInstance)
261
262        //Task #5
263        taskInstance = new Task(taskGroup:TaskGroup.findByName("Production Activites"),
264                 taskStatus:TaskStatus.findByName("Not Started"),
265                 taskPriority:TaskPriority.get(2),
266                 taskType:TaskType.get(5),
267                 leadPerson:Person.get(6),
268                 description:"Production Report",
269                 comment:"Production report for specific production run or shift")
270        BootStrapSaveAndTest(taskInstance)
271
272        //Task #6
273        taskInstance = new Task(taskGroup:TaskGroup.findByName("New Projects"),
274                 taskStatus:TaskStatus.findByName("Not Started"),
275                 taskPriority:TaskPriority.get(2),
276                 taskType:TaskType.get(3),
277                 leadPerson:Person.get(1),
278                 description:"Make killer CMMS app",
279                 comment:"Use Grails and get a move on!")
280        BootStrapSaveAndTest(taskInstance)
281
282//EntryType
283        def entryTypeInstance
284
285        entryTypeInstance = new EntryType(name:"Fault")
286        BootStrapSaveAndTest(entryTypeInstance)
287
288        entryTypeInstance = new EntryType(name:"WorkDone")
289        BootStrapSaveAndTest(entryTypeInstance)
290
291        entryTypeInstance = new EntryType(name:"Production Note")
292        BootStrapSaveAndTest(entryTypeInstance)
293
294        entryTypeInstance = new EntryType(name:"Work Request")
295        BootStrapSaveAndTest(entryTypeInstance)
296
297//Entry
298        def entryInstance
299
300        //Entry #1
301        entryInstance = new Entry(enteredBy: Person.get(6),
302                                                    task: Task.get(1),
303                                                    entryType: EntryType.findByName("Fault"),
304                                                    comment: "This level sensor is causing us trouble.",
305                                                    durationMinute: 20)
306        BootStrapSaveAndTest(entryInstance)
307
308        //Entry #2
309        entryInstance = new Entry(enteredBy: Person.get(4),
310                                                    task: Task.get(1),
311                                                    entryType: EntryType.findByName("WorkDone"),
312                                                    comment: "Cleaned sensor, see how it goes.",
313                                                    durationMinute: 30)
314        BootStrapSaveAndTest(entryInstance)
315
316        //Entry #3
317        entryInstance = new Entry(enteredBy: Person.get(4),
318                                                    task: Task.get(1),
319                                                    entryType: EntryType.findByName("WorkDone"),
320                                                    comment: "Checked up on it later and sensor is dropping out intermittently, created subTask to replace sensor.",
321                                                    durationMinute: 20)
322        BootStrapSaveAndTest(entryInstance)
323
324//ModificationType
325        def taskModificationTypeInstance
326        taskModificationTypeInstance = new TaskModificationType(name:"Created").save()
327        taskModificationTypeInstance = new TaskModificationType(name:"Completed").save()
328        taskModificationTypeInstance = new TaskModificationType(name:"Closed").save()
329        taskModificationTypeInstance = new TaskModificationType(name:"Altered").save()
330        taskModificationTypeInstance = new TaskModificationType(name:"TargetDateModified").save()
331        taskModificationTypeInstance = new TaskModificationType(name:"ScheduledDateModified").save()
332        taskModificationTypeInstance = new TaskModificationType(name:"DescriptionModified").save()
333        taskModificationTypeInstance = new TaskModificationType(name:"AssignedToModified").save()
334        taskModificationTypeInstance = new TaskModificationType(name:"NameModified").save()
335   
336//AssignedPerson
337        def assignedPersonInstance
338
339        //AssignedPerson #1
340        assignedPersonInstance = new AssignedPerson(person: Person.get(4),
341                                                                                        task: Task.get(1),
342                                                                                        estimatedHour: 1,
343                                                                                        estimatedMinute: 20)
344        BootStrapSaveAndTest(assignedPersonInstance)
345
346        //AssignedPerson #2
347        assignedPersonInstance = new AssignedPerson(person: Person.get(5),
348                                                                                        task: Task.get(1),
349                                                                                        estimatedHour: 3,
350                                                                                        estimatedMinute: 30)
351        BootStrapSaveAndTest(assignedPersonInstance)
352
353/*******************
354START OF INVENTORY
355
356*******************/
357
358//Site
359        def siteInstance
360
361        siteInstance = new Site(name: "Creek Mill")
362        BootStrapSaveAndTest(siteInstance)
363
364        siteInstance = new Site(name: "Jasper Street Depot")
365        BootStrapSaveAndTest(siteInstance)
366
367//InventoryStore
368        def inventoryStoreInstance
369
370        inventoryStoreInstance = new InventoryStore(site: Site.get(1), name: "Store #1")
371        BootStrapSaveAndTest(inventoryStoreInstance)
372
373        inventoryStoreInstance = new InventoryStore(site: Site.get(2), name: "Store #2")
374        BootStrapSaveAndTest(inventoryStoreInstance)
375
376//StoreLocation
377        def storeLocation
378       
379        storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "A1-2")
380        BootStrapSaveAndTest(storeLocation)
381
382        storeLocation = new StoreLocation(inventoryStore: InventoryStore.get(1), bin: "C55")
383        BootStrapSaveAndTest(storeLocation)
384
385//UnitOfMeasure
386        def unitOfMeasureInstance
387
388        //UnitOfMeasure #1
389        unitOfMeasureInstance = new UnitOfMeasure(name: "each")
390        BootStrapSaveAndTest(unitOfMeasureInstance)
391
392        //UnitOfMeasure #2
393        unitOfMeasureInstance = new UnitOfMeasure(name: "meter(s)")
394        BootStrapSaveAndTest(unitOfMeasureInstance)
395
396        //UnitOfMeasure #3
397        unitOfMeasureInstance = new UnitOfMeasure(name: "box(es)")
398        BootStrapSaveAndTest(unitOfMeasureInstance)
399
400        //UnitOfMeasure #4
401        unitOfMeasureInstance = new UnitOfMeasure(name: "litre(s)")
402        BootStrapSaveAndTest(unitOfMeasureInstance)
403
404        //UnitOfMeasure #5
405        unitOfMeasureInstance = new UnitOfMeasure(name: "kilogram(s)")
406        BootStrapSaveAndTest(unitOfMeasureInstance)
407
408//InventoryGroup
409        def inventoryGroupInstance
410
411        //InventoryGroup #1
412        inventoryGroupInstance = new InventoryGroup(name: "Misc")
413        BootStrapSaveAndTest(inventoryGroupInstance)
414
415        //InventoryGroup #2
416        inventoryGroupInstance = new InventoryGroup(name: "Electrical")
417        BootStrapSaveAndTest(inventoryGroupInstance)
418
419        //InventoryGroup #3
420        inventoryGroupInstance = new InventoryGroup(name: "Mechanical")
421        BootStrapSaveAndTest(inventoryGroupInstance)
422
423        //InventoryGroup #4
424        inventoryGroupInstance = new InventoryGroup(name: "Production")
425        BootStrapSaveAndTest(inventoryGroupInstance)
426
427//InventoryType
428        def inventoryTypeInstance
429
430        inventoryTypeInstance = new InventoryType(name: "Consumable")
431        BootStrapSaveAndTest(inventoryTypeInstance)
432
433        inventoryTypeInstance = new InventoryType(name: "Repairable")
434        BootStrapSaveAndTest(inventoryTypeInstance)
435
436//InventoryItem
437        def inventoryItemInstance
438
439        //InventoryItem #1
440        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1),
441                                                                                    inventoryType: InventoryType.get(1),
442                                                                                    unitOfMeasure: UnitOfMeasure.get(2),
443                                                                                    name: "J-Rope",
444                                                                                    description: "Twine wound J-Rope",
445                                                                                    reorderPoint: 0)
446        BootStrapSaveAndTest(inventoryItemInstance)
447
448        //InventoryItem #2
449        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(1),
450                                                                                    inventoryType: InventoryType.get(1),
451                                                                                    unitOfMeasure: UnitOfMeasure.get(2),
452                                                                                    name: "L-Rope",
453                                                                                    description: "Twine wound L-Rope",
454                                                                                    alternateItems: InventoryItem.get(1),
455                                                                                    reorderPoint: 0)
456        BootStrapSaveAndTest(inventoryItemInstance)
457
458        //InventoryItem #3
459        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3),
460                                                                                    inventoryType: InventoryType.get(1),
461                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
462                                                                                    name: "2305-2RS",
463                                                                                    description: "Bearing 25x62x24mm double row self aligning ball",
464                                                                                    reorderPoint: 2)
465        BootStrapSaveAndTest(inventoryItemInstance)
466
467        //InventoryItem #4
468        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(2),
469                                                                                    inventoryType: InventoryType.get(1),
470                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
471                                                                                    name: "L1592-K10",
472                                                                                    description: "10kW contactor",
473                                                                                    reorderPoint: 0)
474        BootStrapSaveAndTest(inventoryItemInstance)
475
476        //InventoryItem #5
477        inventoryItemInstance = new InventoryItem(inventoryGroup: InventoryGroup.get(3),
478                                                                                    inventoryType: InventoryType.get(1),
479                                                                                    unitOfMeasure: UnitOfMeasure.get(1),
480                                                                                    name: "6205-ZZ",
481                                                                                    description: "Bearing 25x52x15mm single row ball shielded",
482                                                                                    reorderPoint: 2)
483        BootStrapSaveAndTest(inventoryItemInstance)
484
485//StoredItem
486        def storedItemInstance
487
488        //StoredItem #1
489        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1),
490                                                                            storeLocation: StoreLocation.get(1),
491                                                                            quantity: 8)
492        BootStrapSaveAndTest(storedItemInstance)
493
494        //StoredItem #2
495        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(1),
496                                                                            storeLocation: StoreLocation.get(2),
497                                                                            quantity: 4)
498        BootStrapSaveAndTest(storedItemInstance)
499
500        //StoredItem #3
501        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(2),
502                                                                            storeLocation: StoreLocation.get(1),
503                                                                            quantity: 2)
504        BootStrapSaveAndTest(storedItemInstance)
505
506        //StoredItem #4
507        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(3),
508                                                                            storeLocation: StoreLocation.get(1),
509                                                                            quantity: 2)
510        BootStrapSaveAndTest(storedItemInstance)
511
512        //StoredItem #5
513        storedItemInstance = new StoredItem(inventoryItem: InventoryItem.get(4),
514                                                                            storeLocation: StoreLocation.get(1),
515                                                                            quantity: 30)
516        BootStrapSaveAndTest(storedItemInstance)
517
518/*******************
519START OF ASSET
520
521*******************/
522
523//Frequency
524        def frequencyInstance
525
526        //Frequency #1
527        frequencyInstance = new Frequency(frequency: "Day(s)")
528        BootStrapSaveAndTest(frequencyInstance)
529
530        //Frequency #2
531        frequencyInstance = new Frequency(frequency: "Week(s)")
532        BootStrapSaveAndTest(frequencyInstance)
533
534        //Frequency #3
535        frequencyInstance = new Frequency(frequency: "Month(s)")
536        BootStrapSaveAndTest(frequencyInstance)
537
538        //Frequency #4
539        frequencyInstance = new Frequency(frequency: "Year(s)")
540        BootStrapSaveAndTest(frequencyInstance)
541
542//LifePlan
543        def lifeplanInstance
544
545        lifeplanInstance = new LifePlan(name: "Initial Plan",
546                                                                timeInHours: 1,
547                                                                maintenanceAction: "Visual inspection")
548        BootStrapSaveAndTest(lifeplanInstance)
549
550//Form
551        def formInstance
552
553        formInstance = new Form(name: "Form 1")
554        BootStrapSaveAndTest(formInstance)
555
556//SystemSection
557    def systemSectionInstance
558
559    systemSectionInstance = new SystemSection(name: "Press Section",
560                                                                                   lifeplan: LifePlan.get(1))
561    BootStrapSaveAndTest(systemSectionInstance)
562
563//AssetType
564        def assetTypeInstance
565        assetTypeInstance = new AssetType(name: "Folder", 
566                        lifeplan: LifePlan.get(1),
567                        systemSection: SystemSection.get(1))
568        BootStrapSaveAndTest(assetTypeInstance)
569
570        assetTypeInstance = new AssetType(name: "Print Unit", 
571                        lifeplan: LifePlan.get(1),
572                        systemSection: SystemSection.get(1))
573        BootStrapSaveAndTest(assetTypeInstance)
574   
575//Assembly
576        def assemblyInstance
577        assemblyInstance = new Assembly(name: "Delivery Belts",
578                        lifeplan: LifePlan.get(1))
579        BootStrapSaveAndTest(assemblyInstance)
580   
581        assemblyInstance = new Assembly(name: "Print Couple",
582                        lifeplan: LifePlan.get(1))
583        BootStrapSaveAndTest(assemblyInstance)
584
585//SubAssembly
586        def subAssemblyInstance
587        subAssemblyInstance = new SubAssembly(name: "Centre Belt",
588                        lifeplan: LifePlan.get(1))
589        BootStrapSaveAndTest(subAssemblyInstance)
590   
591        subAssemblyInstance = new SubAssembly(name: "Form Roller",
592                        lifeplan: LifePlan.get(1))
593        BootStrapSaveAndTest(subAssemblyInstance)
594
595//ComponentItem
596    def componentItemInstance
597    componentItemInstance = new ComponentItem(name: "Centre Pulley",
598                                                                                        fmeaNumber: 1,
599                                                                                       lifeplan: LifePlan.get(1))
600    BootStrapSaveAndTest(componentItemInstance)
601
602    componentItemInstance = new ComponentItem(name: "Bearing",
603                                                                                        fmeaNumber: 1,
604                                                                                       lifeplan: LifePlan.get(1))
605    BootStrapSaveAndTest(componentItemInstance)
606
607
608//Asset
609        def assetInstance
610
611        //Asset #1
612        assetInstance = new Asset(name: "Print Unit 23",
613                                                        lifeplan: LifePlan.get(1),
614                                                        assetType: AssetType.get(1),
615                                                        riskPriorityNumber: 1)
616        BootStrapSaveAndTest(assetInstance)
617
618//Finally did it all work.       
619        if(BootStrapDemoDataSuccessful) {
620            println "BootStrapping demo data...successful."
621        }
622        else println "BootStrapping demo data...failed."
623    }
624
625//Call this function instead of .save()
626    void BootStrapSaveAndTest(object) {
627        if(!object.save()) {
628            BootStrapDemoDataSuccessful = false
629            println "'${object}' failed to save!"
630            println object.errors
631
632        }
633    } 
634}
Note: See TracBrowser for help on using the repository browser.