commit e32daf11e2a1d6947e525bb2e42e99f124e02b38
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Jun 7 18:43:08 2018 +0200

    fix #7461 ordering references in comboboxes by titleCache, issn, isbn - consistence by CdmFilterablePagingProviderFactory

diff --git a/src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProviderFactory.java b/src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProviderFactory.java
new file mode 100644
index 00000000..20d58b7b
--- /dev/null
+++ b/src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProviderFactory.java
@@ -0,0 +1,48 @@
+/**
+* Copyright (C) 2018 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import eu.etaxonomy.cdm.api.application.CdmRepository;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.persistence.query.MatchMode;
+import eu.etaxonomy.cdm.persistence.query.OrderHint;
+import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
+
+/**
+ * @author a.kohlbecker
+ * @since Jun 7, 2018
+ *
+ */
+@Component
+public class CdmFilterablePagingProviderFactory {
+
+    @Autowired
+    @Qualifier("cdmRepository")
+    private CdmRepository repo;
+
+
+    public CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider(){
+        List<OrderHint> referenceOrderHints = new ArrayList<OrderHint>();
+        referenceOrderHints.add(OrderHint.ORDER_BY_TITLE_CACHE);
+        referenceOrderHints.add(new OrderHint("issn", SortOrder.ASCENDING));
+        referenceOrderHints.add(new OrderHint("isbn", SortOrder.ASCENDING));
+        CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(repo.getReferenceService(), MatchMode.ANYWHERE, referenceOrderHints);
+
+        return referencePagingProvider;
+    }
+
+
+}
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
index d6ee6041..6057a97d 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
@@ -135,7 +135,7 @@ public class NameTypeDesignationPresenter
         getView().getTypeStatusSelect().setItemCaptionPropertyId("description");
 
         getView().getCitationCombobox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>());
-        CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(getRepo().getReferenceService());
+        CdmFilterablePagingProvider<Reference,Reference> referencePagingProvider = pagingProviderFactory.referencePagingProvider();
         getView().getCitationCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize());
         getView().getCitationCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getCitationCombobox()));
         getView().getCitationCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getCitationCombobox(), this));
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
index b52336e1..7b249595 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
@@ -36,6 +36,7 @@ import eu.etaxonomy.cdm.model.occurrence.Collection;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
+import eu.etaxonomy.cdm.service.CdmFilterablePagingProviderFactory;
 import eu.etaxonomy.cdm.service.CdmStore;
 import eu.etaxonomy.cdm.service.ISpecimenTypeDesignationWorkingSetService;
 import eu.etaxonomy.cdm.service.initstrategies.AgentBaseInit;
@@ -91,6 +92,9 @@ public class SpecimenTypeDesignationWorkingsetEditorPresenter
 
     private ICdmCacher cache;
 
+    @Autowired
+    protected CdmFilterablePagingProviderFactory pagingProviderFactory;
+
     SpecimenTypeDesignationWorkingSetDTO<Registration> workingSetDto;
 
     private Map<CollectionPopupEditor, SpecimenTypeDesignationDTORow> collectionPopupEditorsRowMap = new HashMap<>();
@@ -179,7 +183,7 @@ public class SpecimenTypeDesignationWorkingsetEditorPresenter
 
             CdmFilterablePagingProvider<Collection, Collection> collectionPagingProvider = new CdmFilterablePagingProvider<Collection, Collection>(getRepo().getCollectionService());
 
-            CdmFilterablePagingProvider<Reference, Reference> referencePagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(getRepo().getReferenceService());
+            CdmFilterablePagingProvider<Reference, Reference> referencePagingProvider = pagingProviderFactory.referencePagingProvider();
 
             @Override
             public SpecimenTypeDesignationDTORow create() {
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
index c8fb01f9..3b44ec42 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
@@ -83,6 +83,7 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
 
     private BeanInstantiator<Reference> newReferenceInstantiator;
 
+
     /**
      * {@inheritDoc}
      */
@@ -112,13 +113,14 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
         getView().getExBasionymAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
 
         getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<Reference>());
-        referencePagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(getRepo().getReferenceService());
+        referencePagingProvider = pagingProviderFactory.referencePagingProvider();
         referencePagingProvider.setInitStrategy(REFERENCE_INIT_STRATEGY);
         getView().getNomReferenceCombobox().loadFrom(referencePagingProvider, referencePagingProvider, referencePagingProvider.getPageSize());
         getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getNomReferenceCombobox()));
         getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getNomReferenceCombobox(), this));
 
         getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
+
         CdmFilterablePagingProvider<TaxonName, TaxonName> basionymPagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
         basionymPagingProvider.setInitStrategy(BASIONYM_INIT_STRATEGY);
         getView().getBasionymComboboxSelect().setPagingProviders(basionymPagingProvider, basionymPagingProvider, basionymPagingProvider.getPageSize(), this);
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
index 2f1b6200..d4dea1e1 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
@@ -70,7 +70,7 @@ public class ReferenceEditorPresenter extends AbstractCdmEditorPresenter<Referen
 
         });
 
-        CdmFilterablePagingProvider<Reference, Reference> collectionPagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(getRepo().getReferenceService());
+        CdmFilterablePagingProvider<Reference, Reference> collectionPagingProvider = pagingProviderFactory.referencePagingProvider();
         getView().getInReferenceCombobox().loadFrom(collectionPagingProvider, collectionPagingProvider, collectionPagingProvider.getPageSize());
         getView().getInReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getInReferenceCombobox()));
         getView().getInReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(getView().getInReferenceCombobox(),this));
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java
index 1be404bf..af76bfb8 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/StartRegistrationPresenter.java
@@ -11,6 +11,7 @@ package eu.etaxonomy.cdm.vaadin.view.registration;
 import java.util.EnumSet;
 import java.util.UUID;
 
+import org.springframework.beans.factory.annotation.Autowired;
 import org.vaadin.spring.events.EventScope;
 import org.vaadin.spring.events.annotation.EventBusListenerMethod;
 import org.vaadin.viritin.fields.LazyComboBox;
@@ -26,6 +27,7 @@ import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.reference.ReferenceType;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
+import eu.etaxonomy.cdm.service.CdmFilterablePagingProviderFactory;
 import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter;
 import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.RegistrationEditorAction;
@@ -54,6 +56,9 @@ public class StartRegistrationPresenter extends AbstractEditorPresenter<Registra
 
     private boolean registrationInProgress;
 
+    @Autowired
+    protected CdmFilterablePagingProviderFactory pagingProviderFactory;
+
     public StartRegistrationPresenter (){
         super();
     }
@@ -67,8 +72,7 @@ public class StartRegistrationPresenter extends AbstractEditorPresenter<Registra
 
         super.onPresenterReady();
 
-        CdmFilterablePagingProvider<Reference, Reference> pagingProvider = new CdmFilterablePagingProvider<Reference, Reference>(
-                getRepo().getReferenceService());
+        CdmFilterablePagingProvider<Reference, Reference> pagingProvider = pagingProviderFactory.referencePagingProvider();
         CdmTitleCacheCaptionGenerator<Reference> titleCacheGenrator = new CdmTitleCacheCaptionGenerator<Reference>();
         getView().getReferenceCombobox().setCaptionGenerator(titleCacheGenrator);
         getView().getReferenceCombobox().loadFrom(pagingProvider, pagingProvider, pagingProvider.getPageSize());
diff --git a/src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java b/src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java
index 54bf555b..36415af0 100644
--- a/src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java
+++ b/src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java
@@ -15,6 +15,7 @@ import java.util.UUID;
 
 import org.apache.log4j.Logger;
 import org.hibernate.HibernateException;
+import org.springframework.beans.factory.annotation.Autowired;
 
 import eu.etaxonomy.cdm.api.service.IService;
 import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher;
@@ -24,6 +25,7 @@ import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
 import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
+import eu.etaxonomy.cdm.service.CdmFilterablePagingProviderFactory;
 import eu.etaxonomy.cdm.service.CdmStore;
 import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
 import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
@@ -65,6 +67,9 @@ public abstract class CdmEditorPresenterBase<DTO, CDM extends CdmBase, V extends
 
     protected CdmAuthority newAuthorityCreated;
 
+    @Autowired
+    protected CdmFilterablePagingProviderFactory pagingProviderFactory;
+
     protected CdmStore<CDM, IService<CDM>> getStore() {
         if(store == null){
             store = new CdmStore<>(getRepo(), getService());
