Project

General

Profile

Download (9.27 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.log4j.Logger;
23
import org.hibernate.envers.Audited;
24
import org.hibernate.search.annotations.Indexed;
25

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

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

    
43
 * <P>
44
 * This class corresponds partially to: <ul>
45
 * <li> TaxonRelationshipTerm according to the TDWG ontology
46
 * <li> RelationshipType according to the TCS
47
 * </ul>
48
 * 
49
 * @author m.doering
50
 * @version 1.0
51
 * @created 08-Nov-2007 13:06:27
52
 */
53
@XmlAccessorType(XmlAccessType.FIELD)
54
@XmlType(name = "HybridRelationshipType")
55
@XmlRootElement(name = "HybridRelationshipType")
56
@Entity
57
@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
58
@Audited
59
public class HybridRelationshipType extends RelationshipTermBase<HybridRelationshipType> {
60
	private static final long serialVersionUID = 5225908742890437668L;
61
	@SuppressWarnings("unused")
62
	private static final Logger logger = Logger.getLogger(HybridRelationshipType.class);
63

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

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

    
80
//********************************** Constructor *********************************/	
81

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

    
105
	
106
//************************** METHODS ********************************
107
	
108
	/* (non-Javadoc)
109
	 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
110
	 */
111
	@Override
112
	public void resetTerms(){
113
		termMap = null;
114
	}
115
	
116
	
117
	protected static HybridRelationshipType getTermByUuid(UUID uuid){
118
		if (termMap == null){
119
			return null;  //better return null then initialize the termMap in an unwanted way 
120
		}
121
		return (HybridRelationshipType)termMap.get(uuid);
122
	}
123
	
124
	/**
125
	 * Returns the "first parent" hybrid relationship type. The elements of the
126
	 * {@link NonViralName non-viral taxon name} used as "first parent" affect the
127
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
128
	 * 
129
	 * @see	#SECOND_PARENT()
130
	 * @see #THIRD_PARENT()
131
	 * @see #FOURTH_PARENT()
132
	 * @see #FEMALE_PARENT()
133
	 * @see #MAJOR_PARENT()
134
	 */
135
	public static final HybridRelationshipType FIRST_PARENT(){
136
		return getTermByUuid(uuidFirstParent);
137
	}
138

    
139
	/**
140
	 * Returns the "second parent" hybrid relationship type. The elements of the
141
	 * {@link NonViralName non-viral taxon name} used as "second parent" affect the
142
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
143
	 * 
144
	 * @see	#FIRST_PARENT()
145
	 * @see #MALE_PARENT()
146
	 * @see #MINOR_PARENT()
147
	 */
148
	public static final HybridRelationshipType SECOND_PARENT(){
149
		return getTermByUuid(uuidSecondParent);
150
	}
151
	
152
	/**
153
	 * Returns the "third parent" hybrid relationship type. The elements of the
154
	 * {@link NonViralName non viral taxon name} used as "third parent" affect the
155
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
156
	 * 
157
	 * @see	#FIRST_PARENT()
158
	 */
159
	public static final HybridRelationshipType THIRD_PARENT(){
160
		return getTermByUuid(uuidThirdParent);
161
	}
162
	
163
	/**
164
	 * Returns the "fourth parent" hybrid relationship type. The elements of the
165
	 * {@link NonViralName non viral taxon name} used as "third parent" affect the
166
	 * taxon name string of the hybrid (see Appendix I of the ICBN).
167
	 * 
168
	 * @see	#FIRST_PARENT()
169
	 */
170
	public static final HybridRelationshipType FOURTH_PARENT(){
171
		return getTermByUuid(uuidFourthParent);
172
	}
173
	
174
	/**
175
	 * Returns the "female parent" hybrid relationship type. The taxon the name
176
	 * of which plays the female parent role is the genetic mother of the taxon
177
	 * which is the hybrid (and has the hybrid {@link NonViralName non-viral taxon name})<BR>
178
	 * For nomenclature purposes a "female parent" is also a "first parent".
179
	 * 
180
	 * @see	#MALE_PARENT()
181
	 * @see	#FIRST_PARENT()
182
	 */
183
	public static final HybridRelationshipType FEMALE_PARENT(){
184
		return getTermByUuid(uuidFemaleParent);
185
	}
186

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

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

    
216
	/**
217
	 * Returns the "minor parent" hybrid relationship type. This relationship 
218
	 * maybe used for hybrids which have parents that are not equally represented
219
	 * in the child (e.g. some fern hybrids).<BR>
220
	 * For nomenclature purposes a "major parent" is also a "second parent".
221
	 * Major and minor parent relationships are usually represented in a
222
	 * hybrid formula with a "greater than" symbol (>). It replaces the multiplication
223
	 * symbol which is generally used for hybrid fromulas.
224
	 * 
225
	 * @see	#SECOND_PARENT()
226
	 */
227
	public static final HybridRelationshipType MINOR_PARENT(){
228
		return getTermByUuid(uuidMinorParent);
229
	}
230
	
231
	
232
	@Override
233
	public int compareTo(HybridRelationshipType otherRelationshipType) {
234
		return super.performCompareTo(otherRelationshipType, true);
235
	}
236
	
237
	@Override
238
	protected void setDefaultTerms(TermVocabulary<HybridRelationshipType> termVocabulary) {
239
		termMap = new HashMap<UUID, HybridRelationshipType>();
240
		for (HybridRelationshipType term : termVocabulary.getTerms()){
241
			termMap.put(term.getUuid(), (HybridRelationshipType)term);
242
		}	
243
	}
244
	
245
//	@Override
246
//	public HybridRelationshipType readCsvLine(Class<HybridRelationshipType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
247
//		return super.readCsvLine(termClass, csvLine, terms);
248
//	}
249

    
250
}
(6-6/27)