From 68a31601f44edcb3a284ff5315fd7a0e3ee6a6e9 Mon Sep 17 00:00:00 2001 From: Katja Luther Date: Thu, 18 Oct 2018 10:30:53 +0200 Subject: [PATCH] improve termdeletion, show only a warning when term can not be deleted --- .../operation/DeleteTermBaseOperation.java | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) 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 91f55ab6d..f29d141ba 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 @@ -22,7 +22,6 @@ 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.taxeditor.editor.definedterm.e4.DefinedTermEditorE4; import eu.etaxonomy.taxeditor.editor.definedterm.input.TermEditorInput; import eu.etaxonomy.taxeditor.model.MessagingUtils; import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation; @@ -69,12 +68,12 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation { definedEditorInput.getVocabularies().remove(termBase); DeleteResult result = CdmStore.getService(IVocabularyService.class).delete(termBase.getUuid()); - if (result.isError()){ + if (!result.isOk()){ StringBuffer errorString = new StringBuffer(); for (Exception e:result.getExceptions()){ - errorString.append(e.getMessage() + "\\n"); + errorString.append(e.getMessage() + System.lineSeparator()); } - MessageDialog.openError(null, "Delete failed", errorString.toString()); + MessageDialog.openWarning(null, "Delete failed", errorString.toString()); } } else if (termBase instanceof DefinedTermBase) { @@ -93,31 +92,15 @@ public class DeleteTermBaseOperation extends AbstractPostTaxonOperation { return status; } - - DefinedTermBase partOf = definedTermBase.getPartOf(); - if(partOf != null){ - partOf.removeIncludes(definedTermBase); - } - - DefinedTermBase kindOf = definedTermBase.getKindOf(); - if(kindOf != null){ - definedTermBase.removeGeneralization(kindOf); - } - - TermVocabulary vocabulary = definedTermBase.getVocabulary(); - if(vocabulary != null){ - vocabulary.removeTerm(definedTermBase); - } - DeleteResult result = CdmStore.getService(ITermService.class).delete(termBase.getUuid()); - if (result.isError()){ - StringBuffer errorString = new StringBuffer(); - for (Exception e:result.getExceptions()){ - errorString.append(e.getMessage() + "\\n"); - } - MessageDialog.openError(null, "Delete failed", errorString.toString()); - } + if (!result.isOk()){ + StringBuffer errorString = new StringBuffer(); + for (Exception e:result.getExceptions()){ + errorString.append(e.getMessage() + System.lineSeparator()); + } + MessageDialog.openWarning(null, "Delete failed", errorString.toString()); + } } return postExecute(termBase); -- 2.34.1