(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / SpecimenTypeDesignation.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.occurrence.DerivedUnitBase;
14 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
15 import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
16 import org.apache.log4j.Logger;
17 import org.hibernate.annotations.Cascade;
18 import org.hibernate.annotations.CascadeType;
19
20 import java.util.*;
21
22 import javax.persistence.*;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlElement;
26 import javax.xml.bind.annotation.XmlElementWrapper;
27 import javax.xml.bind.annotation.XmlIDREF;
28 import javax.xml.bind.annotation.XmlSchemaType;
29 import javax.xml.bind.annotation.XmlType;
30
31 /**
32 * Taxon names which have the a rank "species" or below can only be typified
33 * by specimens. Above the species rank the taxon names are generally typified
34 * by taxon names with lower rank (species for genus and genus for family) but
35 * can also be typified directly by specimens.
36 *
37 * @author m.doering
38 * @version 1.0
39 * @created 08-Nov-2007 13:06:52
40 */
41 @XmlAccessorType(XmlAccessType.FIELD)
42 @XmlType(name = "SpecimenTypeDesignation", propOrder = {
43 "homotypicalGroup",
44 "typeSpecimen",
45 "typeStatus",
46 "typifiedNames"
47 })
48 @Entity
49 public class SpecimenTypeDesignation extends ReferencedEntityBase {
50
51 static Logger logger = Logger.getLogger(SpecimenTypeDesignation.class);
52
53 @XmlElement(name = "HomotypicalGroup")
54 @XmlIDREF
55 @XmlSchemaType(name = "IDREF")
56 private HomotypicalGroup homotypicalGroup;
57
58 @XmlElement(name = "TypeSpecimen")
59 // @XmlIDREF
60 // @XmlSchemaType(name = "IDREF")
61 private DerivedUnitBase typeSpecimen;
62
63 @XmlElement(name = "TypeStatus")
64 private TypeDesignationStatus typeStatus;
65
66 @XmlElementWrapper(name = "TypifiedNames")
67 @XmlElement(name = "TypifiedName")
68 @XmlIDREF
69 @XmlSchemaType(name = "IDREF")
70 private Set<TaxonNameBase> typifiedNames = new HashSet<TaxonNameBase>();
71
72 public static SpecimenTypeDesignation NewInstance(DerivedUnitBase specimen, TypeDesignationStatus status,
73 ReferenceBase citation, String citationMicroReference, String originalNameString){
74 SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
75 return specTypeDesig;
76 }
77
78 protected SpecimenTypeDesignation(){
79
80 }
81
82 private SpecimenTypeDesignation(DerivedUnitBase specimen, TypeDesignationStatus status, ReferenceBase citation, String citationMicroReference, String originalNameString) {
83 super(citation, citationMicroReference, originalNameString);
84 this.setTypeSpecimen(specimen);
85 this.setTypeStatus(status);
86 }
87
88
89 @ManyToOne
90 public HomotypicalGroup getHomotypicalGroup() {
91 return homotypicalGroup;
92 }
93 public void setHomotypicalGroup(HomotypicalGroup newHomotypicalGroup) {
94 this.homotypicalGroup = newHomotypicalGroup;
95 }
96
97
98 @ManyToOne
99 @Cascade({CascadeType.SAVE_UPDATE})
100 public DerivedUnitBase getTypeSpecimen(){
101 return this.typeSpecimen;
102 }
103 public void setTypeSpecimen(DerivedUnitBase typeSpecimen){
104 this.typeSpecimen = typeSpecimen;
105 }
106
107 @ManyToOne
108 public TypeDesignationStatus getTypeStatus(){
109 return this.typeStatus;
110 }
111 public void setTypeStatus(TypeDesignationStatus typeStatus){
112 this.typeStatus = typeStatus;
113 }
114
115 /**
116 * @return the typifiedNames
117 */
118 @ManyToMany
119 public Set<TaxonNameBase> getTypifiedNames() {
120 return typifiedNames;
121 }
122
123 /**
124 * @param typifiedNames the typifiedNames to set
125 */
126 public void setTypifiedNames(Set<TaxonNameBase> typifiedNames) {
127 this.typifiedNames = typifiedNames;
128 }
129
130
131
132 }