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.application.ICdmRepository;
|
19
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
20
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
21
|
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
|
22
|
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
|
23
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
24
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
25
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
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>DeleteMisapplicationOperation class.</p>
|
32
|
*
|
33
|
* @author p.ciardelli
|
34
|
* @created 16.01.2009
|
35
|
*/
|
36
|
public class DeleteMisapplicationOperation extends DeleteTaxonBaseOperation {
|
37
|
|
38
|
private final Taxon misapplication;
|
39
|
|
40
|
private Reference citation;
|
41
|
|
42
|
private String microcitation;
|
43
|
|
44
|
/**
|
45
|
* <p>Constructor for DeleteMisapplicationOperation.</p>
|
46
|
*
|
47
|
* @param label a {@link java.lang.String} object.
|
48
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
49
|
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
|
50
|
* @param misapplication a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
|
51
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
52
|
*/
|
53
|
public DeleteMisapplicationOperation(String label, IUndoContext undoContext, TaxonBaseDeletionConfigurator configurator,
|
54
|
Taxon taxon, Taxon misapplication, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled,ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
55
|
//super(label, undoContext, taxon, postOperationEnabled);
|
56
|
super(label, undoContext, configurator, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
|
57
|
this.misapplication = misapplication;
|
58
|
this.element = taxon;
|
59
|
}
|
60
|
|
61
|
@Override
|
62
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
63
|
throws ExecutionException {
|
64
|
|
65
|
// Find misapplication relation, save citation information
|
66
|
|
67
|
// for (TaxonRelationship relationship : element.getTaxonRelations()) {
|
68
|
// if (relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())
|
69
|
// && relationship.getFromTaxon().equals(misapplication)) {
|
70
|
// citation = relationship.getCitation();
|
71
|
// microcitation = relationship.getCitationMicroReference();
|
72
|
// }
|
73
|
// }
|
74
|
monitor.worked(20);
|
75
|
|
76
|
// Remove misapplied name relation from taxon
|
77
|
element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
|
78
|
ICdmRepository controller;
|
79
|
|
80
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
81
|
|
82
|
ITaxonService service = controller.getTaxonService();
|
83
|
|
84
|
result = service.deleteTaxon(misapplication.getUuid(), (TaxonDeletionConfigurator)configurator, null);
|
85
|
monitor.worked(40);
|
86
|
|
87
|
return postExecute(null);
|
88
|
}
|
89
|
|
90
|
@Override
|
91
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
92
|
throws ExecutionException {
|
93
|
return execute(monitor, info);
|
94
|
}
|
95
|
|
96
|
@Override
|
97
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
98
|
throws ExecutionException {
|
99
|
|
100
|
element.addMisappliedName(misapplication, citation, microcitation);
|
101
|
|
102
|
return postExecute(misapplication);
|
103
|
}
|
104
|
}
|