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 javax.persistence.Entity;
|
13
|
import javax.persistence.FetchType;
|
14
|
import javax.persistence.ManyToOne;
|
15
|
import javax.persistence.Transient;
|
16
|
import javax.xml.bind.annotation.XmlAccessType;
|
17
|
import javax.xml.bind.annotation.XmlAccessorType;
|
18
|
import javax.xml.bind.annotation.XmlElement;
|
19
|
import javax.xml.bind.annotation.XmlIDREF;
|
20
|
import javax.xml.bind.annotation.XmlSchemaType;
|
21
|
import javax.xml.bind.annotation.XmlType;
|
22
|
|
23
|
import org.apache.log4j.Logger;
|
24
|
import org.hibernate.annotations.Cascade;
|
25
|
import org.hibernate.annotations.CascadeType;
|
26
|
import org.hibernate.envers.Audited;
|
27
|
|
28
|
import eu.etaxonomy.cdm.model.common.RelationshipBase;
|
29
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
30
|
|
31
|
/**
|
32
|
* The class representing a relationship between two {@link TaxonNameBase taxon names} according
|
33
|
* to the {@link NomenclaturalCode nomenclatural code} which governs both of them.
|
34
|
* This includes a {@link NameRelationshipType name relationship type} (for instance "later homonym" or
|
35
|
* "orthographic variant") and the article of the corresponding nomenclatural
|
36
|
* code on which the assignation of the relationship type is based.
|
37
|
* <P>
|
38
|
* This class corresponds partially to: <ul>
|
39
|
* <li> Relationship according to the TDWG ontology
|
40
|
* <li> TaxonRelationship according to the TCS
|
41
|
* </ul>
|
42
|
*
|
43
|
* @author m.doering
|
44
|
* @version 1.0
|
45
|
* @created 08-Nov-2007 13:06:37
|
46
|
*/
|
47
|
@XmlAccessorType(XmlAccessType.FIELD)
|
48
|
@XmlType(name = "NameRelationship", propOrder = {
|
49
|
"relatedFrom",
|
50
|
"relatedTo",
|
51
|
"type",
|
52
|
"ruleConsidered"
|
53
|
})
|
54
|
@Entity
|
55
|
@Audited
|
56
|
public class NameRelationship extends RelationshipBase<TaxonNameBase, TaxonNameBase, NameRelationshipType> {
|
57
|
|
58
|
static Logger logger = Logger.getLogger(NameRelationship.class);
|
59
|
|
60
|
//The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
|
61
|
//the note property.
|
62
|
@XmlElement(name = "RuleConsidered")
|
63
|
private String ruleConsidered;
|
64
|
|
65
|
@XmlElement(name = "RelatedFrom")
|
66
|
@XmlIDREF
|
67
|
@XmlSchemaType(name = "IDREF")
|
68
|
@ManyToOne(fetch=FetchType.LAZY)
|
69
|
@Cascade(CascadeType.SAVE_UPDATE)
|
70
|
private TaxonNameBase relatedFrom;
|
71
|
|
72
|
@XmlElement(name = "RelatedTo")
|
73
|
@XmlIDREF
|
74
|
@XmlSchemaType(name = "IDREF")
|
75
|
@ManyToOne(fetch=FetchType.LAZY)
|
76
|
@Cascade(CascadeType.SAVE_UPDATE)
|
77
|
private TaxonNameBase relatedTo;
|
78
|
|
79
|
@XmlElement(name = "Type")
|
80
|
@XmlIDREF
|
81
|
@XmlSchemaType(name = "IDREF")
|
82
|
@ManyToOne(fetch = FetchType.LAZY)
|
83
|
private NameRelationshipType type;
|
84
|
|
85
|
//for hibernate, don't use
|
86
|
@Deprecated
|
87
|
private NameRelationship(){
|
88
|
super();
|
89
|
}
|
90
|
|
91
|
|
92
|
// ************* CONSTRUCTORS *************/
|
93
|
/**
|
94
|
* Class constructor: creates a new name relationship instance with no
|
95
|
* reference and adds it to the respective
|
96
|
* {@link TaxonNameBase#getNameRelations() taxon name relation sets} of both involved names.
|
97
|
*
|
98
|
* @param toName the taxon name to be set as target for the new name relationship
|
99
|
* @param fromName the taxon name to be set as source for the new name relationship
|
100
|
* @param type the relationship type to be assigned to the new name relationship
|
101
|
* @param ruleConsidered the string indicating the article of the nomenclatural code for the new name relationship
|
102
|
* @see #NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, ReferenceBase, String, String)
|
103
|
* @see TaxonNameBase#addNameRelationship(NameRelationship)
|
104
|
* @see TaxonNameBase#addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
|
105
|
* @see TaxonNameBase#addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
|
106
|
*/
|
107
|
protected NameRelationship(TaxonNameBase toName, TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered) {
|
108
|
this(toName, fromName, type, null, null, ruleConsidered);
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* Class constructor: creates a new name relationship instance including
|
113
|
* its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and adds it to the respective
|
114
|
*{@link TaxonNameBase#getNameRelations() taxon name relation sets} of both involved names.
|
115
|
*
|
116
|
* @param toName the taxon name to be set as target for the new name relationship
|
117
|
* @param fromName the taxon name to be set as source for the new name relationship
|
118
|
* @param type the relationship type to be assigned to the new name relationship
|
119
|
* @param citation the reference source for the new name relationship
|
120
|
* @param citationMicroReference the string with the details describing the exact localisation within the reference
|
121
|
* @param ruleConsidered the string indicating the article of the nomenclatural code justifying the new name relationship
|
122
|
* @see #NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String)
|
123
|
* @see TaxonNameBase#addNameRelationship(NameRelationship)
|
124
|
* @see TaxonNameBase#addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
|
125
|
* @see TaxonNameBase#addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
|
126
|
*/
|
127
|
protected NameRelationship(TaxonNameBase toName, TaxonNameBase fromName, NameRelationshipType type, ReferenceBase citation, String citationMicroReference, String ruleConsidered) {
|
128
|
super(fromName, toName, type, citation, citationMicroReference);
|
129
|
this.setRuleConsidered(ruleConsidered);
|
130
|
}
|
131
|
|
132
|
//********* METHODS **************************************/
|
133
|
|
134
|
/**
|
135
|
* Returns the {@link TaxonNameBase taxon name} that plays the source role
|
136
|
* in <i>this</i> taxon name relationship.
|
137
|
*
|
138
|
* @see #getToName()
|
139
|
* @see eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedFrom()
|
140
|
*/
|
141
|
@Transient
|
142
|
public TaxonNameBase getFromName(){
|
143
|
return this.getRelatedFrom();
|
144
|
}
|
145
|
|
146
|
/**
|
147
|
* @see #getFromName()
|
148
|
*/
|
149
|
void setFromName(TaxonNameBase fromName){
|
150
|
this.setRelatedFrom(fromName);
|
151
|
}
|
152
|
|
153
|
/**
|
154
|
* Returns the {@link TaxonNameBase taxon name} that plays the target role
|
155
|
* in <i>this</i> taxon name relationship.
|
156
|
*
|
157
|
* @see #getFromName()
|
158
|
* @see eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedTo()
|
159
|
*/
|
160
|
@Transient
|
161
|
public TaxonNameBase getToName(){
|
162
|
return this.getRelatedTo();
|
163
|
}
|
164
|
|
165
|
/**
|
166
|
* @see #getToName()
|
167
|
*/
|
168
|
void setToName(TaxonNameBase toName){
|
169
|
this.setRelatedTo(toName);
|
170
|
}
|
171
|
|
172
|
/**
|
173
|
* Returns the nomenclatural code rule considered (that is the
|
174
|
* article/note/recommendation in the nomenclatural code ruling
|
175
|
* the taxon name(s) of this nomenclatural status).
|
176
|
* The considered rule gives the reason why the
|
177
|
* {@link NomenclaturalStatusType nomenclatural status type} has been
|
178
|
* assigned to the {@link TaxonNameBase taxon name(s)}.
|
179
|
*/
|
180
|
public String getRuleConsidered(){
|
181
|
return this.ruleConsidered;
|
182
|
}
|
183
|
|
184
|
/**
|
185
|
* @see #getRuleConsidered()
|
186
|
*/
|
187
|
public void setRuleConsidered(String ruleConsidered){
|
188
|
this.ruleConsidered = ruleConsidered;
|
189
|
}
|
190
|
|
191
|
protected TaxonNameBase getRelatedFrom() {
|
192
|
return relatedFrom;
|
193
|
}
|
194
|
|
195
|
protected TaxonNameBase getRelatedTo() {
|
196
|
return relatedTo;
|
197
|
}
|
198
|
|
199
|
public NameRelationshipType getType() {
|
200
|
return type;
|
201
|
}
|
202
|
|
203
|
protected void setRelatedFrom(TaxonNameBase relatedFrom) {
|
204
|
this.relatedFrom = relatedFrom;
|
205
|
}
|
206
|
|
207
|
protected void setRelatedTo(TaxonNameBase relatedTo) {
|
208
|
this.relatedTo = relatedTo;
|
209
|
}
|
210
|
|
211
|
protected void setType(NameRelationshipType type) {
|
212
|
this.type = type;
|
213
|
}
|
214
|
}
|