(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameTypeDesignation.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
13 import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
14 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
15
16 import org.apache.log4j.Logger;
17 import org.hibernate.annotations.Cascade;
18 import org.hibernate.annotations.CascadeType;
19 import javax.persistence.*;
20
21 /**
22 * Only taxon names which have a rank above "species" are typified by other
23 * taxon names of lower rank. A type of a name of a genus or of any
24 * subdivision of a genus can only be the name of a species. A type of a name
25 * of a family or of any subdivision of a family is the name of a genus
26 * (or resolving it: a name of a species typifying this genus).
27 * Moreover the mentioned taxon name type may be rejected or conserved.
28 * Depending on the date of publication, the same designation could have the
29 * rejected status according to one reference and later have the conserved
30 * status according to another reference.
31 *
32 * @author m.doering
33 * @version 1.0
34 * @created 08-Nov-2007 13:06:38
35 */
36 @Entity
37 public class NameTypeDesignation extends ReferencedEntityBase {
38 static Logger logger = Logger.getLogger(NameTypeDesignation.class);
39 private boolean isRejectedType;
40 private boolean isConservedType;
41 private TaxonNameBase typeSpecies;
42 private TaxonNameBase typifiedName;
43
44 protected NameTypeDesignation(TaxonNameBase typifiedName, TaxonNameBase typeSpecies, ReferenceBase citation, String citationMicroReference,
45 String originalNameString, boolean isRejectedType, boolean isConservedType) {
46 super(citation, citationMicroReference, originalNameString);
47 this.setTypeSpecies(typeSpecies);
48 this.setTypifiedName(typifiedName);
49 // the typified name has to be part of the same homotypical group as the type species
50 typifiedName.setHomotypicalGroup(typeSpecies.getHomotypicalGroup());
51 this.isRejectedType = isRejectedType;
52 this.isConservedType = isConservedType;
53 }
54
55
56 @Cascade({CascadeType.SAVE_UPDATE})
57 public TaxonNameBase getTypifiedName() {
58 return typifiedName;
59 }
60 private void setTypifiedName(TaxonNameBase typifiedName) {
61 this.typifiedName = typifiedName;
62 if (typifiedName != null){
63 typifiedName.getNameTypeDesignations().add(this);
64 }
65 }
66
67
68 @ManyToOne
69 @Cascade({CascadeType.SAVE_UPDATE})
70 public TaxonNameBase getTypeSpecies(){
71 return this.typeSpecies;
72 }
73 private void setTypeSpecies(TaxonNameBase typeSpecies){
74 this.typeSpecies = typeSpecies;
75 }
76
77 public boolean isRejectedType(){
78 return this.isRejectedType;
79 }
80 public void setRejectedType(boolean isRejectedType){
81 this.isRejectedType = isRejectedType;
82 }
83
84 public boolean isConservedType(){
85 return this.isConservedType;
86 }
87 public void setConservedType(boolean isConservedType){
88 this.isConservedType = isConservedType;
89 }
90
91 }