source: trunk/grails-app/domain/dbnp/data/Term.groovy @ 306

Last change on this file since 306 was 306, checked in by duh, 9 years ago
  • commented out bad piece of convenienve code... see email for more information
  • Property svn:keywords set to Date Rev Author
File size: 1.3 KB
Line 
1package dbnp.data
2
3import dbnp.data.Ontology
4
5/**
6 * The Term object describes a term in the ontology that is referred to in other entities such as events.
7 * The Term object should point to an existing term in an online ontology, therefore instances of this class can also
8 * be seen as a cache of elements of the external ontology.
9 *
10 * Revision information:
11 * $Rev: 306 $
12 * $Author: duh $
13 * $Date: 2010-03-23 13:18:45 +0000 (di, 23 mrt 2010) $
14 */
15class Term implements Serializable {
16        static searchable = true
17        String name
18        Ontology ontology
19        String accession
20
21        static constraints = {
22        }
23
24        def String toString() {
25                return name
26        }
27
28
29        /*
30         * Very scary behaviour... commenting this code out. Refactor
31         * your code that relies on this by using something like
32         * Term.findByName( string ) instead...
33         *
34         * Jeroen 20100323
35         *
36
37        // Covenenice method for delivering Terms.
38        // if the term is already defined, use it.
39        // otherwise, create it and return it.
40        // should be removed when ontologies work.
41        static getTerm( string ) {
42            def term = Term.find("from Term as t where t.name = '${string}'")
43            if( term==null ) { term = new Term()
44                    term.name=string
45                    term.ontology = Ontology.find('from Ontology as o')
46                    term.accession = ''
47                    if( !term.save(flush:true) )  {
48                            term.errors.each{ println it }
49                    }
50            }
51            return term
52        }
53
54         *
55         */
56}
Note: See TracBrowser for help on using the repository browser.