Project

General

Profile

Download (7.24 KB) Statistics
| Branch: | Tag: | Revision:
1 9479da48 Andreas Müller
/**
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 ee91bcd9 ben.clark
import javax.persistence.Entity;
13
import javax.persistence.FetchType;
14
import javax.persistence.ManyToOne;
15 b70a7f94 Andreas Kohlbecker
import javax.persistence.Transient;
16 76b4a40f a.babadshanjan
import javax.xml.bind.annotation.XmlAccessType;
17
import javax.xml.bind.annotation.XmlAccessorType;
18
import javax.xml.bind.annotation.XmlElement;
19 3d2f6860 ben.clark
import javax.xml.bind.annotation.XmlIDREF;
20
import javax.xml.bind.annotation.XmlSchemaType;
21 76b4a40f a.babadshanjan
import javax.xml.bind.annotation.XmlType;
22 9479da48 Andreas Müller
23 ee91bcd9 ben.clark
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 9479da48 Andreas Müller
/**
32 9677085d m.geoffroy
 * 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 8a047684 m.geoffroy
 * <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 9479da48 Andreas Müller
 * @author m.doering
46
 * @version 1.0
47
 * @created 08-Nov-2007 13:06:26
48
 */
49 76b4a40f a.babadshanjan
@XmlAccessorType(XmlAccessType.FIELD)
50
@XmlType(name = "HybridRelationship", propOrder = {
51 3d2f6860 ben.clark
	"relatedFrom",
52
	"relatedTo",
53
	"type",
54 76b4a40f a.babadshanjan
    "ruleConsidered"
55
})
56 9479da48 Andreas Müller
@Entity
57 ee91bcd9 ben.clark
@Audited
58 7ebeb288 Andreas Müller
public class HybridRelationship extends RelationshipBase<BotanicalName, BotanicalName, HybridRelationshipType> {
59 76b4a40f a.babadshanjan
  
60 7ebeb288 Andreas Müller
	private static final Logger logger = Logger.getLogger(HybridRelationship.class);
61 76b4a40f a.babadshanjan
	
62 9479da48 Andreas Müller
	//The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
63
	//the note property.
64 76b4a40f a.babadshanjan
	@XmlElement(name = "RuleConsidered")
65 9479da48 Andreas Müller
	private String ruleConsidered;
66 3d2f6860 ben.clark
	
67
	@XmlElement(name = "RelatedFrom")
68
    @XmlIDREF
69
    @XmlSchemaType(name = "IDREF")
70 ee91bcd9 ben.clark
    @ManyToOne(fetch=FetchType.LAZY)
71
    @Cascade(CascadeType.SAVE_UPDATE)
72 3d2f6860 ben.clark
	private BotanicalName relatedFrom;
73
74
	@XmlElement(name = "RelatedTo")
75
    @XmlIDREF
76
    @XmlSchemaType(name = "IDREF")
77 ee91bcd9 ben.clark
    @ManyToOne(fetch=FetchType.LAZY)
78
    @Cascade(CascadeType.SAVE_UPDATE)
79 3d2f6860 ben.clark
	private BotanicalName relatedTo;
80
	
81
    @XmlElement(name = "Type")
82
    @XmlIDREF
83
    @XmlSchemaType(name = "IDREF")
84 ee91bcd9 ben.clark
    @ManyToOne(fetch=FetchType.LAZY)
85 3d2f6860 ben.clark
	private HybridRelationshipType type;
86 9479da48 Andreas Müller
87 d0408f4d Andreas Müller
	//for hibernate use only, don't use
88 7ebeb288 Andreas Müller
	@Deprecated
89
	private HybridRelationship(){
90
		super();
91 9479da48 Andreas Müller
	}
92
93 7ebeb288 Andreas Müller
	
94 9677085d m.geoffroy
	// ************* CONSTRUCTORS *************/	
95 7ebeb288 Andreas Müller
	/**
96 9677085d m.geoffroy
	 * 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 7ebeb288 Andreas Müller
	 */
107
	protected HybridRelationship(BotanicalName hybridName, BotanicalName parentName, HybridRelationshipType type, String ruleConsidered) {
108 d0408f4d Andreas Müller
		this(hybridName, parentName, type, null, null, ruleConsidered);
109 7ebeb288 Andreas Müller
	}
110
	
111
	/**
112 9677085d m.geoffroy
	 * Class constructor: creates a new hybrid relationship instance including
113 edc80540 m.geoffroy
	 * its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and adds it to the respective 
114 9677085d m.geoffroy
	 *{@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 7ebeb288 Andreas Müller
	 */
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 9677085d m.geoffroy
	//********* METHODS **************************************/
131
132
	/** 
133
	 * Returns the {@link BotanicalName botanical taxon name} that plays the parent role
134 b9d0e8d2 m.geoffroy
	 * in <i>this</i> hybrid relationship.
135 9677085d m.geoffroy
	 *  
136
	 * @see   #getHybridName()
137 edc80540 m.geoffroy
	 * @see   eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedFrom()
138 9677085d m.geoffroy
	 */
139 b70a7f94 Andreas Kohlbecker
	@Transient
140 9479da48 Andreas Müller
	public BotanicalName getParentName(){
141 3d2f6860 ben.clark
		return this.getRelatedFrom();
142 9479da48 Andreas Müller
	}
143 9677085d m.geoffroy
	/**
144
	 * @see  #getParentName()
145
	 */
146 9479da48 Andreas Müller
	public void setParentName(BotanicalName parentName){
147 3d2f6860 ben.clark
		this.setRelatedFrom(parentName);
148 9479da48 Andreas Müller
	}
149
150 9677085d m.geoffroy
	/** 
151
	 * Returns the {@link BotanicalName botanical taxon name} that plays the child role
152 b9d0e8d2 m.geoffroy
	 * (the child is actually the hybrid taxon name) in <i>this</i> hybrid relationship.
153 9677085d m.geoffroy
	 *  
154
	 * @see   #getParentName()
155 edc80540 m.geoffroy
	 * @see   eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedTo()
156 9677085d m.geoffroy
	 */
157 b70a7f94 Andreas Kohlbecker
	@Transient
158 9479da48 Andreas Müller
	public BotanicalName getHybridName(){
159 3d2f6860 ben.clark
		return this.getRelatedTo();
160 9479da48 Andreas Müller
	}
161 9677085d m.geoffroy
	/**
162
	 * @see  #getHybridName()
163
	 */
164 9479da48 Andreas Müller
	public void setHybridName(BotanicalName hybridName){
165 3d2f6860 ben.clark
		this.setRelatedTo(hybridName);
166 9479da48 Andreas Müller
	}
167
168 9677085d m.geoffroy
	/** 
169
	 * Returns the ICBN rule considered (that is the
170
	 * article/note/recommendation in the nomenclatural code) for building
171 edc80540 m.geoffroy
	 * the string representing the (child) hybrid {@link BotanicalName taxon name}
172
	 * within <i>this</i> hybrid relationship.
173 9677085d m.geoffroy
	 */
174 9479da48 Andreas Müller
	public String getRuleConsidered(){
175
		return this.ruleConsidered;
176
	}
177 9677085d m.geoffroy
	/**
178
	 * @see  #getRuleConsidered()
179
	 */
180 9479da48 Andreas Müller
	public void setRuleConsidered(String ruleConsidered){
181
		this.ruleConsidered = ruleConsidered;
182
	}
183
184 3d2f6860 ben.clark
	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 9479da48 Andreas Müller
}