X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/blobdiff_plain/0bb254eee1359f0a18ffefd168cba579584c3768..efc9727aec13c9cb232d941f060104968a04f53c:/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java 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 8cf5d3357..d57ea6866 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 @@ -10,16 +10,17 @@ package eu.etaxonomy.taxeditor.bulkeditor.input; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Map; import java.util.UUID; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IPersistableElement; +import eu.etaxonomy.cdm.api.conversation.ConversationHolder; import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator; import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; import eu.etaxonomy.cdm.model.common.CdmBase; @@ -35,47 +36,38 @@ import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider; import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.CdmBaseSortProvider; import eu.etaxonomy.taxeditor.bulkeditor.input.sortprovider.TitleCacheComparator; import eu.etaxonomy.taxeditor.bulkeditor.internal.TaxeditorBulkeditorPlugin; +import eu.etaxonomy.taxeditor.editor.CdmEntitySessionInput; import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.store.CdmStore; /** - *

Abstract AbstractBulkEditorInput class.

- * * @author p.ciardelli * @created 25.06.2009 * @version 1.0 * @param */ -public abstract class AbstractBulkEditorInput implements IEditorInput, IEntityPersistenceService { +public abstract class AbstractBulkEditorInput extends CdmEntitySessionInput implements IEditorInput , + IEntityPersistenceService { private UUID entityUuid; private List model; private IEntityCreator entityCreator; + private final ConversationHolder conversation; - private static Class serviceClass; + public AbstractBulkEditorInput() { + super(true); + this.conversation = CdmStore.createConversation(); + } - /** - *

NewInstance

- * - * @param inputType a {@link eu.etaxonomy.taxeditor.bulkeditor.input.BulkEditorInputTypeValues.BulkEditorInputType} object. - * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object. - */ static public AbstractBulkEditorInput NewInstance(BulkEditorInputType inputType) { return BulkEditorInputType.getInput(inputType); } - /** - *

NewInstance

- * - * @param entity a {@link eu.etaxonomy.cdm.model.common.IdentifiableEntity} object. - * @return a {@link eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput} object. - */ public static AbstractBulkEditorInput NewInstance(IdentifiableEntity entity) { - BulkEditorInputType inputType = BulkEditorInputType.getByType(entity.getClass()); AbstractBulkEditorInput editorInput = NewInstance(inputType); @@ -85,83 +77,35 @@ public abstract class AbstractBulkEditorInput implements IEd return editorInput; } - /** - *

listEntities

- * - * @param configurator a {@link eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator} object. - * @return a {@link java.util.List} object. - */ protected abstract List listEntities(IIdentifiableEntityServiceConfigurator configurator); - /** - *

loadEntity

- * - * @param entityUuid a {@link java.util.UUID} object. - * @return a T object. - */ - protected T loadEntity(UUID entityUuid) { - List propertyPaths = Arrays.asList(new String[]{}); - return (T) CdmStore.getService(serviceClass).load(entityUuid, propertyPaths); - } + protected abstract T loadEntity(UUID entityUuid); private void setEntityUuid(UUID entityUuid){ this.entityUuid = entityUuid; } - /** - *

Getter for the field entityUuid.

- * - * @return a {@link java.util.UUID} object. - */ public UUID getEntityUuid() { return entityUuid; } - - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#exists() - */ - /** - *

exists

- * - * @return a boolean. - */ @Override public boolean exists() { // TODO Auto-generated method stub return false; } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getImageDescriptor() - */ - /** - *

getImageDescriptor

- * - * @return a {@link org.eclipse.jface.resource.ImageDescriptor} object. - */ @Override public ImageDescriptor getImageDescriptor() { // TODO Auto-generated method stub return null; } - /* (non-Javadoc) - * @see org.eclipse.ui.IEditorInput#getPersistable() - */ - /** - *

getPersistable

- * - * @return a {@link org.eclipse.ui.IPersistableElement} object. - */ @Override public IPersistableElement getPersistable() { return null; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) - */ /** {@inheritDoc} */ @Override @SuppressWarnings("unchecked") @@ -169,11 +113,6 @@ public abstract class AbstractBulkEditorInput implements IEd return null; } - /** - *

Setter for the field query.

- * - * @param bulkEditorQuery a {@link eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorQuery} object. - */ public void performSearch(final BulkEditorQuery bulkEditorQuery) { List entityList = new ArrayList(); @@ -199,29 +138,14 @@ public abstract class AbstractBulkEditorInput implements IEd model = entityList; } - /** - *

isMergingEnabled

- * - * @return a boolean. - */ public boolean isMergingEnabled() { return false; } - /** - *

isMergingEnabled

- * - * @return a boolean. - */ public boolean isConvertingEnabled() { return false; } - /** - *

isMarkerTypeEditingEnabled

- * - * @param markerType a {@link eu.etaxonomy.cdm.model.common.MarkerType} object. - * @return a boolean. - */ + public boolean isMarkerTypeEditingEnabled(MarkerType markerType) { return false; } @@ -232,7 +156,7 @@ public abstract class AbstractBulkEditorInput implements IEd public boolean merge(T entity, T mergeTarget) { if (entity instanceof IMergable) { try { - CdmStore.getCommonService().merge(mergeTarget.getId(), entity.getId(), (Class)entity.getClass()); + CdmStore.getCommonService().merge(mergeTarget.getUuid(), entity.getUuid(), (Class)entity.getClass()); } catch (MergeException e) { MessagingUtils.errorDialog("Bulk Editor Merge Error", this, @@ -248,7 +172,7 @@ public abstract class AbstractBulkEditorInput implements IEd /** {@inheritDoc} */ @Override - public boolean create(T entity) { + public T create(T entity) { return save(entity); } @@ -259,9 +183,6 @@ public abstract class AbstractBulkEditorInput implements IEd return entityCreator; } - /** - * @return - */ protected abstract IEntityCreator createEntityCreator(); /** @@ -288,10 +209,6 @@ public abstract class AbstractBulkEditorInput implements IEd return entity.getClass().getSimpleName(); } - /** - * @param entity - * @return - */ public String getText(T entity) { if(entity instanceof IdentifiableEntity){ IdentifiableEntity identifiableEntity = (IdentifiableEntity) HibernateProxyHelper.deproxy(entity); @@ -302,12 +219,33 @@ public abstract class AbstractBulkEditorInput implements IEd return "No text. Implement in subclass"; } - /** - * @return - */ - public List getModel() { + public List getModel() { return model; } + protected boolean replaceInModel(T entity) { + int index = model.indexOf(entity); + if(index >= 0) { + model.set(index, entity); + return true; + } else { + return false; + } + } + + @Override + public List getRootEntities() { + return getModel(); + } + + @Override + public Map> getPropertyPathsMap() { + // TODO Auto-generated method stub + return null; + } + + public ConversationHolder getConversation() { + return conversation; + } }