#5250 Refactor code for improving derivate search performance
authorCherian Mathew <c.mathew@bgbm.org>
Wed, 25 Nov 2015 17:33:41 +0000 (18:33 +0100)
committerCherian Mathew <c.mathew@bgbm.org>
Wed, 25 Nov 2015 17:33:41 +0000 (18:33 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/DerivateView.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/derivate/searchFilter/DerivateSearchCompositeController.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/SearchManager.java

index 95d3b939215a3751ee4284f09775142d35c8c6fe..c526da1f8e55decbbe46728d511cbffa8a3483e3 100644 (file)
@@ -210,7 +210,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
     }
 
     public void updateRootEntities() {
     }
 
     public void updateRootEntities() {
-        updateRootEntities(null);
+        updateRootEntities((Collection)null);
     }
 
     public void updateRootEntities(Collection<UUID> derivativeUuids) {
     }
 
     public void updateRootEntities(Collection<UUID> derivativeUuids) {
@@ -234,8 +234,23 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
             if(derivativeUuids!=null){
                 this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
                 this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
             if(derivativeUuids!=null){
                 this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
                 this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
-                for (UUID uuid : derivativeUuids) {
-                    SpecimenOrObservationBase<?> derivate = CdmStore.getService(IOccurrenceService.class).load(uuid, SPECIMEN_INIT_STRATEGY);
+                List<SpecimenOrObservationBase> derivates =
+                        CdmStore.getService(IOccurrenceService.class).load(new ArrayList(derivativeUuids), SPECIMEN_INIT_STRATEGY);
+                updateRootEntities(derivates);
+            }
+            refreshTree(false);
+            previousCdmEntitySession.bind();
+        }
+    }
+
+
+    public void updateRootEntities(List<SpecimenOrObservationBase> derivates) {
+
+            if(derivates!=null){
+                this.derivateToRootEntityMap = new HashMap<SpecimenOrObservationBase<?>, SpecimenOrObservationBase<?>>();
+                this.rootElements = new HashSet<SpecimenOrObservationBase<?>>();
+                for (SpecimenOrObservationBase derivate : derivates) {
+
                     if(derivate instanceof FieldUnit){
                         derivateToRootEntityMap.put(derivate, derivate);
                     }
                     if(derivate instanceof FieldUnit){
                         derivateToRootEntityMap.put(derivate, derivate);
                     }
@@ -254,9 +269,7 @@ public class DerivateView extends EditorPart implements IPartContentHasFactualDa
                 }
             }
             viewer.setInput(rootElements);
                 }
             }
             viewer.setInput(rootElements);
-            refreshTree(false);
-            previousCdmEntitySession.bind();
-        }
+
     }
 
     @Override
     }
 
     @Override
index e87fcc5aa4b7b4af58379b51f6f7a24485697511..73ac228364331d4ff8be01dc62e7cbf5873eeb8c 100644 (file)
@@ -119,7 +119,7 @@ public class DerivateSearchCompositeController implements Listener{
         for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
             derivateUuids.add(specimenOrObservationBase.getUuid());
         }
         for (SpecimenOrObservationBase specimenOrObservationBase : occurrences) {
             derivateUuids.add(specimenOrObservationBase.getUuid());
         }
-        derivativeEditor.updateRootEntities(derivateUuids);
+        derivativeEditor.updateRootEntities(occurrences);
     }
 
     @Override
     }
 
     @Override
index 2103ba8e8e05f54d66e752037b9223b688bdb754..395550a7bbad3761097df09ae417939bae6dba74 100644 (file)
@@ -37,8 +37,6 @@ import eu.etaxonomy.cdm.model.common.RelationshipBase;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.name.NameRelationship;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.name.NameRelationship;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
-import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
@@ -162,14 +160,28 @@ public class SearchManager {
         */
        public List<SpecimenOrObservationBase> findOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> configurator, boolean showFieldUnits){
            List<SpecimenOrObservationBase> records = new ArrayList<SpecimenOrObservationBase>();
         */
        public List<SpecimenOrObservationBase> findOccurrences(IIdentifiableEntityServiceConfigurator<SpecimenOrObservationBase> configurator, boolean showFieldUnits){
            List<SpecimenOrObservationBase> records = new ArrayList<SpecimenOrObservationBase>();
-               final List<String> OCCURRENCE_INIT_STRATEGY = Arrays.asList(new String[] {
+               final List<String> BASE_OCCURRENCE_INIT_STRATEGY = Arrays.asList(new String[] {
                        "collection",
                        "descriptions",
                        "identifiers",
                        "derivationEvents.originals",
                        "collection",
                        "descriptions",
                        "identifiers",
                        "derivationEvents.originals",
-                       "derivedFrom.originals"
+                       "derivedFrom.originals",
+                       "gatheringEvent.country.representations",
+                       "gatheringEvent.collector",
+                       "gatheringEvent.locality",
+                       "descriptions.descriptionElements",
+                       "kindOfUnit",
+                       "amplificationResults",
+                       "sequences.singleReadAlignments",
+                       "mediaSpecimen"
                });
                });
-               configurator.setPropertyPaths(OCCURRENCE_INIT_STRATEGY);
+
+               List<String> occurrencePropertyPaths = new ArrayList<String>();
+               occurrencePropertyPaths.addAll(BASE_OCCURRENCE_INIT_STRATEGY);
+               for(String propertyPath:BASE_OCCURRENCE_INIT_STRATEGY) {
+                   occurrencePropertyPaths.add("derivationEvents.derivatives." + propertyPath);
+               }
+               configurator.setPropertyPaths(occurrencePropertyPaths);
 
                if(checkLargeResult(CdmStore.getService(IOccurrenceService.class).countOccurrences(configurator))){
                        records = CdmStore.getService(IOccurrenceService.class).findByTitle(configurator).getRecords();
 
                if(checkLargeResult(CdmStore.getService(IOccurrenceService.class).countOccurrences(configurator))){
                        records = CdmStore.getService(IOccurrenceService.class).findByTitle(configurator).getRecords();