1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
12
|
|
13
|
import org.eclipse.core.commands.ExecutionException;
|
14
|
import org.eclipse.core.commands.operations.IUndoContext;
|
15
|
import org.eclipse.core.runtime.IAdaptable;
|
16
|
import org.eclipse.core.runtime.IProgressMonitor;
|
17
|
import org.eclipse.core.runtime.IStatus;
|
18
|
|
19
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
20
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
21
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
22
|
import eu.etaxonomy.cdm.model.taxon.SynonymType;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
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("Swap Synonym And Accepted Taxon Operation", 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(), "Not yet implemented", null);
|
86
|
return null;
|
87
|
}
|
88
|
}
|