commit 510ac6e7a4c8ebf46906c5d7b2fe5047942b0d58
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Tue Sep 25 09:56:50 2018 +0200

    ref #7630 fixing creation of blocking relations (part 2) and assuring registrations have an identifier when saved

diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java b/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.java
new file mode 100644
index 00000000..ca875fa0
--- /dev/null
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/ui/config/TaxonNamePopupEditorConfig.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.vaadin.ui.config;
+
+import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorMode;
+import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorView;
+
+/**
+ * @author a.kohlbecker
+ * @since Sep 25, 2018
+ *
+ */
+public class TaxonNamePopupEditorConfig {
+
+    /**
+     * Configures the TaxonNamePopupEditorView for nomenclatural act editing.
+     *
+     * TODO consider putting this into a Configurer Bean per UIScope.
+     * In the configurator bean this methods popup parameter should be of the type
+     * AbstractPopupEditor
+     *
+     * @param popup
+     */
+    public static void configureForNomenclaturalAct(TaxonNamePopupEditorView popup) {
+        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
+        popup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
+        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
+        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
+    }
+
+    /**
+     * Configures the TaxonNamePopupEditorView for general purpose editing.
+     *
+     * @param popup
+     */
+    public static void configure(TaxonNamePopupEditorView popup) {
+        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
+        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
+        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
+    }
+
+}
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 b65f0471..3890fa82 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
@@ -42,6 +42,7 @@ import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent.Type;
 import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
 import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
+import eu.etaxonomy.cdm.vaadin.ui.config.TaxonNamePopupEditorConfig;
 import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
 import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
 import eu.etaxonomy.vaadin.mvp.AbstractView;
@@ -256,7 +257,7 @@ public class NameTypeDesignationPresenter
         TaxonNamePopupEditor typeNamePopup = openPopupEditor(TaxonNamePopupEditor.class, action);
         typeNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
         typeNamePopup.withDeleteButton(true);
-        // TODO configure Modes???
+        TaxonNamePopupEditorConfig.configure(typeNamePopup);
         typeNamePopup.loadInEditor(null);
 
     }
@@ -272,7 +273,7 @@ public class NameTypeDesignationPresenter
         TaxonNamePopupEditor typeNamePopup = openPopupEditor(TaxonNamePopupEditor.class, action);
         typeNamePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
         typeNamePopup.withDeleteButton(true);
-        // TODO configure Modes???
+        TaxonNamePopupEditorConfig.configure(typeNamePopup);
         typeNamePopup.loadInEditor(action.getEntityUuid());
 
     }
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
index 1502be27..f062a44b 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
@@ -81,12 +81,12 @@ import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
 import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
 import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
 import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
+import eu.etaxonomy.cdm.vaadin.ui.config.TaxonNamePopupEditorConfig;
 import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
+import eu.etaxonomy.cdm.vaadin.view.name.NameTypeDesignationEditorView;
 import eu.etaxonomy.cdm.vaadin.view.name.NameTypeDesignationPopupEditor;
 import eu.etaxonomy.cdm.vaadin.view.name.SpecimenTypeDesignationWorkingsetPopupEditor;
 import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditor;
-import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorMode;
-import eu.etaxonomy.cdm.vaadin.view.name.TaxonNamePopupEditorView;
 import eu.etaxonomy.cdm.vaadin.view.name.TypeDesignationWorkingsetEditorIdSet;
 import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
 import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
@@ -418,7 +418,7 @@ public class RegistrationWorkingsetPresenter extends AbstractPresenter<Registrat
         TaxonNamePopupEditor popup = openPopupEditor(TaxonNamePopupEditor.class, event);
         popup.setParentEditorActionContext(event.getContext());
         popup.withDeleteButton(true);
-        configureTaxonNameEditor(popup);
+        TaxonNamePopupEditorConfig.configureForNomenclaturalAct(popup);
         popup.loadInEditor(event.getEntityUuid());
         if(event.hasSource() && event.getSource().isReadOnly()){
             // avoid resetting readonly to false
@@ -444,24 +444,10 @@ public class RegistrationWorkingsetPresenter extends AbstractPresenter<Registrat
         popup.setParentEditorActionContext(event.getContext());
         popup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE,CRUD.DELETE));
         popup.withDeleteButton(true);
-        configureTaxonNameEditor(popup);
+        TaxonNamePopupEditorConfig.configureForNomenclaturalAct(popup);
         popup.loadInEditor(newTaxonNameForRegistration.getUuid());
     }
 
-    /**
-     * TODO consider putting this into a Configurer Bean per UIScope.
-     * In the configurator bean this methods popup papamerter should be of the type
-     * AbstractPopupEditor
-     *
-     * @param popup
-     */
-    protected void configureTaxonNameEditor(TaxonNamePopupEditorView popup) {
-        popup.enableMode(TaxonNamePopupEditorMode.AUTOFILL_AUTHORSHIP_DATA);
-        popup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
-        popup.enableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
-        // popup.enableMode(TaxonNamePopupEditorMode.REQUIRE_NOMENCLATURALREFERENCE);
-    }
-
     /**
      * Creates a new <code>Registration</code> for a new name that has just been edited
      * using the <code>TaxonNamePopupEditor</code>. The new name was previously created
@@ -736,7 +722,20 @@ public class RegistrationWorkingsetPresenter extends AbstractPresenter<Registrat
                 if(rootContext.getParentView().equals(getView())){
                     Registration blockingRegistration = getRepo().getRegistrationService().createRegistrationForName(event.getEntityUuid());
                     TypedEntityReference<Registration> regReference = (TypedEntityReference<Registration>)rootContext.getParentEntity();
-                    Registration registration = getRepo().getRegistrationService().load(regReference.getUuid(), REGISTRATION_INIT_STRATEGY);
+//                    Registration registration = getRepo().getRegistrationService().load(regReference.getUuid(), REGISTRATION_INIT_STRATEGY);
+//                    if(registration == null){
+                    Registration registration = null;
+                        for(int i = context.size()-1; i>0; i--){
+                            if(NameTypeDesignationEditorView.class.isAssignableFrom(context.elementAt(i).getParentView().getClass())){
+                                UUID registrationUUID = nameTypeDesignationPopupEditorRegistrationUUIDMap.get(context.elementAt(i).getParentView());
+                                RegistrationDTO registrationDTO = workingset.getRegistrationDTO(registrationUUID).get();
+                                registration = registrationDTO.registration();
+                            }
+                        }
+                        if(registration == null){
+                            throw new NullPointerException("Registration not found for the NameTypeDesignation");
+                        }
+//                    }
                     registration.getBlockedBy().add(blockingRegistration);
                     getRepo().getRegistrationService().saveOrUpdate(registration);
                     logger.debug("Blocking registration created");
