Project

General

Profile

Download (6.36 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

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

    
12
import java.util.HashMap;
13
import java.util.List;
14
import java.util.Map;
15
import java.util.UUID;
16

    
17
import javax.persistence.Entity;
18
import javax.xml.bind.annotation.XmlAccessType;
19
import javax.xml.bind.annotation.XmlAccessorType;
20
import javax.xml.bind.annotation.XmlType;
21

    
22
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
23
import org.hibernate.envers.Audited;
24

    
25
import eu.etaxonomy.cdm.model.term.AvailableForIdentifiableBase;
26
import eu.etaxonomy.cdm.model.term.TermType;
27
import eu.etaxonomy.cdm.model.term.TermVocabulary;
28

    
29
/**
30
 * Extension types similar to dynamically defined attributes. These are not data
31
 * types, but rather content types like "DOI", "2nd nomenclatural reference", "3rd
32
 * hybrid parent" or specific local identifiers.
33
 * @author m.doering
34
 * @since 08-Nov-2007 13:06:23
35
 */
36
@XmlAccessorType(XmlAccessType.FIELD)
37
@XmlType(name = "ExtensionType")
38
@Entity
39
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
40
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
41
@Audited
42
public class ExtensionType extends AvailableForIdentifiableBase<ExtensionType> {
43

    
44
	private static final long serialVersionUID = -7761963794004133427L;
45
	@SuppressWarnings("unused")
46
	private static final Logger logger = LogManager.getLogger(ExtensionType.class);
47

    
48
	private static final UUID uuidXmlFragment = UUID.fromString("ea109c1c-e69b-4e6d-9079-1941b9ee2991");
49
	private static final UUID uuidRdfFragment = UUID.fromString("f3684e25-dcad-4c1e-a5d8-16cddf1c4f5b");
50
	private static final UUID uuidDoi = UUID.fromString("f079aacc-ab08-4cc4-90a0-6d3958fb0dbf");
51
//	private static final UUID uuid2ndNomRef = UUID.fromString("46a98bfa-f11a-47fe-a6c5-50c7e8289b3d");
52
	private static final UUID uuid3rdHybridParent = UUID.fromString("5e552b24-5a2d-498d-a4f4-ccd8e5bc2bae");
53
	private static final UUID uuidAreaOfInterest = UUID.fromString("cefa478e-604f-4db4-8afc-25e06c28ec69");
54
	private static final UUID uuidNomStandard = UUID.fromString("4a6cbbe9-8d79-4d15-b316-2ff1adeff526");
55
	private static final UUID uuidAbbreviation = UUID.fromString("5837e34e-b0f5-4736-8083-ff5eaecd8c43");
56
	private static final UUID uuidOrder = UUID.fromString("ecb7770d-a295-49ee-a88f-e9e137a7cabb");
57
	private static final UUID uuidInformalCategory = UUID.fromString("11bbc52f-a085-43d3-9f9b-cbe0d1eb9a91");
58
	private static final UUID uuidUrl = UUID.fromString("d769fa9f-51ee-4e11-8152-b5ce72b7f413");
59

    
60
	//for storing the full, non truncated cache (title cache is limited to size 800) => TODO make it a CDM extension type
61
	public static final UUID uuidExtNonTruncatedCache = UUID.fromString("4839605b-b72d-493a-94fb-e8f8acb393f9");
62

    
63

    
64
	protected static Map<UUID, ExtensionType> termMap = null;
65

    
66
	/**
67
	 * Creates a new empty extension type instance.
68
	 *
69
	 * @see #NewInstance(String, String, String)
70
	 */
71
	public static ExtensionType NewInstance() {
72
		return new ExtensionType();
73
	}
74

    
75
	/**
76
	 * Creates a new extension type instance with a description (in the {@link Language#DEFAULT() default language}),
77
	 * a label and a label abbreviation.
78
	 *
79
	 * @param	term  		 the string (in the default language) describing the
80
	 * 						 new extension type to be created
81
	 * @param	label  		 the string identifying the new extension type to be created
82
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
83
	 * 						 new extension type to be created
84
	 * @see 				 #readCsvLine(List, Language)
85
	 * @see 				 #NewInstance()
86
	 */
87
	public static ExtensionType NewInstance(String term, String label, String labelAbbrev){
88
		return new ExtensionType(term, label, labelAbbrev);
89
	}
90

    
91
//********************************** Constructor *******************************************************************/
92

    
93
	//for hibernate use only
94
	@Deprecated
95
	protected ExtensionType() {
96
		super(TermType.ExtensionType);
97
	}
98

    
99
	/**
100
	 * Class constructor: creates a new extension type instance with a description (in the {@link Language#DEFAULT() default language}),
101
	 * a label and a label abbreviation.
102
	 *
103
	 * @param	term  		 the string (in the default language) describing the
104
	 * 						 new extension type to be created
105
	 * @param	label  		 the string identifying the new extension type to be created
106
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
107
	 * 						 new extension type to be created
108
	 * @see 				 #ExtensionType()
109
	 */
110
	protected ExtensionType(String term, String label, String labelAbbrev) {
111
		super(TermType.ExtensionType, term, label, labelAbbrev);
112
	}
113

    
114
//************************** METHODS *******************************************************/
115

    
116
	@Override
117
	public void resetTerms(){
118
		termMap = null;
119
	}
120

    
121

    
122
	protected static ExtensionType getTermByUuid(UUID uuid){
123
	    if (termMap == null || termMap.isEmpty()){
124
	        return getTermByClassAndUUID(ExtensionType.class, uuid);
125
	    } else {
126
	        return termMap.get(uuid);
127
	    }
128
	}
129

    
130

    
131
	public static final ExtensionType XML_FRAGMENT(){
132
		return getTermByUuid(uuidXmlFragment);
133
	}
134

    
135
	public static final ExtensionType RDF_FRAGMENT(){
136
		return getTermByUuid(uuidRdfFragment);
137
	}
138

    
139
	public static final ExtensionType DOI(){
140
		return getTermByUuid(uuidDoi);
141
	}
142

    
143

    
144
//	public static final ExtensionType SECOND_NOM_REF(){
145
//		return getTermByUuid(uuid2ndNomRef);
146
//	}
147

    
148

    
149
	public static final ExtensionType THIRD_HYBRID_PARENT(){
150
		return getTermByUuid(uuid3rdHybridParent);
151
	}
152

    
153
	public static final ExtensionType AREA_OF_INTREREST(){
154
		return getTermByUuid(uuidAreaOfInterest);
155
	}
156

    
157
	public static final ExtensionType NOMENCLATURAL_STANDARD(){
158
		return getTermByUuid(uuidNomStandard);
159
	}
160

    
161
	public static final ExtensionType ABBREVIATION(){
162
		return getTermByUuid(uuidAbbreviation);
163
	}
164

    
165
	public static final ExtensionType ORDER(){
166
		return getTermByUuid(uuidOrder);
167
	}
168

    
169
	public static final ExtensionType INFORMAL_CATEGORY(){
170
		return getTermByUuid(uuidInformalCategory);
171
	}
172

    
173
	public static final ExtensionType URL(){
174
		return getTermByUuid(uuidUrl);
175
	}
176

    
177

    
178
	@Override
179
	protected void setDefaultTerms(TermVocabulary<ExtensionType> termVocabulary) {
180
		termMap = new HashMap<UUID, ExtensionType>();
181
		for (ExtensionType term : termVocabulary.getTerms()){
182
			termMap.put(term.getUuid(), term);
183
		}
184
	}
185

    
186
}
(12-12/56)