Changeset 353


Ignore:
Timestamp:
Apr 20, 2010, 10:49:54 AM (13 years ago)
Author:
duh
Message:
  • refactored termField tag
  • refactored subjects page
  • added terms and ontologies to bootstrap
Location:
trunk/grails-app
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/conf/BootStrap.groovy

    r349 r353  
    9292                        .with { if (!validate()) { errors.each { println it} } else save()}
    9393
     94                        // add NCBI species ontology
     95                        println ".adding NCBI species ontology"
     96                        def speciesOntology = new Ontology(
     97                                name: 'NCBI organismal classification',
     98                                description: 'A taxonomic classification of living organisms and associated artifacts for their controlled description within the context of databases.',
     99                                url: 'http://www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/',
     100                                versionNumber: '1.2',
     101                                ncboId: '1132',
     102                                ncboVersionedId: '38802'
     103                        ).with { if (!validate()) { errors.each { println it} } else save()}
     104
     105                        // add TERMS
     106                        println ".adding mouse term"
     107                        def mouseTerm = new Term(
     108                                name: 'Mus musculus',
     109                                ontology: speciesOntology,
     110                                accession: '10090'
     111                        ).with { if (!validate()) { errors.each { println it} } else save()}
     112                        println ".adding human term"
     113                        def humanTerm = new Term(
     114                                name: 'Homo sapiens',
     115                                ontology: speciesOntology,
     116                                accession: '9606'
     117                        ).with { if (!validate()) { errors.each { println it} } else save()}
    94118
    95119
  • trunk/grails-app/domain/dbnp/data/Term.groovy

    r350 r353  
    1919        String name             // BioPortal: label (preferred name)
    2020        Ontology ontology       // Parent ontology
    21         String accession        // BioPortal: fullId
     21        String accession        // BioPortal: conceptId
    2222
    2323        static constraints = {
  • trunk/grails-app/taglib/dbnp/studycapturing/WizardTagLib.groovy

    r349 r353  
    401401
    402402        /**
     403         * Button form element
     404         * @param Map attributes
     405         * @param Closure help content
     406         */
     407        def buttonElement = {attrs, body ->
     408                // render template element
     409                baseElement.call(
     410                        'ajaxButton',
     411                        attrs,
     412                        body
     413                )
     414        }
     415
     416
     417        /**
     418         * Term form element
     419         * @param Map attributes
     420         * @param Closure help content
     421         */
     422        def termElement = { attrs, body ->
     423                // render term element
     424                baseElement.call(
     425                        'termSelect',
     426                        attrs,
     427                        body
     428                )
     429        }
     430
     431        /**
     432         * Term select element
     433         * @param Map attributes
     434         */
     435        def termSelect = { attrs ->
     436                def from = []
     437
     438                // got ontologies?
     439                if (attrs.ontology) {
     440                        attrs.ontology.split(/\,/).each() { ncboId ->
     441                                // trim the id
     442                                ncboId.trim()
     443                               
     444                                // fetch all terms for this ontology
     445                                def ontology = Ontology.findAllByNcboId(ncboId)
     446
     447                                // does this ontology exist?
     448                                if (ontology) {
     449                                        ontology.each() {
     450                                                Term.findAllByOntology(it).each() {
     451                                                        // key = ncboId:concept-id
     452                                                        from[ from.size() ] = it.name
     453                                                }
     454                                        }
     455                                }
     456                        }
     457
     458                        // sort alphabetically
     459                        from.sort()
     460                       
     461                        // define 'from'
     462                        attrs.from = from
     463
     464                        out << select(attrs)
     465                } else {
     466                        out << "you should specify: <i>ontology=\"id\"</i> or <i>ontology=\"id1,id2,...,idN\"</i>"
     467                }
     468        }
     469
     470        /**
    403471         * Template form element
    404472         * @param Map attributes
     
    409477                baseElement.call(
    410478                        'speciesSelect',
    411                         attrs,
    412                         body
    413                 )
    414         }
    415 
    416         /**
    417          * Button form element
    418          * @param Map attributes
    419          * @param Closure help content
    420          */
    421         def buttonElement = {attrs, body ->
    422                 // render template element
    423                 baseElement.call(
    424                         'ajaxButton',
    425479                        attrs,
    426480                        body
     
    564618                        return false
    565619                }
    566         }
    567 
    568         /**
    569          * Term form element
    570          * @param Map attributes
    571          * @param Closure help content
    572          */
    573         def termElement = {attrs, body ->
    574                 // render term element
    575                 baseElement.call(
    576                         'termSelect',
    577                         attrs,
    578                         body
    579                 )
    580         }
    581 
    582         /**
    583          * render a term select element
    584          * @param Map attrs
    585          */
    586         def termSelect = {attrs ->
    587                 // fetch all terms
    588                 attrs.from = Term.findAll()     // for now, all terms as we cannot identify terms as being treatment terms...
    589 
    590                 // got a name?
    591                 if (!attrs.name) {
    592                         attrs.name = 'term'
    593                 }
    594 
    595                 out << select(attrs)
    596620        }
    597621
  • trunk/grails-app/views/wizard/pages/_subjects.gsp

    r349 r353  
    2929                The species of the subjects you would like to add to your study
    3030        </wizard:ontologyElement>
     31        <wizard:termElement name="species" description="of species" value="" ontology="1132">
     32                The species of the subjects you would like to add to your study
     33        </wizard:termElement>
    3134        <wizard:templateElement name="template" description="with template" value="" error="template" entity="${dbnp.studycapturing.Subject}" >
    3235                The template to use for this study
Note: See TracChangeset for help on using the changeset viewer.