source: trunk/grails-app/conf/BootStrapTemplates.groovy @ 1398

Last change on this file since 1398 was 1398, checked in by business@…, 13 years ago

make sure manual adding of ontologies is only done in development and test

  • Property svn:keywords set to Author Date Rev
File size: 26.2 KB
Line 
1/**
2 * @Author kees
3 * @Since Jun 25, 2010
4 *
5 * Revision information:
6 * $Rev: 1398 $
7 * $Author: business@keesvanbochove.nl $
8 * $Date: 2011-01-13 16:29:54 +0000 (do, 13 jan 2011) $
9 */
10
11import dbnp.studycapturing.*
12import dbnp.data.Ontology
13
14class BootStrapTemplates {
15
16        /**
17         * Add the ontologies that are necessary for the templates below manually
18         * This function can be called to avoid the HTTP requests to BioPortal each time
19         * (e.g. in development or automated test environments)
20         */
21        public static void initTemplateOntologies() {
22                "inserting initial ontologies".grom()
23
24                // If running in development or test mode, add ontologies manually to speed up development and allow running offline
25                if (grails.util.GrailsUtil.environment == GrailsApplication.ENV_DEVELOPMENT || grails.util.GrailsUtil.environment == GrailsApplication.ENV_TEST) {
26
27                        // add Species ontology which is used for a.o. the Subject domain field 'species'
28                        def speciesOntology = new Ontology(
29                                name: 'NCBI organismal classification',
30                                description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.',
31                                url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/',
32                                versionNumber: '1.2',
33                                ncboId: '1132',
34                                ncboVersionedId: '38802'
35                        ).with { if (!validate()) { errors.each { println it} } else save()}
36
37                        // add Sample>material ontology
38                        def brendaOntology = new Ontology(
39                                name: 'BRENDA tissue / enzyme source',
40                                description: 'A structured controlled vocabulary for the source of an enzyme. It comprises terms for tissues, cell lines, cell types and cell cultures from uni- and multicellular organisms.',
41                                url: 'http://www.brenda-enzymes.info',
42                                versionNumber: '1.3',
43                                ncboId: '1005',
44                                ncboVersionedId: '40643'
45                        ).with { if (!validate()) { errors.each { println it} } else save()}
46
47                        // add NCI ontology which is used in Mouse genotype template field
48                        def nciOntology = new Ontology(
49                                name: 'NCI Thesaurus',
50                                description: 'A vocabulary for clinical care, translational and basic research, and public information and administrative activities.',
51                                url: 'http://ncicb.nci.nih.gov/core/EVS',
52                                versionNumber: '10.03',
53                                ncboId: '1032',
54                                ncboVersionedId: '42838'
55                        ).with { if (!validate()) { errors.each { println it} } else save()}
56
57                        // add CHEBI ontology which is used for describing chemicals in e.g. events
58                        def chebiOntology = new Ontology(
59                                name: 'Chemical entities of biological interest',
60                                description: 'A structured classification of chemical compounds of biological relevance.',
61                                url: 'http://www.ebi.ac.uk/chebi',
62                                versionNumber: '1.73',
63                                ncboId: '1007',
64                                ncboVersionedId: '44746'
65                        ).with { if (!validate()) { errors.each { println it} } else save()}
66
67                }
68                // otherwise, this may be a production demo instance, so initialize the ontologies dynamically from BioPortal
69                else {
70
71                        def speciesOntology = Ontology.getOrCreateOntologyByNcboId(1132)
72                        def brendaOntology = Ontology.getOrCreateOntologyByNcboId(1005)
73                        def nciOntology = Ontology.getOrCreateOntologyByNcboId(1032)
74                        def chebiOntology = Ontology.getOrCreateOntologyByNcboId(1007)
75                }
76        }
77
78
79        /**
80         * Add example templates, this function would normally be called on an empty database
81         */
82        public static void initTemplates() {
83                "inserting initial templates".grom()
84
85                def genderField = new TemplateField(
86                        name: 'Gender',type: TemplateFieldType.STRINGLIST, entity: Subject,
87                        listEntries: [new TemplateFieldListItem(name:'Male'),new TemplateFieldListItem(name: 'Female'),new TemplateFieldListItem(name: 'Unknown')])
88                .with { if (!validate()) { errors.each { println it} } else save()}
89
90                def ageField = new TemplateField(
91                        name: 'Age',type: TemplateFieldType.LONG,entity: Subject,unit: 'years',comment: 'Either include age at the start of the study or date of birth (if known)')
92                .with { if (!validate()) { errors.each { println it} } else save()}
93
94                def genotypeField = new TemplateField(
95                        name: 'Genotype', type: TemplateFieldType.STRING,entity: Subject,
96                        comment: 'If present, indicate the genetic variance of the subject (e.g., mutagenized populations,knock-out/in,transgene etc)')
97                .with { if (!validate()) { errors.each { println it} } else save()}
98
99                 def genotypeTypeField = new TemplateField(
100                        name: 'Genotype type',type: TemplateFieldType.STRINGLIST,entity: Subject,
101                        listEntries: [new TemplateFieldListItem(name:'wildtype'),
102                                new TemplateFieldListItem(name:'transgenic'),
103                                new TemplateFieldListItem(name:'knock-out'),
104                                new TemplateFieldListItem(name:'knock-in')],
105                        comment: 'If a genotype was specified, please indicate here the type of the genotype')
106                .with { if (!validate()) { errors.each { println it} } else save()}
107
108                def varietyField = new TemplateField(
109                        name: 'Variety', type: TemplateFieldType.STRING,entity: Subject,
110                        comment: 'taxonomic category consisting of members of a species that differ from others of the same species in minor but heritable characteristics')
111                .with { if (!validate()) { errors.each { println it} } else save()}
112
113                def ecotypeField = new TemplateField(
114                        name: 'Ecotype', type: TemplateFieldType.STRING,entity: Subject,
115                         comment: 'a type or subspecies of life that is especially well adapted to a certain environment'
116                )
117                 .with { if (!validate()) { errors.each { println it} } else save()}
118
119                // Nutritional study template
120                def studyTemplate = new Template(
121                        name: 'Academic study',
122                        entity: dbnp.studycapturing.Study
123                )
124                .addToFields(new TemplateField(name: 'Objectives',type: TemplateFieldType.TEXT,entity: Study,comment:'Fill out the aim or questions of the study'))
125                .addToFields(new TemplateField(name: 'Consortium',type: TemplateFieldType.STRING,entity: Study,comment:'If the study was performed within a consortium (e.g. NMC, NuGO), you can indicate this here'))
126                .addToFields(new TemplateField(name: 'Cohort name',type: TemplateFieldType.STRING,entity: Study,comment:'If a cohort was used the name or code of the cohort can be define here (define a cohort template)'))
127                .addToFields(new TemplateField(name: 'Lab id',type: TemplateFieldType.STRING,entity: Study,comment:'In which lab was the study performed; indicate the roomnumber.'))
128                .addToFields(new TemplateField(name: 'Institute',type: TemplateFieldType.STRING,entity: Study,comment:'In which institute was the study performed; indicate the full address information (to be replaced by persons-affiliations?)'))
129                .addToFields(new TemplateField(name: 'Study protocol',type: TemplateFieldType.FILE,entity: Study,comment:'Optionally attach a file in which the protocol in the study is described'))
130                .with { if (!validate()) { errors.each { println it} } else save()}
131
132                // Mouse template
133                def mouseTemplate = new Template(
134                        name: 'Mouse', entity: dbnp.studycapturing.Subject)
135                .addToFields(new TemplateField(
136                        name: 'Strain', type: TemplateFieldType.ONTOLOGYTERM, ontologies: [Ontology.getOrCreateOntologyByNcboId(1032)], entity: Subject, comment: "This is an ontology term, if the right strain is not in the list please add it with 'add more'"))
137                .addToFields(genotypeField)
138                .addToFields(genotypeTypeField)
139                .addToFields(genderField)
140                .addToFields(new TemplateField(
141                        name: 'Age', type: TemplateFieldType.LONG, entity: Subject, unit: 'weeks', comment: 'Age at start of study'))
142                .addToFields(new TemplateField(
143                        name: 'Age type',type: TemplateFieldType.STRINGLIST,entity: Subject,
144                        listEntries: [new TemplateFieldListItem(name:'postnatal'),new TemplateFieldListItem(name:'embryonal')]))
145                .addToFields(new TemplateField(
146                        name: 'Cage',type: TemplateFieldType.STRING,entity: Subject,comment:'Indicate the cage used for housing (type and/or size)'))
147                .addToFields(new TemplateField(
148                        name: '#Mice in cage',type: TemplateFieldType.LONG,entity: Subject,comment:'If known, indicate the number of mice per cage'))
149                .addToFields(new TemplateField(
150                        name: 'Litter size',type: TemplateFieldType.LONG,entity: Subject,comment:'If known, indicate the litter size of the litter from which the subject originates'))
151                .addToFields(new TemplateField(
152                        name: 'Weight', type: TemplateFieldType.DOUBLE, unit: 'gram',entity: Subject,comment:'If known indicate the weight of the subject in grams at the start of the study'))
153                .with { if (!validate()) { errors.each { println it} } else save()}
154
155                // Human template
156                def humanTemplate = new Template(
157                        name: 'Human', entity: dbnp.studycapturing.Subject)
158                .addToFields(genderField)
159                .addToFields(ageField)
160                .addToFields(new TemplateField(
161                        name: 'DOB',type: TemplateFieldType.DATE,entity: Subject,comment:'Date of birth'))
162                .addToFields(new TemplateField(
163                        name: 'Height',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'm'))
164                .addToFields(new TemplateField(
165                        name: 'Weight',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'kg'))
166                .addToFields(new TemplateField(
167                        name: 'BMI',type: TemplateFieldType.DOUBLE, entity: Subject, unit: 'kg/m2',comment:'Body-mass-index'))
168                .addToFields(new TemplateField(
169                        name: 'Race',type: TemplateFieldType.STRING,entity: Subject, comment:'If known and of interest the ethnic group can be indicated'))
170                .addToFields(new TemplateField(
171                        name: 'Waist circumference',type: TemplateFieldType.DOUBLE, unit: 'cm',entity: Subject, comment:'The waist circumference is measured just above the hip bone. Indicate the measure at the start of the study.'))
172                .addToFields(new TemplateField(
173                        name: 'Hip circumference',type: TemplateFieldType.DOUBLE, unit: 'cm',entity: Subject, comment:'The hip circumference is measured at the level of the two bony prominences front of the hips. Indicate the measure at the start of the study.'))
174                .addToFields(new TemplateField(
175                        name: 'Systolic blood pressure',type: TemplateFieldType.DOUBLE, unit: 'mmHg',entity: Subject, comment:'Indicate the levels at the start of the study in mmHG'))
176                .addToFields(new TemplateField(
177                        name: 'Diastolic blood pressure',type: TemplateFieldType.DOUBLE, unit: 'mmHg',entity: Subject, comment:'Indicate the levels at the start of the study in mmHG'))
178                .addToFields(new TemplateField(
179                        name: 'Heart rate',type: TemplateFieldType.DOUBLE, unit: 'beats/min',entity: Subject, comment:'Indicate the heart rate at the start of in study in beats per minute'))
180                .addToFields(new TemplateField(
181                        name: 'Run-in-food',type: TemplateFieldType.TEXT,entity: Subject, comment:'If defined, give a short description of the food used before the measurements'))
182                .with { if (!validate()) { errors.each { println it} } else save()}
183
184                def sampleRemarksField = new TemplateField(
185                        name: 'Remarks',
186                        type: TemplateFieldType.TEXT,
187                    entity: Sample
188                )
189                .with { if (!validate()) { errors.each { println it} } else save()}
190
191                def sampleVialTextField = new TemplateField(
192                        name: 'Text on vial',
193                        type: TemplateFieldType.STRING,
194                    entity: Sample
195                )
196                .with { if (!validate()) { errors.each { println it} } else save()}
197
198                // Human tissue sample template
199                def humanSampleTemplate = new Template(
200                        name: 'Human tissue sample',
201                        entity: dbnp.studycapturing.Sample
202                )
203                .addToFields(sampleRemarksField)
204                .addToFields(sampleVialTextField)
205                .addToFields(
206                        new TemplateField(
207                            name: 'Sample measured weight',
208                            unit: 'mg',
209                            type: TemplateFieldType.DOUBLE,
210                        entity: Sample
211                        )
212                )
213                .with { if (!validate()) { errors.each { println it} } else save()}
214
215                // Human blood sample template
216                def humanBloodSampleTemplate = new Template(
217                    name: 'Human blood sample',
218                        entity: dbnp.studycapturing.Sample
219                )
220                .addToFields(sampleRemarksField)
221                .addToFields(sampleVialTextField)
222                .addToFields(
223                        new TemplateField(
224                            name: 'Sample measured volume',
225                            unit: 'ml',
226                            type: TemplateFieldType.DOUBLE,
227                                entity: Sample
228                        )
229                )
230                .with { if (!validate()) { errors.each { println it} } else save()}
231
232               
233                /*
234                 * Add NMC - DCL Sample Mapping Template
235                 * by Michael van Vliet
236                 *
237                 * For the Pilot running in Leiden (NOV2010)
238                 */
239                def sampleDCLTextField = new TemplateField(
240                        name: 'DCL Sample Reference',
241                        type: TemplateFieldType.STRING,
242                        entity: Sample
243                )
244                .with { if (!validate()) { errors.each { println it} } else save()}
245
246                // Human tissue sample template
247                def dclSampleTemplate = new Template(
248                        name: 'DCL Sample information',
249                        entity: dbnp.studycapturing.Sample
250                )
251                .addToFields(sampleDCLTextField)
252                .with { if (!validate()) { errors.each { println it} } else save()}
253                // EO DCL Sample Mapping Template**********************************
254               
255               
256                /*
257                def GrowthTreatmentTemplate = new Template(
258                        name: 'Growth treatment',
259                        entity: dbnp.studycapturing.Event
260                )
261                .addToFields(sampleDescriptionField)
262                .addToFields(new TemplateField(name: 'position X',type: TemplateFieldType.STRING))
263                .addToFields(new TemplateField(name: 'position Y',type: TemplateFieldType.STRING))
264                .addToFields(new TemplateField(name: 'Block',type: TemplateFieldType.STRING))
265                .addToFields(new TemplateField(name: 'Temparature Day',type: TemplateFieldType.STRING))
266                .addToFields(new TemplateField(name: 'Temparature Night',type: TemplateFieldType.STRING))
267                .addToFields(new TemplateField(name: 'Light Intensity',type: TemplateFieldType.STRING))
268                .addToFields(new TemplateField(name: 'Harvest Delay',type: TemplateFieldType.STRING))
269                .with { if (!validate()) { errors.each { println it} } else save()}
270                 */
271
272                //Plant template
273                def greenHouseTemplate = new Template(
274                        name: 'Plant-green house ',
275                        entity: dbnp.studycapturing.Subject
276                )
277                .addToFields(varietyField)
278                .addToFields(ecotypeField)
279                 .addToFields(genotypeField)
280                /*
281                .addToFields(genotypeTypeField)
282                .addToFields(
283                        new TemplateField(
284                                name: 'Growth location', type: TemplateFieldType.STRINGLIST,
285                                listEntries: [
286                                        new TemplateFieldListItem(name:'Greenhouse'),
287                                        new TemplateFieldListItem(name: 'Field')
288                                ]
289                        )
290                )
291                .addToFields(
292                        new TemplateField(
293                                name: 'Room', type: TemplateFieldType.STRING,
294                                comment: 'Chamber number in case of Greenhouse'
295                        )
296                )
297                */
298                .addToFields(
299                        new TemplateField(
300                                name: 'Chamber no.',
301                                type: TemplateFieldType.STRING,
302                                entity: Subject,
303                                comment: 'Chamber number in the Greenhouse'
304                        )
305                )
306                .addToFields(
307                        new TemplateField(
308                                name: 'Growth type',
309                                entity: Subject,
310                                type: TemplateFieldType.STRINGLIST,
311                                listEntries: [
312                                        new TemplateFieldListItem(name:'Standard'),
313                                new TemplateFieldListItem(name: 'Experimental'),
314                                new TemplateFieldListItem(name: 'Unknown')
315                                ]
316                        )
317                )
318                .addToFields(new TemplateField(
319                        name: 'Growth protocol', entity: Subject, type: TemplateFieldType.TEXT))
320                .addToFields(new TemplateField(
321                        name: 'Position X', entity: Subject, type: TemplateFieldType.DOUBLE))
322                .addToFields(new TemplateField(
323                        name: 'Position Y', entity: Subject, type: TemplateFieldType.DOUBLE))
324                .addToFields(new TemplateField(
325                        name: 'Block', entity: Subject, type: TemplateFieldType.STRING))
326                .addToFields(new TemplateField(
327                        name: 'Temperature at day', entity: Subject, type: TemplateFieldType.DOUBLE))
328                .addToFields(new TemplateField(
329                        name: 'Temperature at night', entity: Subject, type: TemplateFieldType.DOUBLE))
330                .addToFields(new TemplateField(
331                        name: 'Photo period', entity: Subject, type: TemplateFieldType.STRING))
332                .addToFields(new TemplateField(
333                        name: 'Light intensity', entity: Subject, type: TemplateFieldType.STRING))
334                .addToFields(new TemplateField(
335                        name: 'Start date', entity: Subject, type: TemplateFieldType.DATE))
336                .addToFields(new TemplateField(
337                        name: 'Harvest date', entity: Subject, type: TemplateFieldType.DATE))
338                .addToFields(new TemplateField(
339                        name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT))
340                .addToFields(new TemplateField(
341                        name: 'Additional info', entity: Subject, type: TemplateFieldType.TEXT))
342                .with { if (!validate()) { errors.each { println it} } else save()}
343
344                def FieldTemplate = new Template(
345                        name: 'Plant-open field',
346                        entity: dbnp.studycapturing.Subject
347                )
348                .addToFields(varietyField)
349                .addToFields(ecotypeField)
350                .addToFields(genotypeField)
351                .addToFields(new TemplateField(
352                        name: 'Start date', entity: Subject, type: TemplateFieldType.DATE))
353                .addToFields(new TemplateField(
354                        name: 'Harvest date', entity: Subject, type: TemplateFieldType.DATE))
355                .addToFields(new TemplateField(
356                        name: 'Growth type', entity: Subject, type: TemplateFieldType.STRINGLIST,
357                        listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')]))
358                .addToFields(new TemplateField(
359                        name: 'Growth protocol', entity: Subject, type: TemplateFieldType.TEXT))
360                .addToFields(new TemplateField(
361                        name: 'Harvest delay', entity: Subject, type: TemplateFieldType.TEXT))
362                .with { if (!validate()) { errors.each { println it} } else save()}
363
364                //Plant template
365                def chamberTemplate = new Template(
366                        name: 'Plant-chamber',
367                        entity: dbnp.studycapturing.Subject
368                )
369                .addToFields(varietyField)
370                .addToFields(ecotypeField)
371                .addToFields(genotypeField)
372                /*
373                .addToFields(genotypeTypeField)
374                .addToFields(
375                        new TemplateField(
376                                name: 'Growth location',
377                                type: TemplateFieldType.STRINGLIST,
378                                listEntries: [
379                                        new TemplateFieldListItem(name:'Greenhouse'),
380                                        new TemplateFieldListItem(name: 'Field')
381                                ]
382                        )
383                )
384                */
385                .addToFields(new TemplateField(
386                        name: 'Room', type: TemplateFieldType.STRING, entity: Subject,
387                        comment: 'room number'))
388                .addToFields(new TemplateField(
389                        name: 'Chamber no.', type: TemplateFieldType.STRING, entity: Subject,
390                        comment: 'Chamber number'))
391                .addToFields(new TemplateField(
392                        name: 'Block', type: TemplateFieldType.STRING, entity: Subject))
393                .addToFields(new TemplateField(
394                        name: 'Position X', type: TemplateFieldType.DOUBLE, entity: Subject))
395                .addToFields(new TemplateField(
396                        name: 'Position Y', type: TemplateFieldType.DOUBLE, entity: Subject))
397                .addToFields(new TemplateField(
398                        name: 'Temperature at day', type: TemplateFieldType.DOUBLE, entity: Subject))
399                .addToFields(new TemplateField(
400                        name: 'Temperature at night', type: TemplateFieldType.DOUBLE, entity: Subject))
401                .addToFields(new TemplateField(
402                        name: 'Photo period', type: TemplateFieldType.STRING, entity: Subject))
403                .addToFields(new TemplateField(
404                        name: 'Light intensity', type: TemplateFieldType.STRING, entity: Subject))
405                .addToFields(new TemplateField(
406                        name: 'Start date', type: TemplateFieldType.DATE, entity: Subject))
407                .addToFields(new TemplateField(
408                        name: 'Harvest date', type: TemplateFieldType.DATE, entity: Subject))
409                .addToFields(new TemplateField(
410                        name: 'Growth type', type: TemplateFieldType.STRINGLIST, entity: Subject,
411                        listEntries: [new TemplateFieldListItem(name:'Standard'),new TemplateFieldListItem(name: 'Experimental')]))
412                .addToFields(new TemplateField(
413                        name: 'Growth protocol', type: TemplateFieldType.TEXT, entity: Subject))
414                .addToFields(new TemplateField(
415                        name: 'Harvest delay', type: TemplateFieldType.TEXT, entity: Subject))
416                .with { if (!validate()) { errors.each { println it} } else save()}
417
418                def plantSampleTemplate = new Template(
419                        name: 'Plant sample',
420                        entity: dbnp.studycapturing.Sample
421                )
422                .addToFields(sampleRemarksField)
423                .addToFields(sampleVialTextField)
424                .with { if (!validate()) { errors.each { println it} } else save()}
425
426                def materialPrepTemplate = new Template(
427                        name: 'Plant-material preparation',
428                    description: 'material preparation',
429                    entity: dbnp.studycapturing.Event
430                )
431                .addToFields(new TemplateField(
432                         name: 'Tissue',
433                        type: TemplateFieldType.STRING,
434                        entity: Event,
435                    comment: 'organ/ fraction of culture/ plant part')
436                )
437                .addToFields(
438                        new TemplateField(
439                                 name: 'Grinding',
440                                type: TemplateFieldType.STRINGLIST,
441                                entity: Event,
442                            listEntries: [
443                                        new TemplateFieldListItem(name:'yes'),
444                                new TemplateFieldListItem(name: 'no'),
445                                new TemplateFieldListItem(name: 'unknown')
446                                ]
447                        )
448                )
449                .addToFields(
450                        new TemplateField(
451                                name: 'Storage location',
452                                type: TemplateFieldType.STRING,
453                                entity: Event
454                        )
455                )
456                .addToFields(
457                        new TemplateField(
458                                name: 'protocol reference',
459                                type: TemplateFieldType.STRING,
460                                entity: Event
461                        )
462                )
463                .with { if (!validate()) { errors.each { println it} } else save()}
464
465                def protocolField = new TemplateField(
466                        name: 'Protocol',
467                        type: TemplateFieldType.FILE,
468                        entity: Event,
469                        comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the event'
470                )
471                .with { if (!validate()) { errors.each { println it} } else save()}
472
473                // diet treatment template
474                def dietTreatmentTemplate = new Template(
475                        name: 'Diet treatment',
476                        entity: dbnp.studycapturing.Event
477                )
478                .addToFields(
479                        new TemplateField(
480                                name: 'Diet',
481                                type: TemplateFieldType.STRINGLIST,
482                                entity: Event,
483                                listEntries: [
484                                        new TemplateFieldListItem(name:'low fat'),
485                                        new TemplateFieldListItem(name: 'high fat')
486                                ]
487                        )
488                )
489                .addToFields(protocolField)
490                .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
491                dietTreatmentTemplate.refresh()
492
493                // boost treatment template
494                def boostTreatmentTemplate = new Template(
495                        name: 'Compound challenge',
496                        entity: dbnp.studycapturing.Event
497                )
498                .addToFields(
499                        new TemplateField(
500                                name: 'Compound',
501                                type: TemplateFieldType.ONTOLOGYTERM,
502                                entity: Event,
503                                ontologies: [Ontology.getOrCreateOntologyByNcboId(1007)]
504                        )
505                )
506                .addToFields(
507                        new TemplateField(
508                                name: 'Control',
509                                type: TemplateFieldType.BOOLEAN,
510                                entity: Event
511                        )
512                )
513                .addToFields(protocolField)
514                .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
515                boostTreatmentTemplate.refresh()
516
517                // fasting treatment template
518                def fastingTreatment = new Template(
519                        name: 'Fasting treatment',
520                        description: 'Fasting for a specific amount of time',
521                        entity: dbnp.studycapturing.Event
522                )
523                .addToFields(
524                        new TemplateField(
525                                name: 'Fasting period',
526                                type: TemplateFieldType.RELTIME,
527                                entity: Event
528                        )
529                )
530                .with { if (!validate()) { errors.each { println it} } else save()}
531
532                // SamplingEvent templates
533                def samplingProtocolField = new TemplateField(
534                        name: 'Sample Protocol',
535                        entity: SamplingEvent,
536                        type: TemplateFieldType.FILE,
537                        comment: 'You can upload a protocol here which describes the procedure which was used when carrying out the sampling event'
538                )
539                .with { if (!validate()) { errors.each { println it} } else save()}
540
541                // liver sampling event template
542                def liverSamplingEventTemplate = new Template(
543                        name: 'Liver extraction',
544                        description: 'Liver sampling for transcriptomics arrays',
545                        entity: dbnp.studycapturing.SamplingEvent
546                )
547                .addToFields(samplingProtocolField)
548                .addToFields(
549                        new TemplateField(
550                                name: 'Sample weight',
551                                unit: 'mg',
552                                entity: SamplingEvent,
553                                type: TemplateFieldType.DOUBLE
554                        )
555                )
556                .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
557                liverSamplingEventTemplate.refresh()
558
559                // blood sampling
560                def bloodSamplingEventTemplate = new Template(
561                        name: 'Blood extraction',
562                        description: 'Blood extraction targeted at lipid assays',
563                        entity: dbnp.studycapturing.SamplingEvent
564                )
565                .addToFields(samplingProtocolField)
566                .addToFields(
567                        new TemplateField(
568                                name: 'Sample volume',
569                                entity: SamplingEvent,
570                                unit: 'ml',
571                                type: TemplateFieldType.DOUBLE
572                        )
573                )
574                .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
575                bloodSamplingEventTemplate.refresh()
576
577                // plant sample extraction event template
578                def plantSamplingExtractEventTemplate = new Template(
579                        name: 'Plant sample extraction',
580                        description: 'sample extraction',
581                        entity: dbnp.studycapturing.SamplingEvent,
582                    sampleTemplates: [plantSampleTemplate]
583                )
584                .addToFields(samplingProtocolField)
585                .addToFields(
586                        new TemplateField(
587                                name: 'Sample weight',
588                                unit: 'ul',
589                                entity: SamplingEvent,
590                                type: TemplateFieldType.DOUBLE
591                        )
592                )
593                .addToFields(
594                        new TemplateField(
595                                name: 'Sample when measured',
596                                type: TemplateFieldType.STRINGLIST,
597                                entity: SamplingEvent,
598                             listEntries: [
599                                         new TemplateFieldListItem(name:'Dried'),
600                             new TemplateFieldListItem(name: 'Fresh'),
601                             new TemplateFieldListItem(name: 'Unknown')
602                                 ]
603                        )
604                )
605                .with { if (!validate()) { errors.each { println it} } else save()}
606
607                // plant sampling event template
608                def plantSamplingEventTemplate = new Template(
609                        name: 'Plant-sample',
610                        description: 'plant sample ',
611                        entity: dbnp.studycapturing.SamplingEvent,
612                    sampleTemplates: [plantSampleTemplate]
613                )
614                //.addToFields(samplingProtocolField)
615                .addToFields(
616                        new TemplateField(
617                                name: 'material',
618                            comment: 'physical charecteristic. e.g, grounded powder of tomato seed or liquid',
619                                entity: SamplingEvent,
620                                type: TemplateFieldType.STRING
621                        )
622                )
623                .addToFields(
624                        new TemplateField(
625                                name: 'Description',
626                                type: TemplateFieldType.STRING,
627                                entity: SamplingEvent
628                        )
629                )
630                .addToFields(
631                        new TemplateField(
632                                name: 'extracted material',
633                                comment: 'substance to be extracted. e.g., lipids, volatiles, primary metabolites etc',
634                                type: TemplateFieldType.STRING,
635                                entity: SamplingEvent
636                        )
637                )
638                .addToFields(
639                        new TemplateField(
640                                name: 'Text on vial',
641                                entity: SamplingEvent,
642                                type: TemplateFieldType.STRING
643                        )
644                )
645                .with { if (!validate()) { errors.each { println it} } else save()}
646
647
648                // assay templates
649                def assayDescriptionField = new TemplateField(
650                                name: 'Description',
651                            comment: 'add general assay information here',
652                                entity: Assay,
653                                type: TemplateFieldType.STRING
654                );
655                assayDescriptionField.with { if (!validate()) { errors.each { println it} } else save()}
656
657                def ccAssayTemplate = new Template(
658                        name: 'Clinical chemistry assay',
659                        description: 'Clinical chemistry assay stored in a SAM module',
660                        entity: dbnp.studycapturing.Assay
661                )
662                .addToFields(assayDescriptionField)
663                .with { if (!validate()) { errors.each { println it} } else save()}
664
665                def metAssayTemplate = new Template(
666                        name: 'Metabolomics assay',
667                        description: 'Metabolomics assay stored in a metabolomics module',
668                        entity: dbnp.studycapturing.Assay
669                )
670                .addToFields(assayDescriptionField)
671                .addToFields(
672                        new TemplateField(
673                                name: 'Spectrometry technique',
674                            comment: 'Select the used metabolomics technique',
675                                entity: Assay,
676                                type: TemplateFieldType.STRINGLIST,
677                            listEntries: [
678                                        new TemplateFieldListItem(name: 'GC/MS'),
679                                new TemplateFieldListItem(name: 'LC/MS'),
680                                new TemplateFieldListItem(name: 'NMR'),
681                                new TemplateFieldListItem(name: 'HPLC')
682                            ])
683                )
684                .with { if (!validate()) { errors.each { println it} } else save(flush:true)}
685                metAssayTemplate.refresh()
686        }
687
688}
Note: See TracBrowser for help on using the repository browser.