Fix taxon assignment filter
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 26 Oct 2015 17:42:41 +0000 (18:42 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 26 Oct 2015 17:42:41 +0000 (18:42 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchCompositeController.java

index d42f08d8d06b6829917ff5afebcc85ff6be40c31..08aab151b8a754c1d16d11958fbac8124d45ce77 100644 (file)
@@ -80,7 +80,6 @@ public class DerivateSearchCompositeController implements Listener{
         config.setSpecimenType(specimenType.equals(SpecimenOrObservationType.Unknown)?null:specimenType);//unknown := all types
         config.setTitleSearchString(queryString);
         if(selectedTaxon!=null){
-            config.setRetrieveIndirectlyAssociatedSpecimens(true);
             config.setSpecimenType(null);
         }
 
@@ -107,25 +106,21 @@ public class DerivateSearchCompositeController implements Listener{
                 Collection<TaxonBase<?>> associatedTaxa = CdmStore.getService(IOccurrenceService.class).listAssociatedTaxa(specimenOrObservationBase, null, null, null, null);
                 if(!associatedTaxa.isEmpty()){
                     specimenWithAssociations.add(specimenOrObservationBase);
+                    specimenWithAssociations.addAll(CdmStore.getService(IOccurrenceService.class).getFieldUnits(specimenOrObservationBase.getUuid()));
                 }
             }
         }
         if(selectionIndex==DerivateSearchComposite.UNASSIGNED_SPECIMENS){
-            for (SpecimenOrObservationBase<?> specimenOrObservationBase : specimenWithAssociations) {
-                derivativeEditor.removeHierarchy(specimenOrObservationBase);
-            }
-            derivativeEditor.updateRootEntities();
+            occurrences.removeAll(specimenWithAssociations);
         }
-        else{
-            if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){
-                occurrences = new ArrayList<SpecimenOrObservationBase>(specimenWithAssociations);
-            }
-            List<UUID> derivateUuids = new ArrayList<UUID>();
-            for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
-                derivateUuids.add(specimenOrObservationBase.getUuid());
-            }
-            derivativeEditor.updateRootEntities(derivateUuids);
+        else if(selectionIndex==DerivateSearchComposite.ASSIGNED_SPECIMENS){
+            occurrences = new ArrayList<SpecimenOrObservationBase>(specimenWithAssociations);
+        }
+        List<UUID> derivateUuids = new ArrayList<UUID>();
+        for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
+            derivateUuids.add(specimenOrObservationBase.getUuid());
         }
+        derivativeEditor.updateRootEntities(derivateUuids);
     }
 
     @Override