2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.location
;
12 import java
.io
.IOException
;
13 import java
.io
.InputStream
;
14 import java
.util
.HashMap
;
16 import java
.util
.UUID
;
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
;
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
;
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
;
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>
42 * Area terms according to the TDWG GeographicRegion vocabulary
43 * http://rs.tdwg.org/ontology/voc/GeographicRegion.rdf
49 @XmlAccessorType(XmlAccessType
.FIELD
)
50 @XmlType(name
= "TdwgArea")
51 @XmlRootElement(name
= "TdwgArea")
53 @Indexed(index
= "eu.etaxonomy.cdm.model.common.DefinedTermBase")
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);
60 // public static final UUID uuidTdwgAreaVocabulary = UUID.fromString("1fb40504-d1d7-44b0-9731-374fbe6cac77");
63 // private static Map<String, UUID> abbrevMap = null;
64 // private static Map<String, UUID> labelMap = null;
66 // protected static Map<UUID, TdwgArea_Old> termMap = null;
70 //************************** METHODS ********************************
73 // * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
76 // public void resetTerms(){
83 // protected static TdwgArea_Old getTermByUuid(UUID uuid){
84 // if (termMap == null){
85 // DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
86 // vocabularyStore.initialize();
88 // return (TdwgArea_Old)termMap.get(uuid);
92 * FIXME This class should really be refactored into an interface and service implementation,
93 * relying on TermVocabularyDao / service (Ben)
94 * @param tdwgAbbreviation
97 // public static NamedArea getAreaByTdwgAbbreviation(String tdwgAbbreviation){
98 // if (abbrevMap == null){
101 // UUID uuid = abbrevMap.get(tdwgAbbreviation);
102 // if (uuid == null){
103 // logger.info("Unknown TDWG area: " + CdmUtils.Nz(tdwgAbbreviation));
106 // return TdwgArea_Old.getTermByUuid(uuid);
110 // * FIXME This class should really be refactored into an interface and service implementation,
111 // * relying on TermVocabularyDao / service (Ben)
112 // * @param tdwgLabel
115 // public static NamedArea getAreaByTdwgLabel(String tdwgLabel){
116 // if (labelMap == null){
119 // tdwgLabel = tdwgLabel.toLowerCase();
120 // UUID uuid = labelMap.get(tdwgLabel);
121 // if (uuid == null){
122 // logger.info("Unknown TDWG area: " + CdmUtils.Nz(tdwgLabel));
125 // return TdwgArea_Old.getTermByUuid(uuid);
128 // public static boolean isTdwgAreaLabel(String label){
129 // label = (label == null? null : label.toLowerCase());
130 // if (labelMap.containsKey(label)){
137 // public static boolean isTdwgAreaAbbreviation(String abbrev){
138 // if (abbrevMap.containsKey(abbrev)){
147 * @see eu.etaxonomy.cdm.model.location.NamedArea#setDefaultTerms(eu.etaxonomy.cdm.model.common.TermVocabulary)
150 // protected void setDefaultTerms(TermVocabulary<NamedArea> termVocabulary) {
151 // Set<NamedArea> terms = termVocabulary.getTerms();
152 // for (NamedArea term : terms){
153 // addTdwgArea(term);
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);
167 // protected static void addTdwgArea(NamedArea area){
168 // if (area == null){
169 // logger.warn("tdwg area is null");
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");
181 // if (abbrevMap == null){
182 // abbrevMap = new HashMap<String, UUID>();
184 // if (labelMap == null){
185 // labelMap = new HashMap<String, UUID>();
188 // abbrevMap.put(tdwgAbbrevLabel, area.getUuid());
189 // labelMap.put(tdwgLabel, area.getUuid());
191 // area.setType(NamedAreaType.ADMINISTRATION_AREA());
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());
202 // logger.warn("Unknown TDWG Level " + tdwgAbbrevLabel + "! Unvalid string length (" + tdwgAbbrevLabel.length() +")");
206 // private static void initMaps(){
207 // labelMap = new HashMap<String, UUID>();
208 // abbrevMap = new HashMap<String, UUID>();
212 //********************* OLD ******************************/
215 // private static NamedArea getNamedAreaByTdwgLabel(String tdwgLabel){
216 // if (tdwgLabel == null){
221 // file = CdmUtils.getReadableResourceStream("");
222 // } catch (IOException e) {
224 // e.printStackTrace();
227 // Element root = XmlHelp.getRoot(file, "RDF");
228 // Namespace nsRdf = root.getNamespace("rdf");
229 // XmlHelp.getFirstAttributedChild(root, "", "ID", tdwgLabel.trim());
231 // //Filter filter = ;
232 // //root.getDescendants(filter);