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
.taxeditor
.model
;
12 import java
.util
.HashSet
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
25 public class TaxonHelper
{
26 private static final Logger logger
= Logger
27 .getLogger(TaxonHelper
.class);
31 * TODO this method should be in cdm library
34 * TaxonA(fromTaxon) isOverlapping TaxonB(toTaxon)
39 * @deprecated TODO this method should be in the library
41 public static TaxonRelationship
getRelationshipBetweenTwoTaxa(Taxon fromTaxon
, Taxon toTaxon
){
42 Set
<TaxonRelationship
> relations
= new HashSet
<TaxonRelationship
>();
44 for(TaxonRelationship relation
: fromTaxon
.getRelationsFromThisTaxon()){
45 if(relation
.getToTaxon().equals(toTaxon
)){
46 relations
.add(relation
);
50 if(relations
.size() > 1){
51 logger
.warn("Found multiple relations between two taxa. Does this make sense?");
54 if(relations
.size() == 0){
55 logger
.warn("No relations between the two given taxa");
56 new Throwable("No relations between the two given taxa");
59 return relations
.toArray(new TaxonRelationship
[0])[0];