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
|
package eu.etaxonomy.cdm.model.name;
|
10
|
|
11
|
import javax.persistence.Entity;
|
12
|
import javax.persistence.FetchType;
|
13
|
import javax.persistence.ManyToOne;
|
14
|
import javax.xml.bind.annotation.XmlAccessType;
|
15
|
import javax.xml.bind.annotation.XmlAccessorType;
|
16
|
import javax.xml.bind.annotation.XmlElement;
|
17
|
import javax.xml.bind.annotation.XmlIDREF;
|
18
|
import javax.xml.bind.annotation.XmlSchemaType;
|
19
|
import javax.xml.bind.annotation.XmlType;
|
20
|
|
21
|
import org.apache.log4j.Logger;
|
22
|
import org.hibernate.envers.Audited;
|
23
|
|
24
|
import eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase;
|
25
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
26
|
|
27
|
/**
|
28
|
* The class representing the assignation of a nomenclatural status to a
|
29
|
* {@link TaxonName taxon name}. This includes a {@link NomenclaturalStatusType nomenclatural status type}
|
30
|
* (for instance "invalid", "novum" or "conserved") and eventually the article
|
31
|
* of the corresponding {@link NomenclaturalCode nomenclatural code} this status assignation is based on.
|
32
|
*
|
33
|
* @author m.doering
|
34
|
* @since 08-Nov-2007 13:06:39
|
35
|
*/
|
36
|
@XmlAccessorType(XmlAccessType.FIELD)
|
37
|
@XmlType(name = "NomenclaturalStatus", propOrder = {
|
38
|
"name",
|
39
|
"ruleConsidered",
|
40
|
"type"
|
41
|
})
|
42
|
@Entity
|
43
|
@Audited
|
44
|
public class NomenclaturalStatus
|
45
|
extends SingleSourcedEntityBase
|
46
|
implements IRuleConsidered{
|
47
|
|
48
|
private static final long serialVersionUID = -2451270405173131900L;
|
49
|
static Logger logger = Logger.getLogger(NomenclaturalStatus.class);
|
50
|
|
51
|
//The nomenclatural code rule considered. The article/note/recommendation in the code
|
52
|
//in question that is commented on in the note property.
|
53
|
private RuleConsidered ruleConsidered;
|
54
|
|
55
|
@XmlElement(name = "NomenclaturalStatusType")
|
56
|
@XmlIDREF
|
57
|
@XmlSchemaType(name = "IDREF")
|
58
|
@ManyToOne(fetch = FetchType.LAZY)
|
59
|
private NomenclaturalStatusType type;
|
60
|
|
61
|
@XmlElement(name = "Name")
|
62
|
@XmlIDREF
|
63
|
@XmlSchemaType(name = "IDREF")
|
64
|
@ManyToOne(fetch = FetchType.LAZY)
|
65
|
private TaxonName name;
|
66
|
|
67
|
// ************************** FACTORY *********************************/
|
68
|
|
69
|
/**
|
70
|
* Creates a new nomenclatural status instance with a given
|
71
|
* {@link NomenclaturalStatusType nomenclatural status type}.
|
72
|
*
|
73
|
* @see #NomenclaturalStatus()
|
74
|
*/
|
75
|
public static NomenclaturalStatus NewInstance(NomenclaturalStatusType nomStatusType){
|
76
|
return NewInstance(nomStatusType, null, null);
|
77
|
}
|
78
|
|
79
|
|
80
|
/**
|
81
|
* Creates a new nomenclatural status instance with a given
|
82
|
* {@link NomenclaturalStatusType nomenclatural status type}.
|
83
|
*
|
84
|
* @see #NomenclaturalStatus()
|
85
|
*/
|
86
|
public static NomenclaturalStatus NewInstance(NomenclaturalStatusType nomStatusType, Reference citation, String microCitation){
|
87
|
NomenclaturalStatus status = new NomenclaturalStatus();
|
88
|
status.setType(nomStatusType);
|
89
|
status.setCitation(citation);
|
90
|
status.setCitationMicroReference(microCitation);
|
91
|
return status;
|
92
|
}
|
93
|
|
94
|
// ************************ CONSTRUCTOR *************************/
|
95
|
|
96
|
protected NomenclaturalStatus() {
|
97
|
super();
|
98
|
}
|
99
|
|
100
|
// ************************ GETTER / SETTER ************************/
|
101
|
|
102
|
public TaxonName getName() {
|
103
|
return name;
|
104
|
}
|
105
|
protected void setName(TaxonName name) {
|
106
|
if (this.name != null && !this.name.equals(name)){
|
107
|
this.name.removeStatus(this);
|
108
|
}
|
109
|
this.name = name;
|
110
|
if (name != null){
|
111
|
name.addStatus(this);
|
112
|
}
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* Returns the {@link NomenclaturalStatusType nomenclatural status type} of <i>this</i>
|
117
|
* nomenclatural status.
|
118
|
*/
|
119
|
public NomenclaturalStatusType getType(){
|
120
|
return this.type;
|
121
|
}
|
122
|
/**
|
123
|
* @see #getType()
|
124
|
*/
|
125
|
public void setType(NomenclaturalStatusType type){
|
126
|
this.type = type;
|
127
|
}
|
128
|
|
129
|
/**
|
130
|
* Returns the nomenclatural code rule considered (that is the
|
131
|
* article/note/recommendation in the nomenclatural code ruling
|
132
|
* the {@link TaxonName#getNomenclaturalCode() taxon name(s)}) of <i>this</i>
|
133
|
* nomenclatural status. The considered rule gives the reason why the
|
134
|
* {@link NomenclaturalStatusType nomenclatural status type} has been
|
135
|
* assigned to the {@link TaxonName taxon name(s)}.
|
136
|
*/
|
137
|
@Override
|
138
|
public String getRuleConsidered(){
|
139
|
return this.ruleConsidered().getText();
|
140
|
}
|
141
|
/**
|
142
|
* @see #getRuleConsidered()
|
143
|
*/
|
144
|
@Override
|
145
|
public void setRuleConsidered(String ruleConsidered){
|
146
|
this.ruleConsidered().setText(ruleConsidered);
|
147
|
}
|
148
|
|
149
|
/**
|
150
|
* The {@link NomenclaturalCodeEdition code edition} for the {@link #getRuleConsidered() rule considered}.
|
151
|
*/
|
152
|
@Override
|
153
|
public NomenclaturalCodeEdition getCodeEdition() {
|
154
|
return ruleConsidered().getCodeEdition();
|
155
|
}
|
156
|
@Override
|
157
|
public void setCodeEdition(NomenclaturalCodeEdition codeEdition) {
|
158
|
ruleConsidered().setCodeEdition(codeEdition);
|
159
|
}
|
160
|
|
161
|
private RuleConsidered ruleConsidered(){
|
162
|
if(this.ruleConsidered==null){
|
163
|
ruleConsidered = new RuleConsidered();
|
164
|
}
|
165
|
return ruleConsidered;
|
166
|
}
|
167
|
|
168
|
//*********************** CLONE ********************************************************/
|
169
|
|
170
|
/**
|
171
|
* Clones <i>this</i> nomenclatural status. This is a shortcut that enables to create
|
172
|
* a new instance that differs only slightly from <i>this</i> nomenclatural status by
|
173
|
* modifying only some of the attributes.
|
174
|
*
|
175
|
* @see eu.etaxonomy.cdm.model.common.SingleSourcedEntityBase#clone()
|
176
|
* @see java.lang.Object#clone()
|
177
|
*/
|
178
|
@Override
|
179
|
public NomenclaturalStatus clone() {
|
180
|
try {
|
181
|
NomenclaturalStatus result = (NomenclaturalStatus)super.clone();
|
182
|
result.ruleConsidered = this.ruleConsidered == null? null : this.ruleConsidered.clone();
|
183
|
//no changes to: type
|
184
|
return result;
|
185
|
} catch (CloneNotSupportedException e) {
|
186
|
logger.warn("Object does not implement cloneable");
|
187
|
e.printStackTrace();
|
188
|
return null;
|
189
|
}
|
190
|
}
|
191
|
}
|