root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HybridRelationshipType.java

Revision 11297, 9.1 kB (checked in by a.mueller, 16 months ago)

added terms hermaphrodite, sex unknown (Sex) #2236 and third, fourth, major, minor parent (HybridRelationshipType?) #2237.
Bugfix for inverse representations #2238.

  • 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.name;
11
12import java.util.HashMap;
13import java.util.List;
14import java.util.Map;
15import java.util.UUID;
16
17import javax.persistence.Entity;
18import javax.xml.bind.annotation.XmlAccessType;
19import javax.xml.bind.annotation.XmlAccessorType;
20import javax.xml.bind.annotation.XmlRootElement;
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.Language;
29import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
30import eu.etaxonomy.cdm.model.common.TermVocabulary;
31
32/**
33 * The class representing the categories of {@link HybridRelationship hybrid relationships}
34 * between a {@link BotanicalName botanical taxon name} used as a parent of a hybrid taxon
35 * name and the hybrid taxon name itself. Hybrids and their parents are always
36 * plants. The relationships are to be understood as 'is .... of'.
37 * <P>
38 * A standard (ordered) list of hybrid relationship type instances will be
39 * automatically created as the project starts. But this class allows to extend
40 * this standard list by creating new instances of additional hybrid
41 * relationship types if needed. Hybrid relationship types are neither symmetric
42 * nor transitive.
43
44 * <P>
45 * This class corresponds partially to: <ul>
46 * <li> TaxonRelationshipTerm according to the TDWG ontology
47 * <li> RelationshipType according to the TCS
48 * </ul>
49 *
50 * @author m.doering
51 * @version 1.0
52 * @created 08-Nov-2007 13:06:27
53 */
54@XmlAccessorType(XmlAccessType.FIELD)
55@XmlType(name = "HybridRelationshipType")
56@XmlRootElement(name = "HybridRelationshipType")
57@Entity
58@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
59@Audited
60public class HybridRelationshipType extends RelationshipTermBase<HybridRelationshipType> {
61        private static final long serialVersionUID = 5225908742890437668L;
62        @SuppressWarnings("unused")
63        private static final Logger logger = Logger.getLogger(HybridRelationshipType.class);
64
65        protected static Map<UUID, HybridRelationshipType> termMap = null;             
66
67        private static final UUID uuidFirstParent = UUID.fromString("83ae9e56-18f2-46b6-b211-45cdee775bf3");
68        private static final UUID uuidSecondParent = UUID.fromString("0485fc3d-4755-4f53-8832-b82774484c43");
69        private static final UUID uuidThirdParent = UUID.fromString("bfae2780-92ab-4f65-b534-e68826f59e7d");
70        private static final UUID uuidFourthParent = UUID.fromString("9e92083b-cb9b-4c4d-bca5-c543bbefd3c7");
71        private static final UUID uuidFemaleParent = UUID.fromString("189a3ed9-6860-4943-8be8-a1f60133be2a");
72        private static final UUID uuidMaleParent = UUID.fromString("8b7324c5-cc6c-4109-b708-d49b187815c4");
73        private static final UUID uuidMajorParent = UUID.fromString("da759eea-e3cb-4d3c-ae75-084c2d08f4ed");
74        private static final UUID uuidMinorParent = UUID.fromString("e556b240-b03f-46b8-839b-ad89df633c5a");
75       
76       
77        // ************* CONSTRUCTORS *************/   
78        /**
79         * Class constructor: creates a new empty hybrid relationship type instance.
80         *
81         * @see         #HybridRelationshipType(String, String, String)
82         */
83        public HybridRelationshipType() {
84        }
85        /**
86         * Class constructor: creates an additional hybrid relationship type
87         * instance with a description (in the {@link Language#DEFAULT() default language}), a label,
88         * a label abbreviation and the flags indicating whether this new hybrid
89         * relationship type is symmetric and/or transitive.
90         *
91         * @param       term             the string (in the default language) describing the
92         *                                               new hybrid relationship type to be created
93         * @param       label            the string identifying the new hybrid relationship
94         *                                               type to be created
95         * @param       labelAbbrev  the string identifying (in abbreviated form) the
96         *                                               new hybrid relationship type to be created
97         * @see                                  #HybridRelationshipType()
98         */
99        public HybridRelationshipType(String term, String label, String labelAbbrev) {
100                super(term, label, labelAbbrev, false, false);
101        }
102
103       
104//************************** METHODS ********************************
105       
106        /* (non-Javadoc)
107         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
108         */
109        @Override
110        public void resetTerms(){
111                termMap = null;
112        }
113       
114       
115        protected static HybridRelationshipType getTermByUuid(UUID uuid){
116                if (termMap == null){
117                        return null;  //better return null then initialize the termMap in an unwanted way
118                }
119                return (HybridRelationshipType)termMap.get(uuid);
120        }
121       
122        /**
123         * Returns the "first parent" hybrid relationship type. The elements of the
124         * {@link NonViralName non-viral taxon name} used as "first parent" affect the
125         * taxon name string of the hybrid (see Appendix I of the ICBN).
126         *
127         * @see #SECOND_PARENT()
128         * @see #THIRD_PARENT()
129         * @see #FOURTH_PARENT()
130         * @see #FEMALE_PARENT()
131         * @see #MAJOR_PARENT()
132         */
133        public static final HybridRelationshipType FIRST_PARENT(){
134                return getTermByUuid(uuidFirstParent);
135        }
136
137        /**
138         * Returns the "second parent" hybrid relationship type. The elements of the
139         * {@link NonViralName non-viral taxon name} used as "second parent" affect the
140         * taxon name string of the hybrid (see Appendix I of the ICBN).
141         *
142         * @see #FIRST_PARENT()
143         * @see #MALE_PARENT()
144         * @see #MINOR_PARENT()
145         */
146        public static final HybridRelationshipType SECOND_PARENT(){
147                return getTermByUuid(uuidSecondParent);
148        }
149       
150        /**
151         * Returns the "third parent" hybrid relationship type. The elements of the
152         * {@link NonViralName non viral taxon name} used as "third parent" affect the
153         * taxon name string of the hybrid (see Appendix I of the ICBN).
154         *
155         * @see #FIRST_PARENT()
156         */
157        public static final HybridRelationshipType THIRD_PARENT(){
158                return getTermByUuid(uuidThirdParent);
159        }
160       
161        /**
162         * Returns the "fourth parent" hybrid relationship type. The elements of the
163         * {@link NonViralName non viral taxon name} used as "third parent" affect the
164         * taxon name string of the hybrid (see Appendix I of the ICBN).
165         *
166         * @see #FIRST_PARENT()
167         */
168        public static final HybridRelationshipType FOURTH_PARENT(){
169                return getTermByUuid(uuidFourthParent);
170        }
171       
172        /**
173         * Returns the "female parent" hybrid relationship type. The taxon the name
174         * of which plays the female parent role is the genetic mother of the taxon
175         * which is the hybrid (and has the hybrid {@link NonViralName non-viral taxon name})<BR>
176         * For nomenclature purposes a "female parent" is also a "first parent".
177         *
178         * @see #MALE_PARENT()
179         * @see #FIRST_PARENT()
180         */
181        public static final HybridRelationshipType FEMALE_PARENT(){
182                return getTermByUuid(uuidFemaleParent);
183        }
184
185        /**
186         * Returns the "male parent" hybrid relationship type. The taxon the name
187         * of which plays the male parent role is the genetic father of the taxon
188         * which is the hybrid (and has the hybrid {@link NonViralName non-viral taxon name}).<BR>
189         * For nomenclature purposes a "male parent" is also a "second parent".
190         *
191         * @see #MALE_PARENT()
192         * @see #SECOND_PARENT()
193         */
194        public static final HybridRelationshipType MALE_PARENT(){
195                return getTermByUuid(uuidMaleParent);
196        }
197
198        /**
199         * Returns the "major parent" hybrid relationship type. This relationship
200         * maybe used for hybrids which have parents that are not equally represented
201         * in the child (e.g. some fern hybrids).
202         * For nomenclature purposes a "major parent" is also a "first parent".<BR>
203         * Major and minor parent relationships are usually represented in a
204         * hybrid formula with a "greater than" symbol (>). It replaces the multiplication
205         * symbol which is generally used for hybrid fromulas.
206         *
207         * @see #FIRST_PARENT()
208         * @see #MINOR_PARENT()
209         */
210        public static final HybridRelationshipType MAJOR_PARENT(){
211                return getTermByUuid(uuidMajorParent);
212        }
213
214        /**
215         * Returns the "minor parent" hybrid relationship type. This relationship
216         * maybe used for hybrids which have parents that are not equally represented
217         * in the child (e.g. some fern hybrids).<BR>
218         * For nomenclature purposes a "major parent" is also a "second parent".
219         * Major and minor parent relationships are usually represented in a
220         * hybrid formula with a "greater than" symbol (>). It replaces the multiplication
221         * symbol which is generally used for hybrid fromulas.
222         *
223         * @see #SECOND_PARENT()
224         */
225        public static final HybridRelationshipType MINOR_PARENT(){
226                return getTermByUuid(uuidMinorParent);
227        }
228       
229       
230        @Override
231        public int compareTo(HybridRelationshipType otherRelationshipType) {
232                return super.performCompareTo(otherRelationshipType, true);
233        }
234       
235        @Override
236        protected void setDefaultTerms(TermVocabulary<HybridRelationshipType> termVocabulary) {
237                termMap = new HashMap<UUID, HybridRelationshipType>();
238                for (HybridRelationshipType term : termVocabulary.getTerms()){
239                        termMap.put(term.getUuid(), (HybridRelationshipType)term);
240                }       
241        }
242       
243        @Override
244        public HybridRelationshipType readCsvLine(Class<HybridRelationshipType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
245                return super.readCsvLine(termClass, csvLine, terms);
246        }
247
248}
Note: See TracBrowser for help on using the browser.