commit 325e86cfec217269550ce050748fdebd2a0c3b02
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Thu Nov 8 09:54:17 2018 +0100

    ref #7887 Convert delete handler/operation to DTOs

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/handler/DeleteTermBaseHandlerE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/handler/DeleteTermBaseHandlerE4.java
index 73de51e38..e6738e63c 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/handler/DeleteTermBaseHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/e4/handler/DeleteTermBaseHandlerE4.java
@@ -8,6 +8,8 @@
  */
 package eu.etaxonomy.taxeditor.editor.definedterm.e4.handler;
 
+import java.util.UUID;
+
 import javax.inject.Named;
 
 import org.eclipse.core.commands.operations.IUndoContext;
@@ -21,9 +23,9 @@ import org.eclipse.e4.ui.services.IServiceConstants;
 import org.eclipse.jface.dialogs.MessageDialog;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
-import eu.etaxonomy.cdm.model.common.TermBase;
-import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
 import eu.etaxonomy.taxeditor.editor.definedterm.e4.DefinedTermEditorE4;
 import eu.etaxonomy.taxeditor.editor.definedterm.operation.DeleteTermBaseOperation;
 import eu.etaxonomy.taxeditor.model.AbstractUtility;
@@ -59,7 +61,7 @@ public class DeleteTermBaseHandlerE4 {
         AbstractPostOperation operation =
                 new DeleteTermBaseOperation(label,
                         undoContext,
-                        (TermBase) selection.getFirstElement(),
+                        (AbstractTermDto) selection.getFirstElement(),
                         termEditor.getDefinedTermEditorInput(),
                         termEditor);
         AbstractUtility.executeOperation(operation, sync);
@@ -71,16 +73,14 @@ public class DeleteTermBaseHandlerE4 {
         boolean canExecute = false;
         Object firstElement = selection.getFirstElement();
         canExecute = selection.size()==1
-                &&
-                (firstElement instanceof DefinedTermBase
-                        || firstElement instanceof TermVocabulary);
-        TermVocabulary vocabulary = null;
-        if(firstElement instanceof DefinedTermBase){
-            vocabulary = ((DefinedTermBase) firstElement).getVocabulary();
-        }else if(firstElement instanceof TermVocabulary){
-            vocabulary = (TermVocabulary) firstElement;
+                && (firstElement instanceof AbstractTermDto);
+        UUID vocabularyUuid = null;
+        if(firstElement instanceof TermDto){
+            vocabularyUuid = ((TermDto) firstElement).getVocabularyUuid();
+        }else if(firstElement instanceof TermVocabularyDto){
+            vocabularyUuid = ((TermVocabularyDto) firstElement).getUuid();
         }
-        canExecute &= vocabulary!=null;
+        canExecute &= vocabularyUuid!=null;
         menuItem.setVisible(canExecute);
         return canExecute;
     }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
index 91da3303c..7e3d28b7e 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
@@ -18,9 +18,9 @@ import org.eclipse.core.runtime.Status;
 import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.api.service.ITermService;
 import eu.etaxonomy.cdm.api.service.IVocabularyService;
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
-import eu.etaxonomy.cdm.model.common.TermBase;
-import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.persistence.dto.AbstractTermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermDto;
+import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
 import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput;
 import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
@@ -38,11 +38,11 @@ import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
 public class DeleteTermBaseOperation extends AbstractPostTaxonOperation {
 
 	private final TermEditorInput definedEditorInput;
-	private final TermBase termBase;
+	private final AbstractTermDto termBase;
 
 	public DeleteTermBaseOperation(String label,
 			IUndoContext undoContext,
-			TermBase termBase,
+			AbstractTermDto termBase,
 			TermEditorInput definedEditorInput,
 			IPostOperationEnabled postOperationEnabled) {
 		super(label, undoContext, postOperationEnabled);
@@ -53,19 +53,7 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation {
 	@Override
 	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
 			throws ExecutionException {
-		if (termBase instanceof TermVocabulary) {
-			if (((TermVocabulary)termBase).getCreatedBy() == null) {
-				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_SYSTEM_VOC);
-				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_CANNOT_DELETE_VOC, termBase, status);
-				return status;
-			}
-
-			if (!((TermVocabulary)termBase).getTerms().isEmpty()) {
-				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_DELETE_ALL_TERMS_BEFORE);
-				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_VOC_NOT_EMPTY, termBase, status);
-				return status;
-			}
-
+		if (termBase instanceof TermVocabularyDto) {
 			definedEditorInput.getVocabularies().remove(termBase);
 
 			DeleteResult result =	CdmStore.getService(IVocabularyService.class).delete(termBase.getUuid());
@@ -73,28 +61,12 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation {
 			    return showErrorMessage(result);
 			}
 
-		} else if (termBase instanceof DefinedTermBase) {
-
-
-			DefinedTermBase definedTermBase = (DefinedTermBase) termBase;
-
-			if (((DefinedTermBase)termBase).getCreatedBy() == null) {
-				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_SYSTEM_TERM);
-				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_CANNOT_DELETE_TERM, termBase, status);
-				return status;
-			}
-			if(!definedTermBase.getIncludes().isEmpty()){
-				IStatus status = new Status(IStatus.CANCEL, StoreUtil.getPluginId(), Messages.DeleteTermBaseOperation_TERM_INCLUDES_OTHERS);
-				MessagingUtils.warningDialog(Messages.DeleteTermBaseOperation_TERM_INLCUDES, termBase, status);
-				return status;
-			}
-
+		} else if (termBase instanceof TermDto) {
 			DeleteResult result =	CdmStore.getService(ITermService.class).delete(termBase.getUuid());
 			if (!result.isOk()){
 			    return showErrorMessage(result);
             }
 		}
-
 		return postExecute(termBase);
 	}
 
