Changeset 212 for trunk/grails-app/domain
- Timestamp:
- Feb 25, 2010, 3:06:16 PM (13 years ago)
- Location:
- trunk/grails-app/domain/dbnp/studycapturing
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r190 r212 9 9 * $Date$ 10 10 */ 11 class Study implements Serializable {11 class Study extends TemplateEntity implements Serializable { 12 12 static searchable = true 13 13 nimble.User owner … … 22 22 Template template 23 23 24 static hasMany = [ editors: nimble.User, 25 readers: nimble.User, 26 subjects: Subject, 27 groups: SubjectGroup, 28 events: Event, 29 samplingEvents: SamplingEvent, 30 assays: Assay, 31 persons: StudyPerson, 32 publications: Publication 24 static hasMany = [ 25 editors: nimble.User, 26 readers: nimble.User, 27 subjects: Subject, 28 groups: SubjectGroup, 29 events: Event, 30 samplingEvents: SamplingEvent, 31 assays: Assay, 32 persons: StudyPerson, 33 publications: Publication 33 34 ] 34 35 -
trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy
r190 r212 11 11 * $Date$ 12 12 */ 13 class Subject implements Serializable {13 class Subject extends TemplateEntity implements Serializable { 14 14 static searchable = true 15 15 Template template 16 16 String name 17 17 Term species 18 Map templateStringFields19 Map templateIntegerFields20 Map templateFloatFields21 Map templateTermFields22 23 static hasMany = [24 templateStringFields: String, // stores both STRING and STRINGLIST items (latter should be checked against the list)25 templateIntegerFields: int,26 templateFloatFields: float,27 templateTermFields: Term28 ]29 30 static constraints = {31 }32 33 /**34 * Find a template field by its name and return its value for this subject35 * @param fieldName The name of the template subject field36 * @return the value of the field (class depends on the field type)37 * @throws NoSuchFieldException If the field is not found or the field type is not supported38 */39 def getFieldValue(String fieldName) {40 TemplateFieldType fieldType = template.getSubjectFieldType(fieldName)41 if (!fieldType) throw new NoSuchFieldException("Field name ${fieldName} not recognized")42 switch(fieldType) {43 case [TemplateFieldType.STRING, TemplateFieldType.STRINGLIST]:44 return templateStringFields[fieldName]45 case TemplateFieldType.INTEGER:46 return templateIntegerFields[fieldName]47 case TemplateFieldType.FLOAT:48 return templateFloatFields[fieldName]49 case TemplateFieldType.ONTOLOGYTERM:50 return templateTermFields[fieldName]51 default:52 throw new NoSuchFieldException("Field type ${fieldType} not recognized")53 }54 }55 56 def setFieldValue(String fieldName, value) {57 this.properties.each { println it}58 if (this.properties.containsKey(fieldName)) {59 this[fieldName] = value60 }61 else if (templateStringFields.containsKey(fieldName) && value.class == String) {62 this.templateStringFields[fieldName] = value63 }64 else {65 println "Field ${fieldName} not found"66 }67 }68 18 } -
trunk/grails-app/domain/dbnp/studycapturing/Template.groovy
r190 r212 4 4 * The Template class describes a study template, which is basically an extension of the study capture entities 5 5 * in terms of extra fields (described by classes that extend the TemplateField class). 6 * At this moment, only extension of the s ubject entityis implemented.6 * At this moment, only extension of the study and subject entities is implemented. 7 7 * 8 8 * Revision information: -
trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldType.groovy
r190 r212 11 11 STRING('String'), 12 12 INTEGER('Integer number'), 13 FLOAT('Decimal number'), 13 FLOAT('Floating-point number'), 14 DOUBLE('Double precision floating-point number'), 14 15 STRINGLIST('List of items'), 15 ONTOLOGYTERM('Ontology Reference') 16 ONTOLOGYTERM('Ontology Reference'), 17 DATE('Date') 16 18 17 19 String name … … 22 24 23 25 static list() { 24 [STRING, INTEGER, FLOAT, STRINGLIST, ONTOLOGYTERM]26 [STRING, INTEGER, FLOAT, DOUBLE, STRINGLIST, ONTOLOGYTERM, DATE] 25 27 } 26 28 -
trunk/grails-app/domain/dbnp/studycapturing/TemplateStudyField.groovy
r190 r212 12 12 class TemplateStudyField extends TemplateField { 13 13 static constraints = { 14 name(unique: true) 14 15 } 15 16
Note: See TracChangeset
for help on using the changeset viewer.