Project

General

Profile

Download (3.83 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.location;
11

    
12

    
13
import java.util.HashMap;
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.XmlRootElement;
21
import javax.xml.bind.annotation.XmlType;
22

    
23
import org.apache.log4j.Logger;
24
import org.hibernate.envers.Audited;
25

    
26
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27
import eu.etaxonomy.cdm.model.common.TermType;
28
import eu.etaxonomy.cdm.model.common.TermVocabulary;
29

    
30
/**
31
 * Reference systems for coordinates also according to OGC (Open Geographical
32
 * Consortium) The list should be extensible at runtime through configuration.
33
 * This needs to be investigated.
34
 * @author m.doering
35
 * @version 1.0
36
 * @created 08-Nov-2007 13:06:49
37
 */
38
@XmlAccessorType(XmlAccessType.FIELD)
39
@XmlType(name = "ReferenceSystem")
40
@XmlRootElement(name = "ReferenceSystem")
41
@Entity
42
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
43
//@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
44
@Audited
45
public class ReferenceSystem extends DefinedTermBase<ReferenceSystem> {
46
	private static final long serialVersionUID = -9060720949197749047L;
47

    
48
	@SuppressWarnings("unused")
49
	private static final Logger logger = Logger.getLogger(ReferenceSystem.class);
50

    
51
	protected static Map<UUID, ReferenceSystem> termMap = null;
52

    
53
	private static final UUID uuidWGS84 = UUID.fromString("63f4dd55-00fa-49e7-96fd-2b7059a1c1ee");
54
	private static final UUID uuidGoogleEarth = UUID.fromString("1bb67042-2814-4b09-9e76-c8c1e68aa281");
55
	private static final UUID uuidGazetteer = UUID.fromString("e35f1d1c-9347-4190-bd47-a3b00632fcf3");
56
	private static final UUID uuidMap = UUID.fromString("6d72d148-458a-42eb-97b0-9824abcffc91");
57

    
58
	/**
59
	 * Factory method
60
	 * @return
61
	 */
62
	public static ReferenceSystem NewInstance(){
63
		return new ReferenceSystem();
64
	}
65

    
66
	/**
67
	 * Factory method
68
	 * @return
69
	 */
70
	public static ReferenceSystem NewInstance(String term, String label, String labelAbbrev){
71
		return new ReferenceSystem(term, label, labelAbbrev);
72
	}
73

    
74
//********************************** Constructor *******************************************************************/
75

    
76
  	//for hibernate use only
77
  	@Deprecated
78
  	protected ReferenceSystem() {
79
		super(TermType.ReferenceSystem);
80
	}
81

    
82
	/**
83
	 * Constructor
84
	 */
85
	private ReferenceSystem(String term, String label, String labelAbbrev) {
86
		super(TermType.ReferenceSystem, term, label, labelAbbrev);
87
	}
88

    
89
// ************************************* MTEHODS ***************************************************/
90

    
91
	/* (non-Javadoc)
92
	 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
93
	 */
94
	@Override
95
	public void resetTerms(){
96
		termMap = null;
97
	}
98

    
99

    
100

    
101
	protected static ReferenceSystem getTermByUuid(UUID uuid){
102
        if (termMap == null || termMap.isEmpty()){
103
            return getTermByClassAndUUID(ReferenceSystem.class, uuid);
104
        } else {
105
            return termMap.get(uuid);
106
        }
107
	}
108

    
109
	public static final ReferenceSystem WGS84(){
110
		return getTermByUuid(uuidWGS84);
111
	}
112

    
113
	public static final ReferenceSystem GOOGLE_EARTH(){
114
		return getTermByUuid(uuidGoogleEarth);
115
	}
116

    
117
	public static final ReferenceSystem GAZETTEER(){
118
		return getTermByUuid(uuidGazetteer);
119
	}
120

    
121
	public static final ReferenceSystem MAP(){
122
		return getTermByUuid(uuidMap);
123
	}
124

    
125
	@Override
126
	protected void setDefaultTerms(TermVocabulary<ReferenceSystem> termVocabulary){
127
		termMap = new HashMap<UUID, ReferenceSystem>();
128
		for (ReferenceSystem term : termVocabulary.getTerms()){
129
			termMap.put(term.getUuid(), term);
130
		}
131
	}
132

    
133
}
(6-6/8)