Project

General

Profile

Revision 653849b4

ID653849b4a1ceef4fdfcfc4fb6a865f4ddbd83525
Parent 2b1e32ea
Child c331fa7e

Added by Katja Luther over 2 years ago

ref #6559: get and ordered list of MAN, proparte synonyms and invalid designations

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/Taxon.java
13 13
import java.lang.reflect.Field;
14 14
import java.util.ArrayList;
15 15
import java.util.Collections;
16
import java.util.Comparator;
16 17
import java.util.HashMap;
17 18
import java.util.HashSet;
18 19
import java.util.Iterator;
......
1553 1554
        return result;
1554 1555
    }
1555 1556

  
1557
    /**
1558
     * @param comparator
1559
     * @return
1560
     *
1561
     * @see     #getSynonymsGroups()
1562
     */
1563
    @Transient
1564
    public List<Taxon> getAllMisappliedNames(){
1565
        List<Taxon> result = new ArrayList<>();
1566

  
1567
        for (TaxonRelationship rel : this.getRelationsToThisTaxon()){
1568
            if (rel.getType().isAnyMisappliedName() ){
1569
                result.add(rel.getFromTaxon());
1570
            }
1571
        }
1572
        sortBySimpleTitleCacheComparator(result);
1573
        return result;
1574
    }
1575

  
1576
    /**
1577
     * @param comparator
1578
     * @return
1579
     *
1580
     * @see     #getSynonymsGroups()
1581
     */
1582
    @Transient
1583
    public List<Taxon> getInvalidDesignations(){
1584
        List<Taxon> result = new ArrayList<>();
1585
        for (TaxonRelationship rel : this.getRelationsToThisTaxon()){
1586
            if (rel.getType().equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR()) ){
1587
                result.add(rel.getFromTaxon());
1588
            }
1589
        }
1590
        sortBySimpleTitleCacheComparator(result);
1591
        return result;
1592
    }
1593

  
1594
    /**
1595
     * @param comparator
1596
     * @return
1597
     *
1598
     * @see     #getSynonymsGroups()
1599
     */
1600
    @Transient
1601
    public List<Taxon> getAllProParteSynonyms(){
1602
        List<Taxon> result = new ArrayList<>();
1603

  
1604
        for (TaxonRelationship rel : this.getRelationsToThisTaxon()){
1605
            if (rel.getType().isAnySynonym()){
1606
                result.add(rel.getFromTaxon());
1607
            }
1608
        }
1609
        sortBySimpleTitleCacheComparator(result);
1610
        return result;
1611
    }
1612
    /**
1613
     * @param result
1614
     */
1615
    private void sortBySimpleTitleCacheComparator(List<Taxon> result) {
1616

  
1617
        Comparator<Taxon> taxonComparator = new Comparator<Taxon>(){
1618

  
1619
            @Override
1620
            public int compare(Taxon o1, Taxon o2) {
1621

  
1622
                if (o1.getTitleCache() == o2.getTitleCache()){
1623
                    return 0;
1624
                }
1625
                if (o1.getTitleCache() == null){
1626
                    return -1;
1627
                }
1628
                if (o2.getTitleCache() == null){
1629
                    return 1;
1630
                }
1631
                return o1.getTitleCache().compareTo(o2.getTitleCache());
1632

  
1633
            }
1634

  
1635
        };
1636
        Collections.sort(result, taxonComparator);
1637
    }
1638

  
1556 1639

  
1557 1640
    /**
1558 1641
     * Returns the image gallery description. If no image gallery exists, a new one is created using the

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)