commit 26cc98f0fe93d159407c4ee093034ae1360b6755
Author: Katja Luther <k.luther@bgbm.org>
Date:   Wed Jun 13 12:54:28 2018 +0200

    fix #7472: fix lazy loading exceptions for MAN with type specimen

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
index f0627bdc6..c57ca2576 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/e4/TaxonEditorInputE4.java
@@ -67,10 +67,10 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
 
     private TaxonNode taxonNode;
 
-    private Map<TaxonBase, TaxonBaseDeletionConfigurator> toDelete = new HashMap<>();
-    private Set<Synonym> toSaveNewSynonym = new HashSet<>();
-    private Set<TaxonBase> toSaveNewConcept = new HashSet<>();
-    private Set<TaxonName> toSaveNewName = new HashSet<>();
+    private Map<TaxonBase, TaxonBaseDeletionConfigurator> toDeletes = new HashMap<>();
+    private Set<Synonym> toSaveNewSynonyms = new HashSet<>();
+    private Set<TaxonBase> toSaveNewConcepts = new HashSet<>();
+    private Set<TaxonName> toSaveNewNames = new HashSet<>();
 
 
     private Set<AbstractPostTaxonOperation> operations = new HashSet<>();
@@ -307,10 +307,12 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
     }
 
     public void addToSaveNewSynonym(Synonym toSaveNew) {
-        this.toSaveNewSynonym.add(toSaveNew);
+        this.toSaveNewSynonyms.add(toSaveNew);
     }
     public void addToSaveNewConcept(Taxon toSaveNew) {
-        this.toSaveNewConcept.add(toSaveNew);
+        if (!toSaveNew.isPersited()){
+            this.toSaveNewConcepts.add(toSaveNew);
+        }
     }
 
     @Override
@@ -323,43 +325,43 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
         if (!this.getCdmEntitySession().isActive()){
             this.getCdmEntitySession().bind();
         }
-        for(Entry<TaxonBase, TaxonBaseDeletionConfigurator> entry:toDelete.entrySet()){
+        for(Entry<TaxonBase, TaxonBaseDeletionConfigurator> entry:toDeletes.entrySet()){
             delete(entry.getKey(), entry.getValue());
         }
-        toDelete.clear();
+        toDeletes.clear();
         for(AbstractPostOperation entry:operations){
             EditorUtil.executeOperation(entry,sync);
         }
         operations.clear();
 
-        for (Synonym syn: toSaveNewSynonym){
+        for (Synonym syn: toSaveNewSynonyms){
             for (HybridRelationship rel : syn.getName().getHybridChildRelations()){
                 if (!rel.getParentName().isPersited()) {
-                    toSaveNewName.add(rel.getParentName());
+                    toSaveNewNames.add(rel.getParentName());
                 }
                     if (!rel.getHybridName().isPersited()) {
-                   toSaveNewName.add(rel.getHybridName());
+                   toSaveNewNames.add(rel.getHybridName());
                 }
 
             }
         }
 
-        for (TaxonBase concept: toSaveNewConcept){
+        for (TaxonBase concept: toSaveNewConcepts){
             for (HybridRelationship rel : concept.getName().getHybridChildRelations()){
                 if (!rel.getParentName().isPersited()) {
-                    toSaveNewName.add(rel.getParentName());
+                    toSaveNewNames.add(rel.getParentName());
                 }
                 if (!rel.getHybridName().isPersited()) {
-                    toSaveNewName.add(rel.getHybridName());
+                    toSaveNewNames.add(rel.getHybridName());
                 }
 
             }
         }
-        CdmStore.getService(INameService.class).saveOrUpdate(toSaveNewName);
-        CdmStore.getService(ITaxonService.class).saveOrUpdate(toSaveNewConcept);
+        CdmStore.getService(INameService.class).save(toSaveNewNames);
+        CdmStore.getService(ITaxonService.class).save(toSaveNewConcepts);
 
-        toSaveNewName.clear();
-        toSaveNewConcept.clear();
+        toSaveNewNames.clear();
+        toSaveNewConcepts.clear();
 
         CdmStore.getService(ITaxonNodeService.class).merge(taxonNode, true);
 
@@ -404,16 +406,6 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
                 "sources", //$NON-NLS-1$
                 "identifiers",
                 "descriptions", //$NON-NLS-1$
-//                "relationsToThisTaxon.relatedFrom.name.taxonBases.taxonNodes", //$NON-NLS-1$
-//                "relationsToThisTaxon.relatedFrom.name.taxonBases.relationsFromThisTaxon", //$NON-NLS-1$
-//                "relationsToThisTaxon.relatedFrom.name.taxonBases.relationsToThisTaxon", //$NON-NLS-1$
-                "relationsToThisTaxon.relatedFrom.name.typeDesignations.typeSpecimen.derivedFrom.originals",//$NON-NLS-1$
-                "relationsToThisTaxon.relatedFrom.name.typeDesignations.typeName",//$NON-NLS-1$
-//                "relationsFromThisTaxon.relatedTo.name.taxonBases.taxonNodes", //$NON-NLS-1$
-//                "relationsFromThisTaxon.relatedTo.name.taxonBases.relationsFromThisTaxon", //$NON-NLS-1$
-//                "relationsFromThisTaxon.relatedTo.name.taxonBases.relationsToThisTaxon",
-                "relationsFromThisTaxon.relatedTo.name.typeDesignations.typeSpecimen.derivedFrom.originals",//$NON-NLS-1$
-                "relationsFromThisTaxon.relatedTo.name.typeDesignations.typeName",//$NON-NLS-1$
                 "taxonNodes", //$NON-NLS-1$
                 "descriptions.descriptionElements.feature", //$NON-NLS-1$
                 "descriptions.descriptionElements.area", //$NON-NLS-1$
@@ -432,8 +424,6 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
                 "synonyms.name.relationsToThisName.fromName", //$NON-NLS-1$
                 "synonyms.name.nomenclaturalReference.inReference.authorship", //$NON-NLS-1$
                 "synonyms.name.nomenclaturalReference.authorship", //$NON-NLS-1$
-//                "synonyms.name.homotypicalGroup", //$NON-NLS-1$
-//                "synonyms.synonym.name.homotypicalGroup.typifiedNames", //$NON-NLS-1$
                 "synonyms.name.homotypicalGroup.typifiedNames.taxonBases.synonyms" //$NON-NLS-1$
         });
 
@@ -445,7 +435,7 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
      * @param deleteConfig
      */
     public void addTaxonBaseToDelete(TaxonBase selectedElement, TaxonBaseDeletionConfigurator deleteConfig) {
-        this.toDelete.put(selectedElement, deleteConfig);
+        this.toDeletes.put(selectedElement, deleteConfig);
 
     }
 
@@ -453,7 +443,7 @@ public class TaxonEditorInputE4  extends CdmEntitySessionInput implements IConve
      * @param newName
      */
     public void addToSaveNewName(TaxonName newName) {
-        this.toSaveNewName.add(newName);
+        this.toSaveNewNames.add(newName);
     }
 
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java
index d07e797d0..87268dd0b 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/name/SpecimenTypeDesignationElement.java
@@ -9,12 +9,8 @@
 
 package eu.etaxonomy.taxeditor.ui.section.name;
 
-import java.util.Arrays;
-import java.util.List;
-
 import org.eclipse.swt.events.SelectionListener;
 
-import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.name.TypeDesignationStatusComparator;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.TermType;
@@ -22,7 +18,6 @@ import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation;
 import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
 import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
-import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.combo.TermComboElement;
 import eu.etaxonomy.taxeditor.ui.element.AbstractFormSection;
 import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
@@ -64,14 +59,9 @@ public class SpecimenTypeDesignationElement extends
 	/** {@inheritDoc} */
 	@Override
 	public void setEntity(SpecimenTypeDesignation entity) {
-	    List<String> prop = Arrays.asList(new String[] {
-	            "derivedFrom.originals",
-	            "descriptions"
-	    });
-
 	    super.setEntity(entity);
         if (entity.getTypeSpecimen() != null){
-            selection_typeSpecimen.setEntity((DerivedUnit)CdmStore.getService(IOccurrenceService.class).load(entity.getTypeSpecimen().getUuid(), prop));
+            selection_typeSpecimen.setEntity(entity.getTypeSpecimen());
         }else{
             selection_typeSpecimen.setEntity(entity.getTypeSpecimen());
         }
