commit e15dfd39d00f03c158bd0911b0f32c1f96d9c9c8
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Wed Aug 22 17:50:01 2018 +0200

    ref #7674 Adapt to cdmlib change(Add aggregated description to data set)

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 a19893c3e..3e635267e 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
@@ -84,6 +84,7 @@ import ca.odell.glazedlists.TreeList;
 import eu.etaxonomy.cdm.api.service.IDescriptiveDataSetService;
 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.common.monitor.IRemotingProgressMonitor;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
@@ -130,8 +131,7 @@ public class CharacterMatrix extends Composite {
 
     private LinkedMap<String, String> propertyToLabelMap = new LinkedMap<>();
 
-    //FIXME use more concrete generic
-    private EventList<Object> descriptions;
+    private EventList<RowWrapperDTO> descriptions;
 
     private Collection<SpecimenNodeWrapper> specimenCache = null;
 
@@ -139,7 +139,7 @@ public class CharacterMatrix extends Composite {
 
     private Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap = new HashMap<>();
 
-    private ListDataProvider<Object> bodyDataProvider;
+    private ListDataProvider<RowWrapperDTO> bodyDataProvider;
 
     private FreezeLayer freezeLayer;
 
@@ -277,9 +277,9 @@ public class CharacterMatrix extends Composite {
     private void createLayers(boolean treeView) {
         // use the SortedList constructor with 'null' for the Comparator
         // because the Comparator will be set by configuration
-        SortedList<Object> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
+        SortedList<RowWrapperDTO> sortedList = new SortedList<>(descriptions, new MatrixRowComparator());
         // wrap the SortedList with the TreeList
-        TreeList<Object> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
+        TreeList<RowWrapperDTO> treeList = new TreeList(sortedList, new DescriptionTreeFormat(descriptiveDataSet), TreeList.NODES_START_EXPANDED);
         /**
          * data provider
          */
@@ -597,7 +597,7 @@ public class CharacterMatrix extends Composite {
         return natTable;
     }
 
-    public EventList<Object> getDescriptions() {
+    public EventList<RowWrapperDTO> getDescriptions() {
         return descriptions;
     }
 
@@ -614,7 +614,8 @@ public class CharacterMatrix extends Composite {
                 .filter(wrapper ->
         //map descriptions on a list of uuids of the described specimen
         !this.descriptions.stream()
-        .map(o->((RowWrapperDTO)o).getSpecimen().getUuid())
+        .filter(rowWrapper->rowWrapper instanceof SpecimenRowWrapperDTO)
+        .map(specimenRowWrapper->((SpecimenRowWrapperDTO) specimenRowWrapper).getSpecimen().getUuid())
         .collect(Collectors.toList())
         //an check if the specimen to add is already contained
         .contains(wrapper.getUuidAndTitleCache().getUuid())
@@ -626,7 +627,7 @@ public class CharacterMatrix extends Composite {
         return toolbar.getNatTableState();
     }
 
-    public ListDataProvider<Object> getBodyDataProvider() {
+    public ListDataProvider<RowWrapperDTO> getBodyDataProvider() {
         return bodyDataProvider;
     }
 
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 efe97e8fd..f0a559388 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
@@ -90,7 +90,7 @@ public class CharacterMatrixBottomToolbar extends Composite{
                             Feature feature = descriptionElementBase.getFeature();
                             featureToElementMap.put(feature, descriptionElementBase);
                         }
-                        RowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createRowWrapper(wrapper.getTaxonNode(), description, matrix.getDescriptiveDataSet());
+                        RowWrapperDTO rowWrapper = CdmStore.getService(IDescriptiveDataSetService.class).createSpecimenRowWrapper(description, matrix.getDescriptiveDataSet());
                         if(rowWrapper==null){
                             error += description;
                             continue;
@@ -161,7 +161,7 @@ public class CharacterMatrixBottomToolbar extends Composite{
                 }
                 List<UUID> descriptionUuids = new ArrayList<>();
                 matrix.getDescriptiveDataSet().getDescriptions().forEach(desc->descriptionUuids.add(desc.getUuid()));
-                UpdateResult result = CdmStore.getService(IDescriptionService.class).aggregateDescription(taxonUuid, descriptionUuids, matrix.getDescriptiveDataSet().getLabel());
+                UpdateResult result = CdmStore.getService(IDescriptionService.class).aggregateDescription(taxonUuid, descriptionUuids, matrix.getDescriptiveDataSet().getLabel(), matrix.getDescriptiveDataSet().getUuid());
                 matrix.addUpdateResult(result);
                 matrix.setDirty();
 
@@ -176,7 +176,7 @@ public class CharacterMatrixBottomToolbar extends Composite{
     private void aggregateCategorcialHistogram(Map<Feature, CategoricalDataHistogram> featureToHistogramMap) {
         featureToHistogramMap.clear();
         matrix.getDescriptions()
-                .forEach(o -> ((RowWrapperDTO) o).getSpecimenDescription().getElements().stream()
+                .forEach(o -> o.getSpecimenDescription().getElements().stream()
                         .filter(descriptionElement -> descriptionElement instanceof CategoricalData)
                         .forEach(categoricalData -> {
                             Feature feature = ((CategoricalData) categoricalData).getFeature();
@@ -194,7 +194,7 @@ public class CharacterMatrixBottomToolbar extends Composite{
     private void aggregateQuantitativeSummary(Map<Feature, QuantitativeDataStatistics> featureToQuantDataStatisticsMap) {
         featureToQuantDataStatisticsMap.clear();
         matrix.getDescriptions()
-        .forEach(o -> ((RowWrapperDTO) o).getSpecimenDescription().getElements().stream()
+        .forEach(o -> o.getSpecimenDescription().getElements().stream()
                 .filter(descriptionElement -> descriptionElement instanceof QuantitativeData)
                 .forEach(quantData -> {
                     Feature feature = ((QuantitativeData) quantData).getFeature();
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java
index 506a3af91..88283f4e2 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/SpecimenColumnPropertyAccessor.java
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
 import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
 
 import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
+import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
 import eu.etaxonomy.cdm.model.description.Feature;
 
 /**
@@ -20,7 +21,7 @@ import eu.etaxonomy.cdm.model.description.Feature;
  * @since Nov 26, 2017
  *
  */
-public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<Object>{
+public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<RowWrapperDTO>{
 
     private CharacterMatrix matrix;
 
@@ -33,9 +34,9 @@ public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<O
      * {@inheritDoc}
      */
     @Override
-    public Object getDataValue(Object rowObject, int columnIndex) {
-        if(rowObject instanceof RowWrapperDTO){
-            RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject;
+    public Object getDataValue(RowWrapperDTO rowObject, int columnIndex) {
+        if(rowObject instanceof SpecimenRowWrapperDTO){
+            SpecimenRowWrapperDTO rowWrapper = (SpecimenRowWrapperDTO) rowObject;
             switch (columnIndex) {
             case 0:
                 if(matrix.isTreeView()){
@@ -66,12 +67,10 @@ public class SpecimenColumnPropertyAccessor implements IColumnPropertyAccessor<O
      * {@inheritDoc}
      */
     @Override
-    public void setDataValue(Object rowObject, int columnIndex, Object newValue) {
-        if(rowObject instanceof RowWrapperDTO){
-            RowWrapperDTO rowWrapper = (RowWrapperDTO)rowObject;
-            Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
-            rowWrapper.setDataValueForFeature(feature, newValue);
-        }
+    public void setDataValue(RowWrapperDTO rowObject, int columnIndex, Object newValue) {
+        RowWrapperDTO rowWrapper = rowObject;
+        Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
+        rowWrapper.setDataValueForFeature(feature, newValue);
     }
 
     /**
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/AggregateTaxonDescriptionsHandler.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/AggregateTaxonDescriptionsHandler.java
index 1bd2c51f4..718c7f945 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/AggregateTaxonDescriptionsHandler.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/e4/handler/AggregateTaxonDescriptionsHandler.java
@@ -17,7 +17,6 @@ import org.eclipse.swt.widgets.Shell;
 import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
-import eu.etaxonomy.taxeditor.navigation.navigator.operation.AggregateTaxonDescriptionsOperation;
 import eu.etaxonomy.taxeditor.operation.e4.RemotingCdmHandlerE4;
 
 public class AggregateTaxonDescriptionsHandler extends RemotingCdmHandlerE4 {
@@ -51,10 +50,12 @@ public class AggregateTaxonDescriptionsHandler extends RemotingCdmHandlerE4 {
             MPart activePart,
             MHandledMenuItem menuItem) {
 
-      return new AggregateTaxonDescriptionsOperation(getTrigger(),
-              false,
-              ((TaxonNodeDto) selection.getFirstElement()).getUuid()
-              );
+        //FIXME: this handler will probably be removed and secondary aggregation will be handled in the matrix editor
+      return null;
+//              new AggregateTaxonDescriptionsOperation(getTrigger(),
+//              false,
+//              ((TaxonNodeDto) selection.getFirstElement()).getUuid()
+//              );
     }
 
     @CanExecute
diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/AggregateTaxonDescriptionsOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/AggregateTaxonDescriptionsOperation.java
index 5247dc1f3..5a721df00 100644
--- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/AggregateTaxonDescriptionsOperation.java
+++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/AggregateTaxonDescriptionsOperation.java
@@ -16,13 +16,11 @@ import org.eclipse.swt.widgets.Display;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
-import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
 import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.common.monitor.IRemotingProgressMonitor;
 import eu.etaxonomy.taxeditor.event.EventUtility;
 import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
-import eu.etaxonomy.taxeditor.navigation.navigator.e4.TaxonNavigatorE4;
 import eu.etaxonomy.taxeditor.operation.IPostMoniteredOperationEnabled;
 import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
 
@@ -35,13 +33,17 @@ import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
 public class AggregateTaxonDescriptionsOperation extends RemotingCdmUpdateOperation implements IPostMoniteredOperationEnabled {
 
     private UUID nodeUuid;
+    private UUID descriptiveDataSetUuid;
     private UUID monitorUuid;
 
     public AggregateTaxonDescriptionsOperation(Object source,
             boolean async,
-            UUID nodeUuid) {
+            UUID nodeUuid,
+            UUID descriptiveDataSetUuid
+            ) {
         super("Aggregate taxon descriptions", Action.Update, source,async);
         this.nodeUuid = nodeUuid;
+        this.descriptiveDataSetUuid = descriptiveDataSetUuid;
 
     }
 
@@ -52,7 +54,7 @@ public class AggregateTaxonDescriptionsOperation extends RemotingCdmUpdateOperat
     }
 
     public void runMoniteredOperation() {
-        monitorUuid = CdmApplicationState.getLongRunningTasksService().aggregateComputedTaxonDescriptions(nodeUuid);
+        monitorUuid = CdmApplicationState.getLongRunningTasksService().aggregateComputedTaxonDescriptions(nodeUuid, descriptiveDataSetUuid);
 
                 Display.getDefault().asyncExec(new Runnable() {
                     @Override
