(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / HybridRelationship.java
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 eu.etaxonomy.cdm.model.common.RelationshipBase;
13 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
14 import org.apache.log4j.Logger;
15 import javax.persistence.*;
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.XmlType;
20
21 /**
22 * The class representing a hybrid relationship between one of the {@link BotanicalName parents}
23 * of a hybrid taxon name and the hybrid taxon name itself. A hybrid taxon name
24 * is a {@link BotanicalName botanical taxon name} assigned to a hybrid plant following
25 * the {@link NomenclaturalCode#ICBN() ICBN} (Appendix I). A hybrid taxon name must have one
26 * of the hybrid flags set. The hybrid relationship includes a {@link HybridRelationshipType hybrid relationship type}
27 * (for instance "first parent" or "female parent") and the article of the ICBN
28 * on which the hybrid taxon name relies.
29
30 * @author m.doering
31 * @version 1.0
32 * @created 08-Nov-2007 13:06:26
33 */
34 @XmlAccessorType(XmlAccessType.FIELD)
35 @XmlType(name = "HybridRelationship", propOrder = {
36 "ruleConsidered"
37 })
38 @Entity
39 public class HybridRelationship extends RelationshipBase<BotanicalName, BotanicalName, HybridRelationshipType> {
40
41 private static final Logger logger = Logger.getLogger(HybridRelationship.class);
42
43 //The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
44 //the note property.
45 @XmlElement(name = "RuleConsidered")
46 private String ruleConsidered;
47
48 //for hibernate use only, don't use
49 @Deprecated
50 private HybridRelationship(){
51 super();
52 }
53
54
55 // ************* CONSTRUCTORS *************/
56 /**
57 * Class constructor: creates a new hybrid relationship instance with no
58 * reference and adds it to the respective
59 * {@link BotanicalName#getHybridRelationships() botanical taxon name relation sets} of both involved names.
60 *
61 * @param toName the taxon name to be set as target for the new hybrid relationship
62 * @param fromName the taxon name to be set as source for the new hybrid relationship
63 * @param type the relationship type to be assigned to the new hybrid relationship
64 * @param ruleConsidered the string indicating the article of the ICBN for the hybrid taxon name
65 * @see #HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, ReferenceBase, String, String)
66 * @see BotanicalName#addHybridRelationship(HybridRelationship)
67 */
68 protected HybridRelationship(BotanicalName hybridName, BotanicalName parentName, HybridRelationshipType type, String ruleConsidered) {
69 this(hybridName, parentName, type, null, null, ruleConsidered);
70 }
71
72 /**
73 * Class constructor: creates a new hybrid relationship instance including
74 * its {@link reference.ReferenceBase reference source} and adds it to the respective
75 *{@link BotanicalName#getHybridRelationships() botanical taxon name relation sets} of both involved names.
76 *
77 * @param toName the taxon name to be set as target for the new hybrid relationship
78 * @param fromName the taxon name to be set as source for the new hybrid relationship
79 * @param type the relationship type to be assigned to the new hybrid relationship
80 * @param citation the reference source for the new hybrid relationship
81 * @param citationMicroReference the string with the details describing the exact localisation within the reference
82 * @param ruleConsidered the string indicating the article of the ICBN for the hybrid taxon name
83 * @see #HybridRelationship(BotanicalName, BotanicalName, HybridRelationshipType, String)
84 * @see BotanicalName#addHybridRelationship(HybridRelationship)
85 */
86 protected HybridRelationship(BotanicalName hybridName, BotanicalName parentName, HybridRelationshipType type, ReferenceBase citation, String citationMicroReference, String ruleConsidered) {
87 super(parentName, hybridName, type, citation, citationMicroReference);
88 this.setRuleConsidered(ruleConsidered);
89 }
90
91 //********* METHODS **************************************/
92
93 /**
94 * Returns the {@link BotanicalName botanical taxon name} that plays the parent role
95 * in this hybrid relationship.
96 *
97 * @see #getHybridName()
98 * @see common.RelationshipBase#getRelatedFrom()
99 */
100 @Transient
101 public BotanicalName getParentName(){
102 return super.getRelatedFrom();
103 }
104 /**
105 * @see #getParentName()
106 */
107 public void setParentName(BotanicalName parentName){
108 super.setRelatedFrom(parentName);
109 }
110
111 /**
112 * Returns the {@link BotanicalName botanical taxon name} that plays the child role
113 * (the child is actually the hybrid taxon name) in this hybrid relationship.
114 *
115 * @see #getParentName()
116 * @see common.RelationshipBase#getRelatedTo()
117 */
118 @Transient
119 public BotanicalName getHybridName(){
120 return super.getRelatedTo();
121 }
122 /**
123 * @see #getHybridName()
124 */
125 public void setHybridName(BotanicalName hybridName){
126 super.setRelatedTo(hybridName);
127 }
128
129 /**
130 * Returns the ICBN rule considered (that is the
131 * article/note/recommendation in the nomenclatural code) for building
132 * the string representing the hybrid taxon name within this hybrid
133 * relationship.
134 */
135 public String getRuleConsidered(){
136 return this.ruleConsidered;
137 }
138 /**
139 * @see #getRuleConsidered()
140 */
141 public void setRuleConsidered(String ruleConsidered){
142 this.ruleConsidered = ruleConsidered;
143 }
144
145 }