package eu.etaxonomy.taxeditor.model;
-import java.util.Set;
-
import eu.etaxonomy.cdm.common.CdmUtils;
-import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
-import eu.etaxonomy.cdm.model.name.NameRelationship;
-import eu.etaxonomy.cdm.model.name.NameRelationshipType;
import eu.etaxonomy.cdm.model.name.Rank;
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
import eu.etaxonomy.cdm.model.taxon.Taxon;
if (name == null) {
return false;
}
-
- HomotypicalGroup homotypicalGroup = name.getHomotypicalGroup();
- if (homotypicalGroup == null) {
- return false;
- }
-
- Set<TaxonNameBase> typifiedNames = homotypicalGroup.getTypifiedNames();
-
- // Check whether there are any other names in the group
- if (typifiedNames.size() == 1) {
- return false;
- }
-
- for (TaxonNameBase taxonName : typifiedNames) {
- if (!taxonName.equals(name)) {
- if (!isNameBasionymOf(name, taxonName)) {
- return false;
- }
- }
- }
- return true;
+ return name.isGroupsBasionym();
}
- /**
- * Checks whether a basionym relationship exists between fromName and toName.
- *
- * @param fromName
- * @param toName
- * @return
- */
- @SuppressWarnings("unchecked")
- public static boolean isNameBasionymOf(TaxonNameBase fromName, TaxonNameBase toName) {
- Set<NameRelationship> relations = toName.getRelationsToThisName();
- for (NameRelationship relation : relations) {
- if (relation.getType().equals(NameRelationshipType.BASIONYM()) &&
- relation.getFromName().equals(fromName)) {
- return true;
- }
- }
- return false;
- }
/**
* @param name
* @return
*/
public static boolean isNameSupraSpecific(TaxonNameBase<?, ?> name) {
-
if (name == null || name.getRank() == null) {
return false;
}
-
-// Rank rank = CdmBase.deproxy(name.getRank(), Rank.class);
- Rank rank = name.getRank();
-
- if (rank.isHigher(Rank.SPECIES())) {
-// if (name.getRank().isHigher(Rank.SPECIES())) {
-// if (name.isInfraGeneric() || name.isSupraGeneric() || name.isGenus()) {
- return true;
- } else {
- return false;
- }
+ return name.getRank().isHigher(Rank.SPECIES());
}
/**
* @return
*/
public static boolean isNameHomotypic(TaxonNameBase<?, ?> name, Taxon taxon) {
- TaxonNameBase<?, ?> taxonName = taxon.getName();
- if (taxonName == null || name == null) {
- return false;
- }
- HomotypicalGroup homotypicGroup = taxonName.getHomotypicalGroup();
- if (homotypicGroup == null) {
- return false;
- }
- if (homotypicGroup.equals(name.getHomotypicalGroup())) {
- return true;
- }
- return false;
+ return name.isHomotypic(taxon.getName());
}
}