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.UUID;
|
13
|
|
14
|
import org.eclipse.core.commands.ExecutionException;
|
15
|
import org.eclipse.core.commands.operations.IUndoContext;
|
16
|
import org.eclipse.core.runtime.IAdaptable;
|
17
|
import org.eclipse.core.runtime.IProgressMonitor;
|
18
|
import org.eclipse.core.runtime.IStatus;
|
19
|
|
20
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
21
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
22
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
23
|
import eu.etaxonomy.cdm.api.service.exception.HomotypicalGroupChangeException;
|
24
|
import eu.etaxonomy.cdm.model.metadata.SecReferenceHandlingEnum;
|
25
|
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
26
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
27
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
28
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
29
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
30
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
31
|
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
|
32
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
33
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
34
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
35
|
|
36
|
/**
|
37
|
* Change the taxonomic parent of a given taxon.
|
38
|
*
|
39
|
* @author n.hoffmann
|
40
|
* @created 16.01.2009
|
41
|
*/
|
42
|
public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPostOperation {
|
43
|
|
44
|
private final Synonym synonym;
|
45
|
private final ITaxonTreeNode parentNode;
|
46
|
|
47
|
private TaxonNode newNode;
|
48
|
private UUID newSecRefUuid;
|
49
|
private SecReferenceHandlingEnum secHandling;
|
50
|
|
51
|
|
52
|
/**
|
53
|
* <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p>
|
54
|
*
|
55
|
* @param label a {@link java.lang.String} object.
|
56
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
57
|
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
|
58
|
* @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
|
59
|
* @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
|
60
|
* @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects.
|
61
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
62
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
63
|
*/
|
64
|
public ChangeSynonymToAcceptedTaxonOperation(String label,
|
65
|
IUndoContext undoContext,
|
66
|
Taxon taxon,
|
67
|
ITaxonTreeNode parentNode,
|
68
|
Synonym synonym,
|
69
|
UUID newSecUuid,
|
70
|
SecReferenceHandlingEnum secHandling,
|
71
|
IPostOperationEnabled postOperationEnabled,
|
72
|
IConversationEnabled conversationEnabled,
|
73
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
74
|
super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
|
75
|
|
76
|
this.element = taxon;
|
77
|
this.parentNode = parentNode;
|
78
|
this.synonym = synonym;
|
79
|
this.newSecRefUuid = newSecUuid;
|
80
|
this.secHandling = secHandling;
|
81
|
}
|
82
|
|
83
|
@Override
|
84
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
85
|
throws ExecutionException {
|
86
|
|
87
|
|
88
|
UpdateResult result;
|
89
|
try {
|
90
|
result = CdmStore.getService(ITaxonService.class).changeSynonymToAcceptedTaxon(synonym.getUuid(),
|
91
|
element.getUuid(),
|
92
|
parentNode.getUuid(),
|
93
|
newSecRefUuid, null, secHandling,
|
94
|
true);
|
95
|
if (result.isAbort()){
|
96
|
|
97
|
MessagingUtils.warningDialog(Messages.ChangeSynonymToAcceptedTaxonOperation_INCONSISTENT_DATA, getClass(), result.toString());
|
98
|
return postExecute(null);
|
99
|
}
|
100
|
newNode = (TaxonNode) result.getCdmEntity();
|
101
|
} catch (HomotypicalGroupChangeException e) {
|
102
|
// TODO Auto-generated catch block
|
103
|
e.printStackTrace();
|
104
|
}
|
105
|
|
106
|
|
107
|
monitor.worked(20);
|
108
|
return postExecute(newNode);
|
109
|
}
|
110
|
|
111
|
@Override
|
112
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
113
|
throws ExecutionException {
|
114
|
return execute(monitor, info);
|
115
|
}
|
116
|
|
117
|
@Override
|
118
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
119
|
throws ExecutionException {
|
120
|
|
121
|
// TODO implement - biggest problem is that any window open for new taxon must be closed first
|
122
|
MessagingUtils.warn(this.getClass(), Messages.ChangeSynonymToAcceptedTaxonOperation_NOT_IMPLEMENTED);
|
123
|
|
124
|
return postExecute(element);
|
125
|
}
|
126
|
|
127
|
}
|