fix #9229 using NomenclaturalStatusDTO in the TaxonNameEditor
authorAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 22 Sep 2020 12:45:31 +0000 (14:45 +0200)
committerAndreas Kohlbecker <a.kohlbecker@bgbm.org>
Tue, 22 Sep 2020 12:46:51 +0000 (14:46 +0200)
src/main/java/eu/etaxonomy/cdm/service/BeanToDTOConverter.java [new file with mode: 0644]
src/main/java/eu/etaxonomy/cdm/service/CdmBeanItemContainerFactory.java
src/main/java/eu/etaxonomy/cdm/vaadin/model/name/NomenclaturalStatusDTO.java [new file with mode: 0644]
src/main/java/eu/etaxonomy/cdm/vaadin/model/name/TaxonNameDTO.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditor.java
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNamePopupEditorView.java

diff --git a/src/main/java/eu/etaxonomy/cdm/service/BeanToDTOConverter.java b/src/main/java/eu/etaxonomy/cdm/service/BeanToDTOConverter.java
new file mode 100644 (file)
index 0000000..c26702f
--- /dev/null
@@ -0,0 +1,32 @@
+/**
+* Copyright (C) 2020 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 com.vaadin.data.util.BeanItemContainer;
+
+import eu.etaxonomy.cdm.model.common.CdmBase;
+
+/**
+ * Interface for classes converting {@link CdmBase) beans into DTO classes.
+ * <p>
+ * This interface is meant to be used in the context of {@link BeanItemContainer}s,
+ *
+ * @author a.kohlbecker
+ * @since Sep 21, 2020
+ */
+public interface BeanToDTOConverter<CDM extends CdmBase, DTO extends Object> {
+
+    public DTO toDTO(CDM bean);
+
+    /**
+     * @return
+     */
+    public Class<DTO> getDTOType();
+
+}
index 110b461bdd3b5392b28aecd3f0804853b9228c66..c454cca6e25e6c2340898173b005dfd0d78556c3 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.UUID;
+import java.util.stream.Collectors;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
@@ -25,6 +26,7 @@ import eu.etaxonomy.cdm.api.service.pager.Pager;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.cdm.model.term.IEnumTerm;
+import eu.etaxonomy.cdm.model.term.TermBase;
 import eu.etaxonomy.cdm.model.term.TermType;
 import eu.etaxonomy.cdm.model.term.TermVocabulary;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
@@ -53,11 +55,8 @@ public class CdmBeanItemContainerFactory {
         orderHints.add(OrderHint.ORDER_BY_TITLE_CACHE);
     }
 
-    /**
-     * @param termType
-     */
     @Transactional(readOnly=true)
-    public BeanItemContainer<DefinedTermBase> buildBeanItemContainer(TermType termType) {
+    public BeanItemContainer<DefinedTermBase> buildTermItemContainer(TermType termType) {
 
         clearSession();
         // TODO use TermCacher?
@@ -67,11 +66,8 @@ public class CdmBeanItemContainerFactory {
         return termItemContainer;
     }
 
-    /**
-     * @param termType
-     */
     @Transactional(readOnly=true)
-    public BeanItemContainer<DefinedTermBase> buildBeanItemContainer(UUID vocabularyUuid) {
+    public BeanItemContainer<DefinedTermBase> buildVocabularyTermsItemContainer(UUID vocabularyUuid) {
 
         clearSession();
         TermVocabulary vocab = repo.getVocabularyService().find(vocabularyUuid);
@@ -81,17 +77,22 @@ public class CdmBeanItemContainerFactory {
         return termItemContainer;
     }
 
-    /**
-     * @param termType
-     */
+    @Transactional(readOnly=true)
+    public <DTO extends Object> BeanItemContainer<DTO> buildVocabularyTermsItemContainer(UUID vocabularyUuid, BeanToDTOConverter<TermBase, DTO> converter) {
+
+        clearSession();
+        TermVocabulary vocab = repo.getVocabularyService().find(vocabularyUuid);
+        Pager<DefinedTermBase> terms = repo.getVocabularyService().getTerms(vocab, null, null, orderHints, INIT_STRATEGY);
+        BeanItemContainer<DTO> termItemContainer = new BeanItemContainer<>(converter.getDTOType());
+        termItemContainer.addAll(terms.getRecords().stream().map(b -> converter.toDTO(b)).collect(Collectors.toList()));
+        return termItemContainer;
+    }
+
+
     public BeanItemContainer<DefinedTermBase> buildTermItemContainer(UUID ... termUuid) {
         return buildTermItemContainer(Arrays.asList(termUuid));
     }
 
-    /**
-     * @param derivation_EVENT_TYPE_UUIDS
-     * @return
-     */
     @Transactional(readOnly=true)
     public BeanItemContainer<DefinedTermBase> buildTermItemContainer(List<UUID> termsUuids) {
         clearSession();
@@ -101,9 +102,6 @@ public class CdmBeanItemContainerFactory {
         return termItemContainer;
     }
 
-    /**
-     * @param termType
-     */
     @Transactional(readOnly=true)
     public <T extends CdmBase> BeanItemContainer<T> buildBeanItemContainer(Class<T> type, List<OrderHint> orderHints) {
 
@@ -123,10 +121,6 @@ public class CdmBeanItemContainerFactory {
         return buildBeanItemContainer(type, null);
     }
 
-    /**
-     * @param values
-     * @return
-     */
     public <T extends IEnumTerm<T>> BeanItemContainer<T> buildEnumTermItemContainer(Class<T> termType, T ... enumTerms) {
         BeanItemContainer<T> termItemContainer = new BeanItemContainer<>(termType);
         List<T> termList = Arrays.asList(enumTerms);
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/model/name/NomenclaturalStatusDTO.java b/src/main/java/eu/etaxonomy/cdm/vaadin/model/name/NomenclaturalStatusDTO.java
new file mode 100644 (file)
index 0000000..1575e3c
--- /dev/null
@@ -0,0 +1,148 @@
+/**
+* Copyright (C) 2020 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.model.name;
+
+import java.io.Serializable;
+
+import eu.etaxonomy.cdm.model.description.DescriptionElementSource;
+import eu.etaxonomy.cdm.model.name.NomenclaturalCodeEdition;
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
+import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
+import eu.etaxonomy.cdm.model.reference.OriginalSourceType;
+import eu.etaxonomy.cdm.model.reference.Reference;
+
+/**
+ * @author a.kohlbecker
+ * @since Sep 17, 2020
+ */
+public class NomenclaturalStatusDTO implements Serializable {
+
+    private static final long serialVersionUID = -7019899466081978199L;
+
+    private Integer id = 0;
+
+    NomenclaturalStatusType type;
+
+    Reference citation;
+
+    NomenclaturalCodeEdition codeEdition;
+
+    String citationMicroReference;
+
+    String ruleConsidered;
+
+    public static NomenclaturalStatusDTO from(NomenclaturalStatus nomStatus) {
+        return new NomenclaturalStatusDTO(nomStatus.getId(), nomStatus.getType(), nomStatus.getCitation(),
+                nomStatus.getCitationMicroReference(), nomStatus.getRuleConsidered(), nomStatus.getCodeEdition());
+
+    }
+
+    public static NomenclaturalStatusDTO newInstance() {
+        return new NomenclaturalStatusDTO();
+    }
+
+
+    /**
+     * Update an existing or create a new {@link NomenclaturalStatus} for this
+     * DTO.
+     *
+     * @param nomStatus
+     *            the {@link NomenclaturalStatus} to update or <code>null</code>
+     *            in which case a new entity instance will be created.
+     * @return the new or updated entity
+     */
+    public NomenclaturalStatus update(NomenclaturalStatus nomStatus) {
+        if (nomStatus == null) {
+            nomStatus = NomenclaturalStatus.NewInstance(type);
+        } else {
+            nomStatus.setType(type);
+        }
+        nomStatus.setRuleConsidered(ruleConsidered);
+        if (citation != null || citationMicroReference != null) {
+            if (nomStatus.getSource() == null) {
+                // below line as in
+                // DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource)
+                nomStatus.setSource(DescriptionElementSource.NewInstance(OriginalSourceType.PrimaryTaxonomicSource));
+            }
+            nomStatus.getSource().setCitation(citation);
+            nomStatus.getSource().setCitationMicroReference(citationMicroReference);
+        }
+        nomStatus.setCodeEdition(codeEdition);
+        return nomStatus;
+
+    }
+
+    public NomenclaturalStatusDTO(Integer id, NomenclaturalStatusType type, Reference citation,
+            String citationMicroReference, String ruleConsidered, NomenclaturalCodeEdition codeEdition) {
+        this.id = id;
+        this.type = type;
+        this.citation = citation;
+        this.citationMicroReference = citationMicroReference;
+        this.ruleConsidered = ruleConsidered;
+        this.codeEdition = codeEdition;
+    }
+
+    /**
+     *
+     */
+    public NomenclaturalStatusDTO() {
+        // TODO Auto-generated constructor stub
+    }
+
+    public NomenclaturalStatusType getType() {
+        return type;
+    }
+
+    public void setType(NomenclaturalStatusType type) {
+        this.type = type;
+    }
+
+    public Reference getCitation() {
+        return citation;
+    }
+
+    public void setCitation(Reference citation) {
+        this.citation = citation;
+    }
+
+    public String getCitationMicroReference() {
+        return citationMicroReference;
+    }
+
+    public NomenclaturalCodeEdition getCodeEdition() {
+        return codeEdition;
+    }
+
+    public void setCodeEdition(NomenclaturalCodeEdition codeEdition) {
+        this.codeEdition = codeEdition;
+    }
+
+    public void setCitationMicroReference(String citationMicroReference) {
+        this.citationMicroReference = citationMicroReference;
+    }
+
+    public String getRuleConsidered() {
+        return ruleConsidered;
+    }
+
+    public void setRuleConsidered(String ruleConsidered) {
+        this.ruleConsidered = ruleConsidered;
+    }
+
+    /**
+     * The {@link NomenclaturalStatus#getId()} of the original status entity for
+     * which this DTO has been created.
+     * <p>
+     * When the DTO has no corresponding entity in the db the id has the value
+     * of <code>0</code>
+     */
+    public Integer getId() {
+        return id;
+    }
+}
index 0dc02ea9cea4a21c72b2f4208018ee1fb266c882..a15930f2565ede75abecf27c5f299b11208b2c53 100644 (file)
@@ -16,7 +16,6 @@ import java.util.stream.Collectors;
 
 import org.joda.time.DateTime;
 
-import eu.etaxonomy.cdm.model.EntityCollectionSetterAdapter.SetterAdapterException;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.Annotation;
 import eu.etaxonomy.cdm.model.common.Credit;
@@ -27,11 +26,13 @@ import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.NameRelationship;
 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
+import eu.etaxonomy.cdm.model.name.NomenclaturalSource;
 import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.permission.User;
 import eu.etaxonomy.cdm.model.reference.INomenclaturalReference;
+import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.vaadin.model.CdmEntityAdapterDTO;
 
 /**
@@ -49,12 +50,17 @@ public class TaxonNameDTO extends CdmEntityAdapterDTO<TaxonName> {
 
     private TaxonName persistedOrthographicVariant;
 
+    private Set<NomenclaturalStatusDTO> nomenclaturalStatusDTOs = new HashSet<>();
+
     /**
      * @param entity
      */
     public TaxonNameDTO(TaxonName entity) {
         super(entity);
         name = entity;
+        for(NomenclaturalStatus status : name.getStatus()) {
+            nomenclaturalStatusDTOs.add(NomenclaturalStatusDTO.from(status));
+        }
     }
 
     public String getAcronym() {
@@ -325,12 +331,12 @@ public class TaxonNameDTO extends CdmEntityAdapterDTO<TaxonName> {
         return name.getRank();
     }
 
-    public Set<NomenclaturalStatus> getStatus() {
-        return name.getStatus();
+    public Set<NomenclaturalStatusDTO> getStatus() {
+        return nomenclaturalStatusDTOs;
     }
 
-    public void setStatus(Set<NomenclaturalStatus> status) throws SetterAdapterException {
-        name.setStatus(status);
+    public void setStatus(Set<NomenclaturalStatusDTO> status) {
+        nomenclaturalStatusDTOs = status;
     }
 
     public boolean isProtectedAuthorshipCache() {
@@ -422,11 +428,19 @@ public class TaxonNameDTO extends CdmEntityAdapterDTO<TaxonName> {
     }
 
     public void setNomenclaturalMicroReference(String nomenclaturalMicroReference) {
-        name.setNomenclaturalMicroReference(nomenclaturalMicroReference);
+        assureNomenclaturalSource().setCitationMicroReference(nomenclaturalMicroReference);
     }
 
-    public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference) {
-        name.setNomenclaturalReference(nomenclaturalReference);
+    public void setNomenclaturalReference(Reference nomenclaturalReference) {
+        assureNomenclaturalSource().setCitation(nomenclaturalReference);
+    }
+
+    protected NomenclaturalSource assureNomenclaturalSource() {
+        NomenclaturalSource nomSource = name.getNomenclaturalSource();
+        if(nomSource == null) {
+            nomSource = NomenclaturalSource.NewNomenclaturalInstance(name);
+        }
+        return nomSource;
     }
 
     public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache) {
index a58b10296fa5995e5d4e63669e17e7573653167b..983c5b25807970d34b3ee465d27d3cda30b81ec7 100644 (file)
@@ -168,7 +168,7 @@ public class NameTypeDesignationPresenter
 
         getView().getTypifiedNamesComboboxSelect().setPagingProviders(namePagingProvider, namePagingProvider, namePagingProvider.getPageSize(), this);
 
-        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildBeanItemContainer(
+        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildVocabularyTermsItemContainer(
                 AnnotationType.EDITORIAL().getVocabulary().getUuid()));
 
     }
index 97b9a6a8a521b00beb308e64049a10e0686fe5d6..a1f6e0dee05efad27e024b69ec8a06f2e0a2f990 100644 (file)
@@ -176,7 +176,7 @@ public class SpecimenTypeDesignationWorkingsetEditorPresenter
     @Override
     public void handleViewEntered() {
 
-        getView().getCountrySelectField().setContainerDataSource(cdmBeanItemContainerFactory.buildBeanItemContainer(Country.uuidCountryVocabulary));
+        getView().getCountrySelectField().setContainerDataSource(cdmBeanItemContainerFactory.buildVocabularyTermsItemContainer(Country.uuidCountryVocabulary));
 
         CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = pagingProviderFactory.teamOrPersonPagingProvider();
         CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = pagingProviderFactory.personPagingProvider();
@@ -185,13 +185,13 @@ public class SpecimenTypeDesignationWorkingsetEditorPresenter
         getView().getCollectorField().setFilterablePersonPagingProvider(personPagingProvider, this);
         getView().getCollectorField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
 
-        getView().getExactLocationField().getReferenceSystemSelect().setContainerDataSource(cdmBeanItemContainerFactory.buildBeanItemContainer(TermType.ReferenceSystem));
+        getView().getExactLocationField().getReferenceSystemSelect().setContainerDataSource(cdmBeanItemContainerFactory.buildTermItemContainer(TermType.ReferenceSystem));
         getView().getExactLocationField().getReferenceSystemSelect().setItemCaptionPropertyId("label");
 
         getView().getTypeDesignationsCollectionField().addElementRemovedListener(e -> deleteTypeDesignation(e.getElement()));
         getView().getTypeDesignationsCollectionField().addElementAddedListener(e -> addTypeDesignation(e.getElement()));
 
-        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildBeanItemContainer(
+        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildVocabularyTermsItemContainer(
                 AnnotationType.EDITORIAL().getVocabulary().getUuid()));
 
         popuEditorTypeDesignationSourceRows.clear();
index 8076b6ec78d87499da2fc2c1adf2b6449e3fe235..74f2cb68928602b1343b50036b4c601416a27a06 100644 (file)
@@ -11,8 +11,11 @@ package eu.etaxonomy.cdm.vaadin.view.name;
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
 import java.util.UUID;
 
 import org.apache.commons.lang.StringUtils;
@@ -64,6 +67,7 @@ import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorActionStrRep;
 import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
 import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
+import eu.etaxonomy.cdm.vaadin.model.name.NomenclaturalStatusDTO;
 import eu.etaxonomy.cdm.vaadin.model.name.TaxonNameDTO;
 import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
 import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
@@ -90,22 +94,18 @@ import eu.etaxonomy.vaadin.util.PropertyIdPath;
  */
 @SpringComponent
 @Scope("prototype")
-public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, TaxonNamePopupEditorView> {
+public class TaxonNameEditorPresenter
+        extends AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, TaxonNamePopupEditorView> {
 
     private static final long serialVersionUID = -3538980627079389221L;
 
     private static final EnumSet<CRUD> SUB_EDITOR_CRUD = EnumSet.of(CRUD.UPDATE, CRUD.DELETE);
 
-    private static final List<String> RELATED_NAME_INIT_STRATEGY = Arrays.asList(
-            "$",
-            "relationsFromThisName",
-            "relationsToThisName.type",
-            "homotypicalGroup.typifiedNames"
-            );
+    private static final List<String> RELATED_NAME_INIT_STRATEGY = Arrays.asList("$", "nomenclaturalSource.annotations",
+            "relationsFromThisName", "relationsToThisName.type", "homotypicalGroup.typifiedNames");
 
     public static List<String> REFERENCE_INIT_STRATEGY = ReferenceEllypsisFormatter.INIT_STRATEGY;
 
-
     private static final Logger logger = Logger.getLogger(TaxonNameEditorPresenter.class);
 
     private CdmFilterablePagingProvider<Reference, Reference> nomReferencePagingProvider;
@@ -139,17 +139,21 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
 
         super.handleViewEntered();
 
-        List<NomenclaturalCodeEdition> nomCodes = NomenclaturalCodeEdition.forCode(RegistrationUIDefaults.NOMENCLATURAL_CODE);
-        BeanItemContainer<NomenclaturalCodeEdition> codeEditionItemContainer = cdmBeanItemContainerFactory.buildEnumTermItemContainer(
-                NomenclaturalCodeEdition.class, nomCodes.toArray(new NomenclaturalCodeEdition[nomCodes.size()])
-                );
+        List<NomenclaturalCodeEdition> nomCodes = NomenclaturalCodeEdition
+                .forCode(RegistrationUIDefaults.NOMENCLATURAL_CODE);
+        BeanItemContainer<NomenclaturalCodeEdition> codeEditionItemContainer = cdmBeanItemContainerFactory
+                .buildEnumTermItemContainer(NomenclaturalCodeEdition.class,
+                        nomCodes.toArray(new NomenclaturalCodeEdition[nomCodes.size()]));
 
-        getView().getRankSelect().setContainerDataSource(cdmBeanItemContainerFactory.buildBeanItemContainer(TermType.Rank));
+        getView().getRankSelect()
+                .setContainerDataSource(cdmBeanItemContainerFactory.buildTermItemContainer(TermType.Rank));
         getView().getRankSelect().setItemCaptionPropertyId("label");
 
-        CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = pagingProviderFactory.teamOrPersonPagingProvider();
+        CdmFilterablePagingProvider<AgentBase, TeamOrPersonBase> termOrPersonPagingProvider = pagingProviderFactory
+                .teamOrPersonPagingProvider();
         termOrPersonPagingProvider.setInitStrategy(AgentBaseInit.TEAM_OR_PERSON_INIT_STRATEGY);
-        CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = pagingProviderFactory.personPagingProvider();
+        CdmFilterablePagingProvider<AgentBase, Person> personPagingProvider = pagingProviderFactory
+                .personPagingProvider();
 
         getView().getCombinationAuthorshipField().setFilterableTeamPagingProvider(termOrPersonPagingProvider, this);
         getView().getCombinationAuthorshipField().setFilterablePersonPagingProvider(personPagingProvider, this);
@@ -165,94 +169,126 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
 
         nomReferencePagingProvider = pagingProviderFactory.referencePagingProvider();
         nomReferencePagingProvider.setInitStrategy(REFERENCE_INIT_STRATEGY);
-        getView().getNomReferenceCombobox().loadFrom(nomReferencePagingProvider, nomReferencePagingProvider, nomReferencePagingProvider.getPageSize());
-        getView().getNomReferenceCombobox().setNestedButtonStateUpdater(new ToOneRelatedEntityButtonUpdater<Reference>(getView().getNomReferenceCombobox()));
-        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.NOMENCLATURAL, getView().getNomReferenceCombobox().getSelect()));
-        getView().getNomReferenceCombobox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getNomReferenceCombobox(), this));
-        getView().getNomReferenceCombobox().getSelect().addValueChangeListener( e -> updateOrthographicCorrectionRestriction());
-
-        CdmFilterablePagingProvider<Reference, Reference> icbnCodesPagingProvider = pagingProviderFactory.referencePagingProvider();
+        getView().getNomReferenceCombobox().loadFrom(nomReferencePagingProvider, nomReferencePagingProvider,
+                nomReferencePagingProvider.getPageSize());
+        getView().getNomReferenceCombobox().setNestedButtonStateUpdater(
+                new ToOneRelatedEntityButtonUpdater<Reference>(getView().getNomReferenceCombobox()));
+        getView().getNomReferenceCombobox().getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(
+                LabelType.NOMENCLATURAL, getView().getNomReferenceCombobox().getSelect()));
+        getView().getNomReferenceCombobox().getSelect()
+                .addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getNomReferenceCombobox(), this));
+        getView().getNomReferenceCombobox().getSelect()
+                .addValueChangeListener(e -> updateOrthographicCorrectionRestriction());
+
+        CdmFilterablePagingProvider<Reference, Reference> icbnCodesPagingProvider = pagingProviderFactory
+                .referencePagingProvider();
         // @formatter:off
-        // TODO use markers on references instead of isbn. The marker type MarkerType.NOMENCLATURAL_RELEVANT() has already prepared (#7466)
-        icbnCodesPagingProvider.getCriteria().add(Restrictions.in("isbn", new String[]{
+        // TODO use markers on references instead of isbn. The marker type
+        // MarkerType.NOMENCLATURAL_RELEVANT() has already prepared (#7466)
+        icbnCodesPagingProvider.getCriteria().add(Restrictions.in("isbn", new String[] {
                 "3-904144-22-7",     // Saint Louis Code
                 "3-906166-48-1",     // Vienna Code
                 "978-3-87429-425-6", // Melbourne Code
                 "978-3-946583-16-5", // Shenzhen Code
                 "0-85301-006-4"      // ICZN 1999
-                // ICNB
+                                     // ICNB
         }));
         // @formatter:on
 
         statusTypeReferencePopupEditorsRowMap.clear();
         getView().getNomStatusCollectionField().addElementAddedListener(e -> addNomenclaturalStatus(e.getElement()));
-        getView().getNomStatusCollectionField().setEditorInstantiator(new AbstractElementCollection.Instantiator<NomenclaturalStatusRow>() {
+        getView().getNomStatusCollectionField()
+                .setEditorInstantiator(new AbstractElementCollection.Instantiator<NomenclaturalStatusRow>() {
+
+                    @Override
+                    public NomenclaturalStatusRow create() {
+                        NomenclaturalStatusRow row = new NomenclaturalStatusRow();
+
+                        BeanItemContainer<DefinedTermBase> statusTypeItemContainer = cdmBeanItemContainerFactory
+                                .buildVocabularyTermsItemContainer(
+                                        NomenclaturalStatusType.ALTERNATIVE().getVocabulary().getUuid());
+                        row.type.setContainerDataSource(statusTypeItemContainer);
+                        row.type.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
+                        for (DefinedTermBase term : statusTypeItemContainer.getItemIds()) {
+                            row.type.setItemCaption(term,
+                                    term.getPreferredRepresentation(Language.DEFAULT()).getAbbreviatedLabel());
+                        }
+                        row.type.setNullSelectionAllowed(false);
+
+                        row.citation.loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider,
+                                icbnCodesPagingProvider.getPageSize());
+                        row.citation.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(
+                                LabelType.NOMENCLATURAL, row.citation.getSelect()));
+                        row.citation.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(
+                                row.citation.getSelect(), TaxonNameEditorPresenter.this));
+                        row.citation.addClickListenerAddEntity(e -> doReferenceEditorAdd(row));
+                        row.citation.addClickListenerEditEntity(e -> {
+                            if (row.citation.getValue() != null) {
+                                doReferenceEditorEdit(row);
+                            }
+                        });
+                        row.codeEdition.setContainerDataSource(codeEditionItemContainer);
 
-            @Override
-            public NomenclaturalStatusRow create() {
-                NomenclaturalStatusRow row = new NomenclaturalStatusRow();
-
-                BeanItemContainer<DefinedTermBase> statusTypeItemContainer = cdmBeanItemContainerFactory.buildBeanItemContainer(NomenclaturalStatusType.ALTERNATIVE().getVocabulary().getUuid());
-                row.type.setContainerDataSource(statusTypeItemContainer);
-                row.type.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
-                for(DefinedTermBase term : statusTypeItemContainer.getItemIds()){
-                    row.type.setItemCaption(term, term.getPreferredRepresentation(Language.DEFAULT()).getAbbreviatedLabel());
-                }
-                row.type.setNullSelectionAllowed(false);
-
-                row.citation.loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize());
-                row.citation.getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.NOMENCLATURAL, row.citation.getSelect()));
-                row.citation.getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<Reference>(row.citation.getSelect(),
-                        TaxonNameEditorPresenter.this));
-                row.citation.addClickListenerAddEntity(e -> doReferenceEditorAdd(row));
-                row.citation.addClickListenerEditEntity(e -> {
-                    if(row.citation.getValue() != null){
-                        doReferenceEditorEdit(row);
+                        getView().applyDefaultComponentStyle(row.components());
+
+                        return row;
                     }
                 });
-                row.codeEdition.setContainerDataSource(codeEditionItemContainer);
-
-                getView().applyDefaultComponentStyle(row.components());
-
-                return row;
-            }
-        });
-
 
         relatedNamePagingProvider = pagingProviderFactory.taxonNamesWithoutOrthophicIncorrect();
         relatedNamePagingProvider.setInitStrategy(RELATED_NAME_INIT_STRATEGY);
         getView().getBasionymComboboxSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
-        getView().getBasionymComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this);
-
-        getView().getReplacedSynonymsComboboxSelect().setCaptionGenerator( new CdmTitleCacheCaptionGenerator<TaxonName>());
-        getView().getReplacedSynonymsComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this);
-
-        getView().getValidationField().getRelatedNameComboBox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
-        getView().getValidationField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
-        getView().getValidationField().getRelatedNameComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getValidationField().getRelatedNameComboBox(), this));
-        getView().getValidationField().getCitatonComboBox().getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, getView().getValidationField().getCitatonComboBox().getSelect()));
-        getView().getValidationField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize());
-        getView().getValidationField().getCitatonComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getValidationField().getCitatonComboBox(), this));
+        getView().getBasionymComboboxSelect().setPagingProviders(relatedNamePagingProvider, relatedNamePagingProvider,
+                relatedNamePagingProvider.getPageSize(), this);
+
+        getView().getReplacedSynonymsComboboxSelect()
+                .setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
+        getView().getReplacedSynonymsComboboxSelect().setPagingProviders(relatedNamePagingProvider,
+                relatedNamePagingProvider, relatedNamePagingProvider.getPageSize(), this);
+
+        getView().getValidationField().getRelatedNameComboBox().getSelect()
+                .setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
+        getView().getValidationField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider,
+                relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
+        getView().getValidationField().getRelatedNameComboBox().getSelect().addValueChangeListener(
+                new ToOneRelatedEntityReloader<>(getView().getValidationField().getRelatedNameComboBox(), this));
+        getView().getValidationField().getCitatonComboBox().getSelect()
+                .setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC,
+                        getView().getValidationField().getCitatonComboBox().getSelect()));
+        getView().getValidationField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider,
+                icbnCodesPagingProvider.getPageSize());
+        getView().getValidationField().getCitatonComboBox().getSelect().addValueChangeListener(
+                new ToOneRelatedEntityReloader<>(getView().getValidationField().getCitatonComboBox(), this));
         getView().getValidationField().getCodeEditionSelect().setContainerDataSource(codeEditionItemContainer);
 
-        getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect().setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
-        getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getOrthographicVariantField().getRelatedNameComboBox(), this));
-        getView().getOrthographicVariantField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider, relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
-        // The Mode TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION will be handled in the updateOrthographicCorrectionRestriction() method
-        getView().getOrthographicVariantField().getCitatonComboBox().getSelect().setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC, getView().getOrthographicVariantField().getCitatonComboBox().getSelect()));
-        getView().getOrthographicVariantField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider, icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize());
-        getView().getOrthographicVariantField().getCitatonComboBox().getSelect().addValueChangeListener(new ToOneRelatedEntityReloader<>(getView().getOrthographicVariantField().getCitatonComboBox(), this));
+        getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect()
+                .setCaptionGenerator(new CdmTitleCacheCaptionGenerator<TaxonName>());
+        getView().getOrthographicVariantField().getRelatedNameComboBox().getSelect().addValueChangeListener(
+                new ToOneRelatedEntityReloader<>(getView().getOrthographicVariantField().getRelatedNameComboBox(),
+                        this));
+        getView().getOrthographicVariantField().getRelatedNameComboBox().loadFrom(relatedNamePagingProvider,
+                relatedNamePagingProvider, relatedNamePagingProvider.getPageSize());
+        // The Mode TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION will be
+        // handled in the updateOrthographicCorrectionRestriction() method
+        getView().getOrthographicVariantField().getCitatonComboBox().getSelect()
+                .setCaptionGenerator(new ReferenceEllypsisCaptionGenerator(LabelType.BIBLIOGRAPHIC,
+                        getView().getOrthographicVariantField().getCitatonComboBox().getSelect()));
+        getView().getOrthographicVariantField().getCitatonComboBox().loadFrom(icbnCodesPagingProvider,
+                icbnCodesPagingProvider, icbnCodesPagingProvider.getPageSize());
+        getView().getOrthographicVariantField().getCitatonComboBox().getSelect().addValueChangeListener(
+                new ToOneRelatedEntityReloader<>(getView().getOrthographicVariantField().getCitatonComboBox(), this));
         getView().getOrthographicVariantField().getCodeEditionSelect().setContainerDataSource(codeEditionItemContainer);
 
-        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory.buildBeanItemContainer(
-                AnnotationType.EDITORIAL().getVocabulary().getUuid()));
+        getView().getAnnotationsField().setAnnotationTypeItemContainer(cdmBeanItemContainerFactory
+                .buildVocabularyTermsItemContainer(AnnotationType.EDITORIAL().getVocabulary().getUuid()));
     }
 
     /**
      * @param element
      * @return
      */
-    private void addNomenclaturalStatus(NomenclaturalStatus element) {
+    @Deprecated
+    private void addNomenclaturalStatus(NomenclaturalStatusDTO element) {
         // Nothing to do
     }
 
@@ -263,21 +299,26 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
 
     private void updateOrthographicCorrectionRestriction() {
 
-        if(getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)){
-            if(orthographicVariantNamePagingProvider == null){
-                orthographicVariantNamePagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(getRepo().getNameService());
+        if (getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)) {
+            if (orthographicVariantNamePagingProvider == null) {
+                orthographicVariantNamePagingProvider = new CdmFilterablePagingProvider<TaxonName, TaxonName>(
+                        getRepo().getNameService());
                 orthographicVariantNamePagingProvider.setInitStrategy(RELATED_NAME_INIT_STRATEGY);
-                orthographicVariantNamePagingProvider.addRestriction(new Restriction<>("id", Operator.AND_NOT, null, taxonNameId));
-                getView().getOrthographicVariantField().getRelatedNameComboBox().loadFrom(orthographicVariantNamePagingProvider, orthographicVariantNamePagingProvider, orthographicVariantNamePagingProvider.getPageSize());
+                orthographicVariantNamePagingProvider
+                        .addRestriction(new Restriction<>("id", Operator.AND_NOT, null, taxonNameId));
+                getView().getOrthographicVariantField().getRelatedNameComboBox().loadFrom(
+                        orthographicVariantNamePagingProvider, orthographicVariantNamePagingProvider,
+                        orthographicVariantNamePagingProvider.getPageSize());
             }
             Reference nomReference = getView().getNomReferenceCombobox().getValue();
-            if(nomReference == null && orthographicCorrectionRestriction != null){
+            if (nomReference == null && orthographicCorrectionRestriction != null) {
                 orthographicVariantNamePagingProvider.getRestrictions().remove(orthographicCorrectionRestriction);
             } else {
-                if(orthographicCorrectionRestriction == null){
-                    orthographicCorrectionRestriction = new Restriction<>("nomenclaturalSource.citation", Operator.AND, null, nomReference);
+                if (orthographicCorrectionRestriction == null) {
+                    orthographicCorrectionRestriction = new Restriction<>("nomenclaturalSource.citation", Operator.AND,
+                            null, nomReference);
                     orthographicVariantNamePagingProvider.addRestriction(orthographicCorrectionRestriction);
-                } else{
+                } else {
                     orthographicCorrectionRestriction.setValues(Arrays.asList(nomReference));
                 }
             }
@@ -288,68 +329,63 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     @Override
     protected TaxonName loadCdmEntity(UUID identifier) {
 
-        EntityInitStrategy initStrategy = new EntityInitStrategy(
-                Arrays.asList(
-                "$",
-                "annotations.type",
-                "annotations.*", // needed as log as we are using a table in FilterableAnnotationsField
+        EntityInitStrategy initStrategy = new EntityInitStrategy(Arrays.asList("$", "annotations.type", "annotations.*", // needed
+                                                                                                                         // as
+                                                                                                                         // log
+                                                                                                                         // as
+                                                                                                                         // we
+                                                                                                                         // are
+                                                                                                                         // using
+                                                                                                                         // a
+                                                                                                                         // table
+                                                                                                                         // in
+                                                                                                                         // FilterableAnnotationsField
                 "rank.vocabulary", // needed for comparing ranks
 
                 "nomenclaturalSource.citation",
-                "nomenclaturalSource.annotations", // needed to allow access in AnnotatableEntity.checkEmpty()
-                "nomenclaturalSource.markers",  // needed to allow access in AnnotatableEntity.checkEmpty()
-                "nomenclaturalSource.links",  // needed to allow access in OriginalSourceBase.checkEmpty()
 
-                "status.type",
-                "status.citation",
+                "status.type", "status.citation",
 
-                "combinationAuthorship",
-                "exCombinationAuthorship",
-                "basionymAuthorship",
-                "exBasionymAuthorship",
+                "combinationAuthorship", "exCombinationAuthorship", "basionymAuthorship", "exBasionymAuthorship",
 
                 // basionyms: relationsToThisName.fromName
-                "relationsToThisName.type",
-                "relationsToThisName.fromName.rank",
+                "relationsToThisName.type", "relationsToThisName.fromName.rank",
                 "relationsToThisName.fromName.combinationAuthorship",
                 "relationsToThisName.fromName.exCombinationAuthorship",
                 "relationsToThisName.fromName.nomenclaturalSource.citation.authorship",
                 "relationsToThisName.fromName.nomenclaturalSource.citation.inReference.authorship",
                 "relationsToThisName.fromName.nomenclaturalSource.citation.inReference.inReference.inReference.authorship",
                 "relationsToThisName.fromName.relationsToThisName",
-                "relationsToThisName.fromName.relationsFromThisName",
-                "relationsToThisName.citation",
-                "relationsFromThisName",
-                "homotypicalGroup.typifiedNames"
-                )
-              );
+                "relationsToThisName.fromName.relationsFromThisName", "relationsToThisName.citation",
+                "relationsFromThisName", "homotypicalGroup.typifiedNames"));
         initStrategy.extend("nomenclaturalSource.citation", ReferenceEllypsisFormatter.INIT_STRATEGY, false);
         initStrategy.extend("status.citation", ReferenceEllypsisFormatter.INIT_STRATEGY, false);
         initStrategy.extend("relationsToThisName.citation", ReferenceEllypsisFormatter.INIT_STRATEGY, false);
 
         TaxonName taxonName;
-        if(identifier != null){
+        if (identifier != null) {
             taxonName = getRepo().getNameService().load(identifier, initStrategy.getPropertyPaths());
         } else {
             taxonName = createCdmEntity();
         }
 
-        if(getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY)){
+        if (getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY)) {
             Reference nomRef = taxonName.getNomenclaturalReference();
 
-            //getView().getNomReferenceCombobox().setEnabled(nomRef.isOfType(ReferenceType.Section));
+            // getView().getNomReferenceCombobox().setEnabled(nomRef.isOfType(ReferenceType.Section));
             publishedUnit = nomRef;
-            if(publishedUnit != null){
-                while(publishedUnit.isOfType(ReferenceType.Section) && publishedUnit.getInReference() != null){
+            if (publishedUnit != null) {
+                while (publishedUnit.isOfType(ReferenceType.Section) && publishedUnit.getInReference() != null) {
                     publishedUnit = nomRef.getInReference();
                 }
-                // reduce available references to those which are sections of the publishedUnit and the publishedUnit itself
+                // reduce available references to those which are sections of
+                // the publishedUnit and the publishedUnit itself
                 // nomReferencePagingProvider
-                nomReferencePagingProvider.getCriteria().add(Restrictions.or(
-                        Restrictions.and(Restrictions.eq("inReference", publishedUnit), Restrictions.eq("type", ReferenceType.Section)),
-                        Restrictions.idEq(publishedUnit.getId())
-                        )
-                );
+                nomReferencePagingProvider.getCriteria()
+                        .add(Restrictions.or(
+                                Restrictions.and(Restrictions.eq("inReference", publishedUnit),
+                                        Restrictions.eq("type", ReferenceType.Section)),
+                                Restrictions.idEq(publishedUnit.getId())));
             }
             // and remove the empty option
             getView().getNomReferenceCombobox().getSelect().setNullSelectionAllowed(false);
@@ -372,13 +408,40 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
         return taxonName;
     }
 
+    @Override
+    protected TaxonNameDTO preSaveBean(TaxonNameDTO bean) {
+        // ---- sync the name.nomenclaturalStatus set with the modifications
+        Set<NomenclaturalStatus> removeCandidates = new HashSet<>(bean.cdmEntity().getStatus());
+        for (NomenclaturalStatusDTO statusDTO : bean.getStatus()) {
+            if (statusDTO.getId() > 0) {
+                Optional<NomenclaturalStatus> originalEntity = bean.cdmEntity().getStatus().stream()
+                        .filter(s -> s.getId() == statusDTO.getId()).findFirst();
+                if (originalEntity.isPresent()) {
+                    statusDTO.update(originalEntity.get());
+                    removeCandidates.remove(originalEntity.get());
+                } else {
+                    throw new RuntimeException("No original NomenclaturalStatus found for DTO with id="
+                            + statusDTO.getId() + ". Was the TaxonName modified otherwise when opened in the editor?");
+                }
+            } else {
+                // all new status with id = 0
+                bean.cdmEntity().addStatus(statusDTO.update(null));
+            }
+        }
+        for(NomenclaturalStatus toBeRemoved : removeCandidates) {
+            bean.cdmEntity().removeStatus(toBeRemoved);
+        }
+        return super.preSaveBean(bean);
+    }
+
     /**
      * {@inheritDoc}
      */
     @Override
     protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
-        if(crud != null){
-            newAuthorityCreated = UserHelperAccess.userHelper().createAuthorityForCurrentUser(TaxonName.class, identifier, crud, null);
+        if (crud != null) {
+            newAuthorityCreated = UserHelperAccess.userHelper().createAuthorityForCurrentUser(TaxonName.class,
+                    identifier, crud, null);
         }
 
     }
@@ -388,7 +451,7 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
      */
     @Override
     protected void guaranteePerEntityCRUDPermissions(TaxonName bean) {
-        if(crud != null){
+        if (crud != null) {
             newAuthorityCreated = UserHelperAccess.userHelper().createAuthorityForCurrentUser(bean, crud, null);
         }
     }
@@ -401,7 +464,6 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
         return getRepo().getNameService();
     }
 
-
     public void doReferenceEditorAdd(NomenclaturalStatusRow row) {
 
         ReferencePopupEditor referencePopupEditor = openPopupEditor(ReferencePopupEditor.class, null);
@@ -424,20 +486,25 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
 
         statusTypeReferencePopupEditorsRowMap.put(referencePopupEditor, row);
     }
+
     /**
      * @param referenceEditorPopup
      */
     private void configureReferencePopupEditor(ReferencePopupEditor referenceEditorPopup, UUID referenceUUID) {
-        boolean nomRefSectionEditingOnly = getView().isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
-        if(nomRefSectionEditingOnly){
+        boolean nomRefSectionEditingOnly = getView()
+                .isModeEnabled(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
+        if (nomRefSectionEditingOnly) {
             referenceEditorPopup.setBeanInstantiator(newReferenceInstantiator);
         }
 
-        // TODO this should be configurable per UI - RegistrationUiReferenceEditorFormConfigurator as spring bean, different spring profiles
-        referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(nomRefSectionEditingOnly && newReferenceInstantiator != null));
+        // TODO this should be configurable per UI -
+        // RegistrationUiReferenceEditorFormConfigurator as spring bean,
+        // different spring profiles
+        referenceEditorPopup.setEditorComponentsConfigurator(new RegistrationUiReferenceEditorFormConfigurator(
+                nomRefSectionEditingOnly && newReferenceInstantiator != null));
 
         referenceEditorPopup.loadInEditor(referenceUUID);
-        if(!nomRefSectionEditingOnly){
+        if (!nomRefSectionEditingOnly) {
             referenceEditorPopup.getTypeSelect().setValue(ReferenceType.Article);
         }
     }
@@ -445,7 +512,7 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
     public void onReferenceEditorActionAdd(ReferenceEditorAction event) {
 
-        if(getView() == null || event.getSourceView() != getView() ){
+        if (getView() == null || event.getSourceView() != getView()) {
             return;
         }
 
@@ -456,12 +523,10 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
         configureReferencePopupEditor(referenceEditorPopup, null);
     }
 
-
     @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
     public void onReferenceEditorActionEdit(ReferenceEditorAction event) {
 
-
-        if(!isFromOwnView(event)){
+        if (!isFromOwnView(event)) {
             return;
         }
         ReferencePopupEditor referenceEditorPopup = openPopupEditor(ReferencePopupEditor.class, event);
@@ -471,55 +536,59 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     }
 
     @EventBusListenerMethod
-    public void onFieldReplaceEvent(FieldReplaceEvent<String> event){
+    public void onFieldReplaceEvent(FieldReplaceEvent<String> event) {
 
         PropertyIdPath boundPropertyIdPath = boundPropertyIdPath(event.getNewField());
-        if(boundPropertyIdPath != null){
-            TaxonNameDTO taxonNamedto = ((AbstractPopupEditor<TaxonNameDTO, AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName,?>>)getView()).getBean();
-            if(boundPropertyIdPath.matches("specificEpithet")){
+        if (boundPropertyIdPath != null) {
+            TaxonNameDTO taxonNamedto = ((AbstractPopupEditor<TaxonNameDTO, AbstractCdmDTOEditorPresenter<TaxonNameDTO, TaxonName, ?>>) getView())
+                    .getBean();
+            if (boundPropertyIdPath.matches("specificEpithet")) {
                 AbstractField<String> genusOrUninomialField = getView().getGenusOrUninomialField();
-                if(event.getNewField() instanceof CompositeCustomField){
-                    if(specificEpithetPartPagingProvider == null){
-                        specificEpithetPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService(), Rank.SPECIES());
+                if (event.getNewField() instanceof CompositeCustomField) {
+                    if (specificEpithetPartPagingProvider == null) {
+                        specificEpithetPartPagingProvider = new TaxonNameStringFilterablePagingProvider(
+                                getRepo().getNameService(), Rank.SPECIES());
                     }
-                    specificEpithetPartPagingProvider.listenToFields(
-                            genusOrUninomialField,
-                            null, null, null);
+                    specificEpithetPartPagingProvider.listenToFields(genusOrUninomialField, null, null, null);
                     specificEpithetPartPagingProvider.excludeNames(taxonNamedto.cdmEntity());
                     specificEpithetPartPagingProvider.updateFromFields();
-                    WeaklyRelatedEntityCombobox<TaxonName> specificEpithetField = (WeaklyRelatedEntityCombobox<TaxonName>)event.getNewField();
-                    refreshSpecificEpithetComboBoxListener = e -> { specificEpithetField.getSelect().refresh(); specificEpithetField.setValue(null);};
-                    specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider, specificEpithetPartPagingProvider.getPageSize());
+                    WeaklyRelatedEntityCombobox<TaxonName> specificEpithetField = (WeaklyRelatedEntityCombobox<TaxonName>) event
+                            .getNewField();
+                    refreshSpecificEpithetComboBoxListener = e -> {
+                        specificEpithetField.getSelect().refresh();
+                        specificEpithetField.setValue(null);
+                    };
+                    specificEpithetField.loadFrom(specificEpithetPartPagingProvider, specificEpithetPartPagingProvider,
+                            specificEpithetPartPagingProvider.getPageSize());
                     specificEpithetField.setValue(event.getOldField().getValue());
                     specificEpithetField.reload();
                     genusOrUninomialField.addValueChangeListener(refreshSpecificEpithetComboBoxListener);
                 } else {
-                    if(specificEpithetPartPagingProvider != null){
+                    if (specificEpithetPartPagingProvider != null) {
                         specificEpithetPartPagingProvider.unlistenAllFields();
                     }
-                    if(refreshSpecificEpithetComboBoxListener != null){
+                    if (refreshSpecificEpithetComboBoxListener != null) {
                         genusOrUninomialField.removeValueChangeListener(refreshSpecificEpithetComboBoxListener);
                         refreshSpecificEpithetComboBoxListener = null;
                     }
                 }
-            } else if(boundPropertyIdPath.matches("genusOrUninomial")) {
-                if(event.getNewField() instanceof CompositeCustomField){
-                    if(genusOrUninomialPartPagingProvider  == null){
-                        genusOrUninomialPartPagingProvider = new TaxonNameStringFilterablePagingProvider(getRepo().getNameService());
+            } else if (boundPropertyIdPath.matches("genusOrUninomial")) {
+                if (event.getNewField() instanceof CompositeCustomField) {
+                    if (genusOrUninomialPartPagingProvider == null) {
+                        genusOrUninomialPartPagingProvider = new TaxonNameStringFilterablePagingProvider(
+                                getRepo().getNameService());
                     }
-                    genusOrUninomialPartPagingProvider.listenToFields(
-                                null,
-                                getView().getInfraGenericEpithetField(),
-                                getView().getSpecificEpithetField(),
-                                getView().getInfraSpecificEpithetField()
-                               );
+                    genusOrUninomialPartPagingProvider.listenToFields(null, getView().getInfraGenericEpithetField(),
+                            getView().getSpecificEpithetField(), getView().getInfraSpecificEpithetField());
                     genusOrUninomialPartPagingProvider.excludeNames(taxonNamedto.cdmEntity());
-                    WeaklyRelatedEntityCombobox<TaxonName> genusOrUninomialField = (WeaklyRelatedEntityCombobox<TaxonName>)event.getNewField();
-                    genusOrUninomialField.loadFrom(genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
+                    WeaklyRelatedEntityCombobox<TaxonName> genusOrUninomialField = (WeaklyRelatedEntityCombobox<TaxonName>) event
+                            .getNewField();
+                    genusOrUninomialField.loadFrom(genusOrUninomialPartPagingProvider,
+                            genusOrUninomialPartPagingProvider, genusOrUninomialPartPagingProvider.getPageSize());
                     genusOrUninomialField.setValue(event.getOldField().getValue());
                     genusOrUninomialField.reload();
-                }else {
-                    if(genusOrUninomialPartPagingProvider != null){
+                } else {
+                    if (genusOrUninomialPartPagingProvider != null) {
                         genusOrUninomialPartPagingProvider.unlistenAllFields();
                     }
                 }
@@ -530,100 +599,120 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     }
 
     @EventBusListenerMethod
-    public void onEntityChangeEvent(EntityChangeEvent<?> event){
+    public void onEntityChangeEvent(EntityChangeEvent<?> event) {
 
-        if(event.getSourceView() instanceof AbstractPopupEditor) {
+        if (event.getSourceView() instanceof AbstractPopupEditor) {
 
             BoundField boundTargetField = boundTargetField((PopupView) event.getSourceView());
 
-            if(boundTargetField != null){
-                if(boundTargetField.matchesPropertyIdPath("genusOrUninomial")){
-                    if(event.isCreateOrModifiedType()){
+            if (boundTargetField != null) {
+                if (boundTargetField.matchesPropertyIdPath("genusOrUninomial")) {
+                    if (event.isCreateOrModifiedType()) {
                         getCache().load(event.getEntity());
-                        if(getView().getGenusOrUninomialField() instanceof WeaklyRelatedEntityCombobox){
-                            WeaklyRelatedEntityCombobox<TaxonName> weaklyRelatedEntityCombobox = (WeaklyRelatedEntityCombobox<TaxonName>)getView().getGenusOrUninomialField();
-                            weaklyRelatedEntityCombobox.setValue(((TaxonName)event.getEntity()).getGenusOrUninomial());
-                            // NOTE: in contrast to the ToOneRelatedEntityCombobox the .discard() does not
-                            // work here since no datasource is bound to the field, see weaklyRelatedEntityCombobox.reload()
+                        if (getView().getGenusOrUninomialField() instanceof WeaklyRelatedEntityCombobox) {
+                            WeaklyRelatedEntityCombobox<TaxonName> weaklyRelatedEntityCombobox = (WeaklyRelatedEntityCombobox<TaxonName>) getView()
+                                    .getGenusOrUninomialField();
+                            weaklyRelatedEntityCombobox.setValue(((TaxonName) event.getEntity()).getGenusOrUninomial());
+                            // NOTE: in contrast to the
+                            // ToOneRelatedEntityCombobox the .discard() does
+                            // not
+                            // work here since no datasource is bound to the
+                            // field, see weaklyRelatedEntityCombobox.reload()
                             weaklyRelatedEntityCombobox.updateButtons();
                         }
                     }
-                } else
-                if(boundTargetField.matchesPropertyIdPath("specificEpithet")){
-                    if(event.isCreateOrModifiedType()){
+                } else if (boundTargetField.matchesPropertyIdPath("specificEpithet")) {
+                    if (event.isCreateOrModifiedType()) {
                         getCache().load(event.getEntity());
-                        if(getView().getSpecificEpithetField() instanceof WeaklyRelatedEntityCombobox){
-                            WeaklyRelatedEntityCombobox<TaxonName> weaklyRelatedEntityCombobox = (WeaklyRelatedEntityCombobox<TaxonName>)getView().getSpecificEpithetField();
-                            getView().getSpecificEpithetField().setValue(((TaxonName)event.getEntity()).getSpecificEpithet());
+                        if (getView().getSpecificEpithetField() instanceof WeaklyRelatedEntityCombobox) {
+                            WeaklyRelatedEntityCombobox<TaxonName> weaklyRelatedEntityCombobox = (WeaklyRelatedEntityCombobox<TaxonName>) getView()
+                                    .getSpecificEpithetField();
+                            getView().getSpecificEpithetField()
+                                    .setValue(((TaxonName) event.getEntity()).getSpecificEpithet());
                             weaklyRelatedEntityCombobox.reload();
-                            // NOTE: in contrast to the ToOneRelatedEntityCombobox the .discard() does not
-                            // work here since no datasource is bound to the field, see weaklyRelatedEntityCombobox.reload()
+                            // NOTE: in contrast to the
+                            // ToOneRelatedEntityCombobox the .discard() does
+                            // not
+                            // work here since no datasource is bound to the
+                            // field, see weaklyRelatedEntityCombobox.reload()
                             weaklyRelatedEntityCombobox.updateButtons();
                         }
                     }
-                } else
-                if(boundTargetField.matchesPropertyIdPath("nomenclaturalReference")){
-                    if(event.isCreateOrModifiedType()){
+                } else if (boundTargetField.matchesPropertyIdPath("nomenclaturalReference")) {
+                    if (event.isCreateOrModifiedType()) {
                         getCache().load(event.getEntity());
-                        if(event.isCreatedType()){
+                        if (event.isCreatedType()) {
                             getView().getNomReferenceCombobox().setValue((Reference) event.getEntity());
                         } else {
                             getView().getNomReferenceCombobox().reload(); // refreshSelectedValue(modifiedReference);
                         }
-                        getView().getCombinationAuthorshipField().discard(); //refresh from the datasource
+                        getView().getCombinationAuthorshipField().discard(); // refresh
+                                                                             // from
+                                                                             // the
+                                                                             // datasource
                         getView().updateAuthorshipFields();
                     }
-                } else
-                if(boundTargetField.matchesPropertyIdPath("validationFor.otherName") || boundTargetField.matchesPropertyIdPath("orthographicVariant.otherName")){
-                    ReloadableLazyComboBox<TaxonName> otherNameField = asReloadableLazyComboBox(boundTargetField.getField(TaxonName.class));
+                } else if (boundTargetField.matchesPropertyIdPath("validationFor.otherName")
+                        || boundTargetField.matchesPropertyIdPath("orthographicVariant.otherName")) {
+                    ReloadableLazyComboBox<TaxonName> otherNameField = asReloadableLazyComboBox(
+                            boundTargetField.getField(TaxonName.class));
                     TaxonName otherName = (TaxonName) event.getEntity();
-                    if(event.isCreateOrModifiedType()){
+                    if (event.isCreateOrModifiedType()) {
                         getCache().load(otherName);
-                        if(event.isCreatedType()){
-                            // TODO use reloadWith((TaxonName) event.getEntity()); also in this case?
+                        if (event.isCreatedType()) {
+                            // TODO use reloadWith((TaxonName)
+                            // event.getEntity()); also in this case?
                             otherNameField.setValue(otherName);
                         } else {
                             otherNameField.reloadWith(otherName);
                         }
 
-                    } else
-                    if(event.isRemovedType()){
+                    } else if (event.isRemovedType()) {
                         otherNameField.setValue(null);
                     }
-                } else
-                if(boundTargetField.matchesPropertyIdPath("basionyms")){
-                    ReloadableLazyComboBox<TaxonName> basionymSourceField = asReloadableLazyComboBox(boundTargetField.getField(TaxonName.class));
-                    if(event.isCreateOrModifiedType()){
+                } else if (boundTargetField.matchesPropertyIdPath("basionyms")) {
+                    ReloadableLazyComboBox<TaxonName> basionymSourceField = asReloadableLazyComboBox(
+                            boundTargetField.getField(TaxonName.class));
+                    if (event.isCreateOrModifiedType()) {
                         getCache().load(event.getEntity());
-                        if(event.isCreatedType()){
-                            // TODO use reloadWith((TaxonName) event.getEntity()); also in this case?
-                            basionymSourceField .setValue((TaxonName) event.getEntity());
+                        if (event.isCreatedType()) {
+                            // TODO use reloadWith((TaxonName)
+                            // event.getEntity()); also in this case?
+                            basionymSourceField.setValue((TaxonName) event.getEntity());
                         } else {
                             basionymSourceField.reloadWith((TaxonName) event.getEntity());
                         }
-                        getView().getBasionymAuthorshipField().discard(); //refresh from the datasource
-                        getView().getExBasionymAuthorshipField().discard(); //refresh from the datasource
+                        getView().getBasionymAuthorshipField().discard(); // refresh
+                                                                          // from
+                                                                          // the
+                                                                          // datasource
+                        getView().getExBasionymAuthorshipField().discard(); // refresh
+                                                                            // from
+                                                                            // the
+                                                                            // datasource
                         getView().updateAuthorshipFields();
-                    } else
-                    if(event.isRemovedType()){
+                    } else if (event.isRemovedType()) {
                         basionymSourceField.setValue(null);
                         getView().updateAuthorshipFields();
                     }
-                } else
-                if(boundTargetField.matchesPropertyIdPath("replacedSynonyms")){
-                    ReloadableLazyComboBox<TaxonName> replacedSynonyms = asReloadableLazyComboBox(boundTargetField.getField(TaxonName.class));
-                    if(event.isCreateOrModifiedType()){
+                } else if (boundTargetField.matchesPropertyIdPath("replacedSynonyms")) {
+                    ReloadableLazyComboBox<TaxonName> replacedSynonyms = asReloadableLazyComboBox(
+                            boundTargetField.getField(TaxonName.class));
+                    if (event.isCreateOrModifiedType()) {
                         getCache().load(event.getEntity());
-                        if(event.isCreatedType()){
-                            // TODO use reloadWith((TaxonName) event.getEntity()); also in this case?
-                            replacedSynonyms .setValue((TaxonName) event.getEntity());
+                        if (event.isCreatedType()) {
+                            // TODO use reloadWith((TaxonName)
+                            // event.getEntity()); also in this case?
+                            replacedSynonyms.setValue((TaxonName) event.getEntity());
                         } else {
                             replacedSynonyms.reloadWith((TaxonName) event.getEntity());
                         }
-                        getView().getExCombinationAuthorshipField().discard(); //refresh from the datasource
+                        getView().getExCombinationAuthorshipField().discard(); // refresh
+                                                                               // from
+                                                                               // the
+                                                                               // datasource
                         getView().updateAuthorshipFields();
-                    } else
-                    if(event.isRemovedType()){
+                    } else if (event.isRemovedType()) {
                         replacedSynonyms.setValue(null);
                         getView().updateAuthorshipFields();
                     }
@@ -633,33 +722,34 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
         }
     }
 
-    protected <CDM extends CdmBase> ReloadableLazyComboBox<CDM> asReloadableLazyComboBox(Field<CDM> field){
+    protected <CDM extends CdmBase> ReloadableLazyComboBox<CDM> asReloadableLazyComboBox(Field<CDM> field) {
 
-        if(field instanceof ToOneRelatedEntityCombobox){
-            field = ((ToOneRelatedEntityCombobox<CDM>)field).getSelect();
+        if (field instanceof ToOneRelatedEntityCombobox) {
+            field = ((ToOneRelatedEntityCombobox<CDM>) field).getSelect();
         }
-        return (ReloadableLazyComboBox<CDM>)field;
+        return (ReloadableLazyComboBox<CDM>) field;
     }
 
-
-
     @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
     public void onTaxonNameEditorActionEdit(TaxonNameEditorAction event) {
 
-        if(getView() == null || event.getSourceView() != getView() ){
+        if (getView() == null || event.getSourceView() != getView()) {
             return;
         }
 
         PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
 
-        if(boundPropertyId != null){
-            if(boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms") || boundPropertyId.matches("replacedSynonyms")  || boundPropertyId.matches("orthographicVariant.otherName")){
+        if (boundPropertyId != null) {
+            if (boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms")
+                    || boundPropertyId.matches("replacedSynonyms")
+                    || boundPropertyId.matches("orthographicVariant.otherName")) {
                 TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
                 namePopup.withDeleteButton(true);
                 getView().getModesActive().stream()
-                    .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
-                    .forEach(m -> namePopup.enableMode(m));
-                if(boundPropertyId.matches("orthographicVariant.otherName") && getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)){
+                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
+                        .forEach(m -> namePopup.enableMode(m));
+                if (boundPropertyId.matches("orthographicVariant.otherName")
+                        && getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)) {
                     namePopup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
                     namePopup.disableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
                     namePopup.getOrthographicVariantToggle().setVisible(false);
@@ -672,19 +762,19 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     @EventBusListenerMethod(filter = EditorActionTypeFilter.Edit.class)
     public void onTaxonNameEditorActionStrRepEdit(TaxonNameEditorActionStrRep event) {
 
-        if(getView() == null || event.getSourceView() != getView() ){
+        if (getView() == null || event.getSourceView() != getView()) {
             return;
         }
 
         PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
 
-        if(boundPropertyId != null){
-            if(boundPropertyId.matches("genusOrUninomial") || boundPropertyId.matches("specificEpithet")){
+        if (boundPropertyId != null) {
+            if (boundPropertyId.matches("genusOrUninomial") || boundPropertyId.matches("specificEpithet")) {
                 TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
                 namePopup.withDeleteButton(true);
                 getView().getModesActive().stream()
-                    .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
-                    .forEach(m -> namePopup.enableMode(m));
+                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
+                        .forEach(m -> namePopup.enableMode(m));
                 namePopup.loadInEditor(event.getEntityUuid());
             }
         }
@@ -693,30 +783,36 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
     public void onTaxonNameEditorActionAdd(TaxonNameEditorAction event) {
 
-        if(getView() == null || event.getSourceView() != getView() ){
+        if (getView() == null || event.getSourceView() != getView()) {
             return;
         }
 
         PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
 
-        if(boundPropertyId != null){
-            if(boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms") || boundPropertyId.matches("replacedSynonyms") || boundPropertyId.matches("orthographicVariant.otherName")){
+        if (boundPropertyId != null) {
+            if (boundPropertyId.matches("validationFor.otherName") || boundPropertyId.matches("basionyms")
+                    || boundPropertyId.matches("replacedSynonyms")
+                    || boundPropertyId.matches("orthographicVariant.otherName")) {
                 TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
                 namePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
                 namePopup.withDeleteButton(true);
                 getView().getModesActive().stream()
                         .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
                         .forEach(m -> namePopup.enableMode(m));
-                if(boundPropertyId.matches("orthographicVariant.otherName") && getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)){
+                if (boundPropertyId.matches("orthographicVariant.otherName")
+                        && getView().isModeEnabled(TaxonNamePopupEditorMode.ORTHOGRAPHIC_CORRECTION)) {
                     namePopup.enableMode(TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY);
                     namePopup.disableMode(TaxonNamePopupEditorMode.VALIDATE_AGAINST_HIGHER_NAME_PART);
-                    Reference nomrefPreset = (Reference)((AbstractPopupEditor<TaxonNameDTO, TaxonNameEditorPresenter>)getView()).getBean().getNomenclaturalReference();
+                    Reference nomrefPreset = (Reference) ((AbstractPopupEditor<TaxonNameDTO, TaxonNameEditorPresenter>) getView())
+                            .getBean().getNomenclaturalReference();
                     namePopup.setCdmEntityInstantiator(new BeanInstantiator<TaxonName>() {
 
                         @Override
                         public TaxonName createNewBean() {
-                            TaxonName newTaxonName = TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
-                            newTaxonName.setNomenclaturalReference(getRepo().getReferenceService().load(nomrefPreset.getUuid(), TaxonNameEditorPresenter.REFERENCE_INIT_STRATEGY ));
+                            TaxonName newTaxonName = TaxonNameFactory
+                                    .NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
+                            newTaxonName.setNomenclaturalReference(getRepo().getReferenceService()
+                                    .load(nomrefPreset.getUuid(), TaxonNameEditorPresenter.REFERENCE_INIT_STRATEGY));
                             return newTaxonName;
                         }
                     });
@@ -730,37 +826,38 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
     @EventBusListenerMethod(filter = EditorActionTypeFilter.Add.class)
     public void onTaxonNameEditorActionStrRepAdd(TaxonNameEditorActionStrRep event) {
 
-        if(getView() == null || event.getSourceView() != getView() ){
+        if (getView() == null || event.getSourceView() != getView()) {
             return;
         }
 
         PropertyIdPath boundPropertyId = boundPropertyIdPath(event.getTarget());
 
-        if(boundPropertyId != null){
-            if(boundPropertyId.matches("genusOrUninomial") || boundPropertyId.matches("specificEpithet")){
+        if (boundPropertyId != null) {
+            if (boundPropertyId.matches("genusOrUninomial") || boundPropertyId.matches("specificEpithet")) {
                 TaxonNamePopupEditor namePopup = openPopupEditor(TaxonNamePopupEditor.class, event);
                 namePopup.grantToCurrentUser(EnumSet.of(CRUD.UPDATE, CRUD.DELETE));
                 namePopup.withDeleteButton(true);
                 getView().getModesActive().stream()
-                .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
-                .forEach(m -> namePopup.enableMode(m));
+                        .filter(m -> !TaxonNamePopupEditorMode.NOMENCLATURALREFERENCE_SECTION_EDITING_ONLY.equals(m))
+                        .forEach(m -> namePopup.enableMode(m));
                 namePopup.loadInEditor(null);
-                if(boundPropertyId.matches("genusOrUninomial")){
+                if (boundPropertyId.matches("genusOrUninomial")) {
                     namePopup.getRankSelect().setValue(Rank.GENUS());
                 }
-                if(boundPropertyId.matches("specificEpithet")){
+                if (boundPropertyId.matches("specificEpithet")) {
                     namePopup.getGenusOrUninomialField().setValue(getView().getGenusOrUninomialField().getValue());
                     namePopup.getRankSelect().setValue(Rank.SPECIES());
                 }
-                if(WeaklyRelatedEntityField.class.isAssignableFrom(event.getTarget().getClass())){
-                    WeaklyRelatedEntityField<TaxonName> taxoNameField = (WeaklyRelatedEntityField<TaxonName>)event.getTarget();
-                    if(!taxoNameField.isValueInOptions()){
+                if (WeaklyRelatedEntityField.class.isAssignableFrom(event.getTarget().getClass())) {
+                    WeaklyRelatedEntityField<TaxonName> taxoNameField = (WeaklyRelatedEntityField<TaxonName>) event
+                            .getTarget();
+                    if (!taxoNameField.isValueInOptions()) {
                         String nameString = event.getTarget().getValue();
-                        if(StringUtils.isNotEmpty(nameString)){
-                            if(boundPropertyId.matches("genusOrUninomial")){
+                        if (StringUtils.isNotEmpty(nameString)) {
+                            if (boundPropertyId.matches("genusOrUninomial")) {
                                 namePopup.getGenusOrUninomialField().setValue(nameString);
                             }
-                            if(boundPropertyId.matches("specificEpithet")){
+                            if (boundPropertyId.matches("specificEpithet")) {
                                 namePopup.getSpecificEpithetField().setValue(nameString);
                             }
                         }
@@ -787,12 +884,9 @@ public class TaxonNameEditorPresenter extends AbstractCdmDTOEditorPresenter<Taxo
 
             @Override
             public TaxonName createNewBean() {
-                return  TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
+                return TaxonNameFactory.NewNameInstance(RegistrationUIDefaults.NOMENCLATURAL_CODE, Rank.SPECIES());
             }
         };
     }
 
-
-
-
 }
index dc22750ba31d6f879b19a3fd9424f6a950e23022..9b567b81dd2aaebd5c92d575c5f939d25c78f574 100644 (file)
@@ -41,7 +41,6 @@ import eu.etaxonomy.cdm.model.common.AnnotationType;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.RelationshipBase.Direction;
 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.RankClass;
 import eu.etaxonomy.cdm.model.name.TaxonName;
@@ -55,6 +54,7 @@ import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorActionStrRep;
 import eu.etaxonomy.cdm.vaadin.model.name.NameRelationshipDTO;
+import eu.etaxonomy.cdm.vaadin.model.name.NomenclaturalStatusDTO;
 import eu.etaxonomy.cdm.vaadin.model.name.TaxonNameDTO;
 import eu.etaxonomy.cdm.vaadin.permission.CdmEditDeletePermissionTester;
 import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
@@ -116,7 +116,7 @@ public class TaxonNamePopupEditor extends AbstractCdmDTOPopupEditor<TaxonNameDTO
 
     private NameRelationField orthographicVariantField;
 
-    private ElementCollectionField<NomenclaturalStatus> nomStatusCollectionField;
+    private ElementCollectionField<NomenclaturalStatusDTO> nomStatusCollectionField;
 
     private CheckBox basionymToggle;
 
@@ -354,14 +354,14 @@ public class TaxonNamePopupEditor extends AbstractCdmDTOPopupEditor<TaxonNameDTO
 
         // --------------- nom status
         row++;
-        nomStatusCollectionField = new ElementCollectionField<NomenclaturalStatus>(
-                NomenclaturalStatus.class,
-                new Instantiator<NomenclaturalStatus>() {
+        nomStatusCollectionField = new ElementCollectionField<NomenclaturalStatusDTO>(
+                NomenclaturalStatusDTO.class,
+                new Instantiator<NomenclaturalStatusDTO>() {
                     private static final long serialVersionUID = -2427045940046513092L;
 
                     @Override
-                    public NomenclaturalStatus create() {
-                        return NomenclaturalStatus.NewInstance(null);
+                    public NomenclaturalStatusDTO create() {
+                        return NomenclaturalStatusDTO.newInstance();
                     }
                 },
                 NomenclaturalStatusRow.class
@@ -1095,7 +1095,7 @@ public class TaxonNamePopupEditor extends AbstractCdmDTOPopupEditor<TaxonNameDTO
     }
 
     @Override
-    public ElementCollectionField<NomenclaturalStatus> getNomStatusCollectionField(){
+    public ElementCollectionField<NomenclaturalStatusDTO> getNomStatusCollectionField(){
         return nomStatusCollectionField;
     }
 }
index f3af46aa4a0c325b183b76cc0a7cb5e2e0cae5d9..1c1d808f3f570c934c444a884fb4d6c7adc57cff 100644 (file)
@@ -18,14 +18,15 @@ import com.vaadin.ui.Component;
 import com.vaadin.ui.NativeSelect;
 import com.vaadin.ui.TextField;
 
-import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
 import eu.etaxonomy.cdm.model.name.TaxonName;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.vaadin.component.common.TeamOrPersonField;
+import eu.etaxonomy.cdm.vaadin.model.name.NomenclaturalStatusDTO;
 import eu.etaxonomy.cdm.vaadin.view.AnnotationsEditor;
 import eu.etaxonomy.vaadin.component.NameRelationField;
 import eu.etaxonomy.vaadin.component.ToManyRelatedEntitiesComboboxSelect;
 import eu.etaxonomy.vaadin.component.ToOneRelatedEntityCombobox;
+import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
 import eu.etaxonomy.vaadin.mvp.ApplicationView;
 
 /**
@@ -130,7 +131,7 @@ public interface TaxonNamePopupEditorView extends ApplicationView<TaxonNameEdito
      */
     TextField getNomenclaturalReferenceDetail();
 
-    ElementCollectionField<NomenclaturalStatus> getNomStatusCollectionField();
+    ElementCollectionField<NomenclaturalStatusDTO> getNomStatusCollectionField();
 
     /**
      * @param components