commit 56432bdd018d92bebb99ecfdaeca8721d7927416
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Jul 5 17:22:04 2018 +0200

    fix #7533 typeStatus filter for registration list view

diff --git a/src/main/java/eu/etaxonomy/cdm/service/IRegistrationWorkingSetService.java b/src/main/java/eu/etaxonomy/cdm/service/IRegistrationWorkingSetService.java
index e903a2ad..5fb9010b 100644
--- a/src/main/java/eu/etaxonomy/cdm/service/IRegistrationWorkingSetService.java
+++ b/src/main/java/eu/etaxonomy/cdm/service/IRegistrationWorkingSetService.java
@@ -17,6 +17,7 @@ import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.name.RegistrationStatus;
+import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
 import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
 
 /**
@@ -37,7 +38,7 @@ public interface IRegistrationWorkingSetService {
     public Pager<RegistrationDTO> pageDTOs(Integer pageSize, Integer pageIndex);
 
     public Pager<RegistrationDTO> pageDTOs(User submitter, Collection<RegistrationStatus> includedStatus,
-            String identifierFilterPattern, String taxonNameFilterPattern,
+            String identifierFilterPattern, String taxonNameFilterPattern, Set<TypeDesignationStatusBase> typeStatusFilter,
             Integer pageSize, Integer pageIndex);
 
     /**
diff --git a/src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java b/src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java
index d2d6f628..b017f1f7 100644
--- a/src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java
+++ b/src/main/java/eu/etaxonomy/cdm/service/RegistrationWorkingSetService.java
@@ -35,6 +35,7 @@ import eu.etaxonomy.cdm.model.name.Registration;
 import eu.etaxonomy.cdm.model.name.RegistrationStatus;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
 import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
+import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
@@ -177,7 +178,7 @@ public class RegistrationWorkingSetService implements IRegistrationWorkingSetSer
     @Override
     public Pager<RegistrationDTO> pageDTOs(Integer pageSize, Integer pageIndex) {
 
-        return pageDTOs(null, null, null, null, pageSize, pageIndex);
+        return pageDTOs(null, null, null, null, null, pageSize, pageIndex);
     }
 
     /**
@@ -185,7 +186,7 @@ public class RegistrationWorkingSetService implements IRegistrationWorkingSetSer
      */
     @Override
     public Pager<RegistrationDTO> pageDTOs(User submitter, Collection<RegistrationStatus> includedStatus,
-            String identifierFilterPattern, String taxonNameFilterPattern,
+            String identifierFilterPattern, String taxonNameFilterPattern, Set<TypeDesignationStatusBase> typeStatusFilter,
             Integer pageSize, Integer pageIndex) {
 
         if(pageSize == null){
@@ -195,7 +196,7 @@ public class RegistrationWorkingSetService implements IRegistrationWorkingSetSer
         List<OrderHint> orderHints = Arrays.asList(new OrderHint("identifier", SortOrder.ASCENDING));
 
         Pager<Registration> pager = repo.getRegistrationService().page(submitter, includedStatus, identifierFilterPattern, taxonNameFilterPattern,
-                PAGE_SIZE, pageIndex, orderHints , REGISTRATION_INIT_STRATEGY);
+                typeStatusFilter, PAGE_SIZE, pageIndex , orderHints, REGISTRATION_INIT_STRATEGY);
         List<Registration> registrations = pager.getRecords();
         Pager<RegistrationDTO> dtoPager = new DefaultPagerImpl(pager.getCurrentIndex(), pager.getCount(), pager.getPageSize(), makeDTOs(registrations));
         if(logger.isDebugEnabled()){
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
index 843bbf95..18dedfc4 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
@@ -20,6 +20,7 @@ import org.springframework.security.core.Authentication;
 import org.vaadin.spring.events.EventScope;
 import org.vaadin.spring.events.annotation.EventBusListenerMethod;
 
+import com.vaadin.data.util.BeanItemContainer;
 import com.vaadin.navigator.Navigator;
 import com.vaadin.spring.annotation.SpringComponent;
 import com.vaadin.spring.annotation.ViewScope;
@@ -27,8 +28,11 @@ import com.vaadin.ui.TextField;
 
 import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
+import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.name.RegistrationStatus;
+import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
+import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService;
 import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
@@ -37,6 +41,7 @@ import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
 import eu.etaxonomy.cdm.vaadin.event.PagingEvent;
 import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
 import eu.etaxonomy.cdm.vaadin.event.UpdateResultsEvent;
+import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationTermLists;
 import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
 import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
 
@@ -99,6 +104,16 @@ public class ListPresenter extends AbstractPresenter<ListView> {
             getView().getSubmitterFilter().setItemCaptionPropertyId("username");
         }
 
+        List<UUID> typeDesignationStatusUUIDS = new ArrayList<>();
+        typeDesignationStatusUUIDS.addAll(RegistrationTermLists.NAME_TYPE_DESIGNATION_STATUS_UUIDS());
+        typeDesignationStatusUUIDS.addAll(RegistrationTermLists.SPECIMEN_TYPE_DESIGNATION_STATUS_UUIDS());
+        BeanItemContainer<DefinedTermBase> buildTermItemContainer = selectFieldFactory.buildTermItemContainer(typeDesignationStatusUUIDS);
+        getView().getStatusTypeFilter().setContainerDataSource(buildTermItemContainer);
+        for(DefinedTermBase dt : buildTermItemContainer.getItemIds()){
+            String classAbbreviation = dt instanceof SpecimenTypeDesignationStatus ? "ST" : "NT";
+            getView().getStatusTypeFilter().setItemCaption(dt, classAbbreviation + " - " + dt.getLabel());
+        }
+
         getView().populate(pageRegistrations(null, null));
     }
 
@@ -119,12 +134,14 @@ public class ListPresenter extends AbstractPresenter<ListView> {
         } else {
             identifierFilter = getView().getIdentifierFilter().getValue();
         }
+
         String nameFilter;
         if(textFieldOverride != null && textFieldOverride == getView().getTaxonNameFilter()){
             nameFilter = alternativeText;
         } else {
             nameFilter = getView().getTaxonNameFilter().getValue();
         }
+
         User submitter = null;
         if(getView().getSubmitterFilter() != null){
             Object o = getView().getSubmitterFilter().getValue();
@@ -134,6 +151,12 @@ public class ListPresenter extends AbstractPresenter<ListView> {
         } else {
             submitter = (User) authentication.getPrincipal();
         }
+
+        Set<TypeDesignationStatusBase> typeStatusFilter = (Set<TypeDesignationStatusBase>) getView().getStatusTypeFilter().getValue();
+        if(typeStatusFilter.isEmpty()){
+            typeStatusFilter = null;
+        }
+
         EnumSet<RegistrationStatus> includeStatus = inProgressStatus;
         if(getView().getViewMode().equals(ListView.Mode.all)){
             includeStatus = null;
@@ -148,6 +171,7 @@ public class ListPresenter extends AbstractPresenter<ListView> {
                 includeStatus,
                 StringUtils.trimToNull(identifierFilter),
                 StringUtils.trimToNull(nameFilter),
+                typeStatusFilter ,
                 pageSize,
                 pageIndex);
         return dtoPager;
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListView.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListView.java
index 23995336..605ff8fd 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListView.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListView.java
@@ -11,6 +11,7 @@ package eu.etaxonomy.cdm.vaadin.view.registration;
 import java.util.List;
 import java.util.UUID;
 
+import com.vaadin.ui.AbstractSelect;
 import com.vaadin.ui.ListSelect;
 import com.vaadin.ui.TextField;
 
@@ -78,5 +79,7 @@ public interface ListView extends ApplicationView<ListPresenter>{
 
     public RegistrationItem getRegistrationItem(UUID registrationUuid);
 
+    AbstractSelect getStatusTypeFilter();
+
 
 }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
index 88eb0db1..c306dab8 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
@@ -24,6 +24,7 @@ import com.vaadin.navigator.View;
 import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
 import com.vaadin.server.Page;
 import com.vaadin.spring.annotation.SpringView;
+import com.vaadin.ui.AbstractSelect;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.CssLayout;
@@ -72,7 +73,7 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
 
     private Label filterInstructionLabel = new Label("Filter the registrations by");
 
-    private ListSelect statusFilter = null;
+    private ListSelect registrationStatusFilter = null;
 
     private ListSelect submitterFilter = null; // must be null, the presenter relies on this
 
@@ -82,6 +83,8 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
 
     private TextField referenceFilter = new TextFieldNFix("Publication");
 
+    private AbstractSelect statusTypeFilter;
+
     public ListViewBean() {
         super();
     }
@@ -103,14 +106,20 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
         }
 
         if(viewMode.equals(Mode.all)){
-            statusFilter = new ListSelect("Status", Arrays.asList(RegistrationStatus.values()));
-            statusFilter.setNullSelectionAllowed(true);
-            statusFilter.setRows(1);
-            statusFilter.addValueChangeListener(e -> updateResults(null, null));
-            toolBar.addComponent(statusFilter);
+            registrationStatusFilter = new ListSelect("Registration status", Arrays.asList(RegistrationStatus.values()));
+            registrationStatusFilter.setNullSelectionAllowed(true);
+            registrationStatusFilter.setRows(1);
+            registrationStatusFilter.addValueChangeListener(e -> updateResults(null, null));
+            toolBar.addComponent(registrationStatusFilter);
         }
 
-        toolBar.addComponents(identifierFilter, taxonNameFilter);
+        statusTypeFilter = new ListSelect("Type Status");
+        ((ListSelect)statusTypeFilter).setRows(3);
+        statusTypeFilter.setMultiSelect(true);
+        statusTypeFilter.setNullSelectionAllowed(true);
+        statusTypeFilter.addValueChangeListener(e -> updateResults(null, null));
+
+        toolBar.addComponents(identifierFilter, taxonNameFilter, statusTypeFilter);
         int textChangeTimeOut = 200;
         identifierFilter.addTextChangeListener(e -> updateResults(identifierFilter, e.getText()));
         identifierFilter.setTextChangeTimeout(textChangeTimeOut);
@@ -268,11 +277,11 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
     }
 
     /**
-     * @return the statusFilter
+     * @return the registrationStatusFilter
      */
     @Override
     public ListSelect getStatusFilter() {
-        return statusFilter;
+        return registrationStatusFilter;
     }
 
     /**
@@ -309,6 +318,14 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
         return null;
     }
 
+    /**
+     * @return the statusTypeFilter
+     */
+    @Override
+    public AbstractSelect getStatusTypeFilter() {
+        return statusTypeFilter;
+    }
+
 
 
 
