root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/SynonymRelationshipType.java

Revision 12812, 7.6 kB (checked in by a.mueller, 9 months ago)

bugfix for test

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.taxon;
11
12
13import java.util.HashMap;
14import java.util.List;
15import java.util.Map;
16import java.util.UUID;
17
18import javax.persistence.Entity;
19import javax.xml.bind.annotation.XmlAccessType;
20import javax.xml.bind.annotation.XmlAccessorType;
21import javax.xml.bind.annotation.XmlType;
22
23import org.apache.log4j.Logger;
24import org.hibernate.envers.Audited;
25import org.hibernate.search.annotations.Indexed;
26
27import eu.etaxonomy.cdm.model.common.DefinedTermBase;
28import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
29import eu.etaxonomy.cdm.model.common.TermVocabulary;
30
31/**
32 * The class representing categories of {@link SynonymRelationship synonym relationships}
33 * (like "heterotypic synonym of").
34 * <P>
35 * A standard (ordered) list of synonym relationship type instances will be
36 * automatically created as the project starts. But this class allows to extend
37 * this standard list by creating new instances of additional synonym
38 * relationship types if needed.
39 * <P>
40 * This class corresponds in part to: <ul>
41 * <li> TaxonRelationshipTerm according to the TDWG ontology
42 * <li> RelationshipType according to the TCS
43 * </ul>
44 *
45 * @author m.doering
46 * @version 1.0
47 * @created 08-Nov-2007 13:06:55
48 */
49@XmlAccessorType(XmlAccessType.FIELD)
50@XmlType(name = "SynonymRelationshipType")
51@Entity
52@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
53@Audited
54public class SynonymRelationshipType extends RelationshipTermBase<SynonymRelationshipType> {
55       
56        static Logger logger = Logger.getLogger(SynonymRelationshipType.class);
57
58        protected static Map<UUID, SynonymRelationshipType> termMap = null;             
59
60        public static final UUID uuidSynonymOf = UUID.fromString("1afa5429-095a-48da-8877-836fa4fe709e");
61        public static final UUID uuidHomotypicSynonymOf = UUID.fromString("294313a9-5617-4ed5-ae2d-c57599907cb2");
62        public static final UUID uuidHeterotypicSynonymOf = UUID.fromString("4c1e2c59-ca55-41ac-9a82-676894976084");
63        public static final UUID uuidInferredSynonymOf = UUID.fromString("cb5bad12-9dbc-4b38-9977-162e45089c11");
64        public static final UUID uuidInferredGenusOf = UUID.fromString("f55a574b-c1de-45cc-9ade-1aa2e098c3b5");
65        public static final UUID uuidInferredEpithetOf = UUID.fromString("089c1926-eb36-47e7-a2d1-fd5f3918713d");
66        public static final UUID uuidPotentialCombinationOf = UUID.fromString("7c45871f-6dc5-40e7-9f26-228318d0f63a");
67       
68
69        // ************* CONSTRUCTORS *************/   
70        /**
71         * Class constructor: creates a new empty synonym relationship type instance.
72         *
73         * @see         #SynonymRelationshipType(String, String, String)
74         */
75        public SynonymRelationshipType() {
76        }
77
78        /**
79         * Class constructor: creates an additional synonym relationship type
80         * instance with a description (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label and
81         * a label abbreviation. Synonym relationships types can be neither
82         * symmetric nor transitive.
83         *
84         * @param       term             the string (in the default language) describing the
85         *                                               new synonym relationship type to be created
86         * @param       label            the string identifying the new synonym relationship
87         *                                               type to be created
88         * @param       labelAbbrev  the string identifying (in abbreviated form) the
89         *                                               new synonym relationship type to be created
90         * @see                                  #SynonymRelationshipType()
91         */
92        public SynonymRelationshipType(String term, String label, String labelAbbrev) {
93                super(term, label, labelAbbrev, false, false);
94        }
95
96       
97//************************** METHODS ********************************
98       
99        /* (non-Javadoc)
100         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
101         */
102        @Override
103        public void resetTerms(){
104                termMap = null;
105        }
106
107       
108        protected static SynonymRelationshipType getTermByUuid(UUID uuid){
109                if (termMap == null){
110                        return null;  //better return null then initialize the termMap in an unwanted way
111                }
112                return (SynonymRelationshipType)termMap.get(uuid);
113        }
114       
115        /**
116         * Returns the synonym relationship type "is synonym of". This indicates
117         * that the reference asserting the {@link SynonymRelationship synonym relationship} does not know
118         * whether both {@link name.TaxonNameBase taxon names} involved are typified by the same type or
119         * not.
120         *
121         * @see         #HOMOTYPIC_SYNONYM_OF()
122         * @see         #HETEROTYPIC_SYNONYM_OF()
123         */
124        public static final SynonymRelationshipType SYNONYM_OF(){
125                return getTermByUuid(uuidSynonymOf);
126        }
127
128        /**
129         * Returns the synonym relationship type "is homotypic synonym of"
130         * ("is nomenclatural synonym of" in zoology). This indicates that the
131         * the reference asserting the {@link SynonymRelationship synonym relationship} holds that
132         * the {@link name.TaxonNameBase taxon name} used as a {@link Synonym synonym} and the taxon name used as the
133         * ("accepted/correct") {@link Taxon taxon} are typified by the same type.
134         * In this case they should belong to the same {@link name.HomotypicalGroup homotypical group}.
135         *
136         * @see         #HETEROTYPIC_SYNONYM_OF()
137         * @see         #SYNONYM_OF()
138         */
139        public static final SynonymRelationshipType HOMOTYPIC_SYNONYM_OF(){
140                return getTermByUuid(uuidHomotypicSynonymOf);
141        }
142
143        /**
144         * Returns the synonym relationship type "is heterotypic synonym of"
145         * ("is taxonomic synonym of" in zoology). This indicates that the
146         * the reference asserting the {@link SynonymRelationship synonym relationship} holds that
147         * the {@link name.TaxonNameBase taxon name} used as a {@link Synonym synonym} and the taxon name used as the
148         * ("accepted/correct") {@link Taxon taxon} are not typified by the same type.
149         * In this case they should not belong to the same {@link name.HomotypicalGroup homotypical group}.
150         *
151         * @see         #HOMOTYPIC_SYNONYM_OF()
152         * @see         #SYNONYM_OF()
153         */
154        public static final SynonymRelationshipType HETEROTYPIC_SYNONYM_OF(){
155                return getTermByUuid(uuidHeterotypicSynonymOf);
156        }
157       
158        /**
159         * Returns the synonym relationship type "is inferred synonym of".
160         * This synonym relationship type is used in zoology whenever a synonymy relationship on species or infraspecific
161         * level is derived from a genus synonymy.
162         */
163        public static final SynonymRelationshipType INFERRED_SYNONYM_OF(){
164                return getTermByUuid(uuidInferredSynonymOf);
165        }
166       
167        /**
168         * Returns the synonym relationship type "is inferred genus of".
169         * This synonym relationship type is used in zoology whenever a synonymy relationship on species or infraspecific
170         * level is derived from a epithet synonymy.
171         */
172        public static final SynonymRelationshipType INFERRED_GENUS_OF(){
173                return getTermByUuid(uuidInferredGenusOf);
174        }
175       
176        /**
177         * Returns the synonym relationship type "is inferred synonym of".
178         * This synonym relationship type is used in zoology whenever a synonymy relationship on species or infraspecific
179         * level is derived from a genus synonymy.
180         */
181        public static final SynonymRelationshipType INFERRED_EPITHET_OF(){
182                return getTermByUuid(uuidInferredEpithetOf);
183        }
184       
185        public static SynonymRelationshipType POTENTIAL_COMBINATION_OF() {
186                return getTermByUuid(uuidPotentialCombinationOf);
187        }
188       
189
190        @Override
191        public SynonymRelationshipType readCsvLine(Class<SynonymRelationshipType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
192                return super.readCsvLine(termClass, csvLine, terms);
193        }
194
195        @Override
196        protected void setDefaultTerms(TermVocabulary<SynonymRelationshipType> termVocabulary) {
197                termMap = new HashMap<UUID, SynonymRelationshipType>();
198                for (SynonymRelationshipType term : termVocabulary.getTerms()){
199                        termMap.put(term.getUuid(), (SynonymRelationshipType)term);
200                }       
201        }
202
203       
204
205}
Note: See TracBrowser for help on using the browser.