1 | import dbnp.studycapturing.* |
---|
2 | |
---|
3 | import dbnp.data.Ontology |
---|
4 | import dbnp.data.Term |
---|
5 | import dbnp.rest.common.CommunicationManager |
---|
6 | import org.codehaus.groovy.grails.commons.GrailsApplication |
---|
7 | import grails.util.GrailsUtil |
---|
8 | |
---|
9 | /** |
---|
10 | * Application Bootstrapper |
---|
11 | * @Author Jeroen Wesbeek |
---|
12 | * @Since 20091021 |
---|
13 | * |
---|
14 | * Revision information: |
---|
15 | * $Rev: 639 $ |
---|
16 | * $Author: jahn $ |
---|
17 | * $Date: 2010-07-01 15:29:46 +0000 (do, 01 jul 2010) $ |
---|
18 | */ |
---|
19 | class BootStrap { |
---|
20 | def init = {servletContext -> |
---|
21 | // define timezone |
---|
22 | System.setProperty('user.timezone', 'CET') |
---|
23 | |
---|
24 | if (Template.count() == 0) { |
---|
25 | println "No templates in the current database."; |
---|
26 | // Add example study, subject, event etc. templates |
---|
27 | BootStrapTemplates.initTemplates() |
---|
28 | |
---|
29 | // Add example studies |
---|
30 | if (Study.count() == 0 && grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT) { |
---|
31 | |
---|
32 | // When the code is properly refactored, BootStrapStudies.addExampleStudies() may be called here |
---|
33 | } |
---|
34 | } |
---|
35 | |
---|
36 | /** |
---|
37 | * attach ontologies in runtime. Possible problem is that you need |
---|
38 | * an internet connection when bootstrapping though. |
---|
39 | * @see dbnp.studycapturing.Subject |
---|
40 | * @see dbnp.studycapturing.Sample |
---|
41 | */ |
---|
42 | TemplateEntity.getField(Subject.domainFields, 'species').ontologies = [Ontology.getOrCreateOntologyByNcboId(1132)] |
---|
43 | TemplateEntity.getField(Sample.domainFields, 'material').ontologies = [Ontology.getOrCreateOntologyByNcboId(1005)] |
---|
44 | |
---|
45 | // register methods for accessing SAM's Rest services |
---|
46 | CommunicationManager.SAMServerURL = 'nbx5.nugo.org/sam' |
---|
47 | CommunicationManager.registerRestWrapperMethodsSAMtoGSCF() |
---|
48 | } |
---|
49 | |
---|
50 | def destroy = { |
---|
51 | } |
---|
52 | } |
---|