(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameRelationship.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 relationship between two {@link TaxonNameBase taxon names} according
23 * to the {@link NomenclaturalCode nomenclatural code} which governs both of them.
24 * This includes a {@link NameRelationshipType name relationship type} (for instance "later homonym" or
25 * "orthographic variant") and the article of the corresponding nomenclatural
26 * code on which the assignation of the relationship type is based.
27
28 * @author m.doering
29 * @version 1.0
30 * @created 08-Nov-2007 13:06:37
31 */
32 @XmlAccessorType(XmlAccessType.FIELD)
33 @XmlType(name = "NameRelationship", propOrder = {
34 "ruleConsidered",
35 "type"
36 })
37 @Entity
38 public class NameRelationship extends RelationshipBase<TaxonNameBase, TaxonNameBase, NameRelationshipType> {
39
40 static Logger logger = Logger.getLogger(NameRelationship.class);
41
42 //The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in
43 //the note property.
44 @XmlElement(name = "RuleConsidered")
45 private String ruleConsidered;
46
47 @XmlElement(name = "NameRelationshipType")
48 private NameRelationshipType type;
49
50 //for hibernate, don't use
51 @Deprecated
52 private NameRelationship(){
53 super();
54 }
55
56
57 // ************* CONSTRUCTORS *************/
58 /**
59 * Class constructor: creates a new name relationship instance with no
60 * reference and adds it to the respective
61 * {@link TaxonNameBase#getNameRelations() taxon name relation sets} of both involved names.
62 *
63 * @param toName the taxon name to be set as target for the new name relationship
64 * @param fromName the taxon name to be set as source for the new name relationship
65 * @param type the relationship type to be assigned to the new name relationship
66 * @param ruleConsidered the string indicating the article of the nomenclatural code for the new name relationship
67 * @see #NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, ReferenceBase, String, String)
68 * @see TaxonNameBase#addNameRelationship(NameRelationship)
69 * @see TaxonNameBase#addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
70 * @see TaxonNameBase#addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
71 */
72 protected NameRelationship(TaxonNameBase toName, TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered) {
73 this(toName, fromName, type, null, null, ruleConsidered);
74 }
75
76 /**
77 * Class constructor: creates a new name relationship instance including
78 * its {@link reference.ReferenceBase reference source} and adds it to the respective
79 *{@link TaxonNameBase#getNameRelations() taxon name relation sets} of both involved names.
80 *
81 * @param toName the taxon name to be set as target for the new name relationship
82 * @param fromName the taxon name to be set as source for the new name relationship
83 * @param type the relationship type to be assigned to the new name relationship
84 * @param citation the reference source for the new name relationship
85 * @param citationMicroReference the string with the details describing the exact localisation within the reference
86 * @param ruleConsidered the string indicating the article of the nomenclatural code justifying the new name relationship
87 * @see #NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String)
88 * @see TaxonNameBase#addNameRelationship(NameRelationship)
89 * @see TaxonNameBase#addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
90 * @see TaxonNameBase#addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
91 */
92 protected NameRelationship(TaxonNameBase toName, TaxonNameBase fromName, NameRelationshipType type, ReferenceBase citation, String citationMicroReference, String ruleConsidered) {
93 super(fromName, toName, type, citation, citationMicroReference);
94 this.setRuleConsidered(ruleConsidered);
95 }
96
97 //********* METHODS **************************************/
98
99 /**
100 * Returns the {@link TaxonNameBase taxon name} that plays the source role
101 * in this taxon name relationship.
102 *
103 * @see #getToName()
104 * @see common.RelationshipBase#getRelatedFrom()
105 */
106 @Transient
107 public TaxonNameBase getFromName(){
108 return super.getRelatedFrom();
109 }
110 /**
111 * @see #getFromName()
112 */
113 private void setFromName(TaxonNameBase fromName){
114 super.setRelatedFrom(fromName);
115 }
116
117 /**
118 * Returns the {@link TaxonNameBase taxon name} that plays the target role
119 * in this taxon name relationship.
120 *
121 * @see #getFromName()
122 * @see common.RelationshipBase#getRelatedTo()
123 */
124 @Transient
125 public TaxonNameBase getToName(){
126 return super.getRelatedTo();
127 }
128 /**
129 * @see #getToName()
130 */
131 private void setToName(TaxonNameBase toName){
132 super.setRelatedTo(toName);
133 }
134
135 /**
136 * Returns the nomenclatural code rule considered (that is the
137 * article/note/recommendation in the nomenclatural code ruling
138 * the {@link TaxonNameBase#getNomenclaturalCode() taxon name(s)}) of this
139 * nomenclatural status. The considered rule gives the reason why the
140 * {@link NomenclaturalStatusType nomenclatural status type} has been
141 * assigned to the {@link TaxonNameBase taxon name(s)}.
142 */
143 public String getRuleConsidered(){
144 return this.ruleConsidered;
145 }
146
147 /**
148 * @see #getRuleConsidered()
149 */
150 public void setRuleConsidered(String ruleConsidered){
151 this.ruleConsidered = ruleConsidered;
152 }
153
154 }