minor
authorKatja Luther <k.luther@bgbm.org>
Thu, 28 Nov 2013 11:09:17 +0000 (11:09 +0000)
committerKatja Luther <k.luther@bgbm.org>
Thu, 28 Nov 2013 11:09:17 +0000 (11:09 +0000)
13 files changed:
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/annotatedlineeditor/IEntityPersistenceService.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/GroupEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/UserEditorInput.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/key/polytomous/operation/DeleteOperation.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/editor/definedterm/operation/DeleteTermBaseOperation.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/SelectFeatureTreeWizardPage.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermStore.java

index 7c292c52dc428218757f4ddca4eca08236b09345..39acd4ff0fd996a8c7b58dc9b17dcfdf267b56a4 100644 (file)
@@ -10,6 +10,8 @@
 
 package eu.etaxonomy.taxeditor.annotatedlineeditor;
 
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
+
 
 /**
  * Performs the retrieving and saving of a list of entities edited by a <code>ListEditor</code>,
@@ -53,6 +55,7 @@ public interface IEntityPersistenceService<T> {
         *
         * @param entity a {@link java.lang.Object} object.
         * @return a boolean.
+        * @throws ReferencedObjectUndeletableException 
         */
-       boolean delete(T entity);
+       boolean delete(T entity) throws ReferencedObjectUndeletableException;
 }
index d1c0c644594b63d74ce2a45c15ac085c0345b1e5..f08c60f92954a3edc7d4aaa0a1e212547b988190 100644 (file)
@@ -22,8 +22,10 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
+import eu.etaxonomy.cdm.api.service.IReferenceService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
+import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.LineAnnotation;
@@ -71,14 +73,16 @@ public class DeleteHandler extends AbstractHandler {
                                        LineAnnotation annotation = (LineAnnotation) model.getAnnotation(object);
                                                        
                                        try {
+                                               CdmApplicationController controller;
+                                               controller = (CdmApplicationController) CdmStore.getCurrentApplicationConfiguration();
                                                //persistenceService.delete(object);
                                                if (object instanceof SpecimenOrObservationBase){
-                                                       CdmApplicationController controller;
-                                                       
-                                                       controller = (CdmApplicationController) CdmStore.getCurrentApplicationConfiguration();
                                                        
                                                        IOccurrenceService service = controller.getOccurrenceService();
                                                        service.delete((SpecimenOrObservationBase)object);
+                                               } else if (object instanceof Reference){
+                                                       IReferenceService service = controller.getReferenceService();
+                                                       service.delete((Reference)object);
                                                }
                                                
                                        } catch (Exception e){
index 95c0c0b20dd3fe7bda685bd816df31f78ec27f1b..386e714ebbd18f537a20d76a8a63e96a93cc3830 100644 (file)
@@ -13,8 +13,12 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.UUID;
 
+import org.eclipse.core.commands.ExecutionException;
+
 import eu.etaxonomy.cdm.api.service.IAgentService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.agent.AgentBase;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
@@ -109,9 +113,11 @@ public class AgentEditorInput extends AbstractBulkEditorInput<AgentBase> {
                return CdmStore.getService(IAgentService.class).load(uuid, propertyPaths);
        }
 
-       /** {@inheritDoc} */
-       public boolean delete(AgentBase entity) {
-               return CdmStore.getService(IAgentService.class).delete(entity) != null;                 
+       
+       public boolean delete(AgentBase entity) throws ReferencedObjectUndeletableException  {
+               
+                       return CdmStore.getService(IAgentService.class).delete(entity) != null;                 
+               
        }
 
        /** {@inheritDoc} */
index b5d87769da8bdd1b4fd0f05a625a6b867993f2aa..eb5fb3695de01942d23500117fbb0bbdb4e08f1c 100644 (file)
@@ -16,6 +16,7 @@ import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.IGroupService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.common.Group;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.GroupCreator;
@@ -70,7 +71,7 @@ public class GroupEditorInput extends AbstractBulkEditorInput<Group> {
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
         */
        @Override
-       public boolean delete(Group entity) {
+       public boolean delete(Group entity) throws ReferencedObjectUndeletableException {
                return CdmStore.getService(IGroupService.class).delete(entity) != null;
        }
 
index 617fccf59c57ee66c32f74800d97bab13cada3ca..5cec310cd858d86ee290c72fa64c80b7fbc6afe3 100644 (file)
@@ -16,6 +16,7 @@ import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.INameService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.IBulkEditorSortProvider;
@@ -108,8 +109,9 @@ public class NameEditorInput extends AbstractBulkEditorInput<TaxonNameBase> {
                return CdmStore.getService(INameService.class).load(uuid, propertyPaths);
        }
 
-       /** {@inheritDoc} */
-       public boolean delete(TaxonNameBase entity) {
+       /** {@inheritDoc} 
+        * @throws ReferencedObjectUndeletableException */
+       public boolean delete(TaxonNameBase entity) throws ReferencedObjectUndeletableException {
                return CdmStore.getService(INameService.class).delete(entity) != null;
        }
 
index 3f9858869e2122aae96a64f0b947fca3f85008f9..d9417cd81b0b74ab2c1504a4f3784b7f6dfb7183 100644 (file)
@@ -16,6 +16,7 @@ import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
@@ -124,9 +125,10 @@ public class OccurrenceEditorInput extends AbstractBulkEditorInput<SpecimenOrObs
        /* (non-Javadoc)
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
         */
-       /** {@inheritDoc} */
+       /** {@inheritDoc} 
+        * @throws ReferencedObjectUndeletableException */
        @Override
-    public boolean delete(SpecimenOrObservationBase entity) {
+    public boolean delete(SpecimenOrObservationBase entity) throws ReferencedObjectUndeletableException {
                return CdmStore.getService(IOccurrenceService.class).delete(entity) != null;
        }
 
index 8e3f3251375f80fa85bb33e8ebc42380e4f7d9c2..d32a648cd0bf522d3a32dcc2e22ec9fe34612537 100644 (file)
@@ -15,6 +15,7 @@ import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.IReferenceService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
@@ -126,8 +127,9 @@ public class ReferenceEditorInput extends AbstractBulkEditorInput<Reference> {
                return CdmStore.getService(IReferenceService.class).load(entityUuid, propertyPaths);
        }
 
-       /** {@inheritDoc} */
-       public boolean delete(Reference entity) {
+       /** {@inheritDoc} 
+        * @throws ReferencedObjectUndeletableException */
+       public boolean delete(Reference entity) throws ReferencedObjectUndeletableException {
                return CdmStore.getService(IReferenceService.class).delete(entity) != null;
        }
 
index bafce5e950a6f32d509dd817df730ace28a934ff..2d8a7e406807c209c2e5f2c14e6b3eddd19e5f2b 100644 (file)
@@ -16,6 +16,7 @@ import java.util.UUID;
 
 import eu.etaxonomy.cdm.api.service.IUserService;
 import eu.etaxonomy.cdm.api.service.config.IIdentifiableEntityServiceConfigurator;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator;
 import eu.etaxonomy.taxeditor.bulkeditor.input.entitycreator.UserCreator;
@@ -70,7 +71,7 @@ public class UserEditorInput extends AbstractBulkEditorInput<User> {
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityPersistenceService#delete(java.lang.Object)
         */
        @Override
-       public boolean delete(User entity) {
+       public boolean delete(User entity) throws ReferencedObjectUndeletableException {
                return CdmStore.getService(IUserService.class).delete(entity) != null;
        }
 
index 0ded7902e75db9a02424bb2b36e58d565d328c0f..967c481e7a2f4dafdc53e28bb9d966bff4703964 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IStatus;
 
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
 import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.description.PolytomousKey;
 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -51,7 +52,11 @@ public class DeleteOperation extends AbstractPersistentPostOperation {
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
                bind();
-               CdmStore.getService(IPolytomousKeyService.class).delete(key);
+               try{
+                       CdmStore.getService(IPolytomousKeyService.class).delete(key);
+               }catch(ReferencedObjectUndeletableException e){
+                       throw new ExecutionException(e.getMessage());
+               }
                return postExecute(null);
        }
 
index c7b5a37a05725930adb6e478c907326de4ce3724..49c6f77961672d07d05f151e50074920e8933c19 100644 (file)
@@ -26,6 +26,7 @@ import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.ITreeNode;
 import eu.etaxonomy.cdm.model.taxon.Classification;
@@ -116,7 +117,11 @@ public class DeleteOperation extends AbstractPersistentPostOperation{
                                        StoreUtil.warningDialog("Tree is not empty", this, "It is not possible to delete a Taxonomic Tree that " +
                                                        "is not empty. Please delete included taxa first");
                                }else{
+                                       try{
                                        CdmStore.getService(IClassificationService.class).delete(taxonomicTree);
+                                       }catch(ReferencedObjectUndeletableException e){
+                                               throw new ExecutionException(e.getMessage());
+                                       }
                                }
                        } else {
                                try {
index c5bbd9c4ec4a1f9319e4fcc8b8fd0377eb325fe7..eed7baa7d58fd9b55b811b9742adcf0bb7d68da2 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.Status;
 \r
 import eu.etaxonomy.cdm.api.service.ITermService;\r
 import eu.etaxonomy.cdm.api.service.IVocabularyService;\r
+import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;\r
 import eu.etaxonomy.cdm.model.common.DefinedTerm;\r
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;\r
 import eu.etaxonomy.cdm.model.common.TermBase;\r
@@ -77,8 +78,13 @@ public class DeleteTermBaseOperation extends AbstractPostOperation {
                        }                       \r
 \r
                        definedEditorInput.getVocabularies().remove((TermVocabulary)termBase); \r
-                       CdmStore.getService(IVocabularyService.class).delete((TermVocabulary)termBase);\r
-                       \r
+                       try{\r
+                               CdmStore.getService(IVocabularyService.class).delete((TermVocabulary)termBase);\r
+                       } catch (DataChangeNoRollbackException e) {\r
+                               \r
+                               throw new ExecutionException(e.getMessage());\r
+                               \r
+                       }\r
                        \r
                } else if (termBase instanceof DefinedTermBase) {\r
                        \r
@@ -111,8 +117,13 @@ public class DeleteTermBaseOperation extends AbstractPostOperation {
                        if(vocabulary != null){\r
                                vocabulary.removeTerm(definedTermBase);\r
                        }\r
-                       CdmStore.getService(ITermService.class).delete((DefinedTermBase)termBase);\r
-                       \r
+                       try{\r
+                               CdmStore.getService(ITermService.class).delete((DefinedTermBase)termBase);\r
+                       } catch (DataChangeNoRollbackException e) {\r
+                               \r
+                               throw new ExecutionException(e.getMessage());\r
+                               \r
+                       }\r
                }\r
                \r
                return postExecute(termBase);\r
index de1a6b42a257cc4d651907d4d0477c363c38d6f8..b53e1ba83e36a0ec4b773f2b42e2a4c167dca686 100644 (file)
@@ -12,6 +12,7 @@ package eu.etaxonomy.taxeditor.featuretree;
 
 import java.util.List;
 
+import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.ListViewer;
@@ -31,8 +32,10 @@ import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
 import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
+import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
 import eu.etaxonomy.cdm.model.description.FeatureTree;
 import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
 
 /**
  * <p>SelectFeatureTreeWizardPage class.</p>
@@ -158,7 +161,16 @@ public class SelectFeatureTreeWizardPage extends WizardPage implements ISelectio
                        IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
                        for(Object element : selection.toArray()){
                                viewer.remove(element);
-                               CdmStore.getService(IFeatureTreeService.class).delete((FeatureTree) element);
+                               try{
+                                       CdmStore.getService(IFeatureTreeService.class).delete((FeatureTree) element);
+                               } catch (DataChangeNoRollbackException d) {
+                                       
+                                       StoreUtil.warningDialog(
+                                                       "Feature can not be removed",
+                                                       this,
+                                                       "The selected feature can not be removed from the feature tree.");
+                                       
+                               }
                                viewer.setSelection(new StructuredSelection(new Object[0]));
                        }
                }
index ab52136365b62548298657675f3629e01fe29a6a..d7e1c2cf146eaa721ef82870f6e0b96280b24bc5 100644 (file)
@@ -19,6 +19,7 @@ import java.util.List;
 import java.util.Set;
 
 import eu.etaxonomy.cdm.api.service.ITermService;
+import eu.etaxonomy.cdm.api.service.exception.ReferencedObjectUndeletableException;
 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
 import eu.etaxonomy.cdm.model.common.MarkerType;
 import eu.etaxonomy.cdm.model.description.AbsenceTerm;
@@ -103,8 +104,9 @@ public class TermStore {
         * <p>delete</p>
         *
         * @param selected a {@link eu.etaxonomy.cdm.model.common.DefinedTermBase} object.
+        * @throws ReferencedObjectUndeletableException 
         */
-       public static void delete(DefinedTermBase selected) {
+       public static void delete(DefinedTermBase selected) throws ReferencedObjectUndeletableException {
                CdmStore.getService(ITermService.class).delete(selected);
        }