From 4b242b1daae42da47631a1c1ac5e7865218ec3b4 Mon Sep 17 00:00:00 2001 From: Cherian Mathew Date: Thu, 3 Sep 2015 17:42:47 +0200 Subject: [PATCH] Correct merge --- .../navigator/operation/DeleteOperation.java | 207 +++++++++--------- 1 file changed, 100 insertions(+), 107 deletions(-) diff --git a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java index 5e78bd2dd..a2fea9759 100644 --- a/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java +++ b/eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java @@ -1,16 +1,18 @@ // $Id$ /** -* Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy -* http://www.e-taxonomy.eu -* -* The contents of this file are subject to the Mozilla Public License Version 1.1 -* See LICENSE.TXT at the top of this package for the full license terms. -*/ + * Copyright (C) 2007 EDIT + * European Distributed Institute of Taxonomy + * http://www.e-taxonomy.eu + * + * The contents of this file are subject to the Mozilla Public License Version 1.1 + * See LICENSE.TXT at the top of this package for the full license terms. + */ package eu.etaxonomy.taxeditor.navigation.navigator.operation; +import java.util.HashSet; import java.util.Set; +import java.util.UUID; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.operations.IUndoContext; @@ -29,9 +31,9 @@ import eu.etaxonomy.cdm.model.common.CdmBase; import eu.etaxonomy.cdm.model.taxon.Classification; import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.TaxonNode; -import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation; import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled; +import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled; import eu.etaxonomy.taxeditor.store.CdmStore; /** @@ -43,45 +45,51 @@ import eu.etaxonomy.taxeditor.store.CdmStore; */ public class DeleteOperation extends AbstractPersistentPostOperation{ - private Set treeNodes; - protected final TaxonDeletionConfigurator config; + private Set treeNodes; + protected final TaxonDeletionConfigurator config; + private final ICdmEntitySessionEnabled cdmEntitySessionEnabled; + + /** + *

Constructor for DeleteTreeNodeOperation.

+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. + * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object. + * @param treeNodes a {@link java.util.Set} object. + */ + public DeleteOperation(String label, IUndoContext undoContext, + ITaxonTreeNode taxonNode, TaxonDeletionConfigurator config, + IPostOperationEnabled postOperationEnabled, + IConversationEnabled conversationEnabled, + ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled); + this.taxonNode = (ITaxonTreeNode)CdmBase.deproxy(taxonNode, CdmBase.class); + this.config = config; + this.cdmEntitySessionEnabled = cdmEntitySessionEnabled; + } + + /** + *

Constructor for DeleteTreeNodeOperation.

+ * + * @param label a {@link java.lang.String} object. + * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. + * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. + * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object. + * @param treeNodes a {@link java.util.Set} object. + */ + public DeleteOperation(String label, IUndoContext undoContext, + Set treeNodes, TaxonDeletionConfigurator config, + IPostOperationEnabled postOperationEnabled, + IConversationEnabled conversationEnabled, + ICdmEntitySessionEnabled cdmEntitySessionEnabled) { + super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled); + this.treeNodes = treeNodes; + this.config = config; + this.cdmEntitySessionEnabled = cdmEntitySessionEnabled; + } - /** - *

Constructor for DeleteTreeNodeOperation.

- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. - * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object. - * @param treeNodes a {@link java.util.Set} object. - */ - public DeleteOperation(String label, IUndoContext undoContext, - ITaxonTreeNode taxonNode, TaxonDeletionConfigurator config, - IPostOperationEnabled postOperationEnabled, - IConversationEnabled conversationEnabled) { - super(label, undoContext, postOperationEnabled, conversationEnabled); - this.taxonNode = (ITaxonTreeNode)CdmBase.deproxy(taxonNode, CdmBase.class); - this.config = config; - } - - /** - *

Constructor for DeleteTreeNodeOperation.

- * - * @param label a {@link java.lang.String} object. - * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. - * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. - * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object. - * @param treeNodes a {@link java.util.Set} object. - */ - public DeleteOperation(String label, IUndoContext undoContext, - Set treeNodes, TaxonDeletionConfigurator config, - IPostOperationEnabled postOperationEnabled, - IConversationEnabled conversationEnabled) { - super(label, undoContext, postOperationEnabled, conversationEnabled); - this.treeNodes = treeNodes; - this.config = config; - } /* (non-Javadoc) @@ -108,76 +116,61 @@ public class DeleteOperation extends AbstractPersistentPostOperation{ } else if (!result.getExceptions().isEmpty()){ String separator = ", "; String exceptionString = ""; - int count = 1; for (Exception exception : result.getExceptions()) { - exceptionString += exception.getLocalizedMessage(); - if (count < result.getExceptions().size()){ - exceptionString += separator; - } + exceptionString += exception.getLocalizedMessage()+separator; } - MessagingUtils.informationDialog("Delete of the node was successful but the taxon could not be deleted.", exceptionString); + MessageDialog.openInformation(null, "Delete of the node was successful but the taxon could not be deleted.", exceptionString); } }else if(taxonNode != null && taxonNode instanceof Classification){ Classification taxonomicTree = (Classification) taxonNode; - /*if(taxonomicTree.hasChildNodes()){ - if(! MessageDialog.openConfirm(null, "Confirm Deletion", "The selected tree has children, do yu realy want to delete the whole tree with its children?")){ - return null; - } - }*/ - DeleteResult result = CdmStore.getService(IClassificationService.class).delete(taxonomicTree); - if (result.isError() && !result.getExceptions().isEmpty()){ - String separator = ", "; - String exceptionString = ""; - for (Exception exception : result.getExceptions()) { - exceptionString += exception.getLocalizedMessage()+separator; - } - MessagingUtils.error(null, exceptionString, result.getExceptions().iterator().next()); - } - - /*}else{ - try{ - CdmStore.getService(IClassificationService.class).delete(taxonomicTree); - }catch(ReferencedObjectUndeletableException e){ - throw new ExecutionException(e.getMessage()); - } - }*/ - } else { - - DeleteResult result =service.deleteTaxonNodes(treeNodes, config); - if (result.isError() && !result.getExceptions().isEmpty()){ - String separator = ", "; - String exceptionString = ""; - for (Exception exception : result.getExceptions()) { - exceptionString += exception.getLocalizedMessage()+separator; - } - MessagingUtils.error(null, exceptionString, result.getExceptions().iterator().next()); - } + DeleteResult result = CdmStore.getService(IClassificationService.class).delete(taxonomicTree.getUuid()); + if (result.isError() && !result.getExceptions().isEmpty()){ + //TODO:Error message! + MessageDialog.openError(null, "Delete failed", result.getExceptions().iterator().next().getMessage()); + } + } else { + Set treeNodeUuids = new HashSet(); + ITaxonTreeNode entity = null; + for(ITaxonTreeNode treeNode : treeNodes) { + if(entity == null) { + entity = treeNode; + } + treeNodeUuids.add(treeNode.getUuid()); + } + + DeleteResult result = service.deleteTaxonNodes(treeNodeUuids, config); + if (result.isError() && !result.getExceptions().isEmpty()){ + //TODO:Error message! + MessageDialog.openError(null, "Delete failed", result.getExceptions().iterator().next().getMessage()); } - monitor.worked(40); - return postExecute(null); - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - /** {@inheritDoc} */ - @Override - public IStatus redo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) - */ - /** {@inheritDoc} */ - @Override - public IStatus undo(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - return null; - } + } + + monitor.worked(40); + + return postExecute(null); + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + /** {@inheritDoc} */ + @Override + public IStatus redo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + /** {@inheritDoc} */ + @Override + public IStatus undo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + return null; + } } -- 2.34.1