Project

General

Profile

« Previous | Next » 

Revision dd35c5fd

Added by Patrick Plitzner over 8 years ago

Implement taxon assignment filter and refactor DerivativeEditor

  • Input no longer needs session
  • editor itself keeps track of its root elements
  • taxon assignment filter allows filtering specimens with/without taxon assignment or both

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchCompositeController.java
101 101
        }
102 102

  
103 103
        //filter out (un-)assigned specimens
104
        DerivateViewEditorInput editorInput = (DerivateViewEditorInput)derivativeEditor.getEditorInput();
104 105
        int selectionIndex = derivateSearchComposite.getComboTaxonAssignment().getSelectionIndex();
105
        List<SpecimenOrObservationBase> specimensWithAssociations = new ArrayList<SpecimenOrObservationBase>();
106
        List<SpecimenOrObservationBase<?>> specimenWithAssociations = new ArrayList<SpecimenOrObservationBase<?>>();
106 107
        if(selectionIndex!=DerivateSearchComposite.ALL_SPECIMENS){
107 108
            for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
108 109
                Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(specimenOrObservationBase, null, null, null, null);
109 110
                if(!associatedTaxa.isEmpty()){
110
                    specimensWithAssociations.add(specimenOrObservationBase);
111
                    specimenWithAssociations.add(specimenOrObservationBase);
111 112
                }
112 113
            }
113 114
        }
114
        if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){
115
            occurrences = specimensWithAssociations;
116
        }
117
        else if(selectionIndex==DerivateSearchComposite.UNASSIGNED_SPECIMENS){
118
            occurrences.retainAll(specimensWithAssociations);
115
        if(selectionIndex==DerivateSearchComposite.UNASSIGNED_SPECIMENS){
116
            for (SpecimenOrObservationBase<?> specimenOrObservationBase : specimenWithAssociations) {
117
                derivativeEditor.removeHierarchy(specimenOrObservationBase);
118
            }
119
            derivativeEditor.updateRootEntities();
119 120
        }
120

  
121
        List<UUID> derivateUuids = new ArrayList<UUID>();
122
        for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
123
            derivateUuids.add(specimenOrObservationBase.getUuid());
121
        else{
122
            if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){
123
                occurrences = new ArrayList<SpecimenOrObservationBase>(specimenWithAssociations);
124
            }
125
            List<UUID> derivateUuids = new ArrayList<UUID>();
126
            for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
127
                derivateUuids.add(specimenOrObservationBase.getUuid());
128
            }
129
            derivativeEditor.updateRootEntities(derivateUuids);
124 130
        }
125
        //update tree
126
        DerivateViewEditorInput editorInput = (DerivateViewEditorInput)derivativeEditor.getEditorInput();
127
        editorInput.updateRootEntities(derivateUuids);
128
        derivativeEditor.getViewer().setInput(editorInput.getRootEntities());
129
        derivativeEditor.refreshTree();
130 131
    }
131 132

  
132 133
    @Override

Also available in: Unified diff