make Sequence.sequence a clob (#3325)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / location / TdwgArea_Old.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.location;
11
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.util.HashMap;
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.XmlRootElement;
22 import javax.xml.bind.annotation.XmlType;
23
24 import org.apache.log4j.Logger;
25 import org.hibernate.envers.Audited;
26 import org.hibernate.search.annotations.Indexed;
27 import org.jdom.Element;
28 import org.jdom.Namespace;
29
30 import eu.etaxonomy.cdm.common.CdmUtils;
31 import eu.etaxonomy.cdm.common.XmlHelp;
32 import eu.etaxonomy.cdm.model.common.DefaultTermInitializer;
33 import eu.etaxonomy.cdm.model.common.Language;
34 import eu.etaxonomy.cdm.model.common.Representation;
35 import eu.etaxonomy.cdm.model.common.TermVocabulary;
36
37 /**
38 * NOTE:
39 * This class is not in use anymore. It will be removed in one of the next versions.
40 * The former class was called <code>TdwgArea</code>
41 *
42 * Area terms according to the TDWG GeographicRegion vocabulary
43 * http://rs.tdwg.org/ontology/voc/GeographicRegion.rdf
44 *
45 * @author a.mueller
46 * @created 15.07.2008
47
48 */
49 @XmlAccessorType(XmlAccessType.FIELD)
50 @XmlType(name = "TdwgArea")
51 @XmlRootElement(name = "TdwgArea")
52 //@Entity
53 @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
54 //@Audited
55 @Deprecated
56 public class TdwgArea_Old extends NamedArea implements Cloneable{
57 private static final long serialVersionUID = 4662215686356109015L;
58 private static final Logger logger = Logger.getLogger(TdwgArea_Old.class);
59
60 // public static final UUID uuidTdwgAreaVocabulary = UUID.fromString("1fb40504-d1d7-44b0-9731-374fbe6cac77");
61 //
62 //
63 // private static Map<String, UUID> abbrevMap = null;
64 // private static Map<String, UUID> labelMap = null;
65 //
66 // protected static Map<UUID, TdwgArea_Old> termMap = null;
67
68
69
70 //************************** METHODS ********************************
71
72 // /* (non-Javadoc)
73 // * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
74 // */
75 // @Override
76 // public void resetTerms(){
77 // termMap = null;
78 // labelMap = null;
79 // abbrevMap = null;
80 // }
81
82
83 // protected static TdwgArea_Old getTermByUuid(UUID uuid){
84 // if (termMap == null){
85 // DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
86 // vocabularyStore.initialize();
87 // }
88 // return (TdwgArea_Old)termMap.get(uuid);
89 // }
90
91 /**
92 * FIXME This class should really be refactored into an interface and service implementation,
93 * relying on TermVocabularyDao / service (Ben)
94 * @param tdwgAbbreviation
95 * @return
96 */
97 // public static NamedArea getAreaByTdwgAbbreviation(String tdwgAbbreviation){
98 // if (abbrevMap == null){
99 // initMaps();
100 // }
101 // UUID uuid = abbrevMap.get(tdwgAbbreviation);
102 // if (uuid == null){
103 // logger.info("Unknown TDWG area: " + CdmUtils.Nz(tdwgAbbreviation));
104 // return null;
105 // }
106 // return TdwgArea_Old.getTermByUuid(uuid);
107 // }
108 //
109 // /**
110 // * FIXME This class should really be refactored into an interface and service implementation,
111 // * relying on TermVocabularyDao / service (Ben)
112 // * @param tdwgLabel
113 // * @return
114 // */
115 // public static NamedArea getAreaByTdwgLabel(String tdwgLabel){
116 // if (labelMap == null){
117 // initMaps();
118 // }
119 // tdwgLabel = tdwgLabel.toLowerCase();
120 // UUID uuid = labelMap.get(tdwgLabel);
121 // if (uuid == null){
122 // logger.info("Unknown TDWG area: " + CdmUtils.Nz(tdwgLabel));
123 // return null;
124 // }
125 // return TdwgArea_Old.getTermByUuid(uuid);
126 // }
127 //
128 // public static boolean isTdwgAreaLabel(String label){
129 // label = (label == null? null : label.toLowerCase());
130 // if (labelMap.containsKey(label)){
131 // return true;
132 // }else{
133 // return false;
134 // }
135 // }
136 //
137 // public static boolean isTdwgAreaAbbreviation(String abbrev){
138 // if (abbrevMap.containsKey(abbrev)){
139 // return true;
140 // }else{
141 // return false;
142 // }
143 // }
144
145
146 /* (non-Javadoc)
147 * @see eu.etaxonomy.cdm.model.location.NamedArea#setDefaultTerms(eu.etaxonomy.cdm.model.common.TermVocabulary)
148 */
149 // @Override
150 // protected void setDefaultTerms(TermVocabulary<NamedArea> termVocabulary) {
151 // Set<NamedArea> terms = termVocabulary.getTerms();
152 // for (NamedArea term : terms){
153 // addTdwgArea(term);
154 // }
155 // }
156
157 // @Override
158 // protected void setDefaultTerms(TermVocabulary<NamedArea> termVocabulary) {
159 // termMap = new HashMap<UUID, TdwgArea_Old>();
160 // for (NamedArea term : termVocabulary.getTerms()){
161 // termMap.put(term.getUuid(), (TdwgArea_Old)term); //TODO casting
162 // addTdwgArea(term);
163 // }
164 // }
165
166
167 // protected static void addTdwgArea(NamedArea area){
168 // if (area == null){
169 // logger.warn("tdwg area is null");
170 // return;
171 // }
172 // Language lang = Language.DEFAULT();
173 // Representation representation = area.getRepresentation(lang);
174 // String tdwgAbbrevLabel = representation.getAbbreviatedLabel();
175 // String tdwgLabel = representation.getLabel().toLowerCase();
176 // if (tdwgAbbrevLabel == null){
177 // logger.warn("tdwgLabel = null");
178 // return;
179 // }
180 // //init map
181 // if (abbrevMap == null){
182 // abbrevMap = new HashMap<String, UUID>();
183 // }
184 // if (labelMap == null){
185 // labelMap = new HashMap<String, UUID>();
186 // }
187 // //add to map
188 // abbrevMap.put(tdwgAbbrevLabel, area.getUuid());
189 // labelMap.put(tdwgLabel, area.getUuid());
190 // //add type
191 // area.setType(NamedAreaType.ADMINISTRATION_AREA());
192 // //add level
193 // if (tdwgAbbrevLabel.trim().length()== 1){
194 // area.setLevel(NamedAreaLevel.TDWG_LEVEL1());
195 // }else if (tdwgAbbrevLabel.trim().length()== 2){
196 // area.setLevel(NamedAreaLevel.TDWG_LEVEL2());
197 // }else if (tdwgAbbrevLabel.trim().length()== 3){
198 // area.setLevel(NamedAreaLevel.TDWG_LEVEL3());
199 // }else if (tdwgAbbrevLabel.trim().length()== 6){
200 // area.setLevel(NamedAreaLevel.TDWG_LEVEL4());
201 // }else {
202 // logger.warn("Unknown TDWG Level " + tdwgAbbrevLabel + "! Unvalid string length (" + tdwgAbbrevLabel.length() +")");
203 // }
204 // }
205 //
206 // private static void initMaps(){
207 // labelMap = new HashMap<String, UUID>();
208 // abbrevMap = new HashMap<String, UUID>();
209 // }
210
211
212 //********************* OLD ******************************/
213
214
215 // private static NamedArea getNamedAreaByTdwgLabel(String tdwgLabel){
216 // if (tdwgLabel == null){
217 // return null;
218 // }
219 // InputStream file;
220 // try {
221 // file = CdmUtils.getReadableResourceStream("");
222 // } catch (IOException e) {
223 // logger.error(e);
224 // e.printStackTrace();
225 // return null;
226 // }
227 // Element root = XmlHelp.getRoot(file, "RDF");
228 // Namespace nsRdf = root.getNamespace("rdf");
229 // XmlHelp.getFirstAttributedChild(root, "", "ID", tdwgLabel.trim());
230 //
231 // //Filter filter = ;
232 // //root.getDescendants(filter);
233 // return null;
234 // }
235
236 }