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

Last change on this file since 812 was 812, checked in by keesvb, 10 years ago

added Sample tests for deleting samples via parent sampling event and event group, corrected some small errors, updated BootStrap? to find out why Sample.parentEvent gets serialized into the db, still no luck...

  • Property svn:keywords set to Author Date Rev
File size: 2.2 KB
Line 
1import dbnp.studycapturing.*
2
3import dbnp.data.Ontology
4import dbnp.data.Term
5import dbnp.rest.common.CommunicationManager
6import org.codehaus.groovy.grails.commons.GrailsApplication
7import grails.util.GrailsUtil
8
9/**
10 * Application Bootstrapper
11 * @Author Jeroen Wesbeek
12 * @Since 20091021
13 *
14 * Revision information:
15 * $Rev: 812 $
16 * $Author: keesvb $
17 * $Date: 2010-08-16 16:04:00 +0000 (ma, 16 aug 2010) $
18 */
19class BootStrap {
20        def init = {servletContext ->
21                // define timezone
22                System.setProperty('user.timezone', 'CET')
23
24                // If there are no templates yet in the database
25                if (Template.count() == 0) {
26                        println "No templates in the current database.";
27
28                        // If in development or test mode, add the ontologies manually to the database
29                        // without contacting the BioPortal website, to avoid annoying hiccups when the server is busy
30                        if (grails.util.GrailsUtil.environment != GrailsApplication.ENV_PRODUCTION) {
31                                println "Adding ontology descriptors"
32                                BootStrapTemplates.initTemplateOntologies()
33                        }
34
35                        // Add example study, subject, event etc. templates
36                        BootStrapTemplates.initTemplates()
37
38                        // If in development mode and no studies are present, add example studies
39                        if (Study.count() == 0 && grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) {
40                                BootStrapStudies.addExampleStudies()
41                        }
42
43                        println "Finished adding templates and studies"
44                }
45
46                /**
47                 * attach ontologies in runtime. Possible problem is that you need
48                 * an internet connection when bootstrapping though.
49                 * @see dbnp.studycapturing.Subject
50                 * @see dbnp.studycapturing.Sample
51                 */
52                TemplateEntity.getField(Subject.domainFields, 'species').ontologies = [Ontology.getOrCreateOntologyByNcboId(1132)]
53                TemplateEntity.getField(Sample.domainFields, 'material').ontologies = [Ontology.getOrCreateOntologyByNcboId(1005)]
54
55                println "Registering SAM REST methods"
56                // register methods for accessing SAM's Rest services
57                if (grails.util.GrailsUtil.environment == GrailsApplication.ENV_PRODUCTION) {
58                        CommunicationManager.SAMServerURL = 'http://sam.dbnp.org'
59                }
60                else {
61                        CommunicationManager.SAMServerURL = 'http://localhost:8182/sam'
62                }
63                CommunicationManager.registerRestWrapperMethodsSAMtoGSCF()
64
65                println "Done with BootStrap"
66        }
67
68        def destroy = {
69        }
70} 
Note: See TracBrowser for help on using the repository browser.