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

Last change on this file since 836 was 836, checked in by keesvb, 13 years ago

added some example assay templates, started with implementation of assay and assay group steps in wizard

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