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

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

Setup Boostrap and DataSource? so that we have demo data in prod env for deployin
g demo. Adjust the entry domain and rebuild views and controller.

File size: 3.4 KB
Line 
1import grails.util.GrailsUtil
2
3class BootStrap 
4{
5    def init = { servletContext ->
6
7    println "**** BootStrap GrailsUtil.environment = ${GrailsUtil.environment}"
8   
9        switch (GrailsUtil.environment)
10        {
11            case "development":
12                        bootStrapDemoData()
13                        break
14            case "test":
15                        break
16            case "production":
17                        bootStrapDemoData()
18                        break 
19        }
20   
21    }
22
23    def destroy = {
24    }
25
26    //Insert some demo/startup data.
27    void bootStrapDemoData()
28    {
29        println "BootStrapping demo data..."
30   
31        //TypeOfPersonGroup
32        new PersonGroupType(name:"Department").save()
33        new PersonGroupType(name:"Contractor").save()
34        new PersonGroupType(name:"ProjectTeam").save()
35   
36        //PersonGroup
37        new PersonGroup(personGroupType:PersonGroupType.findByName("Department"),
38                        name:"Electrical").save()
39        new PersonGroup(personGroupType:PersonGroupType.get(2),
40                        name:"Kewl AirCon Guys").save()
41        new PersonGroup(personGroupType:PersonGroupType.get(3),
42                        name:"gnuMims").save()
43           
44        //Person
45        new Person(personGroup:PersonGroup.get(1),
46                   firstName:"Craig",
47                   lastName:"SuperTech").save()
48        new Person(personGroup:PersonGroup.get(2),
49                   firstName:"Joe",
50                   lastName:"Samples").save()
51        new Person(personGroup:PersonGroup.get(1),
52                   firstName:"Production",
53                   lastName:"Mann").save()
54               
55        //TaskGroup
56        new TaskGroup(name:"Engineering",
57                      description:"Engineering task group").save()
58        new TaskGroup(name:"Production",
59                      description:"Production task group").save()
60        new TaskGroup(name:"NewProject(s)",
61                      description:" ").save()
62                     
63       
64        //Task
65        new Task(taskGroup:TaskGroup.findByName("Engineering"),
66                 person:Person.get(1),
67                 name:"Check specific level sensor",
68                 description:"Has been noted as problematic, try recallibrating",
69                 scheduledDate: new Date(),
70                 targetDate: new Date() ).save()
71        new Task(taskGroup:TaskGroup.findByName("Production"),
72                 person:Person.get(2),
73                 name:"Production Report",
74                 description:"Production report for specific production run or shift",
75                 scheduledDate: new Date(),
76                 targetDate: new Date() ).save()
77
78        //EntryType
79        new EntryType(name:"Fault").save()
80        new EntryType(name:"WorkDone").save()
81        new EntryType(name:"Production Report").save()
82
83        //ModificationType
84        new ModificationType(name:"Created").save()
85        new ModificationType(name:"Completed").save()
86        new ModificationType(name:"Closed").save()
87        new ModificationType(name:"Altered").save()
88        new ModificationType(name:"TargetDateModified").save()
89        new ModificationType(name:"ScheduledDateModified").save()
90        new ModificationType(name:"DescriptionModified").save()
91        new ModificationType(name:"AssignedToModified").save()
92        new ModificationType(name:"NameModified").save()
93       
94        println "BootStrapping demo data...completed."
95   
96    }
97
98}
Note: See TracBrowser for help on using the repository browser.