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

Last change on this file since 138 was 138, checked in by duh, 14 years ago
  • added development version of wizard subjects page and logic
  • modified some domain classes (again, who reverted them?) to implement Serializable
  • Property svn:keywords set to Date Author Rev
File size: 3.0 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: 138 $
15 * $Author: duh $
16 * $Date: 2010-01-26 15:46:01 +0000 (di, 26 jan 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                        ).save()
32
33                        // terms
34                        def mouseTerm = new Term(
35                                name: 'Mus musculus',
36                                ontology: speciesOntology,
37                                accession: '10090'
38                        ).save()
39                        def humanTerm = new Term(
40                                name: 'Homo sapiens',
41                                ontology: speciesOntology,
42                                accession: '9606'
43                        ).save()
44
45                        // create system user
46                        /*
47                        def systemUser = userService.createUser(InstanceGenerator.user(
48                                username: 'system',
49                                pass: 'system',
50                                passConfirm: 'system',
51                                enabled: true
52                        ))
53                        */
54
55                        // Mouse template
56                        def mouseTemplate = new Template(
57                                name: 'Mouse'
58                        ).addToSubjectFields(new TemplateSubjectField(
59                                name: 'Genotype',type: TemplateFieldType.STRINGLIST))
60                        .addToSubjectFields(new TemplateSubjectField(
61                                name: 'Age',type: TemplateFieldType.NUMBER)
62                        ).save()
63
64                        // studies
65                        def exampleStudy = new Study(
66                                title:"NuGO PPS3 mouse study leptin module",
67                                code:"PPS3_leptin_module",
68                                researchQuestion:"Leptin etc.",
69                                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.",
70                                ecCode:"2007117.c",
71                                startDate: Date.parse('yyyy-MM-dd','2007-12-11'))
72                        def x=1
73                        12.times {
74                                exampleStudy.addToSubjects(new Subject(
75                                        name: "A" + x++,
76                                        species: mouseTerm,
77                                        templateStringFields: ["Genotype" : "C57/Bl6j"],
78                                        templateNumberFields: ["Age" : 17F]
79                                ))}
80                        exampleStudy.save()
81
82                        new Study(title:"example",code:"Excode",researchQuestion:"ExRquestion",description:"Exdescription",ecCode:"ExecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
83                        new Study(title:"testAgain",code:"testcode",researchQuestion:"testRquestion",description:"testdescription",ecCode:"testCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
84                        new Study(title:"Exampletest",code:"Examplecode",researchQuestion:"ExampleRquestion",description:"Exampledescription",ecCode:"ExampleecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
85                }
86        }
87
88        def destroy = {
89        }
90} 
Note: See TracBrowser for help on using the repository browser.