Project

General

Profile

« Previous | Next » 

Revision 2297e423

Added by Patrick Plitzner about 9 years ago

  • fixed exception when changing accepted taxon to synonym of itself

View differences:

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/ChangeAcceptedTaxonToSynonymOperation.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2007 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
15 15
import org.eclipse.core.runtime.IAdaptable;
16 16
import org.eclipse.core.runtime.IProgressMonitor;
17 17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
18 19

  
19 20
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
20 21
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21 22
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
22
import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
23 23
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
24
import eu.etaxonomy.cdm.model.common.ITreeNode;
25 24
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
26
import eu.etaxonomy.cdm.model.taxon.Synonym;
27 25
import eu.etaxonomy.cdm.model.taxon.Taxon;
28 26
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
29
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
27
import eu.etaxonomy.taxeditor.model.MessagingUtils;
28
import eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin;
30 29
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
31 30
import eu.etaxonomy.taxeditor.store.CdmStore;
32 31

  
......
39 38
 */
40 39
public class ChangeAcceptedTaxonToSynonymOperation extends
41 40
	DeleteOperation {
42
	
43
	private TaxonNode newAcceptedTaxonNode;
41

  
42
	private final TaxonNode newAcceptedTaxonNode;
44 43

  
45 44
	//private TaxonNode oldTaxonNode;
46
	
45

  
47 46
	/**
48 47
	 * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
49 48
	 *
......
72 71

  
73 72
		monitor.worked(20);
74 73
		bind();
75
    	Synonym synonym = null;
76 74
    	Taxon oldTaxon = (Taxon) HibernateProxyHelper.deproxy(((TaxonNode) taxonNode).getTaxon());
77
		
78
		synonym = CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode((TaxonNode) taxonNode, newAcceptedTaxonNode, null, null, null);
79
		
75
		try {
76
		    CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode((TaxonNode) taxonNode, newAcceptedTaxonNode, null, null, null);
77
        } catch (IllegalArgumentException e) {
78
            MessagingUtils.errorDialog("Operation failed", this, e.getMessage(), TaxeditorNavigationPlugin.PLUGIN_ID, e, false);
79
            return Status.CANCEL_STATUS;
80
        }
81

  
80 82
		monitor.worked(40);
81
        
83

  
82 84
		return postExecute(oldTaxon);
83 85
	}
84 86

  

Also available in: Unified diff