source: trunk/grails-app/domain/dbnp/studycapturing/Study.groovy @ 176

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

added first version of importer data model, added helper methods to domain class for getting all entity fields, added study template fields

  • Property svn:keywords set to
    Date
    Author
    Rev
File size: 1.3 KB
Line 
1package dbnp.studycapturing
2
3/**
4 * Domain class describing the basic entity in the study capture part: the Study class.
5 *
6 * Revision information:
7 * $Rev: 176 $
8 * $Author: keesvb $
9 * $Date: 2010-02-08 11:42:46 +0000 (ma, 08 feb 2010) $
10 */
11class Study implements Serializable {
12        static searchable = true
13        nimble.User owner
14        String title
15        String code
16        String researchQuestion
17        String description
18        String ecCode
19        Date dateCreated
20        Date lastUpdated
21        Date startDate
22        Template template
23
24        static hasMany = [      editors: nimble.User,
25                                                readers: nimble.User,
26                                                subjects: Subject,
27                                                groups: SubjectGroup,
28                                                events: Event,
29                                                samplingEvents: SamplingEvent
30        ]
31
32        static constraints = {
33                owner(nullable: true, blank: true)
34                title(nullable: false, blank: false)
35                template(nullable: true, blank: true)
36        }
37
38        static mapping = {
39                researchQuestion type: 'text'
40                description type: 'text'
41                autoTimestamp true
42        }
43
44        def String toString() {
45                return title;
46        }
47
48        Map giveAllFields() {
49                def result = [:]
50
51                // Using reflection here gives way too many properties, like searchable, hasMany,
52                // and it will probably extend when we use new plugins
53                // It is probably best
54                // - to either hardcode the above given properties
55                // - or to move all fields to the template
56               
57                this.properties.each{ //public fields only
58                        println it.name
59                        result[it.name] = it.type.name //name of field and name of type
60                }
61
62                return result;
63        }
64}
Note: See TracBrowser for help on using the repository browser.