Changeset 565 for trunk/grails-app/domain/dbnp/data/Ontology.groovy
- Timestamp:
- Jun 15, 2010, 5:45:16 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/data/Ontology.groovy
r558 r565 77 77 ); 78 78 } 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 } 79 120 }
Note: See TracChangeset
for help on using the changeset viewer.