#5160 Use new merge method with ids as arguments
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / input / AbstractBulkEditorInput.java
index 5a7cccc119a7ae8ca03599d85595af7a614f2c8a..8cf5d3357e22a6ace1df8b40854e94f5ff703179 100644 (file)
@@ -22,6 +22,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;
@@ -52,7 +53,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
        private List<T> model;
 
        private IEntityCreator<T> entityCreator;
-       
+
        private static Class serviceClass;
 
        /**
@@ -62,7 +63,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
         * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object.
         */
        static public AbstractBulkEditorInput NewInstance(BulkEditorInputType inputType) {
-               
+
                return BulkEditorInputType.getInput(inputType);
        }
 
@@ -99,7 +100,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
         * @return a T object.
         */
        protected T loadEntity(UUID entityUuid) {
-               List<String> propertyPaths = Arrays.asList(new String[]{}); 
+               List<String> propertyPaths = Arrays.asList(new String[]{});
                return (T) CdmStore.getService(serviceClass).load(entityUuid, propertyPaths);
        }
 
@@ -179,7 +180,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
 
                if(getEntityUuid() != null){
 
-                       T entity = (T) loadEntity(getEntityUuid());
+                       T entity = loadEntity(getEntityUuid());
                        entityList.add(entity);
                        model = entityList;
                }
@@ -191,7 +192,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
                        entityList = listEntities(configurator);
 
                        Collections.sort(entityList, queryComparator);
-                       
+
 
                }
 
@@ -207,6 +208,14 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
                return false;
        }
 
+       /**
+        * <p>isMergingEnabled</p>
+        *
+        * @return a boolean.
+        */
+       public boolean isConvertingEnabled() {
+               return false;
+       }
        /**
         * <p>isMarkerTypeEditingEnabled</p>
         *
@@ -217,16 +226,13 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
                return false;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#merge(eu.etaxonomy.cdm.model.common.IdentifiableEntity, eu.etaxonomy.cdm.model.common.IdentifiableEntity)
-        */
+
        /** {@inheritDoc} */
        @Override
     public boolean merge(T entity, T mergeTarget) {
                if (entity instanceof IMergable) {
                        try {
-                               CdmStore.getCommonService().merge((IMergable)mergeTarget, (IMergable)entity, null);                             
+                               CdmStore.getCommonService().merge(mergeTarget.getId(), entity.getId(), (Class<? extends CdmBase>)entity.getClass());
                        } catch (MergeException e) {
                                MessagingUtils.errorDialog("Bulk Editor Merge Error",
                                                this,
@@ -239,10 +245,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
                return true;
        }
 
-       /*
-        * (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#create(eu.etaxonomy.cdm.model.common.IdentifiableEntity)
-        */
+
        /** {@inheritDoc} */
        @Override
     public boolean create(T entity) {
@@ -277,7 +280,7 @@ public abstract class AbstractBulkEditorInput<T extends ICdmBase> implements IEd
         * Returns a textual representation given object. The default implementation
         * in the abstract base class returns the simple name of the class, this may
         * be overwritten to something more specific in subclasses.
-        * 
+        *
         * @param entity
         * @return a textual representation given object.
         */