add delete to media bulk editor
[taxeditor.git] / eu.etaxonomy.taxeditor.bulkeditor / src / main / java / eu / etaxonomy / taxeditor / bulkeditor / handler / DeleteHandler.java
index 08d0355e8182c4d4e24aaea1bce282a77ba50b35..6936095c42db08efea30b44e5bbdf98b641df720 100644 (file)
@@ -28,6 +28,7 @@ import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
 import eu.etaxonomy.cdm.api.service.DeleteResult;
 import eu.etaxonomy.cdm.api.service.IAgentService;
 import eu.etaxonomy.cdm.api.service.IGroupService;
+import eu.etaxonomy.cdm.api.service.IMediaService;
 import eu.etaxonomy.cdm.api.service.INameService;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.IReferenceService;
@@ -39,6 +40,7 @@ import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.cdm.model.common.User;
+import eu.etaxonomy.cdm.model.media.Media;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.cdm.model.reference.Reference;
@@ -54,7 +56,6 @@ import eu.etaxonomy.taxeditor.model.DeleteResultMessagingUtils;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteConfiguratorDialog;
-import eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator.DeleteTaxonConfiguratorComposite;
 
 
 /**
@@ -128,8 +129,8 @@ public class DeleteHandler extends AbstractHandler {
                                                INameService service = controller.getNameService();
                                                if (object != null){
                                                        NameDeletionConfigurator config = new NameDeletionConfigurator();
-                                                       
-                                                       DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the name", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); 
+
+                                                       DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the name", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
                                                        int result_dialog= dialog.open();
                                                        if (result_dialog == 1){
                                                                return null;
@@ -143,7 +144,7 @@ public class DeleteHandler extends AbstractHandler {
                                                        if (object instanceof Taxon){
                                                                TaxonDeletionConfigurator config = new TaxonDeletionConfigurator();
                                                                config.setDeleteInAllClassifications(true);
-                                                               DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the taxon", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); 
+                                                               DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the taxon", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0);
                                                                int result_dialog= dialog.open();
                                                                if (result_dialog == 1){
                                                                        return null;
@@ -152,7 +153,7 @@ public class DeleteHandler extends AbstractHandler {
                                                                errorMessage = "The taxon ";
                                                        }else{
                                                                SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
-                                                               
+
                                                                result = service.deleteSynonym(((Synonym)object).getUuid(), config);
                                                                errorMessage = "The synonym ";
                                                        }
@@ -162,7 +163,13 @@ public class DeleteHandler extends AbstractHandler {
                                                //TeamOrPersonBase teamOrPerson = (TeamOrPersonBase)service.load(((TeamOrPersonBase) object).getUuid());
                                                result = service.delete(((TeamOrPersonBase)object).getUuid());
                                                errorMessage = "The team or person ";
-                                       }
+                                       } else if (object instanceof Media){
+                        IMediaService service = controller.getMediaService();
+                        //TeamOrPersonBase teamOrPerson = (TeamOrPersonBase)service.load(((TeamOrPersonBase) object).getUuid());
+                        result = service.delete(((Media)object).getUuid());
+                        errorMessage = "The media ";
+                    }
+
                                } catch (Exception e){
                                        MessagingUtils.errorDialog("Exception occured. Delete not possible", getClass(), e.getMessage(), TaxeditorBulkeditorPlugin.PLUGIN_ID, null, true);
                                }