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
|
package eu.etaxonomy.taxeditor.navigation.key.polytomous.operation;
|
10
|
|
11
|
import java.util.UUID;
|
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.ConversationHolder;
|
20
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
|
21
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
22
|
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
|
23
|
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
|
24
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
|
27
|
/**
|
28
|
* Operation responsible for refreshing key nodes node numbers of the Polytomous Keys.
|
29
|
* The refresh is performed on all keys/
|
30
|
*
|
31
|
* @author c.mathew
|
32
|
* @created Jan 17 2013
|
33
|
*/
|
34
|
public class RefreshNodesOperation extends AbstractPostTaxonOperation {
|
35
|
|
36
|
private PolytomousKey key;
|
37
|
|
38
|
public RefreshNodesOperation(String label,
|
39
|
IUndoContext undoContext,
|
40
|
PolytomousKey key,
|
41
|
IPostOperationEnabled postOperationEnabled) {
|
42
|
super(label, undoContext, postOperationEnabled);
|
43
|
this.key = key;
|
44
|
}
|
45
|
|
46
|
@Override
|
47
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
48
|
throws ExecutionException {
|
49
|
UUID polytomousKeyNodeUuid = key.getRoot().getUuid();
|
50
|
ConversationHolder conversation = CdmStore.createConversation();
|
51
|
PolytomousKeyNode root = CdmStore.getService(IPolytomousKeyNodeService.class).load(polytomousKeyNodeUuid, null);
|
52
|
root.refreshNodeNumbering();
|
53
|
CdmStore.getService(IPolytomousKeyNodeService.class).saveOrUpdate(root);
|
54
|
conversation.commit(true);
|
55
|
return postExecute(root);
|
56
|
}
|
57
|
|
58
|
@Override
|
59
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
60
|
throws ExecutionException {
|
61
|
// TODO Auto-generated method stub
|
62
|
return null;
|
63
|
}
|
64
|
|
65
|
@Override
|
66
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
67
|
throws ExecutionException {
|
68
|
// TODO Auto-generated method stub
|
69
|
return null;
|
70
|
}
|
71
|
}
|