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

Last change on this file since 162 was 162, checked in by duh, 13 years ago
  • set keyword expansion
  • Property svn:keywords set to
    Date
    Author
    Rev
File size: 7.8 KB
Line 
1import org.codehaus.groovy.grails.commons.GrailsApplication
2import grails.util.GrailsUtil
3import dbnp.studycapturing.*
4
5import dbnp.data.Ontology
6import dbnp.data.Term
7
8/**
9 * Application Bootstrapper
10 * @Author Jeroen Wesbeek
11 * @Since 20091021
12 *
13 * Revision information:
14 * $Rev: 162 $
15 * $Author: duh $
16 * $Date: 2010-02-02 14:07:02 +0000 (di, 02 feb 2010) $
17 */
18class BootStrap {
19        def init = {servletContext ->
20                // define timezone
21                System.setProperty('user.timezone', 'CET')     
22
23                if (GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) {
24                        printf("development bootstrapping....\n\n");
25
26                        // ontologies
27                        def speciesOntology = new Ontology(
28                                name: 'NCBI Taxonomy',
29                                shortName: 'Taxon',
30                                url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy'
31                        ).with { if (!validate()) { errors.each { println it} } else save()}
32
33
34                        // terms
35                        def mouseTerm = new Term(
36                                name: 'Mus musculus',
37                                ontology: speciesOntology,
38                                accession: '10090'
39                        ).with { if (!validate()) { errors.each { println it} } else save()}
40                        def humanTerm = new Term(
41                                name: 'Homo sapiens',
42                                ontology: speciesOntology,
43                                accession: '9606'
44                        ).with { if (!validate()) { errors.each { println it} } else save()}
45
46                        def madmaxOntology = new Ontology(
47                                name: 'Madmax ontology',
48                                shortName: 'MDMX',
49                                url: 'madmax.bioinformatics.nl'
50                        ).with { if (!validate()) { errors.each { println it} } else save()}
51
52                        def treatmentTerm = new Term(
53                                name: 'ExperimentalProtocol',
54                                ontology: madmaxOntology,
55                                accession: 'P-MDMXGE-264'
56                        ).with { if (!validate()) { errors.each { println it} } else save()}
57
58
59                        def treatmentProtocol = new Protocol(
60                                name: 'MADMAX Experimental Protocol',
61                                reference: treatmentTerm
62                        ).with { if (!validate()) { errors.each { println it} } else save()}
63
64
65                        // added by Jahn for testing the event views
66                        def treatmentProtocol2 = new Protocol(
67                                name: 'MADMAX Experimental Protocol 2',
68                                reference: treatmentTerm
69                        ).with { if (!validate()) { errors.each { println it} } else save()}
70
71
72
73                        treatmentProtocol
74                        .addToParameters(new ProtocolParameter(
75                                name: 'Diet',
76                                type: ProtocolParameterType.STRINGLIST,
77                                listEntries: ['10% fat (palm oil)','45% fat (palm oil)']))
78                        .addToParameters(new ProtocolParameter(
79                                name: 'Compound',
80                                type: ProtocolParameterType.STRINGLIST,
81                                listEntries: ['Vehicle','Leptin']))
82                        .addToParameters(new ProtocolParameter(
83                                name: 'Administration',
84                                type: ProtocolParameterType.STRING))
85                        .save()
86
87
88                        // added by Jahn for testing the event views
89                        treatmentProtocol2
90                        .addToParameters(new ProtocolParameter(
91                                name: 'Diet',
92                                type: ProtocolParameterType.STRINGLIST,
93                                listEntries: ['99% fat (crude oil)','1% fat (palm oil)']))
94                        .addToParameters(new ProtocolParameter(
95                                name: 'Compound',
96                                type: ProtocolParameterType.STRINGLIST,
97                                listEntries: ['Vehicle','Leptin']))
98                        .addToParameters(new ProtocolParameter(
99                                name: 'Administration',
100                                type: ProtocolParameterType.STRING))
101                        .save()
102
103
104
105                        // create system user
106                        /*
107                        def systemUser = userService.createUser(InstanceGenerator.user(
108                                username: 'system',
109                                pass: 'system',
110                                passConfirm: 'system',
111                                enabled: true
112                        ))
113                        */
114
115                        // Mouse template
116                        def mouseTemplate = new Template(
117                                name: 'Mouse'
118                        ).addToSubjectFields(new TemplateSubjectField(
119                                name: 'Genotype',type: TemplateFieldType.STRINGLIST))
120                        .addToSubjectFields(new TemplateSubjectField(
121                                name: 'Gender',type: TemplateFieldType.STRINGLIST, listEntries: ['Male','Female']))
122                        .addToSubjectFields(new TemplateSubjectField(
123                                name: 'Age',type: TemplateFieldType.INTEGER))
124                        .addToSubjectFields(new TemplateSubjectField(
125                                name: 'Cage',type: TemplateFieldType.INTEGER))
126                        .with { if (!validate()) { errors.each { println it} } else save()}
127
128
129                        //events
130                        def eventTreatment = new EventDescription(
131                                name: 'Treatment',
132                                description: 'Experimental Treatment Protocol NuGO PPS3 leptin module',
133                                classification: treatmentTerm,
134                                protocol: treatmentProtocol
135                        ).with { if (!validate()) { errors.each { println it} } else save()}
136
137
138                        // studies
139                        def exampleStudy = new Study(
140                                title:"NuGO PPS3 mouse study leptin module",
141                                code:"PPS3_leptin_module",
142                                researchQuestion:"Leptin etc.",
143                                description:"C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled.",
144                                ecCode:"2007117.c",
145                                startDate: Date.parse('yyyy-MM-dd','2007-12-11'),
146                                template: mouseTemplate
147                        ).with { if (!validate()) { errors.each { println it} } else save()}
148
149                        def x=1
150                        12.times {
151                                def currentSubject = new Subject(
152                                        name: "A" + x++,
153                                        species: mouseTerm,
154                                        template: mouseTemplate,
155                                        templateStringFields: ["Genotype" : "C57/Bl6j", "Gender" : "Male"],
156                                        templateIntegerFields: ["Age" : 17, "Cage" : (int)(x/2)]
157                                ).with { if (!validate()) { errors.each { println it} } else save()}
158
159                                exampleStudy.addToSubjects(currentSubject)
160                                .addToEvents(new Event(
161                                        subject: currentSubject,
162                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
163                                        endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
164                                        eventDescription: eventTreatment,
165                                        parameterStringValues: ['Diet':'10% fat (palm oil)','Compound':'Vehicle','Administration':'intraperitoneal injection'])
166                                ).with { if (!validate()) { errors.each { println it} } else save()}
167                        }
168
169
170                        def secondStudy = new Study(
171                                title:"NuGO PPS1 mouse study leptin module",
172                                code:"PPS1",
173                                researchQuestion:"etc.",
174                                description:"C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled.",
175                                ecCode:"2007.c",
176                                startDate: Date.parse('yyyy-MM-dd','2007-12-11'),
177                                template: mouseTemplate
178                        ).with { if (!validate()) { errors.each { println it} } else save()}
179
180                        def y=1
181                        5.times {
182                                def currentSubject = new Subject(
183                                        name: "A" + y++,
184                                        species: mouseTerm,
185                                        template: mouseTemplate,
186                                        templateStringFields: ["Genotype" : "C57/Bl6j", "Gender" : "Male"],
187                                        templateIntegerFields: ["Age" : 17, "Cage" : (int)(y/2)]
188                                ).with { if (!validate()) { errors.each { println it} } else save()}
189
190                                secondStudy.addToSubjects(currentSubject)
191                                .addToEvents(new SamplingEvent(
192                                        subject: currentSubject,
193                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
194                                        endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
195                                        eventDescription: eventTreatment,
196                                        parameterStringValues: ['Diet':'10% fat (palm oil)','Compound':'Vehicle','Administration':'intraperitoneal injection'])
197                                ).with { if (!validate()) { errors.each { println it} } else save()}
198                        }
199
200//                        new Study(title:"example",code:"Excode",researchQuestion:"ExRquestion",description:"Exdescription",ecCode:"ExecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
201//                        new Study(title:"testAgain",code:"testcode",researchQuestion:"testRquestion",description:"testdescription",ecCode:"testCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
202//                        new Study(title:"Exampletest",code:"Examplecode",researchQuestion:"ExampleRquestion",description:"Exampledescription",ecCode:"ExampleecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
203                }
204        }
205
206        def destroy = {
207        }
208} 
Note: See TracBrowser for help on using the repository browser.