Merge branch 'develop' of wp5.e-taxonomy.eu:/var/git/taxeditor into remoting-4.0
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / operation / DeleteSynonymOperation.java
index cba17dc0758906191e20b0e8e7736a81bbb05e66..b21efefce203544c29ecc999610838e0d97eb536 100644 (file)
@@ -16,8 +16,10 @@ import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.MessageDialog;
 
-import eu.etaxonomy.cdm.api.application.CdmApplicationController;
+import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
@@ -67,16 +69,22 @@ public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
 
                                // Remove synonym from taxon
 
-                               CdmApplicationController controller;
+                               ICdmApplicationConfiguration controller;
 
-                               controller = (CdmApplicationController) CdmStore.getCurrentApplicationConfiguration();
+                               controller = CdmStore.getCurrentApplicationConfiguration();
 
                                ITaxonService service = controller.getTaxonService();
                                if (synonym.getId() == 0){
                                        element.removeSynonym(synonym);
 
                                } else {
-                                       service.deleteSynonym(synonym, null);
+
+                                       DeleteResult result = service.deleteSynonym(synonym.getUuid(), element.getUuid(), null);
+                                       if (result.isError()){
+                                               MessageDialog.openError(null, "Delete failed", result.toString());
+                                       } else if (!result.getUpdatedObjects().isEmpty()){
+                                               MessageDialog.openInformation(null, "Delete successfull", "The Synonym could be deleted, but there is an updated object: " + result.toString());
+                                       }
                                }
                        //      taxon.removeSynonym(synonym);
 //                             CdmStore.getTaxonService().deleteSynonymRelationships(synonym);