Project

General

Profile

Download (8.99 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.name;
11

    
12
import java.util.HashMap;
13
import java.util.Map;
14
import java.util.UUID;
15

    
16
import javax.persistence.Entity;
17
import javax.xml.bind.annotation.XmlAccessType;
18
import javax.xml.bind.annotation.XmlAccessorType;
19
import javax.xml.bind.annotation.XmlRootElement;
20
import javax.xml.bind.annotation.XmlType;
21

    
22
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
23
import org.hibernate.envers.Audited;
24

    
25
import eu.etaxonomy.cdm.model.common.Language;
26
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
27
import eu.etaxonomy.cdm.model.term.TermType;
28
import eu.etaxonomy.cdm.model.term.TermVocabulary;
29

    
30
/**
31
 * The class representing the categories of {@link HybridRelationship hybrid relationships}
32
 * between a {@link BotanicalName botanical taxon name} used as a parent of a hybrid taxon
33
 * name and the hybrid taxon name itself. Hybrids and their parents are always
34
 * plants. The relationships are to be understood as 'is .... of'.
35
 * <P>
36
 * A standard (ordered) list of hybrid relationship type instances will be
37
 * automatically created as the project starts. But this class allows to extend
38
 * this standard list by creating new instances of additional hybrid
39
 * relationship types if needed. Hybrid relationship types are neither symmetric
40
 * nor transitive.
41

    
42
 * <P>
43
 * This class corresponds partially to: <ul>
44
 * <li> TaxonRelationshipTerm according to the TDWG ontology
45
 * <li> RelationshipType according to the TCS
46
 * </ul>
47
 *
48
 * @author m.doering
49
 * @since 08-Nov-2007 13:06:27
50
 */
51
@XmlAccessorType(XmlAccessType.FIELD)
52
@XmlType(name = "HybridRelationshipType")
53
@XmlRootElement(name = "HybridRelationshipType")
54
@Entity
55
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
56
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
57
@Audited
58
public class HybridRelationshipType extends RelationshipTermBase<HybridRelationshipType> {
59
	private static final long serialVersionUID = 5225908742890437668L;
60
	@SuppressWarnings("unused")
61
	private static final Logger logger = LogManager.getLogger(HybridRelationshipType.class);
62

    
63
	protected static Map<UUID, HybridRelationshipType> termMap = null;
64

    
65
	private static final UUID uuidFirstParent = UUID.fromString("83ae9e56-18f2-46b6-b211-45cdee775bf3");
66
	private static final UUID uuidSecondParent = UUID.fromString("0485fc3d-4755-4f53-8832-b82774484c43");
67
	private static final UUID uuidThirdParent = UUID.fromString("bfae2780-92ab-4f65-b534-e68826f59e7d");
68
	private static final UUID uuidFourthParent = UUID.fromString("9e92083b-cb9b-4c4d-bca5-c543bbefd3c7");
69
	private static final UUID uuidFemaleParent = UUID.fromString("189a3ed9-6860-4943-8be8-a1f60133be2a");
70
	private static final UUID uuidMaleParent = UUID.fromString("8b7324c5-cc6c-4109-b708-d49b187815c4");
71
	private static final UUID uuidMajorParent = UUID.fromString("da759eea-e3cb-4d3c-ae75-084c2d08f4ed");
72
	private static final UUID uuidMinorParent = UUID.fromString("e556b240-b03f-46b8-839b-ad89df633c5a");
73

    
74

    
75
	public static HybridRelationshipType NewInstance(String term, String label, String labelAbbrev) {
76
		return new HybridRelationshipType(term, label, labelAbbrev);
77
	}
78

    
79
//********************************** Constructor *********************************/
80

    
81
  	//for hibernate use only
82
  	@Deprecated
83
  	protected HybridRelationshipType() {
84
		super(TermType.HybridRelationshipType);
85
	}
86
	/**
87
	 * Class constructor: creates an additional hybrid relationship type
88
	 * instance with a description (in the {@link Language#DEFAULT() default language}), a label,
89
	 * a label abbreviation and the flags indicating whether this new hybrid
90
	 * relationship type is symmetric and/or transitive.
91
	 *
92
	 * @param	term  		 the string (in the default language) describing the
93
	 * 						 new hybrid relationship type to be created
94
	 * @param	label  		 the string identifying the new hybrid relationship
95
	 * 						 type to be created
96
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
97
	 * 						 new hybrid relationship type to be created
98
	 * @see 				 #HybridRelationshipType()
99
	 */
100
	private HybridRelationshipType(String term, String label, String labelAbbrev) {
101
		super(TermType.HybridRelationshipType, term, label, labelAbbrev, false, false);
102
	}
103

    
104

    
105
//************************** METHODS ********************************
106

    
107
	@Override
108
	public void resetTerms(){
109
		termMap = null;
110
	}
111

    
112
	protected static HybridRelationshipType getTermByUuid(UUID uuid){
113
        if (termMap == null || termMap.isEmpty()){
114
            return getTermByClassAndUUID(HybridRelationshipType.class, uuid);
115
        } else {
116
            return termMap.get(uuid);
117
        }
118
	}
119

    
120
	/**
121
	 * Returns the "first parent" hybrid relationship type. The elements of the
122
	 * {@link INonViralName non-viral taxon name} used as "first parent" affect the
123
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
124
	 *
125
	 * @see	#SECOND_PARENT()
126
	 * @see #THIRD_PARENT()
127
	 * @see #FOURTH_PARENT()
128
	 * @see #FEMALE_PARENT()
129
	 * @see #MAJOR_PARENT()
130
	 */
131
	public static final HybridRelationshipType FIRST_PARENT(){
132
		return getTermByUuid(uuidFirstParent);
133
	}
134

    
135
	/**
136
	 * Returns the "second parent" hybrid relationship type. The elements of the
137
	 * {@link INonViralName non-viral taxon name} used as "second parent" affect the
138
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
139
	 *
140
	 * @see	#FIRST_PARENT()
141
	 * @see #MALE_PARENT()
142
	 * @see #MINOR_PARENT()
143
	 */
144
	public static final HybridRelationshipType SECOND_PARENT(){
145
		return getTermByUuid(uuidSecondParent);
146
	}
147

    
148
	/**
149
	 * Returns the "third parent" hybrid relationship type. The elements of the
150
	 * {@link INonViralName non viral taxon name} used as "third parent" affect the
151
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
152
	 *
153
	 * @see	#FIRST_PARENT()
154
	 */
155
	public static final HybridRelationshipType THIRD_PARENT(){
156
		return getTermByUuid(uuidThirdParent);
157
	}
158

    
159
	/**
160
	 * Returns the "fourth parent" hybrid relationship type. The elements of the
161
	 * {@link INonViralName non viral taxon name} used as "third parent" affect the
162
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
163
	 *
164
	 * @see	#FIRST_PARENT()
165
	 */
166
	public static final HybridRelationshipType FOURTH_PARENT(){
167
		return getTermByUuid(uuidFourthParent);
168
	}
169

    
170
	/**
171
	 * Returns the "female parent" hybrid relationship type. The taxon the name
172
	 * of which plays the female parent role is the genetic mother of the taxon
173
	 * which is the hybrid (and has the hybrid {@link INonViralName non-viral taxon name})<BR>
174
	 * For nomenclature purposes a "female parent" is also a "first parent".
175
	 *
176
	 * @see	#MALE_PARENT()
177
	 * @see	#FIRST_PARENT()
178
	 */
179
	public static final HybridRelationshipType FEMALE_PARENT(){
180
		return getTermByUuid(uuidFemaleParent);
181
	}
182

    
183
	/**
184
	 * Returns the "male parent" hybrid relationship type. The taxon the name
185
	 * of which plays the male parent role is the genetic father of the taxon
186
	 * which is the hybrid (and has the hybrid {@link INonViralName non-viral taxon name}).<BR>
187
	 * For nomenclature purposes a "male parent" is also a "second parent".
188
	 *
189
	 * @see	#MALE_PARENT()
190
	 * @see	#SECOND_PARENT()
191
	 */
192
	public static final HybridRelationshipType MALE_PARENT(){
193
		return getTermByUuid(uuidMaleParent);
194
	}
195

    
196
	/**
197
	 * Returns the "major parent" hybrid relationship type. This relationship
198
	 * maybe used for hybrids which have parents that are not equally represented
199
	 * in the child (e.g. some fern hybrids).
200
	 * For nomenclature purposes a "major parent" is also a "first parent".<BR>
201
	 * Major and minor parent relationships are usually represented in a
202
	 * hybrid formula with a "greater than" symbol (>). It replaces the multiplication
203
	 * symbol which is generally used for hybrid fromulas.
204
	 *
205
	 * @see	#FIRST_PARENT()
206
	 * @see #MINOR_PARENT()
207
	 */
208
	public static final HybridRelationshipType MAJOR_PARENT(){
209
		return getTermByUuid(uuidMajorParent);
210
	}
211

    
212
	/**
213
	 * Returns the "minor parent" hybrid relationship type. This relationship
214
	 * maybe used for hybrids which have parents that are not equally represented
215
	 * in the child (e.g. some fern hybrids).<BR>
216
	 * For nomenclature purposes a "major parent" is also a "second parent".
217
	 * Major and minor parent relationships are usually represented in a
218
	 * hybrid formula with a "greater than" symbol (>). It replaces the multiplication
219
	 * symbol which is generally used for hybrid formulas.
220
	 *
221
	 * @see	#SECOND_PARENT()
222
	 */
223
	public static final HybridRelationshipType MINOR_PARENT(){
224
		return getTermByUuid(uuidMinorParent);
225
	}
226

    
227

    
228
	@Override
229
	public int compareTo(HybridRelationshipType otherRelationshipType) {
230
		return super.performCompareTo(otherRelationshipType, true);
231
	}
232

    
233
	@Override
234
	protected void setDefaultTerms(TermVocabulary<HybridRelationshipType> termVocabulary) {
235
		termMap = new HashMap<>();
236
		for (HybridRelationshipType term : termVocabulary.getTerms()){
237
			termMap.put(term.getUuid(), term);
238
		}
239
	}
240

    
241
}
(3-3/39)