Project

General

Profile

Download (3.03 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.editor.name.operation;
11

    
12
import org.eclipse.core.commands.ExecutionException;
13
import org.eclipse.core.commands.operations.IUndoContext;
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
17

    
18
import eu.etaxonomy.cdm.api.service.ITaxonService;
19
import eu.etaxonomy.cdm.api.service.UpdateResult;
20
import eu.etaxonomy.cdm.model.taxon.Synonym;
21
import eu.etaxonomy.cdm.model.taxon.SynonymType;
22
import eu.etaxonomy.cdm.model.taxon.Taxon;
23
import eu.etaxonomy.taxeditor.editor.Messages;
24
import eu.etaxonomy.taxeditor.model.MessagingUtils;
25
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
26
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
27
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
28
import eu.etaxonomy.taxeditor.store.CdmStore;
29

    
30
/**
31
 * <p>SwapSynonymAndAcceptedOperation class.</p>
32
 *
33
 * @author n.hoffmann
34
 * @created 23.04.2009
35
 */
36
public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation {
37

    
38
	private final Synonym synonym;
39
	// TODO store the old relationship for undo reasons
40
	private SynonymType synonymType;
41

    
42
	/**
43
	 * <p>Constructor for SwapSynonymAndAcceptedOperation.</p>
44
	 *
45
	 * @param label a {@link java.lang.String} object.
46
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
47
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
48
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49
	 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
50
	 */
51
	public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext,
52
			Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled,
53
			ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
54
		super(Messages.SwapSynonymAndAcceptedOperation_SWAP_SYN_ACC_TAXON, undoContext, taxon, postOperationEnabled, cdmEntitySessionEnabled);
55

    
56
		this.synonym = synonym;
57
	}
58

    
59
	/** {@inheritDoc} */
60
	@Override
61
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
62
			throws ExecutionException {
63

    
64
		monitor.worked(20);
65

    
66
		UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid());
67

    
68
		monitor.worked(40);
69

    
70
		return postExecute(element);
71
	}
72

    
73
	/** {@inheritDoc} */
74
	@Override
75
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
76
			throws ExecutionException {
77
		// TODO Auto-generated method stub
78
		return execute(monitor, info);
79
	}
80

    
81
	/** {@inheritDoc} */
82
	@Override
83
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
84
			throws ExecutionException {
85
		MessagingUtils.error(this.getClass(), Messages.SwapSynonymAndAcceptedOperation_NOT_IMPLEMENTED, null);
86
		return null;
87
	}
88
}
(19-19/19)