ref #5974 Remove synonym relationships (compiling)
authorAndreas Müller <a.mueller@bgbm.org>
Thu, 13 Oct 2016 11:34:02 +0000 (13:34 +0200)
committerAndreas Müller <a.mueller@bgbm.org>
Thu, 10 Nov 2016 12:50:41 +0000 (13:50 +0100)
14 files changed:
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetListener.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/NameEditorMenuPropertyTester.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToAcceptedTaxonOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExistingHomotypicalGroupOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInNewGroupOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/DeleteSynonymOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/MoveSynonymToAnotherAcceptedTaxonOperation.java
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperationTest.java
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/CreateSynonymInExisitingHomotypicalGroupOperationTest.java
eu.etaxonomy.taxeditor.editor/src/test/java/eu/etaxonomy/taxeditor/editor/name/operation/SwapSynonymAndAcceptedOperationTest.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/NavigationUtil.java

index 98481d4..782cd3d 100644 (file)
@@ -131,7 +131,11 @@ public class TaxonEditorInput  extends CdmEntitySessionInput implements IEditorI
             }else if(taxonBase instanceof Synonym){
                 Synonym synonym = (Synonym) taxonBase;
 
-                Set<Taxon> taxa = synonym.getAcceptedTaxa();
+                Set<Taxon> taxa = new HashSet<>();
+                Taxon taxon = synonym.getAcceptedTaxon();
+                if (taxon != null){
+                       taxa.add(taxon);
+                }
                 setInputForMultipleTaxa(conversation, taxa);
             }
         }
index c8bccaa..661c0c7 100644 (file)
@@ -4,17 +4,13 @@
 package eu.etaxonomy.taxeditor.editor.name.dnd;
 
 import org.eclipse.core.runtime.Assert;
-import org.eclipse.swt.SWTException;
 import org.eclipse.swt.dnd.DND;
 import org.eclipse.swt.dnd.DropTargetAdapter;
 import org.eclipse.swt.dnd.DropTargetEvent;
 
 import eu.etaxonomy.cdm.model.common.ICdmBase;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
-import eu.etaxonomy.cdm.model.reference.Reference;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
@@ -22,7 +18,6 @@ import eu.etaxonomy.taxeditor.editor.EditorUtil;
 import eu.etaxonomy.taxeditor.editor.IDropTargetable;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
 import eu.etaxonomy.taxeditor.editor.name.container.AbstractHomotypicalGroupContainer;
-import eu.etaxonomy.taxeditor.editor.name.container.HomotypicalSynonymGroup;
 import eu.etaxonomy.taxeditor.editor.name.container.MisappliedGroup;
 import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptRelationshipTypeOperation;
 import eu.etaxonomy.taxeditor.editor.name.operation.ChangeConceptToSynonymOperation;
index 3afdefc..fa85760 100644 (file)
@@ -10,8 +10,6 @@
 
 package eu.etaxonomy.taxeditor.editor.name.handler;
 
-import java.util.Set;
-
 import org.eclipse.core.expressions.PropertyTester;
 import org.eclipse.jface.viewers.IStructuredSelection;
 
@@ -51,9 +49,6 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
        public NameEditorMenuPropertyTester() {
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
-        */
        /** {@inheritDoc} */
        @Override
     public boolean test(Object receiver, String property, Object[] args,
@@ -127,10 +122,10 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
        private boolean isNotHomotypicSynonymOfAcceptedTaxon(Object selectedElement) {
                if (isSynonym(selectedElement)){
                        Synonym synonym = (Synonym) selectedElement;
-                       for (Taxon taxon:synonym.getAcceptedTaxa()){
-                               if (taxon.getHomotypicGroup().equals(synonym.getHomotypicGroup())){
-                                       return false;
-                               }
+                       Taxon taxon = synonym.getAcceptedTaxon();
+                       if (taxon != null && 
+                                       taxon.getHomotypicGroup().equals(synonym.getHomotypicGroup())){
+                               return false;
                        }
                }
                return true;
@@ -177,12 +172,7 @@ public class NameEditorMenuPropertyTester extends PropertyTester {
                return ((Taxon) selectedElement).isOrphaned();
            }
            else if(selectedElement instanceof Synonym){
-               Set<Taxon> acceptedTaxa = ((Synonym) selectedElement).getAcceptedTaxa();
-               for (Taxon taxon : acceptedTaxa) {
-                if(!taxon.isOrphaned()){
-                    return false;
-                }
-            }
+               return ((Synonym) selectedElement).isOrphaned();
            }
            return false;
        }
index d964006..0837e4b 100644 (file)
@@ -22,7 +22,6 @@ import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
@@ -49,8 +48,6 @@ public class ChangeConceptToSynonymOperation extends
        private TaxonRelationship taxonRelationship;
        private TaxonRelationshipType oldRelationshipType;
 
-       private SynonymRelationship newSynonymRelationship;
-
        /**
         * <p>Constructor for ChangeConceptToSynonymOperation.</p>
         *
@@ -81,9 +78,6 @@ public class ChangeConceptToSynonymOperation extends
                this.homotypicalGroup = homotypicalGroup != null ? homotypicalGroup : HomotypicalGroup.NewInstance();
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
@@ -107,9 +101,6 @@ public class ChangeConceptToSynonymOperation extends
                return postExecute(synonym);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
@@ -118,9 +109,6 @@ public class ChangeConceptToSynonymOperation extends
                return null;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
index 89a8bf7..86dfa56 100644 (file)
@@ -29,7 +29,6 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
  *
  * @author n.hoffmann
  * @created 19.01.2009
- * @version 1.0
  */
 public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation {
 
@@ -70,9 +69,6 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation {
                this.newHomotypicalGroup = newHomotypicalGroup != null ? newHomotypicalGroup : HomotypicalGroup.NewInstance();
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
@@ -89,12 +85,13 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation {
                monitor.worked(40);
                newHomotypicalGroup = HibernateProxyHelper.deproxy(newHomotypicalGroup, HomotypicalGroup.class);
                newHomotypicalGroup.addTypifiedName(synonymName);
-
-               if(! synonym.getAcceptedTaxa().contains(element)){
-                       for(Taxon acceptedTaxon : synonym.getAcceptedTaxa()){
-                               acceptedTaxon.removeSynonym(synonym);
+               
+               Taxon acc = synonym.getAcceptedTaxon();
+               if(acc == null || !acc.equals(element)){
+                       if(acc != null){
+                               acc.removeSynonym(synonym);
                        }
-
+                       
                        SynonymRelationshipType type = SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF();
                        if(newHomotypicalGroup.getTypifiedNames().contains(element.getName())){
                                type = SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF();
@@ -107,9 +104,6 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation {
                return postExecute(synonym);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
@@ -117,9 +111,6 @@ public class ChangeHomotypicGroupOperation extends AbstractPostTaxonOperation {
                return execute(monitor, info);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
index c62759b..3253f2a 100644 (file)
@@ -77,9 +77,7 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos
                //this.namesInHomotypicGroup = namesInHomotypicalGroup;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
+
        /** {@inheritDoc} */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
@@ -89,10 +87,7 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos
                        newNode = (TaxonNode) CdmStore.getService(ITaxonService.class).changeSynonymToAcceptedTaxon(synonym.getUuid(),
                                element.getUuid(),
                                parentNode.getUuid(),
-                               true,
-                               true,
-                               null,
-                               null).getCdmEntity();
+                               true).getCdmEntity();
                } catch (HomotypicalGroupChangeException e) {
                        MessagingUtils.warningDialog("Operation may lead to inconsistent data", getClass(), e.getMessage());
                        return postExecute(null);
@@ -116,9 +111,6 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos
                return postExecute(newNode);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
@@ -126,9 +118,6 @@ public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPos
                return execute(monitor, info);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
index c53f5d0..b247d8c 100644 (file)
@@ -17,7 +17,7 @@ import org.eclipse.core.runtime.IStatus;
 
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.NonViralName;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -27,7 +27,6 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
  *
  * @author n.hoffmann
  * @created 02.02.2009
- * @version 1.0
  */
 public class CreateSynonymInExistingHomotypicalGroupOperation extends
                AbstractPostTaxonOperation {
@@ -35,7 +34,7 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends
        private final HomotypicalGroup group;
        private final NonViralName newSynonymName;
 
-       private SynonymRelationship synonymRelationship;
+       private Synonym synonym;
 
        /**
         * <p>Constructor for CreateSynonymInExistingHomotypicalGroupOperation.</p>
@@ -54,9 +53,6 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends
                this.newSynonymName = newSynonymName;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
@@ -69,9 +65,9 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends
                // Create a new synonym for the taxon
                // TODO add citations
                if(group.equals(element.getHomotypicGroup())){
-                       synonymRelationship = element.addHomotypicSynonymName(newSynonymName, null, null);
+                       synonym = element.addHomotypicSynonymName(newSynonymName);
                }else{
-                       synonymRelationship = element.addHeterotypicSynonymName(newSynonymName);
+                       synonym = element.addHeterotypicSynonymName(newSynonymName);
                }
                monitor.worked(40);
 
@@ -84,12 +80,9 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends
 //                     }
 //             }
 
-               return postExecute(synonymRelationship.getSynonym());
+               return postExecute(synonym);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
@@ -97,15 +90,12 @@ public class CreateSynonymInExistingHomotypicalGroupOperation extends
                return execute(monitor, info);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
 
-               element.removeSynonymRelation(synonymRelationship);
+               element.removeSynonym(synonym);
 
                return postExecute(null);
        }
index 2ef74bc..0d1a8b8 100644 (file)
@@ -18,7 +18,7 @@ import org.eclipse.core.runtime.IStatus;
 import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
+import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
@@ -33,13 +33,11 @@ import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
  * @author p.ciardelli
  * @author n.hoffmann
  * @created 16.01.2009
- * @version 1.0
  */
 public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation {
 
-       // TODO replace this with TaxonNameBase
        private final TaxonNameBase newSynonymName;
-       private SynonymRelationship newSynonymRelationship;
+       private Synonym newSynonym;
 
        /**
         * <p>Constructor for CreateSynonymInNewGroupOperation.</p>
@@ -57,9 +55,6 @@ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation
                this.newSynonymName = newSynonymName;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
@@ -70,15 +65,12 @@ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation
                monitor.worked(20);
                HibernateProxyHelper.deproxy(element);
                // Create a new synonym for the taxon
-               newSynonymRelationship = element.addHeterotypicSynonymName(newSynonymName);
+               newSynonym = element.addHeterotypicSynonymName(newSynonymName);
                monitor.worked(40);
                
-               return postExecute(newSynonymRelationship.getSynonym());
+               return postExecute(newSynonym);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
@@ -86,17 +78,14 @@ public class CreateSynonymInNewGroupOperation extends AbstractPostTaxonOperation
                return execute(monitor, info);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
 
                // Remove the synonym
-               element.removeSynonymRelation(newSynonymRelationship);
-               newSynonymRelationship = null;
+               element.removeSynonym(newSynonym);
+               newSynonym = null;
 
                return postExecute(null);
        }
index d005de5..33a7c08 100644 (file)
@@ -34,12 +34,11 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  *
  * @author p.ciardelli
  * @created 14.01.2009
- * @version 1.0
  */
 public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
 
        private final Synonym synonym;
-       private Set<SynonymRelationshipType> synonymTypes;
+       private SynonymRelationshipType synonymType;
 
        /**
         * <p>Constructor for DeleteSynonymOperation.</p>
@@ -56,51 +55,44 @@ public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
                this.synonym = synonym;
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
 
                // Store synonymRelationshipType for later undo operations
-                               synonymTypes = synonym.getRelationType(element);
-                               monitor.worked(20);
-
-                               // Remove synonym from taxon
-
-                               ICdmApplicationConfiguration controller;
-
-                               controller = CdmStore.getCurrentApplicationConfiguration();
-
-                               ITaxonService service = controller.getTaxonService();
-                               if (synonym.getId() == 0){
-                                       element.removeSynonym(synonym);
-
-                               } else {
-//TODO: this should be moved to the handler, the operations should not contain ui code
-                                       DeleteResult result = service.deleteSynonym(synonym.getUuid(), element.getUuid(), null);
-                                       if (result.isError()){
-                                               DeleteResultMessagingUtils.messageDialogWithDetails(result, "Delete failed", TaxeditorEditorPlugin.PLUGIN_ID);
-                                       } else if (!result.getUpdatedObjects().isEmpty()){
-                                           DeleteResultMessagingUtils.messageDialogWithDetails(result, "The Synonym could be deleted, but related object(s) could not be deleted", TaxeditorEditorPlugin.PLUGIN_ID);
-                                       }
-                               }
-                       //      taxon.removeSynonym(synonym);
+               synonymType = synonym.getType();
+               monitor.worked(20);
+
+               // Remove synonym from taxon
+               ICdmApplicationConfiguration controller;
+
+               controller = CdmStore.getCurrentApplicationConfiguration();
+
+               ITaxonService service = controller.getTaxonService();
+               if (synonym.getId() == 0){
+                       element.removeSynonym(synonym);
+
+               } else {
+                       //TODO: this should be moved to the handler, the operations should not contain ui code
+                       DeleteResult result = service.deleteSynonym(synonym.getUuid(), null);
+                       if (result.isError()){
+                               DeleteResultMessagingUtils.messageDialogWithDetails(result, "Delete failed", TaxeditorEditorPlugin.PLUGIN_ID);
+                       } else if (!result.getUpdatedObjects().isEmpty()){
+                           DeleteResultMessagingUtils.messageDialogWithDetails(result, "The Synonym could be deleted, but related object(s) could not be deleted", TaxeditorEditorPlugin.PLUGIN_ID);
+                       }
+               }
+       //      taxon.removeSynonym(synonym);
 //                             CdmStore.getTaxonService().deleteSynonymRelationships(synonym);
 //                             CdmStore.getTaxonService().delete(synonym);
 
-                               monitor.worked(40);
+               monitor.worked(40);
 
-                               // Redraw editor if exists
+               // Redraw editor if exists
 
-                               return postExecute(element);
+               return postExecute(element);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
@@ -108,18 +100,13 @@ public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
                return execute(monitor, info);
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
        /** {@inheritDoc} */
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
 
                // Add synonym to taxon
-               for (SynonymRelationshipType synonymType : synonymTypes){
-                       element.addSynonym(synonym, synonymType);
-               }
+               element.addSynonym(synonym, synonymType);
 
                // Redraw editor if exists
                return postExecute(synonym);
index 1e3b300..19bee8a 100644 (file)
@@ -15,7 +15,6 @@ import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;\r
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
 import eu.etaxonomy.cdm.model.taxon.Synonym;\r
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;\r
 import eu.etaxonomy.cdm.model.taxon.Taxon;\r
 import eu.etaxonomy.taxeditor.editor.EditorUtil;\r
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;\r
@@ -67,24 +66,18 @@ public class MoveSynonymToAnotherAcceptedTaxonOperation extends
                TaxonNameBase<?, ?> synonymName = synonym.getName();\r
                monitor.worked(20);\r
 \r
-\r
-\r
                // Switch groups\r
 \r
                monitor.worked(40);\r
-               SynonymRelationship synRel = synonym.getSynonymRelations().iterator().next();\r
-\r
-\r
 \r
                ((TaxonNameEditor)EditorUtil.getActiveMultiPageTaxonEditor().getActiveEditor()).getConversationHolder().commit();\r
                UpdateResult result;\r
 \r
-\r
                try {\r
-                       result = CdmStore.getService(ITaxonService.class).moveSynonymToAnotherTaxon(synRel,\r
+                       result = CdmStore.getService(ITaxonService.class).moveSynonymToAnotherTaxon(synonym,\r
                                this.element.getUuid(),\r
                                true,\r
-                               synRel.getType(),\r
+                               synonym.getType(),\r
                                null,\r
                                null,\r
                                true);\r
@@ -94,10 +87,8 @@ public class MoveSynonymToAnotherAcceptedTaxonOperation extends
                }\r
                ((TaxonNameEditor)EditorUtil.getActiveMultiPageTaxonEditor().getActiveEditor()).getConversationHolder().commit();\r
 \r
-\r
-\r
                // Redraw editor if it exists\r
-               return postExecute(synRel.getSynonym());\r
+               return postExecute(synonym);\r
        }\r
 \r
        @Override\r
index 9573988..9416926 100644 (file)
@@ -79,7 +79,7 @@ public class ChangeSynonymToMisapplicationOperationTest extends AbstractTaxedito
                Assert.assertTrue("Taxon should have synonyms.", taxon.getSynonyms().size() > 0);
                Assert.assertTrue("Taxon should not have taxon relationship.", taxon.getTaxonRelations().size() == 0);
                Assert.assertEquals("Not the expected synonym.", synonym, taxon.getSynonyms().toArray(new Synonym[0])[0]);
-               Assert.assertEquals("SynonymRelationshipType is not the expected.", synonymRelationshipType, taxon.getSynonyms().toArray(new Synonym[0])[0].getRelationType(taxon));
+               Assert.assertEquals("SynonymRelationshipType is not the expected.", synonymRelationshipType, taxon.getSynonyms().iterator().next().getType());
        }
        
        /**
index 7f476f1..04f3d24 100644 (file)
@@ -17,7 +17,6 @@ import org.junit.Test;
 
 import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
 import eu.etaxonomy.cdm.model.name.NonViralName;
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.taxeditor.store.operations.AbstractTaxeditorOperationTestBase;
@@ -82,7 +81,7 @@ public class CreateSynonymInExisitingHomotypicalGroupOperationTest extends Abstr
 
                Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
                Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0);
-               Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonymRelations().toArray(new SynonymRelationship[0])[0].getType());
+               Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonyms().iterator().next().getType());
        }
 
 
@@ -140,7 +139,7 @@ public class CreateSynonymInExisitingHomotypicalGroupOperationTest extends Abstr
 
                Assert.assertTrue("Taxon should have a synonym now.", taxon.getSynonyms().size() > 0);
                Assert.assertTrue("Taxon should have a homotypic group", taxon.getHomotypicSynonymyGroups().size() > 0);
-               Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonymRelations().toArray(new SynonymRelationship[0])[0].getType());
+               Assert.assertEquals("Synonym relationship should be heterotypic", SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), taxon.getSynonyms().iterator().next().getType());
 
        }
 }
index a871786..c165a82 100644 (file)
@@ -84,7 +84,7 @@ public class SwapSynonymAndAcceptedOperationTest extends AbstractTaxeditorOperat
 //             childTaxon.setTaxonomicParent(taxon, null, null);
 
                // Create a homotypic synonym for the accepted taxon
-               taxon.addHomotypicSynonymName(NonViralName.NewInstance(null), null, null);
+               taxon.addHomotypicSynonymName(NonViralName.NewInstance(null));
 //             homotypicSynonym = Synonym.NewInstance(NonViralName.NewInstance(null), null);
 //             HomotypicalGroup acceptedHomotypicalGroup = HomotypicalGroup.NewInstance();
 //             acceptedHomotypicalGroup.addTypifiedName(oldTaxon.getName());
index da31d1c..c4d361d 100644 (file)
@@ -10,6 +10,7 @@
 package eu.etaxonomy.taxeditor.navigation;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
@@ -289,7 +290,11 @@ public class NavigationUtil extends AbstractUtility{
                }else if(selection instanceof Synonym){
                        Synonym synonym = (Synonym) selection;
 
-                       handleOpeningOfMultipleTaxa(synonym.getAcceptedTaxa());
+                       Set<Taxon> accTaxa = new HashSet<Taxon>();
+                       if (synonym.getAcceptedTaxon() != null){
+                               accTaxa.add(synonym.getAcceptedTaxon());
+                       }
+                       handleOpeningOfMultipleTaxa(accTaxa);
 
                }else{
                        MessagingUtils.warningDialog("Not implemented yet", NavigationUtil.class, "You chose to open a name that has no connection to a taxon. The Editor does not support editing of such a content type at the moment.");