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

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

forgot class import

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