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
|
|
25
|
import eu.etaxonomy.cdm.model.common.Language;
|
26
|
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
|
27
|
import eu.etaxonomy.cdm.model.common.TermType;
|
28
|
import eu.etaxonomy.cdm.model.common.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
|
* @version 1.0
|
50
|
* @since 08-Nov-2007 13:06:27
|
51
|
*/
|
52
|
@XmlAccessorType(XmlAccessType.FIELD)
|
53
|
@XmlType(name = "HybridRelationshipType")
|
54
|
@XmlRootElement(name = "HybridRelationshipType")
|
55
|
@Entity
|
56
|
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
|
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 || termMap.isEmpty()){
|
119
|
return getTermByClassAndUUID(HybridRelationshipType.class, uuid);
|
120
|
} else {
|
121
|
return termMap.get(uuid);
|
122
|
}
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* Returns the "first parent" hybrid relationship type. The elements of the
|
127
|
* {@link INonViralName non-viral taxon name} used as "first parent" affect the
|
128
|
* taxon name string of the hybrid (see Appendix I of the ICBN).
|
129
|
*
|
130
|
* @see #SECOND_PARENT()
|
131
|
* @see #THIRD_PARENT()
|
132
|
* @see #FOURTH_PARENT()
|
133
|
* @see #FEMALE_PARENT()
|
134
|
* @see #MAJOR_PARENT()
|
135
|
*/
|
136
|
public static final HybridRelationshipType FIRST_PARENT(){
|
137
|
return getTermByUuid(uuidFirstParent);
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* Returns the "second parent" hybrid relationship type. The elements of the
|
142
|
* {@link INonViralName non-viral taxon name} used as "second parent" affect the
|
143
|
* taxon name string of the hybrid (see Appendix I of the ICBN).
|
144
|
*
|
145
|
* @see #FIRST_PARENT()
|
146
|
* @see #MALE_PARENT()
|
147
|
* @see #MINOR_PARENT()
|
148
|
*/
|
149
|
public static final HybridRelationshipType SECOND_PARENT(){
|
150
|
return getTermByUuid(uuidSecondParent);
|
151
|
}
|
152
|
|
153
|
/**
|
154
|
* Returns the "third parent" hybrid relationship type. The elements of the
|
155
|
* {@link INonViralName non viral taxon name} used as "third parent" affect the
|
156
|
* taxon name string of the hybrid (see Appendix I of the ICBN).
|
157
|
*
|
158
|
* @see #FIRST_PARENT()
|
159
|
*/
|
160
|
public static final HybridRelationshipType THIRD_PARENT(){
|
161
|
return getTermByUuid(uuidThirdParent);
|
162
|
}
|
163
|
|
164
|
/**
|
165
|
* Returns the "fourth parent" hybrid relationship type. The elements of the
|
166
|
* {@link INonViralName non viral taxon name} used as "third parent" affect the
|
167
|
* taxon name string of the hybrid (see Appendix I of the ICBN).
|
168
|
*
|
169
|
* @see #FIRST_PARENT()
|
170
|
*/
|
171
|
public static final HybridRelationshipType FOURTH_PARENT(){
|
172
|
return getTermByUuid(uuidFourthParent);
|
173
|
}
|
174
|
|
175
|
/**
|
176
|
* Returns the "female parent" hybrid relationship type. The taxon the name
|
177
|
* of which plays the female parent role is the genetic mother of the taxon
|
178
|
* which is the hybrid (and has the hybrid {@link INonViralName non-viral taxon name})<BR>
|
179
|
* For nomenclature purposes a "female parent" is also a "first parent".
|
180
|
*
|
181
|
* @see #MALE_PARENT()
|
182
|
* @see #FIRST_PARENT()
|
183
|
*/
|
184
|
public static final HybridRelationshipType FEMALE_PARENT(){
|
185
|
return getTermByUuid(uuidFemaleParent);
|
186
|
}
|
187
|
|
188
|
/**
|
189
|
* Returns the "male parent" hybrid relationship type. The taxon the name
|
190
|
* of which plays the male parent role is the genetic father of the taxon
|
191
|
* which is the hybrid (and has the hybrid {@link INonViralName non-viral taxon name}).<BR>
|
192
|
* For nomenclature purposes a "male parent" is also a "second parent".
|
193
|
*
|
194
|
* @see #MALE_PARENT()
|
195
|
* @see #SECOND_PARENT()
|
196
|
*/
|
197
|
public static final HybridRelationshipType MALE_PARENT(){
|
198
|
return getTermByUuid(uuidMaleParent);
|
199
|
}
|
200
|
|
201
|
/**
|
202
|
* Returns the "major parent" hybrid relationship type. This relationship
|
203
|
* maybe used for hybrids which have parents that are not equally represented
|
204
|
* in the child (e.g. some fern hybrids).
|
205
|
* For nomenclature purposes a "major parent" is also a "first parent".<BR>
|
206
|
* Major and minor parent relationships are usually represented in a
|
207
|
* hybrid formula with a "greater than" symbol (>). It replaces the multiplication
|
208
|
* symbol which is generally used for hybrid fromulas.
|
209
|
*
|
210
|
* @see #FIRST_PARENT()
|
211
|
* @see #MINOR_PARENT()
|
212
|
*/
|
213
|
public static final HybridRelationshipType MAJOR_PARENT(){
|
214
|
return getTermByUuid(uuidMajorParent);
|
215
|
}
|
216
|
|
217
|
/**
|
218
|
* Returns the "minor parent" hybrid relationship type. This relationship
|
219
|
* maybe used for hybrids which have parents that are not equally represented
|
220
|
* in the child (e.g. some fern hybrids).<BR>
|
221
|
* For nomenclature purposes a "major parent" is also a "second parent".
|
222
|
* Major and minor parent relationships are usually represented in a
|
223
|
* hybrid formula with a "greater than" symbol (>). It replaces the multiplication
|
224
|
* symbol which is generally used for hybrid fromulas.
|
225
|
*
|
226
|
* @see #SECOND_PARENT()
|
227
|
*/
|
228
|
public static final HybridRelationshipType MINOR_PARENT(){
|
229
|
return getTermByUuid(uuidMinorParent);
|
230
|
}
|
231
|
|
232
|
|
233
|
@Override
|
234
|
public int compareTo(HybridRelationshipType otherRelationshipType) {
|
235
|
return super.performCompareTo(otherRelationshipType, true);
|
236
|
}
|
237
|
|
238
|
@Override
|
239
|
protected void setDefaultTerms(TermVocabulary<HybridRelationshipType> termVocabulary) {
|
240
|
termMap = new HashMap<UUID, HybridRelationshipType>();
|
241
|
for (HybridRelationshipType term : termVocabulary.getTerms()){
|
242
|
termMap.put(term.getUuid(), term);
|
243
|
}
|
244
|
}
|
245
|
|
246
|
// @Override
|
247
|
// public HybridRelationshipType readCsvLine(Class<HybridRelationshipType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
|
248
|
// return super.readCsvLine(termClass, csvLine, terms);
|
249
|
// }
|
250
|
|
251
|
}
|