root/trunk/grails-app/conf/BootStrap.groovy @ 662

Revision 662, 1.9 KB (checked in by keesvb, 4 years ago)

restructured BootStrap?, it should now run faster because there are no BioPortal? connections, and it adds sample studies in development mode (outcomment the addExampleStudies call in the BootStrap? if you don't want that). Renamed TemplateEntity?.getFieldType to giveFieldType and added tests to SampleTests? for the method.

  • Property svn:keywords set to Author Rev Date
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$
16 * $Author$
17 * $Date$
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
44                /**
45                 * attach ontologies in runtime. Possible problem is that you need
46                 * an internet connection when bootstrapping though.
47                 * @see dbnp.studycapturing.Subject
48                 * @see dbnp.studycapturing.Sample
49                 */
50                TemplateEntity.getField(Subject.domainFields, 'species').ontologies = [Ontology.getOrCreateOntologyByNcboId(1132)]
51                TemplateEntity.getField(Sample.domainFields, 'material').ontologies = [Ontology.getOrCreateOntologyByNcboId(1005)]
52
53                // register methods for accessing SAM's Rest services
54                CommunicationManager.SAMServerURL = 'nbx5.nugo.org/sam'
55                CommunicationManager.registerRestWrapperMethodsSAMtoGSCF()
56        }
57
58        def destroy = {
59        }
60}
Note: See TracBrowser for help on using the browser.