change synonym to accepted taxon message when taxon could not be deleted
authorKatja Luther <k.luther@bgbm.org>
Wed, 3 Jun 2015 13:22:24 +0000 (13:22 +0000)
committerKatja Luther <k.luther@bgbm.org>
Wed, 3 Jun 2015 13:22:24 +0000 (13:22 +0000)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/ChangeAcceptedTaxonToSynonymOperation.java

index 4dd1c61dbf3a5e01904d92a7aefe610d489afe79..1f17047020c0cb07cca4806cc6edb94b48364a27 100644 (file)
@@ -16,8 +16,10 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
 
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
@@ -73,12 +75,24 @@ public class ChangeAcceptedTaxonToSynonymOperation extends
                bind();
        Taxon oldTaxon = (Taxon) HibernateProxyHelper.deproxy(((TaxonNode) taxonNode).getTaxon());
                try {
-                   CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode((TaxonNode) taxonNode, newAcceptedTaxonNode, null, null, null);
-        } catch (IllegalArgumentException e) {
+                   DeleteResult result = CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode((TaxonNode) taxonNode, newAcceptedTaxonNode, null, null, null);
+        
+                   if (!result.getExceptions().isEmpty() && result.isOk()){
+                       String separator = ", ";
+                           String exceptionString = "";
+                           for (Exception exception : result.getExceptions()) {
+                           exceptionString += exception.getLocalizedMessage()+separator;
+                       }
+                               
+                       MessagingUtils.informationDialog("Synonym created but taxon is not deleted.", exceptionString);                 
+                   } else if (result.isAbort() || result.isError()){
+                       MessagingUtils.errorDialog("Synonym could not created", null, result.toString(), null, null, true);
+                   }
+               } catch (IllegalArgumentException e) {
             MessagingUtils.errorDialog("Operation failed", this, e.getMessage(), TaxeditorNavigationPlugin.PLUGIN_ID, e, false);
             return Status.CANCEL_STATUS;
         }
-
+               
                monitor.worked(40);
 
                return postExecute(oldTaxon);