Ignore:
Timestamp:
Feb 25, 2010, 3:06:16 PM (13 years ago)
Author:
keesvb
Message:

refactored template entity code into TemplateEntity?, added more template field types, updated BootStrap? with some more details on PPSH, changed code in study overview to get template field contents in a nicer way

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  
    99 * $Date$
    1010 */
    11 class Study implements Serializable {
     11class Study extends TemplateEntity implements Serializable {
    1212        static searchable = true
    1313        nimble.User owner
     
    2222        Template template
    2323
    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
    3334        ]
    3435
  • trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy

    r190 r212  
    1111 * $Date$
    1212 */
    13 class Subject implements Serializable {
     13class Subject extends TemplateEntity implements Serializable {
    1414        static searchable = true
    1515        Template template
    1616        String name
    1717        Term species
    18         Map templateStringFields
    19         Map templateIntegerFields
    20         Map templateFloatFields
    21         Map templateTermFields
    22 
    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: Term
    28         ]
    29 
    30         static constraints = {
    31         }
    32 
    33         /**
    34          * Find a template field by its name and return its value for this subject
    35          * @param fieldName The name of the template subject field
    36          * @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 supported
    38          */
    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] = value
    60                 }
    61                 else if (templateStringFields.containsKey(fieldName) && value.class == String) {
    62                         this.templateStringFields[fieldName] = value
    63                 }
    64                 else {
    65                         println "Field ${fieldName} not found"
    66                 }
    67         }
    6818}
  • trunk/grails-app/domain/dbnp/studycapturing/Template.groovy

    r190 r212  
    44 * The Template class describes a study template, which is basically an extension of the study capture entities
    55 * in terms of extra fields (described by classes that extend the TemplateField class).
    6  * At this moment, only extension of the subject entity is implemented.
     6 * At this moment, only extension of the study and subject entities is implemented.
    77 *
    88 * Revision information:
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldType.groovy

    r190 r212  
    1111        STRING('String'),
    1212        INTEGER('Integer number'),
    13         FLOAT('Decimal number'),
     13        FLOAT('Floating-point number'),
     14        DOUBLE('Double precision floating-point number'),
    1415        STRINGLIST('List of items'),
    15         ONTOLOGYTERM('Ontology Reference')
     16        ONTOLOGYTERM('Ontology Reference'),
     17        DATE('Date')
    1618
    1719        String name
     
    2224
    2325        static list() {
    24                 [STRING, INTEGER, FLOAT, STRINGLIST, ONTOLOGYTERM]
     26                [STRING, INTEGER, FLOAT, DOUBLE, STRINGLIST, ONTOLOGYTERM, DATE]
    2527        }
    2628
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateStudyField.groovy

    r190 r212  
    1212class TemplateStudyField extends TemplateField {
    1313        static constraints = {
     14                name(unique: true)
    1415        }
    1516
Note: See TracChangeset for help on using the changeset viewer.