Ignore:
Timestamp:
Jun 15, 2010, 5:45:16 PM (13 years ago)
Author:
duh
Message:
  • upon adding a term the termEditorController now also adds the ontology when the ontologies doest not exist
  • extended the Ontology domain class with functionality to instantiate the Ontology class using the versioned ncboId
  • added 'addDummy' support to termElements and templateElements which caused the study and subject page not to work properly on an empty database (these fields were not rendered so exceptions were thrown).
  • this fixed bug # 107 in half... now the species select (ONTOLOGYTERM) somehow does not show the species in the database, still needs to be fixed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/data/Ontology.groovy

    r558 r565  
    7777                );
    7878        }
     79
     80        /**
     81         * Instantiate Ontotology class by searching the web service for (versioned)id.
     82         * @param       ontologyId (bioportal versionedId)
     83         * @return      ontology instance
     84         */
     85        static Ontology getBioPortalOntologyByVersionedId(String ncboVersionedId) {
     86                try {
     87                        // use the NCBO REST service to fetch ontology information
     88                        def url = "http://rest.bioontology.org/bioportal/ontologies/" + ncboVersionedId
     89                        def xml = new URL(url).getText()
     90                        def data = new XmlParser().parseText(xml)
     91                        def bean = data.data.ontologyBean
     92
     93                        // instantiate Ontology with the proper values
     94                        def ontology = new dbnp.data.Ontology(
     95                                name: bean.displayLabel.text(),
     96                                description: bean.description.text(),
     97                                url: bean.homepage.text(),
     98                                versionNumber: bean.versionNumber.text(),
     99                                ncboId: bean.ontologyId.text() as int,
     100                                ncboVersionedId: bean.id.text() as int
     101                        )
     102
     103                        // validate ontology
     104                        if (ontology.validate()) {
     105                                // proper instance
     106                                return ontology
     107                        } else {
     108                                // it does not validate
     109                                println ".encountered errors instantiating Ontology by versionedId [" + ncboVersionedId + "] :"
     110                                ontology.errors.each() {
     111                                        println "  -" + it
     112                                }
     113                                throw new Exception("instantiating Ontology by (versioned) id [" + ncboVersionedId + "] failed")
     114                        }
     115                } catch (Exception e) {
     116                        // whoops?!
     117                        return false
     118                }
     119        }
    79120}
Note: See TracChangeset for help on using the changeset viewer.