Merging cdmlib-model; pesi. Merge rev 8256:8526.
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / ExtensionType.java
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
13 import java.util.HashMap;
14 import java.util.List;
15 import java.util.Map;
16 import java.util.UUID;
17
18 import javax.persistence.Entity;
19 import javax.xml.bind.annotation.XmlAccessType;
20 import javax.xml.bind.annotation.XmlAccessorType;
21 import javax.xml.bind.annotation.XmlType;
22
23 import org.apache.log4j.Logger;
24 import org.hibernate.envers.Audited;
25 import org.hibernate.search.annotations.Indexed;
26
27 import eu.etaxonomy.cdm.model.description.Feature;
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 * @version 1.0
35 * @created 08-Nov-2007 13:06:23
36 */
37 @XmlAccessorType(XmlAccessType.FIELD)
38 @XmlType(name = "ExtensionType")
39 @Entity
40 @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
41 @Audited
42 public class ExtensionType extends DefinedTermBase<ExtensionType> {
43 private static final long serialVersionUID = -7761963794004133427L;
44 @SuppressWarnings("unused")
45 private static final Logger logger = Logger.getLogger(ExtensionType.class);
46
47 private static final UUID uuidXmlFragment = UUID.fromString("ea109c1c-e69b-4e6d-9079-1941b9ee2991");
48 private static final UUID uuidRdfFragment = UUID.fromString("f3684e25-dcad-4c1e-a5d8-16cddf1c4f5b");
49 private static final UUID uuidDoi = UUID.fromString("f079aacc-ab08-4cc4-90a0-6d3958fb0dbf");
50 private static final UUID uuid2ndNomRef = UUID.fromString("46a98bfa-f11a-47fe-a6c5-50c7e8289b3d");
51 private static final UUID uuid3rdHybridParent = UUID.fromString("5e552b24-5a2d-498d-a4f4-ccd8e5bc2bae");
52 private static final UUID uuidAreaOfInterest = UUID.fromString("cefa478e-604f-4db4-8afc-25e06c28ec69");
53 private static final UUID uuidNomStandard = UUID.fromString("4a6cbbe9-8d79-4d15-b316-2ff1adeff526");
54 private static final UUID uuidAbbreviation = UUID.fromString("5837e34e-b0f5-4736-8083-ff5eaecd8c43");
55 private static final UUID uuidOrder = UUID.fromString("ecb7770d-a295-49ee-a88f-e9e137a7cabb");
56 private static final UUID uuidInformalCategory = UUID.fromString("11bbc52f-a085-43d3-9f9b-cbe0d1eb9a91");
57 private static final UUID uuidUrl = UUID.fromString("d769fa9f-51ee-4e11-8152-b5ce72b7f413");
58
59 protected static Map<UUID, ExtensionType> termMap = null;
60
61 /**
62 * Creates a new empty extension type instance.
63 *
64 * @see #NewInstance(String, String, String)
65 */
66 public static ExtensionType NewInstance() {
67 return new ExtensionType();
68 }
69
70 /**
71 * Creates a new extension type instance with a description (in the {@link Language#DEFAULT() default language}),
72 * a label and a label abbreviation.
73 *
74 * @param term the string (in the default language) describing the
75 * new extension type to be created
76 * @param label the string identifying the new extension type to be created
77 * @param labelAbbrev the string identifying (in abbreviated form) the
78 * new extension type to be created
79 * @see #readCsvLine(List, Language)
80 * @see #NewInstance()
81 */
82 public static ExtensionType NewInstance(String term, String label, String labelAbbrev){
83 return new ExtensionType(term, label, labelAbbrev);
84 }
85
86 //public only for Term Loader
87 @Deprecated
88 public ExtensionType() {
89 }
90
91 /**
92 * Class constructor: creates a new extension type instance with a description (in the {@link Language#DEFAULT() default language}),
93 * a label and a label abbreviation.
94 *
95 * @param term the string (in the default language) describing the
96 * new extension type to be created
97 * @param label the string identifying the new extension type to be created
98 * @param labelAbbrev the string identifying (in abbreviated form) the
99 * new extension type to be created
100 * @see #ExtensionType()
101 */
102 protected ExtensionType(String term, String label, String labelAbbrev) {
103 super(term, label, labelAbbrev);
104 }
105
106 protected static ExtensionType getTermByUuid(UUID uuid){
107 if (termMap == null){
108 DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
109 vocabularyStore.initialize();
110 }
111 return (ExtensionType)termMap.get(uuid);
112 }
113
114
115 public static final ExtensionType XML_FRAGMENT(){
116 return getTermByUuid(uuidXmlFragment);
117 }
118
119 public static final ExtensionType RDF_FRAGMENT(){
120 return getTermByUuid(uuidRdfFragment);
121 }
122
123 public static final ExtensionType DOI(){
124 return getTermByUuid(uuidDoi);
125 }
126
127
128 public static final ExtensionType SECOND_NOM_REF(){
129 return getTermByUuid(uuid2ndNomRef);
130 }
131
132
133 public static final ExtensionType THIRD_HYBRID_PARENT(){
134 return getTermByUuid(uuid3rdHybridParent);
135 }
136
137 public static final ExtensionType AREA_OF_INTREREST(){
138 return getTermByUuid(uuidAreaOfInterest);
139 }
140
141 public static final ExtensionType NOMENCLATURAL_STANDARD(){
142 return getTermByUuid(uuidNomStandard);
143 }
144
145 public static final ExtensionType ABBREVIATION(){
146 return getTermByUuid(uuidAbbreviation);
147 }
148
149 public static final ExtensionType ORDER(){
150 return getTermByUuid(uuidOrder);
151 }
152
153 public static final ExtensionType INFORMAL_CATEGORY(){
154 return getTermByUuid(uuidInformalCategory);
155 }
156
157 public static final ExtensionType URL(){
158 return getTermByUuid(uuidUrl);
159 }
160
161
162 @Override
163 protected void setDefaultTerms(TermVocabulary<ExtensionType> termVocabulary) {
164 termMap = new HashMap<UUID, ExtensionType>();
165 for (ExtensionType term : termVocabulary.getTerms()){
166 termMap.put(term.getUuid(), term);
167 }
168 }
169
170 }