Project

General

Profile

« Previous | Next » 

Revision acdb1584

Added by Patrick Plitzner over 4 years ago

ref #7095 Filter by rank when adding descriptions

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/workingSet/matrix/SpecimenSelectionDialog.java
25 25
import org.eclipse.swt.widgets.Shell;
26 26

  
27 27
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
28
import eu.etaxonomy.cdm.api.service.ITaxonService;
28 29
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
29 30
import eu.etaxonomy.cdm.model.description.WorkingSet;
31
import eu.etaxonomy.cdm.model.name.Rank;
32
import eu.etaxonomy.cdm.model.name.TaxonName;
30 33
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
31 34
import eu.etaxonomy.cdm.model.taxon.Taxon;
32 35
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
......
62 65
        Set<TaxonNode> taxonNodes = workingSet.getTaxonSubtreeFilter();
63 66
        Set<SpecimenOrObservationBase> specimens = new HashSet<>();
64 67
        for (TaxonNode node : taxonNodes) {
65
            specimens.addAll(addDescriptionsRecursively(node));
68
            specimens.addAll(addSpecimensRecursively(node));
66 69
        }
67 70
        list.setInput(specimens);
68 71
        return composite;
69 72
    }
70 73

  
71
    private Collection<SpecimenOrObservationBase> addDescriptionsRecursively(TaxonNode node){
74
    private Collection<SpecimenOrObservationBase> addSpecimensRecursively(TaxonNode node){
72 75
        Collection<SpecimenOrObservationBase> specimens = new HashSet<>();
73 76
        if(node.getTaxon()!=null){
74 77
            Taxon taxon = HibernateProxyHelper.deproxy(node.getTaxon(), Taxon.class);
75
            specimens = CdmStore.getService(IOccurrenceService.class).listByAssociatedTaxon(SpecimenOrObservationBase.class, null, taxon, null, null, null, null, null);
78
            TaxonName name = taxon.getName();
79
            //filter by Rank
80
            if(name!=null &&
81
                    (name.getRank().equals(workingSet.getMinRank())
82
                    || name.getRank().isHigher(workingSet.getMinRank())
83
                    || name.getRank().equals(workingSet.getMaxRank())
84
                    || name.getRank().isLower(workingSet.getMaxRank()))){
85
                IOccurrenceService service = CdmStore.getService(IOccurrenceService.class);
86
                //TODO extend FindOccurrencesConfigurator to support area and rank filter
87
                //            FindOccurrencesConfigurator config = new FindOccurrencesConfigurator();
88
                //            config.setAssociatedTaxonNameUuid(taxon.getUuid());
89
                //            service.findByTitle(config);
90

  
91
                specimens = service.listByAssociatedTaxon(SpecimenOrObservationBase.class, null, taxon, null, null, null, null, null);
92
            }
76 93
        }
77 94
        List<TaxonNode> childNodes = node.getChildNodes();
78 95
        for (TaxonNode childNode : childNodes) {
79
            specimens.addAll(addDescriptionsRecursively(childNode));
96
            specimens.addAll(addSpecimensRecursively(childNode));
80 97
        }
81 98
        return specimens;
82 99
    }

Also available in: Unified diff