#5160 Use new merge method with ids as arguments
authorCherian Mathew <c.mathew@bgbm.org>
Tue, 25 Aug 2015 11:09:07 +0000 (13:09 +0200)
committerCherian Mathew <c.mathew@bgbm.org>
Tue, 25 Aug 2015 11:09:07 +0000 (13:09 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java

index 0c22bd9bd0dd58da6dda2cad74262458cf2ac08b..1f2f06e333a42e53417713b9c58f47d2fd6edbf6 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.ui.IPersistableElement;
 
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
+import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.ICdmBase;
 import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
 import eu.etaxonomy.cdm.model.common.MarkerType;
@@ -238,7 +239,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> extends CdmEnt
     public boolean merge(T entity, T mergeTarget) {
                if (entity instanceof IMergable) {
                        try {
-                               CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity);
+                               CdmStore.getCommonService().merge(mergeTarget.getId(), entity.getId(), (Class<? extends CdmBase>)entity.getClass());
                        } catch (MergeException e) {
                                MessagingUtils.errorDialog("Bulk Editor Merge Error",
                                                this,
index 6e52be2699e824f72e76cce95fc11db75a67aef4..83795a4aa5485383159f8584b6bb5f5af63f4ba6 100644 (file)
@@ -120,9 +120,15 @@ public class AgentEditorInput extends AbstractBulkEditorInput<TeamOrPersonBase>
     public boolean merge(TeamOrPersonBase entity, TeamOrPersonBase mergeTarget) {
                if (entity instanceof IMergable) {
                        try {
-                               IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(Person.class);
-                               strategy.setMergeMode("institutionalMemberships", MergeMode.FIRST);
-                               CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, Person.class);
+                               if(entity instanceof Person) {
+                                   IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(Person.class);
+                                   strategy.setMergeMode("institutionalMemberships", MergeMode.FIRST);
+                                   CdmStore.getCommonService().merge(mergeTarget.getId(), entity.getId(), Person.class);
+                               } else {
+                                   IMergeStrategy strategy = DefaultMergeStrategy.NewInstance(TeamOrPersonBase.class);
+                                   CdmStore.getCommonService().merge(mergeTarget.getId(), entity.getId(), TeamOrPersonBase.class);
+                               }
+
                        } catch (MergeException e) {
                                MessagingUtils.errorDialog("Bulk Editor Merge Error",
                                                this,