Changeset 139


Ignore:
Timestamp:
Jan 27, 2010, 9:58:59 AM (13 years ago)
Author:
keesvb
Message:

changed domain model for events and protocol parameters, and for template field storage, added NuGO PPS3 events, added searchable plugin for full text queries, corrected a few HTML errors in create study

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/application.properties

    r130 r139  
    11#Grails Metadata file
    2 #Mon Jan 25 12:50:44 CET 2010
     2#Tue Jan 26 12:10:14 CET 2010
    33app.grails.version=1.2.0
    44app.name=gscf
    55app.servlet.version=2.4
    66app.version=0.1
    7 plugins.class-diagram=0.4.1
    87plugins.db-util=0.4
    98plugins.hibernate=1.2.0
     
    1110plugins.mail=0.9
    1211plugins.nimble=0.3-SNAPSHOT
     12plugins.searchable=0.5.5
    1313plugins.shiro=1.0.1
    1414plugins.tomcat=1.2.0
  • trunk/grails-app/conf/BootStrap.groovy

    r138 r139  
    2929                                shortName: 'Taxon',
    3030                                url: 'http://www.obofoundry.org/cgi-bin/detail.cgi?id=ncbi_taxonomy'
    31                         ).save()
     31                        ).with { if (!validate()) { errors.each { println it} } else save()}
     32
    3233
    3334                        // terms
     
    3637                                ontology: speciesOntology,
    3738                                accession: '10090'
    38                         ).save()
     39                        ).with { if (!validate()) { errors.each { println it} } else save()}
    3940                        def humanTerm = new Term(
    4041                                name: 'Homo sapiens',
    4142                                ontology: speciesOntology,
    4243                                accession: '9606'
    43                         ).save()
     44                        ).with { if (!validate()) { errors.each { println it} } else save()}
     45
     46                        def madmaxOntology = new Ontology(
     47                                name: 'Madmax ontology',
     48                                shortName: 'MDMX',
     49                                url: 'madmax.bioinformatics.nl'
     50                        ).with { if (!validate()) { errors.each { println it} } else save()}
     51
     52                        def treatmentTerm = new Term(
     53                                name: 'ExperimentalProtocol',
     54                                ontology: madmaxOntology,
     55                                accession: 'P-MDMXGE-264'
     56                        ).with { if (!validate()) { errors.each { println it} } else save()}
     57
     58
     59                        def treatmentProtocol = new Protocol(
     60                                name: 'MADMAX Experimental Protocol',
     61                                reference: treatmentTerm
     62                        ).with { if (!validate()) { errors.each { println it} } else save()}
     63
     64                        treatmentProtocol
     65                        .addToParameters(new ProtocolParameter(
     66                                name: 'Diet',
     67                                type: ProtocolParameterType.STRINGLIST,
     68                                listEntries: ['10% fat (palm oil)','45% fat (palm oil)']))
     69                        .addToParameters(new ProtocolParameter(
     70                                name: 'Compound',
     71                                type: ProtocolParameterType.STRINGLIST,
     72                                listEntries: ['Vehicle','Leptin']))
     73                        .addToParameters(new ProtocolParameter(
     74                                name: 'Administration',
     75                                type: ProtocolParameterType.STRING))
     76                        .save()
     77
    4478
    4579                        // create system user
     
    5993                                name: 'Genotype',type: TemplateFieldType.STRINGLIST))
    6094                        .addToSubjectFields(new TemplateSubjectField(
    61                                 name: 'Age',type: TemplateFieldType.NUMBER)
    62                         ).save()
     95                                name: 'Gender',type: TemplateFieldType.STRINGLIST))
     96                        .addToSubjectFields(new TemplateSubjectField(
     97                                name: 'Age',type: TemplateFieldType.INTEGER))
     98                        .addToSubjectFields(new TemplateSubjectField(
     99                                name: 'Cage',type: TemplateFieldType.INTEGER))
     100                        .with { if (!validate()) { errors.each { println it} } else save()}
     101
     102
     103                        //events
     104                        def eventTreatment = new EventDescription(
     105                                name: 'Treatment',
     106                                description: 'Experimental Treatment Protocol NuGO PPS3 leptin module',
     107                                classification: treatmentTerm,
     108                                protocol: treatmentProtocol
     109                        ).with { if (!validate()) { errors.each { println it} } else save()}
    63110
    64111                        // studies
     
    69116                                description:"C57Bl/6 mice were fed a high fat (45 en%) or low fat (10 en%) diet after a four week run-in on low fat diet. After 1 week 10 mice that received a low fat diet were given an IP leptin challenge and 10 mice of the low-fat group received placebo injections. The same procedure was performed with mice that were fed the high-fat diet. After 4 weeks the procedure was repeated. In total 80 mice were culled.",
    70117                                ecCode:"2007117.c",
    71                                 startDate: Date.parse('yyyy-MM-dd','2007-12-11'))
     118                                startDate: Date.parse('yyyy-MM-dd','2007-12-11')
     119                        ).with { if (!validate()) { errors.each { println it} } else save()}
     120
    72121                        def x=1
    73122                        12.times {
    74                                 exampleStudy.addToSubjects(new Subject(
     123                                def currentSubject = new Subject(
    75124                                        name: "A" + x++,
    76125                                        species: mouseTerm,
    77                                         templateStringFields: ["Genotype" : "C57/Bl6j"],
    78                                         templateNumberFields: ["Age" : 17F]
    79                                 ))}
    80                         exampleStudy.save()
     126                                        templateStringFields: ["Genotype" : "C57/Bl6j", "Gender" : "Male"],
     127                                        templateNumberFields: ["Age" : 17, "Cage" : (int)(x/2)]
     128                                ).with { if (!validate()) { errors.each { println it} } else save()}
     129
     130                                exampleStudy.addToSubjects(currentSubject)
     131                                .addToEvents(new Event(
     132                                        subject: currentSubject,
     133                                        startTime: Date.parse('yyyy-MM-dd','2008-01-07'),
     134                                        endTime: Date.parse('yyyy-MM-dd','2008-01-14'),
     135                                        eventDescription: eventTreatment,
     136                                        parameterStringValues: ['Diet':'10% fat (palm oil)','Compound':'Vehicle','Administration':'intraperitoneal injection'])
     137                                ).with { if (!validate()) { errors.each { println it} } else save()}
     138                        }
    81139
    82140                        new Study(title:"example",code:"Excode",researchQuestion:"ExRquestion",description:"Exdescription",ecCode:"ExecCode",dateCreated:new Date(),lastUpdated:new Date(),startDate:new Date()).save()
  • trunk/grails-app/domain/dbnp/data/Term.groovy

    r138 r139  
    77 * The Term object should point to an existing term in an online ontology, therefore instances of this class can also
    88 * be seen as a cache of elements of the external ontology.
    9  *
    10  * Revision information:
    11  * $Rev$
    12  * $Author$
    13  * $Date$
    149 */
    15 class Term implements Serializable {
    16         String name
    17         Ontology ontology
    18         String accession
     10class Term {
     11    static searchable = true
     12    String name
     13    Ontology ontology
     14    String accession
    1915
    20         static constraints = {
    21         }
     16    static constraints = {
     17    }
    2218
    23         def String toString() {
    24                 return name
    25         }
     19  def String toString() {
     20    return name
     21  }
     22
     23
    2624}
  • trunk/grails-app/domain/dbnp/studycapturing/Event.groovy

    r124 r139  
    22
    33import groovy.time.*
    4 
    54
    65/**
     
    1110class Event {
    1211
    13     Subject subject
    14     EventDescription eventDescription
    15     Date startTime
    16     Date endTime
     12        Subject subject
     13        EventDescription eventDescription
     14        Date startTime
     15        Date endTime
     16        Map parameterStringValues
     17        Map parameterIntegerValues
     18        Map parameterFloatValues
     19
     20        static hasMany = [
     21                parameterStringValues : String, // stores both STRING and STRINGLIST items (latter should be checked against the list)
     22                parameterIntegerValues : int,
     23                parameterFloatValues : float
     24        ]
     25
     26        // static constraints = { }
     27
     28        def getDuration() {
     29                //endTime - startTime  // this is not documented and does not work either
     30                // so, it's useless.
     31                // thus, do this manually as follows
     32
     33                def timeMillis = (endTime.getTime() - startTime.getTime()).abs()
     34                def days = (timeMillis / (1000 * 60 * 60 * 24)).toInteger()
     35                def hours = (timeMillis / (1000 * 60 * 60)).toInteger()
     36                def minutes = (timeMillis / (1000 * 60)).toInteger()
     37                def seconds = (timeMillis / 1000).toInteger()
     38                def millis = (timeMillis % 1000).toInteger()
     39
     40                return new Duration(days, hours, minutes, seconds, millis)
     41        }
    1742
    1843
    19     // static constraints = { }
    20     def getDuration() {
    21         //endTime - startTime  // this is not documented and does not work either
    22                                // so, it's useless.
    23                                // thus, do this manually as follows
    24 
    25         def timeMillis = (endTime.getTime() - startTime.getTime()).abs()
    26         def days    = (timeMillis/(1000*60*60*24)).toInteger()
    27         def hours   = (timeMillis/(1000*60*60)).toInteger()
    28         def minutes = (timeMillis/(1000*60)).toInteger()
    29         def seconds = (timeMillis/1000).toInteger()
    30         def millis  = (timeMillis%1000).toInteger()
    31 
    32         return new Duration(days,hours,minutes,seconds,millis)
    33     }
    34 
    35 
    36     def getDurationString()
    37     {
    38         def d = getDuration()
    39         return  "${d.days} days, ${d.hours} hrs, ${d.minutes} min, ${d.seconds} sec."
    40     }
     44        def getDurationString() {
     45                def d = getDuration()
     46                return "${d.days} days, ${d.hours} hrs, ${d.minutes} min, ${d.seconds} sec."
     47        }
    4148
    4249
  • trunk/grails-app/domain/dbnp/studycapturing/EventDescription.groovy

    r116 r139  
    1313    String description
    1414    Term classification
    15     ProtocolInstance protocol
     15    Protocol protocol
    1616
    1717    static constraints = {
  • trunk/grails-app/domain/dbnp/studycapturing/ProtocolInstance.groovy

    r112 r139  
    11package dbnp.studycapturing
     2
     3// this class is now obsolete, should be deleted by Jahn when he's done with Event controller/views
    24
    35/**
     
    911
    1012
    11     // TODO: check how the values can be indexed so that they can be mapped to their respective parameters (should we use maps here?)
    12     static hasMany = [values : ProtocolParameterInstance]
    1313    static constraints = {
    1414    }
  • trunk/grails-app/domain/dbnp/studycapturing/ProtocolParameter.groovy

    r114 r139  
    1010
    1111    String name
    12     String type       //  development. replace by: ProtocolParameterType type
     12    ProtocolParameterType type
    1313    String unit
    1414    String description
     
    1818
    1919    static constraints = {
     20            unit(nullable: true)
     21            reference(nullable: true)
     22            description(nullable: true)
    2023    }
    2124}
  • trunk/grails-app/domain/dbnp/studycapturing/ProtocolParameterInstance.groovy

    r115 r139  
    11package dbnp.studycapturing
    22
     3// this class is now obsolete, should be deleted by Jahn when he's done with Event controller/views
    34class ProtocolParameterInstance {
    45
  • trunk/grails-app/domain/dbnp/studycapturing/ProtocolParameterType.groovy

    r84 r139  
    66public enum ProtocolParameterType {
    77    STRING('String'),
    8     NUMBER('Number'),
     8    INTEGER('Integer number'),
     9    FLOAT('Decimal number'),
    910    STRINGLIST('List')
    1011
     
    1617
    1718    static list() {
    18      [STRING, NUMBER, STRINGLIST]
     19     [STRING, INTEGER, FLOAT, STRINGLIST]
    1920    }
    2021
  • trunk/grails-app/domain/dbnp/studycapturing/Sample.groovy

    r106 r139  
    77 */
    88class Sample {
     9        static searchable = true
    910
    1011    // TODO: should Sample also carry a reference to its parent study,
  • trunk/grails-app/domain/dbnp/studycapturing/Study.groovy

    r138 r139  
    1010 */
    1111class Study implements Serializable {
     12        static searchable = true
    1213        nimble.User owner
    1314        String title
  • trunk/grails-app/domain/dbnp/studycapturing/Subject.groovy

    r138 r139  
    11package dbnp.studycapturing
     2
    23import dbnp.data.Term
    34
    45/**
    56 * This domain class describes the subjects in a study.
    6  *
    7  * Revision information:
    8  * $Rev$
    9  * $Author$
    10  * $Date$
    117 */
    12 class Subject implements Serializable {
     8class Subject {
     9        static searchable = true
    1310        String name
    1411        Term species
    1512        Map templateStringFields
    16         Map templateNumberFields
    17         Map templateStringListFields
     13        Map templateIntegerFields
     14        Map templateFloatFields
    1815        Map templateTermFields
    1916
    2017        static hasMany = [
    21                 templateStringFields: String,
    22                 templateNumberFields: float,
    23                 templateStringListFields: String,
    24                 templateTermFields: Term
     18                templateStringFields : String, // stores both STRING and STRINGLIST items (latter should be checked against the list)
     19                templateIntegerFields : int,
     20                templateFloatFields : float,
     21                templateTermFields : Term
    2522        ]
    26 
     23       
    2724        static constraints = {
    2825        }
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateFieldType.groovy

    r84 r139  
    66public enum TemplateFieldType {
    77    STRING('String'),
    8     NUMBER('Number'),
    9     STRINGLIST('List'),
     8    INTEGER('Integer number'),
     9    FLOAT('Decimal number'),
     10    STRINGLIST('List of items'),
    1011    ONTOLOGYTERM('Ontology Reference')
    1112
     
    1718
    1819    static list() {
    19      [STRING, NUMBER, STRINGLIST, ONTOLOGYTERM]
     20     [STRING, INTEGER, FLOAT, STRINGLIST, ONTOLOGYTERM]
    2021    }
    2122
  • trunk/grails-app/views/query/index.gsp

    r132 r139  
    1717      </ul>
    1818      <div id="tab-simple">
    19         <g:form url="[action:'list',controller:'study']">
     19        <g:form url="[action:'index',controller:'searchable',params: 'q']">
    2020          <input type="hidden" name="targetUri" value="${targetUri}" />
    21           <label class="grey" for="querytext">Search for:</label>
    22           <input class="field" type="text" name="querytext" id="querytext" size="40" />
     21          <label class="grey" for="q">Search for:</label>
     22          <input class="field" type="text" name="q" id="q" size="40" />
    2323          <input type="submit" name="submit" value="Query"/>
    2424        </g:form>
  • trunk/grails-app/views/study/create.gsp

    r85 r139  
    3030                            <tr class="prop">
    3131                                <td valign="top" class="name">
    32                                     <label for="template"><g:message code="study.template.label" default="Template" /></label>
     32                                    <label for="template.id"><g:message code="study.template.label" default="Template" /></label>
    3333                                </td>
    3434                                <td valign="top" class="value ${hasErrors(bean: studyInstance, field: 'template', 'errors')}">
     
    102102                            <tr class="prop">
    103103                                <td valign="top" class="name">
    104                                     <label for="owner"><g:message code="study.owner.label" default="Owner" /></label>
     104                                    <label for="owner.id"><g:message code="study.owner.label" default="Owner" /></label>
    105105                                </td>
    106106                                <td valign="top" class="value ${hasErrors(bean: studyInstance, field: 'owner', 'errors')}">
Note: See TracChangeset for help on using the changeset viewer.