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

Revision 702, 2.1 KB (checked in by keesvb, 4 years ago)

updated SAM urls

  • 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                if (grails.util.GrailsUtil.environment == GrailsApplication.ENV_PRODUCTION) {
55                        CommunicationManager.SAMServerURL = 'http://sam.dbnp.org'
56                }
57                else {
58                        CommunicationManager.SAMServerURL = 'http://localhost:8182/sam'
59                }
60                CommunicationManager.registerRestWrapperMethodsSAMtoGSCF()
61        }
62
63        def destroy = {
64        }
65}
Note: See TracBrowser for help on using the browser.