Project

General

Profile

Download (7.24 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 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 hybrid relationship between one of the {@link BotanicalName parents}
33
 * of a hybrid taxon name and the hybrid taxon name itself. A hybrid taxon name
34
 * is a {@link BotanicalName botanical taxon name} assigned to a hybrid plant following
35
 * the {@link NomenclaturalCode#ICBN() ICBN} (Appendix I). A hybrid taxon name must have one 
36
 * of the hybrid flags set. The hybrid relationship includes a {@link HybridRelationshipType hybrid relationship type}
37
 * (for instance "first parent" or "female parent") and the article of the ICBN
38
 * on which the hybrid taxon name relies.
39
 * <P>
40
 * This class corresponds partially to: <ul>
41
 * <li> Relationship according to the TDWG ontology
42
 * <li> TaxonRelationship according to the TCS
43
 * </ul>
44
 * 
45
 * @author m.doering
46
 * @version 1.0
47
 * @created 08-Nov-2007 13:06:26
48
 */
49
@XmlAccessorType(XmlAccessType.FIELD)
50
@XmlType(name = "HybridRelationship", propOrder = {
51
	"relatedFrom",
52
	"relatedTo",
53
	"type",
54
    "ruleConsidered"
55
})
56
@Entity
57
@Audited
58
public class HybridRelationship extends RelationshipBase<BotanicalName, BotanicalName, HybridRelationshipType> {
59
  
60
	private static final Logger logger = Logger.getLogger(HybridRelationship.class);
61
	
62
	//The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
63
	//the note property.
64
	@XmlElement(name = "RuleConsidered")
65
	private String ruleConsidered;
66
	
67
	@XmlElement(name = "RelatedFrom")
68
    @XmlIDREF
69
    @XmlSchemaType(name = "IDREF")
70
    @ManyToOne(fetch=FetchType.LAZY)
71
    @Cascade(CascadeType.SAVE_UPDATE)
72
	private BotanicalName relatedFrom;
73

    
74
	@XmlElement(name = "RelatedTo")
75
    @XmlIDREF
76
    @XmlSchemaType(name = "IDREF")
77
    @ManyToOne(fetch=FetchType.LAZY)
78
    @Cascade(CascadeType.SAVE_UPDATE)
79
	private BotanicalName relatedTo;
80
	
81
    @XmlElement(name = "Type")
82
    @XmlIDREF
83
    @XmlSchemaType(name = "IDREF")
84
    @ManyToOne(fetch=FetchType.LAZY)
85
	private HybridRelationshipType type;
86

    
87
	//for hibernate use only, don't use
88
	@Deprecated
89
	private HybridRelationship(){
90
		super();
91
	}
92

    
93
	
94
	// ************* CONSTRUCTORS *************/	
95
	/**
96
	 * Class constructor: creates a new hybrid relationship instance with no
97
	 * reference and adds it to the respective
98
	 * {@link BotanicalName#getHybridRelationships() botanical taxon name relation sets} of both involved names.
99
	 * 
100
	 * @param toName			the taxon name to be set as target for the new hybrid relationship
101
	 * @param fromName			the taxon name to be set as source for the new hybrid relationship
102
	 * @param type				the relationship type to be assigned to the new hybrid relationship
103
	 * @param ruleConsidered	the string indicating the article of the ICBN for the hybrid taxon name
104
	 * @see						#HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, ReferenceBase, String, String)
105
	 * @see						BotanicalName#addHybridRelationship(HybridRelationship)
106
	 */
107
	protected HybridRelationship(BotanicalName hybridName, BotanicalName parentName, HybridRelationshipType type, String ruleConsidered) {
108
		this(hybridName, parentName, type, null, null, ruleConsidered);
109
	}
110
	
111
	/**
112
	 * Class constructor: creates a new hybrid relationship instance including
113
	 * its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and adds it to the respective 
114
	 *{@link BotanicalName#getHybridRelationships() botanical taxon name relation sets} of both involved names.
115
	 * 
116
	 * @param toName				the taxon name to be set as target for the new hybrid relationship
117
	 * @param fromName				the taxon name to be set as source for the new hybrid relationship
118
	 * @param type					the relationship type to be assigned to the new hybrid relationship
119
	 * @param citation				the reference source for the new hybrid 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 ICBN for the hybrid taxon name
122
	 * @see							#HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, String)
123
	 * @see							BotanicalName#addHybridRelationship(HybridRelationship)
124
	 */
125
	protected HybridRelationship(BotanicalName  hybridName, BotanicalName parentName, HybridRelationshipType type, ReferenceBase citation, String citationMicroReference, String ruleConsidered) {
126
		super(parentName, hybridName, type, citation, citationMicroReference);
127
		this.setRuleConsidered(ruleConsidered);
128
	}	
129
	
130
	//********* METHODS **************************************/
131

    
132
	/** 
133
	 * Returns the {@link BotanicalName botanical taxon name} that plays the parent role
134
	 * in <i>this</i> hybrid relationship.
135
	 *  
136
	 * @see   #getHybridName()
137
	 * @see   eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedFrom()
138
	 */
139
	@Transient
140
	public BotanicalName getParentName(){
141
		return this.getRelatedFrom();
142
	}
143
	/**
144
	 * @see  #getParentName()
145
	 */
146
	public void setParentName(BotanicalName parentName){
147
		this.setRelatedFrom(parentName);
148
	}
149

    
150
	/** 
151
	 * Returns the {@link BotanicalName botanical taxon name} that plays the child role
152
	 * (the child is actually the hybrid taxon name) in <i>this</i> hybrid relationship.
153
	 *  
154
	 * @see   #getParentName()
155
	 * @see   eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedTo()
156
	 */
157
	@Transient
158
	public BotanicalName getHybridName(){
159
		return this.getRelatedTo();
160
	}
161
	/**
162
	 * @see  #getHybridName()
163
	 */
164
	public void setHybridName(BotanicalName hybridName){
165
		this.setRelatedTo(hybridName);
166
	}
167

    
168
	/** 
169
	 * Returns the ICBN rule considered (that is the
170
	 * article/note/recommendation in the nomenclatural code) for building
171
	 * the string representing the (child) hybrid {@link BotanicalName taxon name}
172
	 * within <i>this</i> hybrid relationship.
173
	 */
174
	public String getRuleConsidered(){
175
		return this.ruleConsidered;
176
	}
177
	/**
178
	 * @see  #getRuleConsidered()
179
	 */
180
	public void setRuleConsidered(String ruleConsidered){
181
		this.ruleConsidered = ruleConsidered;
182
	}
183

    
184
	protected BotanicalName getRelatedFrom() {
185
		return relatedFrom;
186
	}
187

    
188
	protected BotanicalName getRelatedTo() {
189
		return relatedTo;
190
	}
191

    
192
	public HybridRelationshipType getType() {
193
		return type;
194
	}
195

    
196
	protected void setRelatedFrom(BotanicalName relatedFrom) {
197
		this.relatedFrom = relatedFrom;
198
	}
199

    
200
	protected void setRelatedTo(BotanicalName relatedTo) {
201
		this.relatedTo = relatedTo;
202
	}
203

    
204
	protected void setType(HybridRelationshipType type) {
205
		this.type = type;
206
	}
207
}
(5-5/25)