| 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 | import org.hibernate.search.annotations.Indexed; |
|---|
| 26 | |
|---|
| 27 | import eu.etaxonomy.cdm.model.common.DefaultTermInitializer; |
|---|
| 28 | import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|---|
| 29 | import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|---|
| 30 | |
|---|
| 31 | /** |
|---|
| 32 | * Reference systems for coordinates also according to OGC (Open Geographical |
|---|
| 33 | * Consortium) The list should be extensible at runtime through configuration. |
|---|
| 34 | * This needs to be investigated. |
|---|
| 35 | * @author m.doering |
|---|
| 36 | * @version 1.0 |
|---|
| 37 | * @created 08-Nov-2007 13:06:49 |
|---|
| 38 | */ |
|---|
| 39 | @XmlAccessorType(XmlAccessType.FIELD) |
|---|
| 40 | @XmlType(name = "ReferenceSystem") |
|---|
| 41 | @XmlRootElement(name = "ReferenceSystem") |
|---|
| 42 | @Entity |
|---|
| 43 | @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase") |
|---|
| 44 | @Audited |
|---|
| 45 | public class ReferenceSystem extends DefinedTermBase<ReferenceSystem> { |
|---|
| 46 | private static final long serialVersionUID = 2704455299046749175L; |
|---|
| 47 | @SuppressWarnings("unused") |
|---|
| 48 | private static final Logger logger = Logger.getLogger(ReferenceSystem.class); |
|---|
| 49 | |
|---|
| 50 | protected static Map<UUID, ReferenceSystem> termMap = null; |
|---|
| 51 | |
|---|
| 52 | private static final UUID uuidWGS84 = UUID.fromString("63f4dd55-00fa-49e7-96fd-2b7059a1c1ee"); |
|---|
| 53 | private static final UUID uuidGoogleEarth = UUID.fromString("1bb67042-2814-4b09-9e76-c8c1e68aa281"); |
|---|
| 54 | private static final UUID uuidGazetteer = UUID.fromString("e35f1d1c-9347-4190-bd47-a3b00632fcf3"); |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | /** |
|---|
| 58 | * Factory method |
|---|
| 59 | * @return |
|---|
| 60 | */ |
|---|
| 61 | public static ReferenceSystem NewInstance(){ |
|---|
| 62 | return new ReferenceSystem(); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | /** |
|---|
| 66 | * Factory method |
|---|
| 67 | * @return |
|---|
| 68 | */ |
|---|
| 69 | public static ReferenceSystem NewInstance(String term, String label, String labelAbbrev){ |
|---|
| 70 | return new ReferenceSystem(term, label, labelAbbrev); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | /** |
|---|
| 74 | * Constructor |
|---|
| 75 | */ |
|---|
| 76 | public ReferenceSystem() { |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | /** |
|---|
| 80 | * Constructor |
|---|
| 81 | */ |
|---|
| 82 | private ReferenceSystem(String term, String label, String labelAbbrev) { |
|---|
| 83 | super(term, label, labelAbbrev); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | // ************************************* MTEHODS ***************************************************/ |
|---|
| 87 | |
|---|
| 88 | /* (non-Javadoc) |
|---|
| 89 | * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms() |
|---|
| 90 | */ |
|---|
| 91 | @Override |
|---|
| 92 | public void resetTerms(){ |
|---|
| 93 | termMap = null; |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | protected static ReferenceSystem getTermByUuid(UUID uuid){ |
|---|
| 99 | if (termMap == null){ |
|---|
| 100 | DefaultTermInitializer vocabularyStore = new DefaultTermInitializer(); |
|---|
| 101 | vocabularyStore.initialize(); |
|---|
| 102 | } |
|---|
| 103 | return (ReferenceSystem)termMap.get(uuid); |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | public static final ReferenceSystem WGS84(){ |
|---|
| 107 | return getTermByUuid(uuidWGS84); |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | public static final ReferenceSystem GOOGLE_EARTH(){ |
|---|
| 111 | return getTermByUuid(uuidGoogleEarth); |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | public static final ReferenceSystem GAZETTEER(){ |
|---|
| 115 | return getTermByUuid(uuidGazetteer); |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | @Override |
|---|
| 119 | protected void setDefaultTerms(TermVocabulary<ReferenceSystem> termVocabulary){ |
|---|
| 120 | termMap = new HashMap<UUID, ReferenceSystem>(); |
|---|
| 121 | for (ReferenceSystem term : termVocabulary.getTerms()){ |
|---|
| 122 | termMap.put(term.getUuid(), term); |
|---|
| 123 | } |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | } |
|---|