Last change
on this file since 267 was
267,
checked in by jahn, 12 years ago
|
Added convenience function that creates a Term if it does not exist in the db. This should be updated in accordance with the Ontologies.
|
-
Property svn:keywords set to
Author Rev Date
|
File size:
1.2 KB
|
Line | |
---|
1 | package dbnp.data |
---|
2 | |
---|
3 | import 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: 267 $ |
---|
12 | * $Author: jahn $ |
---|
13 | * $Date: 2010-03-15 15:59:34 +0000 (ma, 15 mrt 2010) $ |
---|
14 | */ |
---|
15 | class 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 | // 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 | } |
---|
47 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.