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