Ignore:
Timestamp:
Jun 16, 2010, 2:57:34 PM (12 years ago)
Author:
duh
Message:
  • commit related to bug # 107

-- extended Ontology domain class with a getOrCreateOntologyByNcboId(...) method which can be used as a replacement for findByNcboId(...). This method now returns the Ontology if it exists, or creates it (by using the bioportal webservices) on the fly.
-- changed the runtime bootstrap 'hack' to use getOrCreateOntologyByNcboId(...) instead
-- removed the ontology create code from the TemplateEditor? (added in #567)

File:
1 edited

Legend:

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

    r565 r569  
    5656                        ncboVersionedId: o.id
    5757                );
     58        }
     59
     60
     61        /**
     62         * Return the Ontology by ncboId, or create it if nonexistent.
     63         * @param ncboId
     64         * @return Ontology
     65         */
     66        static Ontology getOrCreateOntologyByNcboId( Integer ncboId ) {
     67                return getOrCreateOntologyByNcboId( ncboId as String )
     68        }
     69        static Ontology getOrCreateOntologyByNcboId( String ncboId ) {
     70                def ontology = findByNcboId( ncboId )
     71
     72                // got an ontology?
     73                if (!ontology) {
     74                        // no, fetch it from the webservice
     75                        ontology = getBioPortalOntology( ncboId )
     76
     77                        if (ontology && ontology.validate() && ontology.save(flush:true)) {
     78                                ontology.refresh()
     79                        }
     80                }
     81
     82                return ontology
    5883        }
    5984
Note: See TracChangeset for help on using the changeset viewer.