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 java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
import org.eclipse.core.commands.ExecutionException;
|
16
|
import org.eclipse.core.commands.operations.IUndoContext;
|
17
|
import org.eclipse.core.runtime.IAdaptable;
|
18
|
import org.eclipse.core.runtime.IProgressMonitor;
|
19
|
import org.eclipse.core.runtime.IStatus;
|
20
|
|
21
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
22
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
24
|
import eu.etaxonomy.cdm.model.taxon.SynonymType;
|
25
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
26
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
27
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
28
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
29
|
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
30
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
31
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
32
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
33
|
|
34
|
/**
|
35
|
* <p>SwapSynonymAndAcceptedOperation class.</p>
|
36
|
*
|
37
|
* @author n.hoffmann
|
38
|
* @created 23.04.2009
|
39
|
*/
|
40
|
public class SwapSynonymAndAcceptedOperation extends AbstractPostTaxonOperation {
|
41
|
|
42
|
private final Synonym synonym;
|
43
|
// TODO store the old relationship for undo reasons
|
44
|
private SynonymType synonymType;
|
45
|
|
46
|
private List<TaxonNode> nodes;
|
47
|
|
48
|
private boolean setNameInSource;
|
49
|
|
50
|
/**
|
51
|
* <p>Constructor for SwapSynonymAndAcceptedOperation.</p>
|
52
|
*
|
53
|
* @param label a {@link java.lang.String} object.
|
54
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
55
|
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
|
56
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
57
|
* @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
|
58
|
*/
|
59
|
public SwapSynonymAndAcceptedOperation(String label, IUndoContext undoContext,
|
60
|
Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled,
|
61
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled, boolean setNameInSource) {
|
62
|
super(Messages.SwapSynonymAndAcceptedOperation_SWAP_SYN_ACC_TAXON, undoContext, taxon, postOperationEnabled, cdmEntitySessionEnabled);
|
63
|
this.setNameInSource = setNameInSource;
|
64
|
this.synonym = synonym;
|
65
|
this.nodes = new ArrayList<TaxonNode>(taxon.getTaxonNodes());
|
66
|
|
67
|
}
|
68
|
|
69
|
@Override
|
70
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
71
|
throws ExecutionException {
|
72
|
|
73
|
monitor.worked(20);
|
74
|
|
75
|
UpdateResult result = CdmStore.getService(ITaxonService.class).swapSynonymAndAcceptedTaxon(synonym.getUuid(), element.getUuid(), setNameInSource, false);//TODO
|
76
|
element = (Taxon)result.getCdmEntity();
|
77
|
List<String> propertyPath = new ArrayList<>();
|
78
|
propertyPath.add("synonyms");
|
79
|
|
80
|
monitor.worked(40);
|
81
|
|
82
|
return postExecute(element);
|
83
|
}
|
84
|
|
85
|
@Override
|
86
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
87
|
throws ExecutionException {
|
88
|
// TODO Auto-generated method stub
|
89
|
return execute(monitor, info);
|
90
|
}
|
91
|
|
92
|
@Override
|
93
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
94
|
throws ExecutionException {
|
95
|
MessagingUtils.error(this.getClass(), Messages.SwapSynonymAndAcceptedOperation_NOT_IMPLEMENTED, null);
|
96
|
return null;
|
97
|
}
|
98
|
}
|