Changeset 267


Ignore:
Timestamp:
Mar 15, 2010, 4:59:34 PM (7 years ago)
Author:
jahn
Message:

Added convenience function that creates a Term if it does not exist in the db. This should be updated in accordance with the Ontologies.

File:
1 edited

Legend:

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

    r247 r267  
    2525                return name
    2626        }
     27
     28
     29        // Covenenice method for delivering Terms.
     30        // if the term is already defined, use it.
     31        // otherwise, create it.
     32        // should be removed when ontologies work.
     33        static getTerm( string ) {
     34            def term = Term.find("from Term as t where t.name = '${string}'")
     35            if( term==null ) { term = new Term()
     36                    term.name=string
     37                    term.ontology = Ontology.find('from Ontology as o')
     38                    term.accession = ''
     39                    println string
     40                    if( term.save(flush:true) ) { println "okay, saved" }
     41                    else {
     42                            term.errors.each{ println it }
     43                            println "not okay, not saved" }
     44            }
     45            return term
     46        }
    2747}
Note: See TracChangeset for help on using the changeset viewer.