commit 92749440c55d13272b4d45fee634d44c0db26dc0
Author: Katja Luther <k.luther@bgbm.org>
Date:   Mon Apr 8 11:47:58 2019 +0200

    fix #8111: fix saving problem for members in group

diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
index bd410b50a..c7fcea8af 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java
@@ -36,6 +36,8 @@ import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.common.CdmBase;
+import eu.etaxonomy.cdm.model.common.Group;
+import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.description.DescriptionBase;
 import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
 import eu.etaxonomy.cdm.model.description.TaxonDescription;
@@ -47,6 +49,7 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.bulkeditor.BulkEditorQuery;
 import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
+import eu.etaxonomy.taxeditor.bulkeditor.input.GroupEditorInput;
 import eu.etaxonomy.taxeditor.bulkeditor.input.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.editor.ITaxonEditor;
 import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
@@ -252,6 +255,11 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
                     getEditorInput().addSaveCandidate(changedTaxon);
                     input.replaceInModel(changedTaxon);
                 }
+            }else if(element instanceof Group){
+                 Group oldGroup = ((GroupEditorInput)input).getEntityFromModel((Group)element);
+                 ((GroupEditorInput)input).getSaveUserCandidates().addAll(oldGroup.getMembers());
+                 getEditorInput().addSaveCandidate((Group)element);
+                 input.replaceInModel((CdmBase) element);
             }else{
                 getEditorInput().addSaveCandidate((CdmBase)element);
                 input.replaceInModel((CdmBase) element);
@@ -324,4 +332,12 @@ public class BulkEditorE4 implements IPartContentHasDetails, IConversationEnable
         }
     }
 
+    @Inject
+    @Optional
+    private void updatefromDelete(@UIEventTopic(WorkbenchEventConstants.REMOVE_USER) User user) {
+        if (input instanceof GroupEditorInput){
+            ((GroupEditorInput)input).getSaveUserCandidates().add(user);
+        }
+    }
+
 }
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
index 03917cc57..6499a1ae1 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
@@ -32,6 +32,7 @@ import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.MarkerType;
+import eu.etaxonomy.cdm.persistence.dto.MergeResult;
 import eu.etaxonomy.cdm.strategy.merge.IMergable;
 import eu.etaxonomy.cdm.strategy.merge.MergeException;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
@@ -357,7 +358,13 @@ public abstract class AbstractBulkEditorInput<T extends CdmBase> extends CdmEnti
             }
 	    }
 	    if (!saveCandidates.isEmpty()){
-	        CdmStore.getService(saveCandidates.iterator().next()).merge(new ArrayList<>(saveCandidates), true);
+	        List<MergeResult<T>> results = CdmStore.getService(saveCandidates.iterator().next()).merge(new ArrayList<>(saveCandidates), true);
+	        for (MergeResult<T> result: results){
+	            if (result.getMergedEntity() != null){
+	                T entitiy = result.getMergedEntity();
+	            }
+
+	        }
         }
 	    if(resetMerge){
 	        //merge entities
diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
index ab53b8584..b7100b6fb 100644
--- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
+++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
@@ -12,15 +12,19 @@ package eu.etaxonomy.taxeditor.bulkeditor.input;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Comparator;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.IGroupService;
+import eu.etaxonomy.cdm.api.service.IUserService;
 import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
 import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.common.Group;
+import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.persistence.query.OrderHint;
 import eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
@@ -38,6 +42,8 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
 	public static final String ID = "bulkeditor.input.group";
 
 	private static GroupEditorInput instance;
+	private Set<User> saveUserCandidates = new HashSet<>();
+
 
 	public static GroupEditorInput getInstance() {
 		if(instance == null){
@@ -107,4 +113,26 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
         return new GroupNameComparator();
     }
 
+	@Override
+    public void saveModel(boolean resetMerge){
+        super.saveModel(resetMerge);
+        if (!saveUserCandidates.isEmpty()){
+            CdmStore.getService(IUserService.class).merge(new ArrayList<>(saveUserCandidates), true);
+        }
+        saveUserCandidates.clear();
+    }
+
+	public Group getEntityFromModel(Group group){
+	    return this.getModel().get(this.getModel().indexOf(group));
+	}
+
+    public Set<User> getSaveUserCandidates() {
+        return saveUserCandidates;
+    }
+
+    public void setSaveUserCandidates(Set<User> saveUserCandidates) {
+        this.saveUserCandidates = saveUserCandidates;
+    }
+
+
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
index 87ab0683d..6daec0860 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/event/WorkbenchEventConstants.java
@@ -39,4 +39,6 @@ public interface WorkbenchEventConstants {
 
     public static final String REFRESH_DETAILS = "REFRESH/DETAILS/DISTRIBUTION";
 
+    public static final String REMOVE_USER = "UPDATE/GROUP/REMOVEUSER";
+
 }
