source: trunk/grails-app/domain/dbnp/studycapturing/Template.groovy @ 224

Last change on this file since 224 was 224, checked in by keesvb, 10 years ago

revised templating system: templates are now per entity rather than per study, moved samples to Study

  • Property svn:keywords set to Rev Date Author
File size: 1.1 KB
RevLine 
[77]1package dbnp.studycapturing
2
[84]3/**
4 * The Template class describes a study template, which is basically an extension of the study capture entities
5 * in terms of extra fields (described by classes that extend the TemplateField class).
[212]6 * At this moment, only extension of the study and subject entities is implemented.
[140]7 *
8 * Revision information:
9 * $Rev: 224 $
10 * $Author: keesvb $
11 * $Date: 2010-03-02 17:10:52 +0000 (di, 02 mrt 2010) $
[84]12 */
[140]13class Template implements Serializable {
[224]14
[146]15        String name
[224]16        Class entity
[146]17        //nimble.User owner
[84]18
[224]19        static hasMany = [fields: TemplateField]
[80]20
[146]21        static constraints = {
[224]22                name(unique:['entity'])
23
[146]24        }
25
26        def String toString() {
27                return this.name;
28        }
29
30        /**
31         * Look up the type of a certain template subject field
32         * @param fieldName The name of the template field
33         * @return The type (static member of TemplateFieldType) of the field, or null of the field does not exist
34         */
[224]35        def TemplateFieldType getFieldType(String fieldName) {
36                def field = fields.find {
[146]37                        it.name == fieldName   
38                }
39                field?.type
40        }
[224]41
42        def getFieldsByType(TemplateFieldType fieldType) {
43                def result = fields.findAll {
44                        it.type == fieldType
45                }
46                return result;
47        }
[77]48}
Note: See TracBrowser for help on using the repository browser.