ref #7854: fix problem of wrong setting of values in other cell
authorKatja Luther <k.luther@bgbm.org>
Thu, 31 Jan 2019 14:11:05 +0000 (15:11 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 31 Jan 2019 14:15:01 +0000 (15:15 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionCellSelectionListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionColumnAccessor.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/DistributionEditorPart.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/checklist/e4/StatusDataCellEditor.java

index db8ff4b937e32ebbfee3b99f341ee24a607ddcfb..8681f7bd9f078aaa2e39751c6b55959f25c2d368 100755 (executable)
@@ -71,7 +71,8 @@ public class DistributionCellSelectionListener extends E4SelectionListener<Taxon
                     return;
                 }
             }
-        }else if (event instanceof CellVisualChangeEvent){
+        }
+        else if (event instanceof CellVisualChangeEvent){
             CellVisualChangeEvent cellSelectionEvent = (CellVisualChangeEvent)event;
             int columnPosition = cellSelectionEvent.getColumnPosition();
             int rowPosition = cellSelectionEvent.getRowPosition();
index 05e3f374487fed1d0965e498f6f49f27a5839290..c084e4d6af7e1c2d85fc859406bacaba2b39de16 100755 (executable)
@@ -117,6 +117,7 @@ public class DistributionColumnAccessor implements IColumnPropertyAccessor<Taxon
      */
     @Override
     public void setDataValue(TaxonDistributionDTO taxonWrapper, int columnIndex, Object newValue) {
+        System.err.println("DistributionColumnAccessor: " + taxonWrapper.getNameCache());
            if (newValue instanceof PresenceAbsenceTerm){
                 NamedArea area =editor.getAreaToColumnIndexMap().get(columnIndex);
                 Map<NamedArea, Set<DescriptionElementBase>> distributionMap = editor.taxonDistributionMap.get(taxonWrapper.getTaxonUuid());
@@ -154,7 +155,9 @@ public class DistributionColumnAccessor implements IColumnPropertyAccessor<Taxon
                       dist.addSource(DescriptionElementSource.NewPrimarySourceInstance(editor.getDefaultSource(), null));
                     }
                     desc.addElement(dist);
-                    editor.part.getCdmEntitySession().load(desc, true);
+                    if(desc.isPersited()){
+                        editor.part.getCdmEntitySession().load(desc, true);
+                    }
                     distributions.add(dist);
 
 
index eca27b12162279a5ab1fdb2c287d28a9bf9b2361..ced9a80dc47bd77efc74c4cf13796f6468bedcb9 100755 (executable)
@@ -231,6 +231,7 @@ ICdmEntitySessionEnabled, IPartContentHasSupplementalData, IPartContentHasDetail
     protected void saveDistributions() {
         Set<TaxonDistributionDTO> coll = new HashSet();
         editor.getDescriptionsToSave().forEach(dto->coll.add(dto));
+        Set<TaxonDistributionDTO> removeList = new HashSet();
         for (TaxonDistributionDTO dto: coll){
             Taxon taxon = null;
             for(TaxonDescription desc: dto.getDescriptionsWrapper().getDescriptions()){
@@ -241,11 +242,13 @@ ICdmEntitySessionEnabled, IPartContentHasSupplementalData, IPartContentHasDetail
                     taxon.addDescription(desc);
                 }
                 if (taxon != null){
-                    CdmStore.getService(ITaxonService.class).merge(taxon, true);
+                    MergeResult result = CdmStore.getService(ITaxonService.class).merge(taxon, true);
+                    boolean removed = dto.getDescriptionsWrapper().getDescriptions().remove(desc);
+                    System.err.println("removed:"  + removed);
                 }
             }
         }
-
+        coll.removeAll(removeList);
         List<MergeResult<DescriptionBase>> result = CdmStore.getService(IDescriptionService.class).mergeDescriptionElements(coll, true);
         for (MergeResult<DescriptionBase> mergeRes: result ){
             cdmEntitySession.load(mergeRes, true);
index 26600f54da83db67de744fe0fd8895b73c4bd795..c3aa058d4b346e9c0a6949da1d55fa08f733c207 100755 (executable)
@@ -49,6 +49,7 @@ public class StatusDataCellEditor extends ComboBoxCellEditor {
             Object rowWrapper = editor.getBodyDataProvider().getRowObject(this.getRowIndex());
             if(rowWrapper instanceof TaxonDistributionDTO){
                 NamedArea area = editor.getAreaToColumnIndexMap().get(getColumnIndex());
+                System.err.println("StatusDataCellEditor: " + ((TaxonDistributionDTO)rowWrapper).getNameCache());
                 Map<NamedArea, Set<DescriptionElementBase>> distributionMap = editor.taxonDistributionMap.get(((TaxonDistributionDTO) rowWrapper).getTaxonUuid());
                 if (distributionMap == null){
                     distributionMap = new HashMap();
@@ -60,7 +61,7 @@ public class StatusDataCellEditor extends ComboBoxCellEditor {
                 }else if (elements.size() == 1){
                     DescriptionElementBase base = elements.iterator().next();
                     Distribution distr = (Distribution) base;
-                    editor.descriptionsToSave.add( (TaxonDistributionDTO) rowWrapper);
+                    //editor.descriptionsToSave.add( (TaxonDistributionDTO) rowWrapper);
                     //TODO set value corresponding to preference
                     if (distr.getStatus() != null){
                         if (distr.getStatus().getLabel() == ""){