2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.name
;
12 import javax
.persistence
.Entity
;
13 import javax
.persistence
.FetchType
;
14 import javax
.persistence
.ManyToOne
;
15 import javax
.xml
.bind
.annotation
.XmlAccessType
;
16 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
17 import javax
.xml
.bind
.annotation
.XmlElement
;
18 import javax
.xml
.bind
.annotation
.XmlIDREF
;
19 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
20 import javax
.xml
.bind
.annotation
.XmlType
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.hibernate
.annotations
.Cascade
;
24 import org
.hibernate
.annotations
.CascadeType
;
25 import org
.hibernate
.envers
.Audited
;
27 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
31 * The class representing a hybrid relationship between one of the {@link BotanicalName parents}
32 * of a hybrid taxon name and the hybrid taxon name itself. A hybrid taxon name
33 * is a {@link BotanicalName botanical taxon name} assigned to a hybrid plant following
34 * the {@link NomenclaturalCode#ICBN() ICBN} (Appendix I). A hybrid taxon name must have one
35 * of the hybrid flags set. The hybrid relationship includes a {@link HybridRelationshipType hybrid relationship type}
36 * (for instance "first parent" or "female parent") and the article of the ICBN
37 * on which the hybrid taxon name relies.
39 * This class corresponds partially to: <ul>
40 * <li> Relationship according to the TDWG ontology
41 * <li> TaxonRelationship according to the TCS
46 * @created 08-Nov-2007 13:06:26
48 @XmlAccessorType(XmlAccessType
.FIELD
)
49 @XmlType(name
= "HybridRelationship", propOrder
= {
57 public class HybridRelationship
extends RelationshipBase
<BotanicalName
, BotanicalName
, HybridRelationshipType
> {
59 private static final Logger logger
= Logger
.getLogger(HybridRelationship
.class);
61 //The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
63 @XmlElement(name
= "RuleConsidered")
64 private String ruleConsidered
;
66 @XmlElement(name
= "RelatedFrom")
68 @XmlSchemaType(name
= "IDREF")
69 @ManyToOne(fetch
=FetchType
.LAZY
)
70 @Cascade(CascadeType
.SAVE_UPDATE
)
71 private BotanicalName relatedFrom
;
73 @XmlElement(name
= "RelatedTo")
75 @XmlSchemaType(name
= "IDREF")
76 @ManyToOne(fetch
=FetchType
.LAZY
)
77 @Cascade(CascadeType
.SAVE_UPDATE
)
78 private BotanicalName relatedTo
;
80 @XmlElement(name
= "Type")
82 @XmlSchemaType(name
= "IDREF")
83 @ManyToOne(fetch
=FetchType
.LAZY
)
84 private HybridRelationshipType type
;
86 //for hibernate use only, don't use
88 private HybridRelationship(){
93 // ************* CONSTRUCTORS *************/
95 * Class constructor: creates a new hybrid relationship instance with no
96 * reference and adds it to the respective
97 * {@link BotanicalName#getHybridRelationships() botanical taxon name relation sets} of both involved names.
99 * @param toName the taxon name to be set as target for the new hybrid relationship
100 * @param fromName the taxon name to be set as source for the new hybrid relationship
101 * @param type the relationship type to be assigned to the new hybrid relationship
102 * @param ruleConsidered the string indicating the article of the ICBN for the hybrid taxon name
103 * @see #HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, ReferenceBase, String, String)
104 * @see BotanicalName#addHybridRelationship(HybridRelationship)
106 protected HybridRelationship(BotanicalName hybridName
, BotanicalName parentName
, HybridRelationshipType type
, String ruleConsidered
) {
107 this(hybridName
, parentName
, type
, null, null, ruleConsidered
);
111 * Class constructor: creates a new hybrid relationship instance including
112 * its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and adds it to the respective
113 *{@link BotanicalName#getHybridRelationships() botanical taxon name relation sets} of both involved names.
115 * @param toName the taxon name to be set as target for the new hybrid relationship
116 * @param fromName the taxon name to be set as source for the new hybrid relationship
117 * @param type the relationship type to be assigned to the new hybrid relationship
118 * @param citation the reference source for the new hybrid relationship
119 * @param citationMicroReference the string with the details describing the exact localisation within the reference
120 * @param ruleConsidered the string indicating the article of the ICBN for the hybrid taxon name
121 * @see #HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, String)
122 * @see BotanicalName#addHybridRelationship(HybridRelationship)
124 protected HybridRelationship(BotanicalName hybridName
, BotanicalName parentName
, HybridRelationshipType type
, ReferenceBase citation
, String citationMicroReference
, String ruleConsidered
) {
125 super(parentName
, hybridName
, type
, citation
, citationMicroReference
);
126 this.setRuleConsidered(ruleConsidered
);
129 //********* METHODS **************************************/
132 * Returns the {@link BotanicalName botanical taxon name} that plays the parent role
133 * in <i>this</i> hybrid relationship.
135 * @see #getHybridName()
136 * @see eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedFrom()
138 public BotanicalName
getParentName(){
139 return this.getRelatedFrom();
142 * @see #getParentName()
144 public void setParentName(BotanicalName parentName
){
145 this.setRelatedFrom(parentName
);
149 * Returns the {@link BotanicalName botanical taxon name} that plays the child role
150 * (the child is actually the hybrid taxon name) in <i>this</i> hybrid relationship.
152 * @see #getParentName()
153 * @see eu.etaxonomy.cdm.model.common.RelationshipBase#getRelatedTo()
155 public BotanicalName
getHybridName(){
156 return this.getRelatedTo();
159 * @see #getHybridName()
161 public void setHybridName(BotanicalName hybridName
){
162 this.setRelatedTo(hybridName
);
166 * Returns the ICBN rule considered (that is the
167 * article/note/recommendation in the nomenclatural code) for building
168 * the string representing the (child) hybrid {@link BotanicalName taxon name}
169 * within <i>this</i> hybrid relationship.
171 public String
getRuleConsidered(){
172 return this.ruleConsidered
;
175 * @see #getRuleConsidered()
177 public void setRuleConsidered(String ruleConsidered
){
178 this.ruleConsidered
= ruleConsidered
;
181 protected BotanicalName
getRelatedFrom() {
185 protected BotanicalName
getRelatedTo() {
189 public HybridRelationshipType
getType() {
193 protected void setRelatedFrom(BotanicalName relatedFrom
) {
194 this.relatedFrom
= relatedFrom
;
197 protected void setRelatedTo(BotanicalName relatedTo
) {
198 this.relatedTo
= relatedTo
;
201 protected void setType(HybridRelationshipType type
) {