1
|
package eu.etaxonomy.taxeditor.navigation.key.polytomous.operation;
|
2
|
|
3
|
import java.util.UUID;
|
4
|
|
5
|
import org.eclipse.core.commands.ExecutionException;
|
6
|
import org.eclipse.core.commands.operations.IUndoContext;
|
7
|
import org.eclipse.core.runtime.IAdaptable;
|
8
|
import org.eclipse.core.runtime.IProgressMonitor;
|
9
|
import org.eclipse.core.runtime.IStatus;
|
10
|
|
11
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
12
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
|
13
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
14
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
15
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
16
|
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
|
17
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
18
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
19
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
20
|
|
21
|
/**
|
22
|
* Operation responsible for refreshing key nodes node numbers of the Polytomous Keys.
|
23
|
* The refresh is performed on all keys/
|
24
|
*
|
25
|
* @author c.mathew
|
26
|
* @created Jan 17 2013
|
27
|
* @version 1.0
|
28
|
*
|
29
|
*/
|
30
|
public class RefreshNodesOperation extends AbstractPostOperation {
|
31
|
|
32
|
PolytomousKey key;
|
33
|
|
34
|
public RefreshNodesOperation(String label,
|
35
|
IUndoContext undoContext,
|
36
|
PolytomousKey key,
|
37
|
IPostOperationEnabled postOperationEnabled) {
|
38
|
super(label, undoContext, postOperationEnabled);
|
39
|
this.key = key;
|
40
|
}
|
41
|
|
42
|
/* (non-Javadoc)
|
43
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
44
|
*/
|
45
|
@Override
|
46
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
47
|
throws ExecutionException {
|
48
|
UUID polytomousKeyNodeUuid = key.getRoot().getUuid();
|
49
|
ConversationHolder conversation = CdmStore.createConversation();
|
50
|
PolytomousKeyNode root = CdmStore.getService(IPolytomousKeyNodeService.class).load(polytomousKeyNodeUuid, null);
|
51
|
root.refreshNodeNumbering();
|
52
|
CdmStore.getService(IPolytomousKeyNodeService.class).saveOrUpdate(root);
|
53
|
conversation.commit(true);
|
54
|
return postExecute(root);
|
55
|
}
|
56
|
|
57
|
/* (non-Javadoc)
|
58
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
59
|
*/
|
60
|
@Override
|
61
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
62
|
throws ExecutionException {
|
63
|
// TODO Auto-generated method stub
|
64
|
return null;
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
69
|
*/
|
70
|
@Override
|
71
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
72
|
throws ExecutionException {
|
73
|
// TODO Auto-generated method stub
|
74
|
return null;
|
75
|
}
|
76
|
|
77
|
}
|