commit d50317d6cec65a89fe9104ca1ea14e5533b690e2
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Wed Feb 6 13:09:14 2019 +0100

    ref #8041 Use existing service method for retrieval of UuidAndTitleCache

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java
index 81924867d..bfc4d5780 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureSelectionDialog.java
@@ -9,8 +9,6 @@
 
 package eu.etaxonomy.taxeditor.ui.dialog.selection;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.UUID;
 
 import org.eclipse.swt.widgets.Shell;
@@ -18,7 +16,6 @@ import org.eclipse.swt.widgets.Shell;
 import eu.etaxonomy.cdm.api.service.ITermService;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -66,19 +63,7 @@ public class FeatureSelectionDialog extends
 
 	@Override
 	protected void callService(String pattern) {
-		List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
-
-		List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
-
-		for(Feature feature : features){
-			UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
-			if (pattern == null || uuidAndTitleCache.getTitleCache().matches("(?i)"+pattern + ".*")) {
-                featureUuidAndTitleCache.add(uuidAndTitleCache);
-            }
-		}
-
-		model =  featureUuidAndTitleCache;
-
+        model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(Feature.class, limitOfInitialElements, pattern);
 	}
 
 	/* (non-Javadoc)
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java
index 53841084c..ca287fdcf 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/FeatureTreeSelectionDialog.java
@@ -9,8 +9,6 @@
 
 package eu.etaxonomy.taxeditor.ui.dialog.selection;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.UUID;
 
 import org.eclipse.jface.dialogs.InputDialog;
@@ -22,7 +20,6 @@ import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -55,19 +52,7 @@ public class FeatureTreeSelectionDialog extends
 
 	@Override
 	protected void callService(String pattern) {
-		List<FeatureTree> featureTrees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null);
-
-		if(model == null){
-			model = new ArrayList<>();
-		}
-		model.clear();
-		for(FeatureTree featureTree : featureTrees){
-			UuidAndTitleCache<FeatureTree> element = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
-			if(pattern == null || element.getTitleCache().matches("(?i)"+pattern + ".*")) { //$NON-NLS-1$ //$NON-NLS-2$
-                model.add(element);
-            }
-		}
-
+        model = CdmStore.getService(IFeatureTreeService.class).getUuidAndTitleCache(FeatureTree.class, limitOfInitialElements, pattern);
 	}
 
 	@Override
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java
index c845f0c64..98b51c1f3 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/TermVocabularySelectionDialog.java
@@ -9,15 +9,12 @@
 
 package eu.etaxonomy.taxeditor.ui.dialog.selection;
 
-import java.util.ArrayList;
-import java.util.List;
 import java.util.UUID;
 
 import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.service.IVocabularyService;
 import eu.etaxonomy.cdm.model.common.TermVocabulary;
-import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.newWizard.NewVocabularyWizard;
 import eu.etaxonomy.taxeditor.store.CdmStore;
@@ -61,17 +58,7 @@ public class TermVocabularySelectionDialog extends
 
 	@Override
 	protected void callService(String pattern) {
-		List<TermVocabulary> vocabularies = CdmStore.getService(IVocabularyService.class).list(TermVocabulary.class, null, null, null, null);
-
-		List<UuidAndTitleCache<TermVocabulary>> featureUuidAndTitleCache = new ArrayList<>();
-
-		for(TermVocabulary voc : vocabularies){
-			UuidAndTitleCache<TermVocabulary> uuidAndTitleCache = new UuidAndTitleCache<>(TermVocabulary.class, voc.getUuid(), voc.getId(), voc.getTitleCache());
-			if (pattern == null || uuidAndTitleCache.getTitleCache().matches("(?i)"+pattern + ".*")) {
-                featureUuidAndTitleCache.add(uuidAndTitleCache);
-            }
-		}
-		model =  featureUuidAndTitleCache;
+        model = CdmStore.getService(IVocabularyService.class).getUuidAndTitleCache(TermVocabulary.class, limitOfInitialElements, pattern);
 	}
 
 	@Override
