Project

General

Profile

« Previous | Next » 

Revision b5dbd2f6

Added by Katja Luther almost 6 years ago

add methods for Pro Parte synonyms

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Taxon.java
826 826
        return count;
827 827
    }
828 828

  
829
    /**
830
     * Returns the boolean value indicating whether <i>this</i> taxon is a misapplication
831
     * (misapplied name) for at least one other taxon.
832
     */
833
    // TODO cache as for #hasTaxonomicChildren
834
    @Transient
835
    public boolean isProparteSynonym(){
836
        return computeProparteSynonymRelations() > 0;
837
    }
838

  
839
    /**
840
     * Counts the number of misapplied name relationships (including pro parte misapplied
841
     * names) where this taxon represents the
842
     * misapplied name for another taxon.
843
     * @return
844
     */
845
    private int computeProparteSynonymRelations(){
846
        int count = 0;
847
        for (TaxonRelationship rel: this.getRelationsFromThisTaxon()){
848
            if (rel.getType().equals(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR())
849
                    || rel.getType().equals(TaxonRelationshipType.PARTIAL_SYNONYM_FOR())){
850
                count++;
851
            }
852
        }
853
        return count;
854
    }
855

  
829 856
    /**
830 857
     * Returns the boolean value indicating whether <i>this</i> taxon is a related
831 858
     * concept for at least one other taxon.
......
965 992
        return taxa;
966 993
    }
967 994

  
995
    /*
996
     * PRO PARTE SYNONYMS
997
     */
998
    /**
999
     * Returns the set of taxa playing the source role in {@link TaxonRelationship taxon relationships}
1000
     * (with {@link TaxonRelationshipType taxon relationship type} "Pro Parte Synonym for") where
1001
     * <i>this</i> taxon plays the target role.
1002
     *
1003
     * @see  #getTaxonRelations()
1004
     * @see  #getRelationsToThisTaxon()
1005

  
1006
     */
1007
    @Transient
1008
    public Set<Taxon> getProParteSynonyms(){
1009
        Set<Taxon> taxa = new HashSet<>();
1010
        Set<TaxonRelationship> rels = this.getRelationsToThisTaxon();
1011
        for (TaxonRelationship rel: rels){
1012
            TaxonRelationshipType relType = rel.getType();
1013
            if ( relType.equals(TaxonRelationshipType.PRO_PARTE_SYNONYM_FOR())){
1014
                taxa.add(rel.getFromTaxon());
1015
            }
1016
        }
1017
        return taxa;
1018
    }
1019

  
1020

  
968 1021

  
969 1022
    /*
970 1023
     * DEALING WITH SYNONYMS

Also available in: Unified diff