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 java
.util
.ArrayList
;
13 import java
.util
.HashSet
;
14 import java
.util
.List
;
17 import javax
.persistence
.Entity
;
18 import javax
.persistence
.FetchType
;
19 import javax
.persistence
.OneToMany
;
20 import javax
.persistence
.Transient
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.hibernate
.annotations
.Cascade
;
24 import org
.hibernate
.annotations
.CascadeType
;
26 import eu
.etaxonomy
.cdm
.model
.common
.AnnotatableEntity
;
27 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
28 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
33 * A homotypical group represents all names that share the same type specimens.
34 * This also includes supergeneric names like genera or families which usually have a name type designation
35 * that finally (a name type designation can also point to another supergeneric name) points to a species name,
36 * which in turn has a (set of) physical type specimen(s).
41 public class HomotypicalGroup
extends AnnotatableEntity
{
42 static Logger logger
= Logger
.getLogger(HomotypicalGroup
.class);
44 protected Set
<TaxonNameBase
> typifiedNames
= new HashSet();
45 protected Set
<SpecimenTypeDesignation
> typeDesignations
= new HashSet();
47 public static HomotypicalGroup
NewInstance(){
48 return new HomotypicalGroup();
52 public HomotypicalGroup() {
57 @OneToMany(mappedBy
="homotypicalGroup", fetch
=FetchType
.EAGER
)
58 public Set
<TaxonNameBase
> getTypifiedNames() {
61 protected void setTypifiedNames(Set
<TaxonNameBase
> typifiedNames
) {
62 this.typifiedNames
= typifiedNames
;
64 public void addTypifiedName(TaxonNameBase typifiedName
) {
65 if (typifiedName
!= null){
66 typifiedName
.setHomotypicalGroup(this);
67 typifiedNames
.add(typifiedName
);
70 public void removeTypifiedName(TaxonNameBase typifiedName
) {
71 typifiedName
.setHomotypicalGroup(null);
72 typifiedNames
.remove(typifiedName
);
77 @Cascade({CascadeType
.SAVE_UPDATE
})
78 public Set
<SpecimenTypeDesignation
> getTypeDesignations() {
79 return typeDesignations
;
81 protected void setTypeDesignations(Set
<SpecimenTypeDesignation
> typeDesignations
) {
82 this.typeDesignations
= typeDesignations
;
84 public void addTypeDesignation(SpecimenTypeDesignation typeDesignation
) {
85 typeDesignation
.setHomotypicalGroup(this);
87 public void removeTypeDesignation(SpecimenTypeDesignation typeDesignation
) {
88 typeDesignation
.setHomotypicalGroup(null);
90 public void addTypeDesignation(Specimen typeSpecimen
, TypeDesignationStatus status
, ReferenceBase citation
, String citationMicroReference
, String originalNameString
) {
91 SpecimenTypeDesignation td
= new SpecimenTypeDesignation(this, typeSpecimen
, status
, citation
, citationMicroReference
, originalNameString
);
92 td
.setHomotypicalGroup(this);
96 * Retrieves the synonyms of reference sec that are part of this homotypical group.
97 * If other names are part of this group that are not considered synonyms in the respective sec-reference,
98 * then they will not be included in the resultset.
103 public List
<Synonym
> getSynonymsInGroup(ReferenceBase sec
){
104 List
<Synonym
> result
= new ArrayList();
105 for (TaxonNameBase
<TaxonNameBase
> n
:this.getTypifiedNames()){
106 for (Synonym s
:n
.getSynonyms()){
107 if ( (s
.getSec() == null && sec
== null) ||
108 s
.getSec().equals(sec
)){
113 // TODO: sort result list according to date first published, see nomenclatural reference