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.navigation.navigator.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.conversation.IConversationEnabled;
|
20
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
21
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
22
|
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
|
23
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
24
|
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
|
25
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
26
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
27
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
28
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
29
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
30
|
|
31
|
/**
|
32
|
* <p>ChangeAcceptedTaxonToSynonymOperation class.</p>
|
33
|
*
|
34
|
* @author n.hoffmann
|
35
|
* @created Jan 4, 2010
|
36
|
* @version 1.0
|
37
|
*/
|
38
|
public class ChangeAcceptedTaxonToSynonymOperation extends
|
39
|
DeleteOperation {
|
40
|
|
41
|
private final TaxonNode newAcceptedTaxonNode;
|
42
|
private final ICdmEntitySessionEnabled cdmEntitySessionEnabled;
|
43
|
|
44
|
//private TaxonNode oldTaxonNode;
|
45
|
|
46
|
/**
|
47
|
* <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
|
48
|
*
|
49
|
* @param label a {@link java.lang.String} object.
|
50
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
51
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
52
|
* @param oldTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
|
53
|
* @param newAcceptedTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
|
54
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
55
|
*/
|
56
|
public ChangeAcceptedTaxonToSynonymOperation(String label,
|
57
|
IUndoContext undoContext,
|
58
|
ITaxonTreeNode oldTaxonNode,
|
59
|
TaxonNode newAcceptedTaxonNode,
|
60
|
IPostOperationEnabled postOperationEnabled,
|
61
|
IConversationEnabled conversationEnabled,
|
62
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
63
|
super(label, undoContext, oldTaxonNode, new TaxonDeletionConfigurator(),postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
|
64
|
this.newAcceptedTaxonNode = newAcceptedTaxonNode;
|
65
|
this.cdmEntitySessionEnabled = cdmEntitySessionEnabled;
|
66
|
}
|
67
|
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
71
|
*/
|
72
|
/** {@inheritDoc} */
|
73
|
@Override
|
74
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
75
|
throws ExecutionException {
|
76
|
|
77
|
monitor.worked(20);
|
78
|
bind();
|
79
|
|
80
|
Taxon oldTaxon = (Taxon) HibernateProxyHelper.deproxy(((TaxonNode) taxonNode).getTaxon());
|
81
|
|
82
|
UpdateResult result = CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(taxonNode.getUuid(), newAcceptedTaxonNode.getUuid(), null, null, null);
|
83
|
|
84
|
monitor.worked(40);
|
85
|
return postExecute(oldTaxon);
|
86
|
}
|
87
|
|
88
|
/* (non-Javadoc)
|
89
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
90
|
*/
|
91
|
/** {@inheritDoc} */
|
92
|
@Override
|
93
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
94
|
throws ExecutionException {
|
95
|
// TODO Auto-generated method stub
|
96
|
return null;
|
97
|
}
|
98
|
|
99
|
/* (non-Javadoc)
|
100
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
101
|
*/
|
102
|
/** {@inheritDoc} */
|
103
|
@Override
|
104
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
105
|
throws ExecutionException {
|
106
|
// TODO Auto-generated method stub
|
107
|
return null;
|
108
|
}
|
109
|
}
|