package eu.etaxonomy.cdm.model.name;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import javax.persistence.Entity;
import eu.etaxonomy.cdm.model.common.AnnotatableEntity;
import eu.etaxonomy.cdm.model.occurrence.Specimen;
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
+import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
@Entity
public class HomotypicalGroup extends AnnotatableEntity {
td.setHomotypicalGroup(this);
}
+ /**
+ * Retrieves the synonyms of reference sec that are part of this homotypical group.
+ * If other names are part of this group that are not considered synonyms in the respective sec-reference,
+ * then they will not be included in the resultset.
+ * @param sec
+ * @return
+ */
+ public List<Synonym> getSynonymsInGroup(ReferenceBase sec){
+ List<Synonym> result = new ArrayList();
+ for (TaxonNameBase n:this.getTypifiedNames()){
+ for (Synonym s:n.getSynonyms()){
+ if (s.getSec().equals(sec)){
+ result.add(s);
+ }
+ }
+ }
+ // TODO: sort result list according to date first published, see nomenclatural reference
+ return result;
+ }
}
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
import eu.etaxonomy.cdm.model.reference.StrictReferenceBase;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
import eu.etaxonomy.cdm.model.common.IReferencedEntity;
import org.apache.log4j.Logger;
public boolean parseName(String fullname){
return false;
}
+
+ /**
+ * Return a set of taxa that use this name
+ * @return
+ */
+ public Set<Taxon> getTaxa(){
+ // TODO: implement this method via bidirectional TaxonBase-NameBase relation or use a DAO instead
+ return null;
+ }
+ /**
+ * Return a set of synonyms that use this name
+ * @return
+ */
+ public Set<Synonym> getSynonyms(){
+ // TODO: implement this method via bidirectional TaxonBase-NameBase relation or use a DAO instead
+ return null;
+ }
}
\ No newline at end of file
return taxa;
}
+ /**
+ * Return the synonymy relationship type for the relation to a given accepted taxon.
+ * If no relation exists to that taxon return null.
+ * @param t
+ * @return
+ */
+ @Transient
+ public SynonymRelationshipType getRelationType(Taxon t){
+ for (SynonymRelationship rel:getSynonymRelations()){
+ if (rel.getAcceptedTaxon().equals(t)){
+ return rel.getType();
+ }
+ }
+ // TODO: should we raise an error in case no relationship to the taxon exists?
+ return null;
+ }
}
\ No newline at end of file
import eu.etaxonomy.cdm.model.description.DescriptionBase;
import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
* @param microcitation
*/
public void setTaxonomicParent(Taxon parent, ReferenceBase citation, String microcitation){
- if (parent == null){
- throw new NullPointerException("Parent Taxon is 'null'");
- }else{
+ // TODO: remove previously existing parent relationship!!!
+ if (parent != null){
addTaxonRelation(parent, TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN(),citation,microcitation);
}
}
public void remove() { throw new UnsupportedOperationException(); }
}
+ @Transient
+ public HomotypicalGroup getHomotypicGroup(){
+ return this.getName().getHomotypicalGroup();
+ }
+
+ @Transient
+ public List<Synonym> getHomotypicSynonyms(){
+ return this.getHomotypicGroup().getSynonymsInGroup(this.getSec());
+ }
+
+ @Transient
+ public List<HomotypicalGroup> getHeterotypicSynonymyGroups(){
+ List<HomotypicalGroup> result = new ArrayList();
+ for (TaxonNameBase n:this.getSynonymNames()){
+ if (!result.contains(n.getHomotypicalGroup())){
+ result.add(n.getHomotypicalGroup());
+ }
+ }
+ // TODO: sort list according to date of first published name within each group
+ return result;
+ }
}
\ No newline at end of file