Project

General

Profile

Revision c398ed0b

IDc398ed0b3c9e82b5e3abce45becb17d8ed086715
Parent cc3a997a
Child 4e6343a4

Added by Andreas Müller over 8 years ago

implemented IEnumTerm and its hierarchies #3611, #3618

View differences:

.gitattributes
704 704
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/DefaultTermInitializer.java -text
705 705
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/DefinedTerm.java -text
706 706
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/DefinedTermBase.java -text
707
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/EnumeratedTermVoc.java -text
707 708
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/EventBase.java -text
708 709
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/Extension.java -text
709 710
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ExtensionType.java -text
......
712 713
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IAnnotatableEntity.java -text svneol=unset#text/plain
713 714
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ICdmBase.java -text
714 715
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IDefinedTerm.java -text
716
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IEnumTerm.java -text
715 717
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IEvent.java -text
716 718
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IIdentifiableEntity.java -text
717 719
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ILoadableTerm.java -text
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/EnumeratedTermVoc.java
1
// $Id$
2
/**
3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10

  
11
package eu.etaxonomy.cdm.model.common;
12

  
13
import java.util.HashMap;
14
import java.util.HashSet;
15
import java.util.Map;
16
import java.util.Set;
17
import java.util.UUID;
18

  
19
/**
20
 * @author a.mueller
21
 *
22
 */
23
public class EnumeratedTermVoc<T extends ISimpleTerm<?>> {
24

  
25
	private static Map<Class<? extends ISimpleTerm<?>>,EnumeratedTermVoc<ISimpleTerm>> vocsMap= new HashMap<Class<? extends ISimpleTerm<?>>, EnumeratedTermVoc<ISimpleTerm>>();
26
	
27
	private final Map<T,SingleEnumTerm<T>> lookup = new HashMap<T, SingleEnumTerm<T>>();
28
	
29
//	public interface EnumTerm<R extends EnumTerm<?>> extends ISimpleTerm<R>{
30
//		public String getKey();
31
//	}
32
	
33
	private class SingleEnumTerm<S extends T> implements IEnumTerm<T>{
34
		private S term;
35
		private String readableString;
36
		private UUID uuid;
37
		private String key;
38
		private Set<T> children = new HashSet<T>();
39
		private S parent;
40

  
41

  
42
		
43
		private	SingleEnumTerm(S term, UUID uuid, String defaultString, String key, S parent){
44
			this.term = term;
45
			this.readableString = defaultString;
46
			this.key = key;
47
			this.uuid = uuid;
48
			this.parent = parent;
49
			SingleEnumTerm<T> parentSingleEnum = lookup.get(parent); 
50
			if (parentSingleEnum != null){
51
				parentSingleEnum.children.add(term);
52
			}
53
		}
54
		
55
		@Override
56
		public UUID getUuid() {	return uuid;}
57
		@Override
58
		public T getKindOf() {return parent;}
59
		public T getTerm() {return term;}
60
		@Override
61
		public String getKey() {return key;	}
62
		@Override
63
		public String getReadableString() {return readableString;}
64

  
65
		@Override
66
		public String getMessage() {return getMessage(Language.DEFAULT());}
67

  
68
		@Override
69
		public String getMessage(Language language) {
70
			//TODO make multi-lingual
71
			return getReadableString();
72
		}
73
		
74
		@Override
75
		public Set<T> getGeneralizationOf() {
76
//			return Collections.unmodifiableSet( children );   //TODO creates stack overflow
77
			return new HashSet<T>(children);
78
		}
79

  
80
	} //end of inner class
81

  
82
//******************* DELEGATE NETHODS ************************
83
	
84
	public String getReadableString(T term) {return lookup.get(term).getReadableString();}
85

  
86
	public String getKey(T term) {return lookup.get(term).getKey();}
87

  
88
	public UUID getUuid(T term) {return lookup.get(term).getUuid();}
89
	
90
	public T getKindOf(T term) {return lookup.get(term).getKindOf();}
91

  
92
	public Set<T> getGeneralizationOf(T term) {return lookup.get(term).getGeneralizationOf();}
93

  
94
//******************* DELEGATE CLASS NETHODS ************************
95

  
96
	
97
	public static <S extends ISimpleTerm<?>> IEnumTerm addTerm(Class<? extends ISimpleTerm<?>> clazz, S term, UUID uuid, String defaultString, String key, S parent){
98
		if (vocsMap.get(clazz) == null){
99
			vocsMap.put(clazz, new EnumeratedTermVoc());
100
		}
101
		IEnumTerm myTerm = vocsMap.get(clazz).add(term, uuid, defaultString, key, parent);
102
		return myTerm;
103
	}
104
	
105
	private  SingleEnumTerm<T> add(ISimpleTerm<?> term, UUID uuid, String defaultString, String key, ISimpleTerm<?> parent) {
106
		SingleEnumTerm<T> singleTerm = new SingleEnumTerm<T>((T)term, uuid, defaultString, key, (T)parent);
107
		if (containsKey(lookup, key)){
108
			throw new RuntimeException(String.format("Key must be unique in TermType but was not for '%s'", key));
109
		}
110
		if (containsUuid(lookup, uuid)){
111
			throw new RuntimeException(String.format("UUID must be unique in TermType but was not for '%s'", uuid));
112
		}
113
		lookup.put((T)term, singleTerm);
114
		return singleTerm;
115
	}
116

  
117
	public boolean containsKey(Map<T, SingleEnumTerm<T>> lookup, String key) {
118
		for (SingleEnumTerm<T> term : lookup.values()){
119
			if (term.getKey().equals(key)){
120
				return true;
121
			}
122
		}
123
		return false;
124
	}
125

  
126
	public boolean containsUuid(Map<T, SingleEnumTerm<T>> lookup, UUID uuid) {
127
		for (SingleEnumTerm<T> term : lookup.values()){
128
			if (term.getUuid().equals(uuid)){
129
				return true;
130
			}
131
		}
132
		return false;
133
	}
134

  
135
	public static <R extends ISimpleTerm<?>> R byKey(Class<R> clazz, String key) {
136
		EnumeratedTermVoc<R> voc = getVoc(clazz);
137
		return voc == null? null:voc.getByKey(key);
138
	}
139

  
140
	public static <R extends ISimpleTerm<?>> R byUuid(Class<R> clazz, UUID uuid) {
141
		EnumeratedTermVoc<R> voc = getVoc(clazz);
142
		return voc == null? null:voc.getByUuid(uuid);
143
	}
144

  
145
	
146
	public T getByKey(String key) {
147
		for (SingleEnumTerm<T> term : lookup.values()){
148
			if (term.getKey().equals(key)){
149
				return term.getTerm();
150
			}
151
		}
152
		return null;
153
	}
154
	
155
	public T getByUuid(UUID uuid) {
156
		for (SingleEnumTerm<T> term : lookup.values()){
157
			if (term.getUuid().equals(uuid)){
158
				return term.getTerm();
159
			}
160
		}
161
		return null;
162
	}
163

  
164
	public static <R extends ISimpleTerm<?>> EnumeratedTermVoc<R> getVoc(Class<R> clazz) {
165
		return (EnumeratedTermVoc<R>)vocsMap.get(clazz);
166
	}
167

  
168

  
169

  
170
	
171

  
172
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IEnumTerm.java
1
/**
2
 * 
3
 */
4
package eu.etaxonomy.cdm.model.common;
5

  
6
/**
7
 * @author a.mueller
8
 * @created 15-Jul-2013
9
 *
10
 */
11
public interface IEnumTerm<T extends ISimpleTerm> extends ISimpleTerm<T> {
12

  
13
	String getKey();
14

  
15
	String getReadableString();
16

  
17
	String getMessage();	
18

  
19
	String getMessage(Language language);
20

  
21
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/ISimpleTerm.java
20 20
	@Transient
21 21
	public UUID getUuid();
22 22
	
23
	public T getByUuid(UUID uuid);
23
	//is static !!
24
//	public T getByUuid(UUID uuid);
24 25

  
25 26

  
26 27
	/**
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OriginalSourceType.java
11 11
package eu.etaxonomy.cdm.model.common;
12 12

  
13 13
import java.io.Serializable;
14
import java.util.HashSet;
15
import java.util.List;
16 14
import java.util.Set;
17 15
import java.util.UUID;
18 16

  
19
import javax.persistence.Transient;
20 17
import javax.xml.bind.annotation.XmlEnum;
21 18
import javax.xml.bind.annotation.XmlEnumValue;
22 19

  
23 20
import org.apache.log4j.Logger;
24 21

  
25
import au.com.bytecode.opencsv.CSVWriter;
26
import eu.etaxonomy.cdm.model.media.Media;
27

  
28 22

  
29 23

  
30 24
/**
......
36 30
 * @created 15.05.2013
37 31
 */
38 32
@XmlEnum
39
public enum OriginalSourceType implements ISimpleTerm<OriginalSourceType>, Serializable{
33
public enum OriginalSourceType implements IEnumTerm<OriginalSourceType>, Serializable{
40 34
	
41 35
	//0
42 36
	/**
......
45 39
	 *   
46 40
	 */
47 41
	@XmlEnumValue("Unknown")
48
	Unknown(UUID.fromString("b48a443c-05f2-47ff-b885-1d3bd31118e1"), "Unknown Provenance"),
42
	Unknown(UUID.fromString("b48a443c-05f2-47ff-b885-1d3bd31118e1"), "Unknown Provenance", "UNK", null),
49 43
	
50 44
	//1
51 45
	/**
......
58 52
	 *   
59 53
	 */
60 54
	@XmlEnumValue("Primary Taxonomic Source")
61
	PrimaryTaxonomicSource(UUID.fromString("c990beb3-3bc9-4dad-bbdf-9c11683493da"), "Primary Taxonomic Source"),
55
	PrimaryTaxonomicSource(UUID.fromString("c990beb3-3bc9-4dad-bbdf-9c11683493da"), "Primary Taxonomic Source", "PTS", null),
62 56
	
63 57
	//2
64 58
	/**
65
	 * Data Lineage describes the data life cycle of electronically available data. A typical use-case for 
66
	 * data lineage is a data import from one database to another. Sources of type data lineage will store information about the
67
	 * original database and the identifier and table (->namespace) used in the original database.
68
	 * There are multiple types of data lineage: Blackbox, Dispatcher, Aggregator ({@link http://de.wikipedia.org/wiki/Data-Lineage})  
59
	 * Data Lineage describes the data life cycle of electronically available data. A typical
60
	 * use-case for data lineage is a data import from one database to another. Sources of 
61
	 * type data lineage will store information about the original database and the identifier 
62
	 * and table (->namespace) used in the original database.
63
	 * There are multiple types of data lineage: Blackbox, Dispatcher, Aggregator 
64
	 * ({@link http://de.wikipedia.org/wiki/Data-Lineage})  
69 65
	 */
70 66
	@XmlEnumValue("Data Lineage")
71
	Lineage(UUID.fromString("4f9fdf9a-f3b5-490c-96f0-90e050599b0e"), "Data Lineage"),
67
	Lineage(UUID.fromString("4f9fdf9a-f3b5-490c-96f0-90e050599b0e"), "Data Lineage", "DLI", null),
72 68

  
73 69
	//3
74 70
	/**
75
	 * Database Import is a specialisation of {@value #Lineage}. It describes the electronic import of data 
76
	 * from an external datasource into the given datasource. This step may include data transformations also
77
	 * but the primary process is the import of data.
71
	 * Database Import is a specialization of {@value #Lineage}. It describes the electronic
72
	 * import of data from an external datasource into the given datasource. This step may
73
	 * include data transformations also but the primary process is the import of data.
78 74
	*/
79 75
	@XmlEnumValue("Database Import")
80
	Import(UUID.fromString("2a3902ff-06a7-4307-b542-c743e664b8f2"), "Database Import"),
76
	Import(UUID.fromString("2a3902ff-06a7-4307-b542-c743e664b8f2"), "Database Import", "DIM", Lineage),
81 77

  
82 78
	//4
83 79
	/**
84
	 * Data Transformation is a specification of {@value #Lineage} and describes a data transformation process 
85
	 * that happens primarily  on the given dataset but may also include external data.
80
	 * Data Transformation is a specialization of {@value #Lineage} and describes a data 
81
	 * transformation process that happens primarily  on the given dataset but may also 
82
	 * include external data.
86 83
	 */
87 84
	@XmlEnumValue("Data Transformation")
88
	Transformation(UUID.fromString("d59e80e5-cbb7-4658-b74d-0626bbb0da7f"), "Data Transformation"),
85
	Transformation(UUID.fromString("d59e80e5-cbb7-4658-b74d-0626bbb0da7f"), "Data Transformation", "TRA", Lineage),
89 86

  
90 87

  
91 88
	//5
92 89
	/**
93
	 * Data aggregation is a spcification of {@value #Lineage} and describes the data transformation process
94
	 * that primarily includes data aggregation processes but may also include data imports and transformations.
90
	 * Data aggregation is a spcification of {@value #Lineage} and describes the 
91
	 * data transformation process that primarily includes data aggregation processes 
92
	 * but may also include data imports and transformations.
95 93
	 */
96 94
	@XmlEnumValue("Data Aggregation")
97
	Aggregation(UUID.fromString("944f2f40-5144-4c81-80d9-f61aa10507b8"), "Data Aggregation"),
95
	Aggregation(UUID.fromString("944f2f40-5144-4c81-80d9-f61aa10507b8"), "Data Aggregation", "DAG", Lineage),
98 96

  
99 97
	//6
100 98
	/**
101 99
	 * <code>Other</code> is the type to be used if none of the other types is applicable.
102 100
	 */
103 101
	@XmlEnumValue("Other")
104
	Other(UUID.fromString("b7c4b7fe-0aef-428a-bb7b-9153a11bf845"), "Other"),
102
	Other(UUID.fromString("b7c4b7fe-0aef-428a-bb7b-9153a11bf845"), "Other", "OTH", null),
105 103

  
106
	//1
104
	//7
107 105
	/**
108 106
	 * Primary Media Source describes the original source for any media file. 
109 107
	 * E.g. a taxonomist may have used three books/articles/other references to gather information
......
113 111
	 *   
114 112
	 */
115 113
	@XmlEnumValue("Primary Media Source")
116
	PrimaryMediaSource(UUID.fromString("72be3615-a6da-4728-948a-b3c5797fa4bc"), "Primary Media Source"),
114
	PrimaryMediaSource(UUID.fromString("72be3615-a6da-4728-948a-b3c5797fa4bc"), "Primary Media Source", "PMS", null),
117 115

  
118
	
119 116
	;
120 117
	
121 118
	
122 119
	@SuppressWarnings("unused")
123 120
	private static final Logger logger = Logger.getLogger(OriginalSourceType.class);
124 121

  
125
	private String readableString;
126
	private UUID uuid;
127 122

  
128
	private OriginalSourceType(UUID uuid, String defaultString){
129
		this.uuid = uuid;
130
		readableString = defaultString;
123
	private OriginalSourceType(UUID uuid, String defaultString, String key, OriginalSourceType parent){
124
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
131 125
	}
132 126

  
133
	@Transient
134
	public String getMessage(){
135
		return getMessage(Language.DEFAULT());
136
	}
137
	public String getMessage(Language language){
138
		//TODO make multi-lingual
139
		return readableString;
140
	}
141 127

  
142 128

  
143
	@Override
144
    public UUID getUuid() {
145
		return this.uuid;
129
// *************************** DELEGATE **************************************/	
130
	
131
	private static EnumeratedTermVoc<OriginalSourceType> delegateVoc;
132
	private IEnumTerm<OriginalSourceType> delegateVocTerm;
133

  
134
	static {
135
		delegateVoc = EnumeratedTermVoc.getVoc(OriginalSourceType.class);
146 136
	}
137
	
138
	@Override
139
	public String getKey(){return delegateVocTerm.getKey();}
140
	
141
	@Override
142
    public String getMessage(){return delegateVocTerm.getMessage();}
147 143

  
144
	@Override
145
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
148 146

  
149 147
	@Override
150
    public OriginalSourceType getByUuid(UUID uuid) {
151
		for (OriginalSourceType referenceType : OriginalSourceType.values()){
152
			if (referenceType.getUuid().equals(uuid)){
153
				return referenceType;
154
			}
155
		}
156
		return null;
157
	}
148
	public String getReadableString() {return delegateVocTerm.getReadableString();}
149
		
150
	@Override
151
    public UUID getUuid() {return delegateVocTerm.getUuid();}
158 152

  
159 153
	@Override
160
    public OriginalSourceType getKindOf() {
161
		return null;
162
	}
154
    public OriginalSourceType getKindOf() {return delegateVocTerm.getKindOf();}
155
	
156
	@Override
157
    public Set<OriginalSourceType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
163 158

  
159
	public static OriginalSourceType getByKey(String key){return delegateVoc.getByKey(key);}
160
    public static OriginalSourceType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
164 161

  
165
	@Override
166
    public Set<OriginalSourceType> getGeneralizationOf() {
167
		return new HashSet<OriginalSourceType>();
168
	}
169 162

  
170 163
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/TermType.java
11 11
package eu.etaxonomy.cdm.model.common;
12 12

  
13 13
import java.io.Serializable;
14
import java.util.Collections;
15
import java.util.HashMap;
16
import java.util.HashSet;
17
import java.util.List;
18
import java.util.Map;
19 14
import java.util.Set;
20 15
import java.util.UUID;
21 16

  
22
import javax.persistence.Transient;
17
import javax.lang.model.element.Modifier;
23 18
import javax.xml.bind.annotation.XmlEnum;
24 19
import javax.xml.bind.annotation.XmlEnumValue;
25 20

  
26 21
import org.apache.log4j.Logger;
27 22

  
28
import au.com.bytecode.opencsv.CSVWriter;
29 23
import eu.etaxonomy.cdm.model.agent.Institution;
30 24
import eu.etaxonomy.cdm.model.description.CategoricalData;
31 25
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
......
36 30
import eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue;
37 31
import eu.etaxonomy.cdm.model.description.TaxonDescription;
38 32
import eu.etaxonomy.cdm.model.description.TextData;
33
import eu.etaxonomy.cdm.model.location.NamedArea;
39 34
import eu.etaxonomy.cdm.model.location.Point;
40
import eu.etaxonomy.cdm.model.media.Media;
41 35
import eu.etaxonomy.cdm.model.media.Rights;
42 36
import eu.etaxonomy.cdm.model.molecular.Amplification;
43
import eu.etaxonomy.cdm.model.molecular.Sequence;
44 37
import eu.etaxonomy.cdm.model.name.HybridRelationship;
45 38
import eu.etaxonomy.cdm.model.name.NameRelationship;
46 39
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
......
53 46
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
54 47
import eu.etaxonomy.cdm.model.taxon.Taxon;
55 48
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
49
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
56 50

  
57 51

  
58 52

  
......
70 64
 * @created 11.06.2013
71 65
 */
72 66
@XmlEnum
73
public enum TermType implements ISimpleTerm<TermType>, Serializable{
67
public enum TermType implements IEnumTerm<TermType>, Serializable{
74 68
	
75 69
	//0
76 70
	/**
......
79 73
	 * we find an appropriate usage in future.
80 74
	 */
81 75
	@XmlEnumValue("Unknown")
82
	Unknown(UUID.fromString("b2836c89-3b1d-4758-ba6d-568ef8d6fbc4"), "Unknown term type","UNK"),
76
	Unknown(UUID.fromString("b2836c89-3b1d-4758-ba6d-568ef8d6fbc4"), "Unknown term type","UNK", null),
83 77

  
84 78
	//1
85 79
	/**
86 80
	 * Term type to represent languages.
87 81
	 */
88 82
	@XmlEnumValue("Language")
89
	Language(UUID.fromString("5591dc6c-ad1f-4abd-b6c2-4852ea8e46df"), "Language", "LA"),
83
	Language(UUID.fromString("5591dc6c-ad1f-4abd-b6c2-4852ea8e46df"), "Language", "LA", null),
90 84
	
91 85
	//2
92 86
	/**
93 87
	 * Term type for areas.
94 88
	 */
95 89
	@XmlEnumValue("NamedArea")
96
	NamedArea(UUID.fromString("8c9a0bc9-da91-478d-bc8b-44b11565e160"), "Named area", "NA"),
90
	NamedArea(UUID.fromString("8c9a0bc9-da91-478d-bc8b-44b11565e160"), "Named area", "NA", null),
97 91

  
98 92
	//3
99 93
	/**
100 94
	 * Term type for taxonomic ranks.
101 95
	 */
102 96
	@XmlEnumValue("Rank")
103
	Rank(UUID.fromString("8d26b6a9-8a89-45d5-8358-49c3e4f30ade"), "Rank", "RK"),	
97
	Rank(UUID.fromString("8d26b6a9-8a89-45d5-8358-49c3e4f30ade"), "Rank", "RK", null),	
104 98
	
105 99
	//4
106 100
	/**
......
108 102
	 * @see DescriptionElementBase
109 103
	 */
110 104
	@XmlEnumValue("Feature")
111
	Feature(UUID.fromString("b866a1d6-f962-4c23-bb8e-a3b66d33aedc"), "Feature", "FE"),
105
	Feature(UUID.fromString("b866a1d6-f962-4c23-bb8e-a3b66d33aedc"), "Feature", "FE", null),
112 106
	
113 107
	//5
114 108
	/**
......
116 110
	 * @see Annotation
117 111
	 */
118 112
	@XmlEnumValue("AnnotationType")
119
	AnnotationType(UUID.fromString("c3aabb64-6174-4152-95b1-7cec57e485cf"), "Annotation type", "ANT"),
113
	AnnotationType(UUID.fromString("c3aabb64-6174-4152-95b1-7cec57e485cf"), "Annotation type", "ANT", null),
120 114
	
121 115
	//6
122 116
	/**
......
124 118
	 * @see Marker
125 119
	 */
126 120
	@XmlEnumValue("MarkerType")
127
	MarkerType(UUID.fromString("d28a1bf8-95ed-483a-8f02-3515b14998e0"), "MarkerType", "MAT"),
121
	MarkerType(UUID.fromString("d28a1bf8-95ed-483a-8f02-3515b14998e0"), "MarkerType", "MAT", null),
128 122
	
129 123
	//7
130 124
	/**
......
132 126
	 * @see Extension
133 127
	 */
134 128
	@XmlEnumValue("ExtensionType")
135
	ExtensionType(UUID.fromString("12f5c03b-528a-4909-b81b-e525feabc97c"), "Extension type", "EXT"),
129
	ExtensionType(UUID.fromString("12f5c03b-528a-4909-b81b-e525feabc97c"), "Extension type", "EXT", null),
136 130
	
137 131
	//8
138 132
	/**
......
140 134
	 * @see DerivationEvent
141 135
	 */
142 136
	@XmlEnumValue("DerivationEventType")
143
	DerivationEventType(UUID.fromString("ba8e4b10-c792-42e7-a3f5-874708f10094"), "Derivation event type", "DET"),
137
	DerivationEventType(UUID.fromString("ba8e4b10-c792-42e7-a3f5-874708f10094"), "Derivation event type", "DET", null),
144 138

  
145 139
	//9
146 140
	/**
......
148 142
	 * @see Distribution
149 143
	 */
150 144
	@XmlEnumValue("PresenceAbsenceTerm")
151
	PresenceAbsenceTerm(UUID.fromString("f6b80f88-c8c5-456b-bbd6-d63ecf35606e"), "Presence or absence term", "PAT"),
145
	PresenceAbsenceTerm(UUID.fromString("f6b80f88-c8c5-456b-bbd6-d63ecf35606e"), "Presence or absence term", "PAT", null),
152 146

  
153 147
	//10
154 148
	/**
......
156 150
	 * @see NomenclaturalStatus
157 151
	 */
158 152
	@XmlEnumValue("NomenclaturalStatusType")
159
	NomenclaturalStatusType(UUID.fromString("c1acb71a-1d11-4305-8818-c2268d341742"), "Nomenclatural status type", "NST"),
153
	NomenclaturalStatusType(UUID.fromString("c1acb71a-1d11-4305-8818-c2268d341742"), "Nomenclatural status type", "NST", null),
160 154

  
161 155
	//11
162 156
	/**
......
166 160
	@XmlEnumValue("NameRelationshipType")
167 161
	NameRelationshipType(UUID.fromString("acd8189a-23b9-4a53-8f48-1d2aa270a6ba"), "Name relationship type", "NRT"),
168 162

  
169

  
170 163
	//12
171 164
	/**
172 165
	 * Term type for the type of a hybrid relationship between {@link TaxonNameBase taxon names}
......
175 168
	@XmlEnumValue("HybridRelationshipType")
176 169
	HybridRelationshipType(UUID.fromString("aade9e61-eaa1-40fe-9eb1-40f9e8ae1114"), "Hybrid relationship type", "HRT"),
177 170

  
178
	
179 171
	//13
180 172
	/**
181 173
	 * Term type for the type of a synonym relationship between 2 {@link TaxonBase taxa}
......
222 214
	 * @see Institution
223 215
	 */
224 216
	@XmlEnumValue("InstitutionType")
225
	InstitutionType(UUID.fromString("09d78265-18b5-4352-b154-d2f39e84d3f3"), "Institution type", "IT"),
217
	InstitutionType(UUID.fromString("09d78265-18b5-4352-b154-d2f39e84d3f3"), "Institution type", "IT", null),
226 218

  
227 219
	//18
228 220
	/**
......
231 223
	 * @see eu.etaxonomy.cdm.model.location.NamedAreaType
232 224
	 */
233 225
	@XmlEnumValue("NamedAreaType")
234
	NamedAreaType(UUID.fromString("6a9aba35-6272-4373-8386-000cf95b729e"), "Named area type", "NAT"),
226
	NamedAreaType(UUID.fromString("6a9aba35-6272-4373-8386-000cf95b729e"), "Named area type", "NAT", null),
235 227
	
236 228
	//19
237 229
	/**
......
240 232
	 * @see eu.etaxonomy.cdm.model.location.NamedAreaLevel
241 233
	 */
242 234
	@XmlEnumValue("NamedAreaLevel")
243
	NamedAreaLevel(UUID.fromString("62c16c74-dc79-4970-9031-bb1504be46f5"), "Named area level", "NAL"),
235
	NamedAreaLevel(UUID.fromString("62c16c74-dc79-4970-9031-bb1504be46f5"), "Named area level", "NAL", null),
244 236

  
245 237
	//20
246 238
	/**
......
248 240
	 * @see Rights
249 241
	 */
250 242
	@XmlEnumValue("RightsType")
251
	RightsType(UUID.fromString("80e06b04-8d0d-4bd5-bcd6-d35f73c24d55"), "Rights type", "RT"),
243
	RightsType(UUID.fromString("80e06b04-8d0d-4bd5-bcd6-d35f73c24d55"), "Rights type", "RT", null),
252 244
	
253 245
	//21
254 246
	/**
......
256 248
	 * @see MeasurementUnit
257 249
	 */
258 250
	@XmlEnumValue("MeasurementUnit")
259
	MeasurementUnit(UUID.fromString("f9e6c44f-f0d6-428b-9bc0-bb00a6514883"), "Measurement unit", "MU"),
251
	MeasurementUnit(UUID.fromString("f9e6c44f-f0d6-428b-9bc0-bb00a6514883"), "Measurement unit", "MU", null),
260 252

  
261 253
	//22
262 254
	/**
......
265 257
	 * @see StatisticalMeasurementValue
266 258
	 */
267 259
	@XmlEnumValue("StatisticalMeasure")
268
	StatisticalMeasure(UUID.fromString("a22d19cd-a342-4af2-b156-d688a7aa8a6b"), "Statistical measure", "SM"),
260
	StatisticalMeasure(UUID.fromString("a22d19cd-a342-4af2-b156-d688a7aa8a6b"), "Statistical measure", "SM", null),
269 261

  
270 262
	//23
271 263
	@XmlEnumValue("PreservationMethod")
......
281 273
	 * <P>
282 274
	 * This class corresponds to GeneralModifierNLDType according to
283 275
	 * the SDD schema.
276
	 * This class is a generalization of {@link #Scope} and {@link #DeterminationModifier}
284 277
	 */
285 278
	@XmlEnumValue("Modifier")
286
	Modifier(UUID.fromString("97c4db67-ccf5-40bf-9fb8-83fb7446a364"), "Modifier", "MO"),
279
	Modifier(UUID.fromString("97c4db67-ccf5-40bf-9fb8-83fb7446a364"), "Modifier", "MO", null),
287 280
	
288 281
	//25
289 282
	/**
......
291 284
	 * {@link TaxonDescription taxon descriptions} and others. 
292 285
	 * This could include not only Stage (life stage) and Sex 
293 286
	 * but also for instance particular organism parts or seasons.<BR>
294
	 * Scope is a specification of Modifier.
287
	 * Scope is a specification of {@link #Modifier} and a generalization of 
288
	 * {@link #Sex} and {@link #Stage}
289
	 *
295 290
	 * @see Modifier
296 291
	 * @see DescriptionElementBase
297 292
	 * @see TaxonDescription
......
307 302
	 * does not belong to a {@link SpecimenDescription specimen description} but is an attribute of
308 303
	 * the specimen itself.<BR>
309 304
	 * 
310
	 * A stage is a specification of Scope.
305
	 * Stage is a specification of {@link #Scope}.
311 306
	 */
312 307
	@XmlEnumValue("Stage")
313 308
	Stage(UUID.fromString("cf411ef0-8eee-4461-99e9-c03f4f0a1656"), "Stage", "STG", Scope),
......
320 315
	 * does not belong to a {@link SpecimenDescription specimen description} but is an attribute of
321 316
	 * the specimen itself.<BR>
322 317
	 * 
323
	 * A sex is a specification of Scope.
318
	 * Sex is a specification of {@link #Scope}.
324 319
	 */
325 320
	@XmlEnumValue("Sex")
326 321
	Sex(UUID.fromString("4046f91f-063b-4b84-b34a-6245c2abc06f"), "Sex", "SEX", Scope),
......
332 327
	 * @see Point#getReferenceSystem()
333 328
	 */
334 329
	@XmlEnumValue("ReferenceSystem")
335
	ReferenceSystem(UUID.fromString("b8cfa986-ef90-465e-9609-1dadae2a0f5b"), "Reference system", "RS"),
330
	ReferenceSystem(UUID.fromString("b8cfa986-ef90-465e-9609-1dadae2a0f5b"), "Reference system", "RS", null),
336 331

  
337 332
	//29
338 333
	/**
......
341 336
	 * @see StateData#getState()
342 337
	 */
343 338
	@XmlEnumValue("State")
344
	State(UUID.fromString("5e5b8b60-7300-440a-8706-72fbf31a594f"), "State", "STA"),
339
	State(UUID.fromString("5e5b8b60-7300-440a-8706-72fbf31a594f"), "State", "STA", null),
345 340

  
346 341
	//30
347 342
	/**
348 343
	 * Term type representing a natural language term.
349 344
	 */
350 345
	@XmlEnumValue("NaturalLanguageTerm")
351
	NaturalLanguageTerm(UUID.fromString("9a42ac4e-c175-4633-8b31-74ba8203566a"), "Natural language term", "NLT"),
346
	NaturalLanguageTerm(UUID.fromString("9a42ac4e-c175-4633-8b31-74ba8203566a"), "Natural language term", "NLT", null),
352 347

  
353 348

  
354 349
	//31
......
357 352
	 * @see TextData
358 353
	 */
359 354
	@XmlEnumValue("TextFormat")
360
	TextFormat(UUID.fromString("d26cfdb4-baeb-43d0-a51b-a3428d838790"), "Text format", "TF"),
355
	TextFormat(UUID.fromString("d26cfdb4-baeb-43d0-a51b-a3428d838790"), "Text format", "TF", null),
361 356

  
362 357
	//32
363 358
	/**
364 359
	 * TODO
365 360
	 * 
366
	 * A determination modifier is a specification of a Modifier.
361
	 * Determination modifier is a specification of {@link #Modifier}.
367 362
	 */
368 363
	@XmlEnumValue("DeterminationModifier")
369 364
	DeterminationModifier(UUID.fromString("ce910516-bc5d-4ac5-be4d-f3c14c27dd85"), "Determination modifier", "DMO", Modifier),
......
380 375
	 * @see Sequencing#getMarker() 
381 376
	 */
382 377
	@XmlEnumValue("Marker")
383
	DnaMarker(UUID.fromString("7fdddb4f-b0ec-4ce0-bc28-dc94e30e8252"), "DNA Marker", "MAR"),
384
	
378
	DnaMarker(UUID.fromString("7fdddb4f-b0ec-4ce0-bc28-dc94e30e8252"), "DNA Marker", "MAR", null),
385 379
	;
386 380
	
387
	
381
	@SuppressWarnings("unused")
388 382
	private static final Logger logger = Logger.getLogger(TermType.class);
389 383

  
390
	private String readableString;
391
	private UUID uuid;
392
	private String key;
393
	private static final Map<String,TermType> lookup = new HashMap<String, TermType>();
394

  
395
	private TermType parent;
396
	private Set<TermType> children = new HashSet<TermType>();
397
	
398
	static {
399
		for (TermType t : TermType.values()){
400
			if (lookup.containsKey(t.key)){
401
				throw new RuntimeException("Key must be unique in TermType but was not for " + t.key);
402
			}
403
			lookup.put(t.key, t);
404
		}
405
	}
406
	
407 384
	private TermType(UUID uuid, String defaultString, String key){
408 385
		this(uuid, defaultString, key, null);
409 386
	}
410 387

  
411 388
	private TermType(UUID uuid, String defaultString, String key, TermType parent){
412
		this.uuid = uuid;
413
		readableString = defaultString;
414
		this.key = key;
415
		this.parent = parent;
416
		if (parent != null){
417
			parent.children.add(this);
418
		}
389
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
419 390
	}
420 391

  
392

  
393
// *************************** DELEGATE **************************************/	
421 394
	
422
	public String getKey(){
423
		return key;
424
	}
425
	
426
	public static TermType byKey(String key){
427
		return lookup.get(key);
428
	}
429
	
430
	
431
	@Transient
432
	public String getMessage(){
433
		return getMessage(eu.etaxonomy.cdm.model.common.Language.DEFAULT());
434
	}
435
	public String getMessage(Language language){
436
		//TODO make multi-lingual
437
		return readableString;
395
	private static EnumeratedTermVoc<TermType> delegateVoc;
396
	private IEnumTerm<TermType> delegateVocTerm;
397

  
398
	static {
399
		delegateVoc = EnumeratedTermVoc.getVoc(TermType.class);
438 400
	}
439 401
	
402
	@Override
403
	public String getKey(){return delegateVocTerm.getKey();}
440 404
	
441

  
442

  
443 405
	@Override
444
    public UUID getUuid() {
445
		return this.uuid;
446
	}
447

  
406
    public String getMessage(){return delegateVocTerm.getMessage();}
448 407

  
449 408
	@Override
450
    public TermType getByUuid(UUID uuid) {
451
		for (TermType type : TermType.values()){
452
			if (type.getUuid().equals(uuid)){
453
				return type;
454
			}
455
		}
456
		return null;
457
	}
409
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
458 410

  
411
	@Override
412
	public String getReadableString() {return delegateVocTerm.getReadableString();}
413
		
414
	@Override
415
    public UUID getUuid() {return delegateVocTerm.getUuid();}
459 416

  
460 417
	@Override
461
    public TermType getKindOf() {
462
		return parent;
463
	}
464
	
418
    public TermType getKindOf() {return delegateVocTerm.getKindOf();}
465 419
	
466 420
	@Override
467
    public Set<TermType> getGeneralizationOf() {
468
//		return Collections.unmodifiableSet( children );   //TODO creates stack overflow
469
		return new HashSet<TermType>(children);
470
	}
421
    public Set<TermType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
422

  
423
	public static TermType getByKey(String key){return delegateVoc.getByKey(key);}
424
    public static TermType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
425

  
471 426

  
472 427
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/TermVocabulary.java
183 183
		//preliminary until above is solved
184 184
		this.setTitleCache(label, true);
185 185
		
186
		this.setTermType(TermType.byKey(csvLine.get(4)));
186
		this.setTermType(TermType.getByKey(csvLine.get(4)));
187 187
		
188 188
		return this;
189 189
	}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NomenclaturalCode.java
21 21

  
22 22
import org.apache.log4j.Logger;
23 23

  
24
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
25
import eu.etaxonomy.cdm.model.common.IEnumTerm;
24 26
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
27
import eu.etaxonomy.cdm.model.common.Language;
28
import eu.etaxonomy.cdm.model.common.TermType;
25 29

  
26 30
/**
27 31
 * The class for the five nomenclature codes (ICNB, ICBN, ICNCP, ICZN and ICVCN)
......
44 48

  
45 49
@XmlType(name = "NomenclaturalCode")
46 50
@XmlEnum
47
public enum NomenclaturalCode implements ISimpleTerm<NomenclaturalCode>, Serializable {
51
public enum NomenclaturalCode implements IEnumTerm<NomenclaturalCode>, Serializable {
48 52
	//0
49 53
	/**
50 54
	 * International Code of Nomenclature of Bacteria
......
82 86

  
83 87
	private static final Logger logger = Logger.getLogger(NomenclaturalCode.class);
84 88
	
85
	private UUID uuid;
86

  
87
	private String titleCache;
88
	
89 89
	public String getTitleCache() {
90
		return titleCache;
90
		return getReadableString();
91 91
	}
92 92
	
93 93
	private NomenclaturalCode(UUID uuid, String titleCache){
94
		this.uuid = uuid;
95
		this.titleCache = titleCache;
94
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, titleCache, titleCache, null);
96 95
	}
97 96
	
98 97
	
99 98
	
100 99
	/* (non-Javadoc)
101
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getUuid()
102
	 */
103
	public UUID getUuid(){
104
		return this.uuid;
105
	}
106
	
107
	/* (non-Javadoc)
108 100
	 * @see java.lang.Enum#toString()
109 101
	 */
110 102
	@Override
111 103
	public String toString() {
112
		return "NomenclaturalCode" + " <" + uuid + "> " + this.name();
104
		return "NomenclaturalCode" + " <" + getUuid() + "> " + this.name();
113 105
	}
114 106

  
115 107
	public static NomenclaturalCode fromString(String string){
......
123 115
		}
124 116
		return null;
125 117
	}
126
	
127
	/* (non-Javadoc)
128
	 * @see eu.etaxonomy.cdm.model.common.IDefinedTerm#getByUuid(java.util.UUID)
129
	 */
130
	@Override
131
	public NomenclaturalCode getByUuid(UUID uuid) {
132
		for (NomenclaturalCode nomCode : NomenclaturalCode.values()){
133
			if (nomCode.getUuid().equals(uuid)){
134
				return nomCode;
135
			}
136
		}
137
		return null;
138
	}
139

  
140
	@Override
141
	public Set<NomenclaturalCode> getGeneralizationOf() {
142
		return new HashSet<NomenclaturalCode>();
143
	}
144

  
145

  
146
	@Override
147
	public NomenclaturalCode getKindOf() {
148
		return null;
149
	}
150 118

  
151 119
	/**
152 120
	 * Creates a new particular {@link TaxonNameBase taxon name} (botanical, zoological,
......
255 223
			return "synonym";
256 224
		}
257 225
	}
226

  
227
// *************************** DELEGATE **************************************/	
228
	
229
	private static EnumeratedTermVoc<NomenclaturalCode> delegateVoc;
230
	private IEnumTerm<NomenclaturalCode> delegateVocTerm;
231

  
232
	static {
233
		delegateVoc = EnumeratedTermVoc.getVoc(NomenclaturalCode.class);
234
	}
235
	
236
	@Override
237
	public String getKey(){return delegateVocTerm.getKey();}
238
	
239
	@Override
240
    public String getMessage(){return delegateVocTerm.getMessage();}
241

  
242
	@Override
243
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
244

  
245
	@Override
246
	public String getReadableString() {return delegateVocTerm.getReadableString();}
247
		
248
	@Override
249
    public UUID getUuid() {return delegateVocTerm.getUuid();}
250

  
251
	@Override
252
    public NomenclaturalCode getKindOf() {return delegateVocTerm.getKindOf();}
253
	
254
	@Override
255
    public Set<NomenclaturalCode> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
256

  
257
	public static NomenclaturalCode getByKey(String key){return delegateVoc.getByKey(key);}
258
    public static NomenclaturalCode getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
259
	
258 260
	
259 261
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/Rank.java
915 915
    @Override
916 916
    public Rank readCsvLine(Class<Rank> termClass, List<String> csvLine, Map<UUID, DefinedTermBase> terms) {
917 917
        Rank rank = super.readCsvLine(termClass, csvLine, terms);
918
        RankClass rankClass = RankClass.byKey(csvLine.get(5));
918
        RankClass rankClass = RankClass.getByKey(csvLine.get(5));
919 919
        assert rankClass != null: "XXXXXXXXXXXXXXXXXXXXX  Rank class must not be null: " + csvLine ;
920 920
        rank.setRankClass(rankClass);
921 921
        return rank;
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/RankClass.java
11 11
package eu.etaxonomy.cdm.model.name;
12 12

  
13 13
import java.io.Serializable;
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.Map;
17 14
import java.util.Set;
18 15
import java.util.UUID;
19 16

  
20
import javax.persistence.Transient;
21 17
import javax.xml.bind.annotation.XmlEnum;
22 18
import javax.xml.bind.annotation.XmlEnumValue;
23 19

  
24 20
import org.apache.log4j.Logger;
25 21

  
26
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
22
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
23
import eu.etaxonomy.cdm.model.common.IEnumTerm;
24
import eu.etaxonomy.cdm.model.common.Language;
27 25

  
28 26
/**
29 27
 * The rank class defines the category of ranks a certain rank belongs to. This information is
......
36 34
 * @created 11.06.2013
37 35
 */
38 36
@XmlEnum
39
public enum RankClass implements ISimpleTerm<RankClass>, Serializable{
37
public enum RankClass implements IEnumTerm<RankClass>, Serializable{
40 38
	
41 39
	//0
42 40
	/**
......
45 43
	 * we find an appropriate usage in future and in case one needs a short term dummy.
46 44
	 */
47 45
	@XmlEnumValue("Unknown")
48
	@Deprecated Unknown(UUID.fromString("8c99ba63-2904-4dbb-87cb-3d3d7467e95d"), "Unknown rank class","UN"),
46
	@Deprecated Unknown(UUID.fromString("8c99ba63-2904-4dbb-87cb-3d3d7467e95d"), "Unknown rank class","UN", null),
49 47

  
50 48
	//1
51 49
	@XmlEnumValue("Suprageneric")
52
	Suprageneric(UUID.fromString("439a7897-9e0d-4560-b238-459d827f8a70"), "Suprageneric", "SG"),
50
	Suprageneric(UUID.fromString("439a7897-9e0d-4560-b238-459d827f8a70"), "Suprageneric", "SG", null),
53 51
	
54 52
	//2
55 53
	@XmlEnumValue("Genus")
56
	Genus(UUID.fromString("86de25dc-3594-462f-a716-6d008caf2662"), "Genus", "GE"),
54
	Genus(UUID.fromString("86de25dc-3594-462f-a716-6d008caf2662"), "Genus", "GE", null),
57 55

  
58 56
	//3
59 57
	@XmlEnumValue("Infrageneric")
60
	Infrageneric(UUID.fromString("37d5b535-3bf9-4749-af66-1a1c089dc0ae"), "Rank", "IG"),	
58
	Infrageneric(UUID.fromString("37d5b535-3bf9-4749-af66-1a1c089dc0ae"), "Rank", "IG", null),	
61 59
	
62 60
	//4
63 61
	@XmlEnumValue("SpeciesGroup")
64
	SpeciesGroup(UUID.fromString("702edcb7-ee53-45b7-8635-efcbbfd69bca"), "Species group or aggr.", "AG"),
62
	SpeciesGroup(UUID.fromString("702edcb7-ee53-45b7-8635-efcbbfd69bca"), "Species group or aggr.", "AG", null),
65 63
	
66 64
	//5
67 65
	@XmlEnumValue("Species")
68
	Species(UUID.fromString("74cc173b-788e-4b01-9d70-a988498458b7"), "Species", "SP"),
66
	Species(UUID.fromString("74cc173b-788e-4b01-9d70-a988498458b7"), "Species", "SP", null),
69 67
	
70 68
	//6
71 69
	@XmlEnumValue("Infraspecific")
72
	Infraspecific(UUID.fromString("25915b4c-7f07-442f-bdaa-9d0223f6be42"), "Infraspecific", "IS"),
70
	Infraspecific(UUID.fromString("25915b4c-7f07-442f-bdaa-9d0223f6be42"), "Infraspecific", "IS", null),
73 71

  
74 72
	;
75 73
	
......
77 75
	@SuppressWarnings("unused")
78 76
	private static final Logger logger = Logger.getLogger(RankClass.class);
79 77

  
80
	private String readableString;
81
	private UUID uuid;
82
	private String key;
83
	private static final Map<String,RankClass> lookup = new HashMap<String, RankClass>();
84 78

  
85
	static {
86
		for (RankClass t : RankClass.values()){
87
			if (lookup.containsKey(t.key)){
88
				throw new RuntimeException("Key must be unique in rank class but was not for " + t.key);
89
			}
90
			lookup.put(t.key, t);
91
		}
92
	}
93 79
	
94
	private RankClass(UUID uuid, String defaultString, String key){
95
		this.uuid = uuid;
96
		readableString = defaultString;
97
		this.key = key;
98
	}
99

  
100
	public String getKey(){
101
		return key;
80
	private RankClass(UUID uuid, String defaultString, String key, RankClass parent){
81
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
102 82
	}
103 83
	
104
	public static RankClass byKey(String key){
105
		return lookup.get(key);
84
// *************************** DELEGATE **************************************/	
85

  
86
	private static EnumeratedTermVoc<RankClass> delegateVoc;
87
	private IEnumTerm<RankClass> delegateVocTerm;
88

  
89
	static {
90
		delegateVoc = EnumeratedTermVoc.getVoc(RankClass.class);
106 91
	}
107 92
	
93
	@Override
94
	public String getKey(){return delegateVocTerm.getKey();}
108 95
	
109
	@Transient
110
	public String getMessage(){
111
		return getMessage(eu.etaxonomy.cdm.model.common.Language.DEFAULT());
112
	}
113
	public String getMessage(eu.etaxonomy.cdm.model.common.Language language){
114
		//TODO make multi-lingual
115
		return readableString;
116
	}
117

  
118

  
119 96
	@Override
120
    public UUID getUuid() {
121
		return this.uuid;
122
	}
123

  
97
    public String getMessage(){return delegateVocTerm.getMessage();}
124 98

  
125 99
	@Override
126
    public RankClass getByUuid(UUID uuid) {
127
		for (RankClass type : RankClass.values()){
128
			if (type.getUuid().equals(uuid)){
129
				return type;
130
			}
131
		}
132
		return null;
133
	}
100
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
134 101

  
102
	@Override
103
	public String getReadableString() {return delegateVocTerm.getReadableString();}
104
		
105
	@Override
106
    public UUID getUuid() {return delegateVocTerm.getUuid();}
135 107

  
136 108
	@Override
137
    public RankClass getKindOf() {
138
		return null;
139
	}
109
    public RankClass getKindOf() {return delegateVocTerm.getKindOf();}
110
	
111
	@Override
112
    public Set<RankClass> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
113

  
114
	public static RankClass getByKey(String key){return delegateVoc.getByKey(key);}
115
    public static RankClass getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
140 116

  
141 117

  
142
	@Override
143
    public Set<RankClass> getGeneralizationOf() {
144
		return new HashSet<RankClass>();
145
	}
146 118
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationType.java
11 11
package eu.etaxonomy.cdm.model.occurrence;
12 12

  
13 13
import java.io.Serializable;
14
import java.util.HashMap;
15
import java.util.HashSet;
16
import java.util.Map;
17 14
import java.util.Set;
18 15
import java.util.UUID;
19 16

  
20
import javax.persistence.Transient;
21 17
import javax.xml.bind.annotation.XmlEnum;
22 18
import javax.xml.bind.annotation.XmlEnumValue;
23 19

  
24 20
import org.apache.log4j.Logger;
25 21

  
26
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
22
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
23
import eu.etaxonomy.cdm.model.common.IEnumTerm;
27 24
import eu.etaxonomy.cdm.model.common.Language;
28 25

  
29 26

  
......
41 38
 * @created 27.06.2013
42 39
 */
43 40
@XmlEnum
44
public enum SpecimenOrObservationType implements ISimpleTerm<SpecimenOrObservationType>, Serializable{
41
public enum SpecimenOrObservationType implements IEnumTerm<SpecimenOrObservationType>, Serializable{
45 42
	
46 43
	//0
47 44
	/**
......
50 47
	 * use "DerivedUnit", "Observation" or "OtherSpecimen" instead.
51 48
	 */
52 49
	@XmlEnumValue("Unknown")
53
	Unknown(UUID.fromString("971a0c72-d4d2-4e41-8520-c9a87df34f48"), "Unknown term type","UN"),
50
	Unknown(UUID.fromString("971a0c72-d4d2-4e41-8520-c9a87df34f48"), "Unknown term type","UN", null),
54 51

  
55 52
	//1
56 53
	/**
......
65 62
	 * from a fossil.
66 63
	 */
67 64
	@XmlEnumValue("FossilSpecimen")
68
	Fossil(UUID.fromString("1b0f8534-35eb-4c64-8e53-69e734043bd6"), "Fossil Specimen", "FS"),
65
	Fossil(UUID.fromString("1b0f8534-35eb-4c64-8e53-69e734043bd6"), "Fossil Specimen", "FS", PreservedSpecimen),
69 66

  
70 67
	//3
71 68
	/**
......
90 87
	 * Derived from the former (before v3.3.) CDM class "DerivedUnit".  
91 88
	 */
92 89
	@XmlEnumValue("DerivedUnit")
93
	DerivedUnit(UUID.fromString("da80443a-360b-4861-abeb-21e13beb5186"), "Derived Unit", "DU"),
90
	DerivedUnit(UUID.fromString("da80443a-360b-4861-abeb-21e13beb5186"), "Derived Unit", "DU", null),
94 91

  
95 92
	//6
96 93
	/**
......
98 95
	 * Derived from the former (before v3.3) CDM class "Observation".
99 96
	 */
100 97
	@XmlEnumValue("Observation")
101
	Observation(UUID.fromString("a8a254f1-7bed-47ec-bbee-86a794819c3b"), "Observation", "OB"),
98
	Observation(UUID.fromString("a8a254f1-7bed-47ec-bbee-86a794819c3b"), "Observation", "OB", DerivedUnit),
102 99

  
103 100
	//7
104 101
	/**
......
106 103
	 * Specification of "Observation".
107 104
	 */
108 105
	@XmlEnumValue("HumanObservation")
109
	HumanObservation(UUID.fromString("b960c06d-4bfc-4bea-bc53-aec0600409b1"), "HumanObservation", "HO"),
106
	HumanObservation(UUID.fromString("b960c06d-4bfc-4bea-bc53-aec0600409b1"), "HumanObservation", "HO", Observation),
110 107

  
111 108
	//8
112 109
	/**
......
114 111
	 * Specification of "Observation".
115 112
	 */
116 113
	@XmlEnumValue("MachineObservation")
117
	MachineObservation(UUID.fromString("b12a13fc-0f61-4055-b9b7-4eabd417c54c"), "MachineObservation", "MO"),
114
	MachineObservation(UUID.fromString("b12a13fc-0f61-4055-b9b7-4eabd417c54c"), "MachineObservation", "MO", Observation),
118 115

  
119 116
//	
120 117
//	//10
......
128 125
	 * One should try to use a specification instead of using the general type Media.
129 126
	 */
130 127
	@XmlEnumValue("Media")
131
	Media(UUID.fromString("0efa6b3e-e67a-49d4-a758-f3fc688901a7"), "Media", "ME"),
128
	Media(UUID.fromString("0efa6b3e-e67a-49d4-a758-f3fc688901a7"), "Media", "ME", null),
132 129

  
133 130
	
134 131
	//10
......
136 133
	 * A photograph, drawing, painting or similar.
137 134
	 */
138 135
	@XmlEnumValue("StillImage")
139
	StillImage(UUID.fromString("a8d9ada5-7f22-4fcf-8693-ae68d527289b"), "Still Image", "SI"),
136
	StillImage(UUID.fromString("a8d9ada5-7f22-4fcf-8693-ae68d527289b"), "Still Image", "SI", Media),
140 137

  
141 138
	//11
142 139
	/**
......
144 141
	 * may include sound.
145 142
	 */
146 143
	@XmlEnumValue("MovingImage")
147
	MovingImage(UUID.fromString("56722418-9398-4367-afa1-46982fb93959"), "Moving Image", "MI"),
144
	MovingImage(UUID.fromString("56722418-9398-4367-afa1-46982fb93959"), "Moving Image", "MI", Media),
148 145

  
149 146
	//12
150 147
	/**
151 148
	 * An audio recording.
152 149
	 */
153 150
	@XmlEnumValue("SoundRecording")
154
	SoundRecording(UUID.fromString("2a39ec19-4aae-4b74-bc5c-578c5dc94e7d"), "Moving Image", "SR"),
151
	SoundRecording(UUID.fromString("2a39ec19-4aae-4b74-bc5c-578c5dc94e7d"), "Moving Image", "SR", Media),
155 152

  
156 153
	//13
157 154
	/**
158 155
	 * Any multi media object which is not covered by DrawingOrPhoto, MovingImage or SoundRecording.
159 156
	 */
160 157
	@XmlEnumValue("Multimedia")
161
	Multimedia(UUID.fromString("bfe3fef8-d294-4554-847a-c9d8a6b74313"), "Multimedia Object", "MM"),
158
	Multimedia(UUID.fromString("bfe3fef8-d294-4554-847a-c9d8a6b74313"), "Multimedia Object", "MM", Media),
162 159
	
163 160
	//14
164 161
	/**
......
168 165
	//TODO do we really need an own type for FieldUnit or is this covered by any of the other 
169 166
	//types (e.g. Observation)
170 167
	@XmlEnumValue("FieldUnit")
171
	FieldUnit(UUID.fromString("d38d22db-17f9-45ba-a32f-32393788726f"), "Field Unit", "FU"),	
168
	FieldUnit(UUID.fromString("d38d22db-17f9-45ba-a32f-32393788726f"), "Field Unit", "FU", null),	
172 169
	;
173 170
	
174 171
	@SuppressWarnings("unused")
175 172
	private static final Logger logger = Logger.getLogger(SpecimenOrObservationType.class);
176 173

  
177
	private String readableString;
178
	private UUID uuid;
179
	private String key;
180
	private static final Map<String,SpecimenOrObservationType> lookup = new HashMap<String, SpecimenOrObservationType>();
181

  
182
	static {
183
		for (SpecimenOrObservationType t : SpecimenOrObservationType.values()){
184
			if (lookup.containsKey(t.key)){
185
				String message = "Key must be unique in %s but was not for %s";
186
				throw new RuntimeException(String.format(message, Unknown.getClass().getName(), t.key));
187
			}
188
			lookup.put(t.key, t);
189
		}
190
	}
191 174
	
192 175
	private SpecimenOrObservationType(UUID uuid, String defaultString, String key){
193
		this.uuid = uuid;
194
		readableString = defaultString;
195
		this.key = key;
196
	}
197

  
198
	public String getKey(){
199
		return key;
176
		this(uuid, defaultString, key, null);
177
		System.out.println("SpecimenOrObservationType hierarchie not yet fully implemented");
200 178
	}
201 179
	
202
	public static SpecimenOrObservationType byKey(String key){
203
		return lookup.get(key);
180
	private SpecimenOrObservationType(UUID uuid, String defaultString, String key, SpecimenOrObservationType parent){
181
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
204 182
	}
205 183

  
184
	
206 185
	public boolean isFeatureObservation() {
207 186
		if (this == Observation || this == HumanObservation || this == MachineObservation 
208 187
			){
......
265 244
		}
266 245
	}	
267 246

  
268
	
269
	
270
	@Transient
271
	public String getMessage(){
272
		return getMessage(Language.DEFAULT());
273
	}
274
	public String getMessage(Language language){
275
		//TODO make multi-lingual
276
		return readableString;
277
	}
278
	
279

  
280 247
	/**
281 248
	 * This method was initially created in the former class
282 249
	 * "DerivedUnitFacade.DerivedUnitType" for some specimen imports .
......
307 274
		}
308 275
		return null;
309 276
	}
277
	
278
	// *************************** DELEGATE **************************************/	
279
	
280
		private static EnumeratedTermVoc<SpecimenOrObservationType> delegateVoc;
281
		private IEnumTerm<SpecimenOrObservationType> delegateVocTerm;
310 282

  
283
		static {
284
			delegateVoc = EnumeratedTermVoc.getVoc(SpecimenOrObservationType.class);
285
		}
286
		
287
		@Override
288
		public String getKey(){return delegateVocTerm.getKey();}
289
		
290
		@Override
291
	    public String getMessage(){return delegateVocTerm.getMessage();}
311 292

  
312
	@Override
313
    public UUID getUuid() {
314
		return this.uuid;
315
	}
293
		@Override
294
	    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
316 295

  
296
		@Override
297
		public String getReadableString() {return delegateVocTerm.getReadableString();}
298
			
299
		@Override
300
	    public UUID getUuid() {return delegateVocTerm.getUuid();}
317 301

  
318
	@Override
319
    public SpecimenOrObservationType getByUuid(UUID uuid) {
320
		for (SpecimenOrObservationType type : SpecimenOrObservationType.values()){
321
			if (type.getUuid().equals(uuid)){
322
				return type;
323
			}
324
		}
325
		return null;
326
	}
302
		@Override
303
	    public SpecimenOrObservationType getKindOf() {return delegateVocTerm.getKindOf();}
304
		
305
		@Override
306
	    public Set<SpecimenOrObservationType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
307

  
308
		public static SpecimenOrObservationType getByKey(String key){return delegateVoc.getByKey(key);}
309
	    public static SpecimenOrObservationType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
327 310

  
328 311

  
329
	@Override
330
    public SpecimenOrObservationType getKindOf() {
331
		return null;
332
	}
333 312

  
334 313

  
335
	@Override
336
    public Set<SpecimenOrObservationType> getGeneralizationOf() {
337
		return new HashSet<SpecimenOrObservationType>();
338
	}
339 314
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/reference/ReferenceType.java
11 11
package eu.etaxonomy.cdm.model.reference;
12 12

  
13 13
import java.io.Serializable;
14
import java.util.HashSet;
15 14
import java.util.Set;
16 15
import java.util.UUID;
17 16

  
18
import javax.persistence.Transient;
19 17
import javax.xml.bind.annotation.XmlEnum;
20 18
import javax.xml.bind.annotation.XmlEnumValue;
21 19

  
22 20
import org.apache.log4j.Logger;
23 21

  
24
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
22
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
23
import eu.etaxonomy.cdm.model.common.IEnumTerm;
25 24
import eu.etaxonomy.cdm.model.common.Language;
26 25
import eu.etaxonomy.cdm.strategy.cache.reference.ArticleDefaultCacheStrategy;
27 26
import eu.etaxonomy.cdm.strategy.cache.reference.BookDefaultCacheStrategy;
......
44 43
 * @version 1.0
45 44
 */
46 45
@XmlEnum
47
public enum ReferenceType implements ISimpleTerm<ReferenceType>, Serializable{
46
public enum ReferenceType implements IEnumTerm<ReferenceType>, Serializable{
48 47
	//0
49 48
	@XmlEnumValue("Article")
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)