commit 1dc37073556859ea37a848507732c6f35bb87889
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Aug 31 12:03:18 2018 +0200

    ref #7674 Create default taxon description when adding specimens

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
index 03f9fb3fe..3ad659476 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
@@ -97,6 +97,7 @@ import eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper;
 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
 import eu.etaxonomy.taxeditor.editor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.workbench.WorkbenchUtility;
 
@@ -664,4 +665,8 @@ public class CharacterMatrix extends Composite {
         return isShowTooltips;
     }
 
+    public ICdmEntitySession getCdmEntitiySession(){
+        return part.getCdmEntitySession();
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
index 92459f953..fe0599703 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixBottomToolbar.java
@@ -10,10 +10,8 @@ package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.UUID;
 import java.util.stream.Collectors;
 
@@ -32,9 +30,9 @@ import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
 import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
+import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
 import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.description.CategoricalData;
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.Feature;
 import eu.etaxonomy.cdm.model.description.QuantitativeData;
 import eu.etaxonomy.cdm.model.description.SpecimenDescription;
@@ -81,23 +79,25 @@ public class CharacterMatrixBottomToolbar extends Composite{
                 if(dialog.open()==Window.OK){
                     Collection<SpecimenNodeWrapper> wrappers = dialog.getSpecimen();
                     for (SpecimenNodeWrapper wrapper : wrappers) {
-                        SpecimenDescription description = CdmStore.getService(IDescriptiveDataSetService.class)
-                                .findDescriptionForDescriptiveDataSet(matrix.getDescriptiveDataSet().getUuid(),
+                        SpecimenDescription specimenDescription = CdmStore.getService(IDescriptiveDataSetService.class)
+                                .findSpecimenDescription(matrix.getDescriptiveDataSet().getUuid(),
                                         wrapper.getUuidAndTitleCache().getUuid());
-                        // description elements
-                        Map<Feature, DescriptionElementBase> featureToElementMap = new HashMap<>();
-                        Set<DescriptionElementBase> elements = description.getElements();
-                        for (DescriptionElementBase descriptionElementBase : elements) {
-                            Feature feature = descriptionElementBase.getFeature();
-                            featureToElementMap.put(feature, descriptionElementBase);
-                        }
-                        RowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createSpecimenRowWrapper(description, matrix.getDescriptiveDataSet());
+                        SpecimenRowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class)
+                                .createSpecimenRowWrapper(specimenDescription, matrix.getDescriptiveDataSet(), true);
                         if(rowWrapper==null){
-                            error += description;
+                            error += specimenDescription;
                             continue;
                         }
+                        //add specimen description
                         matrix.getDescriptions().add(rowWrapper);
-                        matrix.getDescriptiveDataSet().addDescription(description);
+                        matrix.getDescriptiveDataSet().addDescription(specimenDescription);
+                        matrix.getCdmEntitiySession().load(specimenDescription, true);
+
+                        //add taxon description
+                        TaxonRowWrapperDTO taxonDescription = rowWrapper.getDefaultTaxonDescription();
+                        matrix.getDescriptiveDataSet().addDescription(taxonDescription.getDescription());
+                        matrix.getCdmEntitiySession().load(taxonDescription.getDescription(), true);
+
                         matrix.setDirty();
                         matrix.getSpecimenCache().remove(wrapper);
                     }
