1
|
/**
|
2
|
* Copyright (C) 2018 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.featuretree.e4.operation;
|
10
|
|
11
|
import java.util.UUID;
|
12
|
|
13
|
import org.eclipse.core.commands.ExecutionException;
|
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.service.IFeatureNodeService;
|
19
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
20
|
import eu.etaxonomy.cdm.model.description.Feature;
|
21
|
import eu.etaxonomy.cdm.model.term.TermNode;
|
22
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
23
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
24
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
25
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
26
|
import eu.etaxonomy.taxeditor.store.StoreUtil;
|
27
|
|
28
|
/**
|
29
|
* @author pplitzner
|
30
|
* @since Apr 30, 2018
|
31
|
*
|
32
|
*/
|
33
|
public class AddFeatureOperation extends AbstractPostOperation<Feature> {
|
34
|
|
35
|
private TermNode<Feature> node;
|
36
|
private int position;
|
37
|
private UUID featureUuid;
|
38
|
|
39
|
public AddFeatureOperation(UUID featureUuid, TermNode<Feature> node,
|
40
|
IPostOperationEnabled postOperationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
41
|
this(featureUuid, node, 0, postOperationEnabled, cdmEntitySessionEnabled);
|
42
|
}
|
43
|
public AddFeatureOperation(UUID featureUuid, TermNode<Feature> node, int position,
|
44
|
IPostOperationEnabled postOperationEnabled, ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
45
|
super("Add Feature", StoreUtil.getUndoContext(), null, postOperationEnabled, cdmEntitySessionEnabled);
|
46
|
this.node = node;
|
47
|
this.featureUuid = featureUuid;
|
48
|
this.position = position;
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
53
|
UpdateResult updateResult = CdmStore.getService(IFeatureNodeService.class).addChildFeatureNode(node.getUuid(), featureUuid, position);
|
54
|
return postExecute(updateResult.getCdmEntity());
|
55
|
}
|
56
|
|
57
|
@Override
|
58
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
59
|
return null;
|
60
|
}
|
61
|
|
62
|
@Override
|
63
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
64
|
return null;
|
65
|
}
|
66
|
|
67
|
}
|