1
|
package eu.etaxonomy.taxeditor.editor.name.operation;
|
2
|
|
3
|
import java.util.Iterator;
|
4
|
import java.util.Set;
|
5
|
|
6
|
import org.eclipse.core.commands.ExecutionException;
|
7
|
import org.eclipse.core.commands.operations.IUndoContext;
|
8
|
import org.eclipse.core.runtime.IAdaptable;
|
9
|
import org.eclipse.core.runtime.IProgressMonitor;
|
10
|
import org.eclipse.core.runtime.IStatus;
|
11
|
import org.eclipse.ui.IWorkbenchPage;
|
12
|
|
13
|
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
|
14
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
15
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
16
|
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
|
17
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
18
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
19
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
20
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
21
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
22
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
23
|
|
24
|
public class DeleteTaxonOperation extends DeleteTaxonBaseOperation{
|
25
|
|
26
|
private final Classification classification;
|
27
|
|
28
|
public DeleteTaxonOperation(String label,
|
29
|
IUndoContext undoContext,
|
30
|
Taxon taxon,
|
31
|
TaxonDeletionConfigurator configurator,
|
32
|
Classification classification,
|
33
|
IWorkbenchPage activePage,
|
34
|
IPostOperationEnabled postOperationEnabled,
|
35
|
IConversationEnabled conversationEnabled,
|
36
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
37
|
super(label, undoContext, configurator, activePage, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
|
38
|
this.element = taxon;
|
39
|
|
40
|
Set<TaxonNode> nodes = taxon.getTaxonNodes();
|
41
|
if (nodes.size() == 1 && classification == null){
|
42
|
this.taxonNode = nodes.iterator().next();
|
43
|
} else if (classification != null){
|
44
|
Iterator<TaxonNode> iterator = nodes.iterator();
|
45
|
while (iterator.hasNext()){
|
46
|
TaxonNode node = iterator.next();
|
47
|
if (node.getClassification().equals(classification)){
|
48
|
this.taxonNode = node;
|
49
|
}
|
50
|
}
|
51
|
} else{
|
52
|
//TODO
|
53
|
}
|
54
|
this.classification = classification;
|
55
|
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
60
|
throws ExecutionException {
|
61
|
|
62
|
monitor.worked(20);
|
63
|
bind();
|
64
|
|
65
|
|
66
|
ICdmApplicationConfiguration controller;
|
67
|
|
68
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
69
|
|
70
|
ITaxonService service = controller.getTaxonService();
|
71
|
|
72
|
result = service.deleteTaxon(element.getUuid(), (TaxonDeletionConfigurator)configurator, classification.getUuid());
|
73
|
|
74
|
|
75
|
|
76
|
monitor.worked(40);
|
77
|
|
78
|
|
79
|
return postExecute(null);
|
80
|
}
|
81
|
|
82
|
@Override
|
83
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
84
|
throws ExecutionException {
|
85
|
// TODO Auto-generated method stub
|
86
|
return null;
|
87
|
}
|
88
|
|
89
|
@Override
|
90
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
91
|
throws ExecutionException {
|
92
|
// TODO Auto-generated method stub
|
93
|
return null;
|
94
|
}
|
95
|
|
96
|
}
|