1
|
/**
|
2
|
* Copyright (C) 2015 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.operation;
|
10
|
|
11
|
import org.eclipse.core.commands.ExecutionException;
|
12
|
import org.eclipse.core.commands.operations.IUndoContext;
|
13
|
import org.eclipse.core.runtime.IAdaptable;
|
14
|
import org.eclipse.core.runtime.IProgressMonitor;
|
15
|
import org.eclipse.core.runtime.IStatus;
|
16
|
|
17
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
18
|
import eu.etaxonomy.cdm.api.service.config.SubtreeCloneConfigurator;
|
19
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
20
|
import eu.etaxonomy.cdm.api.service.UpdateResult;
|
21
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
22
|
import eu.etaxonomy.cdm.model.taxon.Classification;
|
23
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
24
|
import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
|
25
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
26
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
27
|
|
28
|
/**
|
29
|
* @author pplitzner
|
30
|
*/
|
31
|
public class CloneClassificationOperation extends AbstractPersistentPostOperation {
|
32
|
|
33
|
private final Classification classification;
|
34
|
|
35
|
private final ITaxonNodeService service;
|
36
|
|
37
|
private String classificationName;
|
38
|
|
39
|
private Reference sec;
|
40
|
|
41
|
private TaxonRelationshipType relationType;
|
42
|
|
43
|
public CloneClassificationOperation(String label, IUndoContext undoContext, Classification classification,
|
44
|
String classificationName, Reference sec, TaxonRelationshipType relationType,
|
45
|
IPostOperationEnabled postOperationEnabled,
|
46
|
IConversationEnabled conversationEnabled) {
|
47
|
super(label, undoContext, postOperationEnabled, conversationEnabled);
|
48
|
|
49
|
this.classification = classification;
|
50
|
this.classificationName = classificationName;
|
51
|
this.sec = sec;
|
52
|
this.relationType = relationType;
|
53
|
this.service = CdmStore.getService(ITaxonNodeService.class);
|
54
|
}
|
55
|
|
56
|
@Override
|
57
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
58
|
|
59
|
SubtreeCloneConfigurator cloneConfig = SubtreeCloneConfigurator.NewBaseInstance(
|
60
|
classification.getRootNode().getUuid(), classificationName);
|
61
|
cloneConfig.setTaxonSecundum(sec);
|
62
|
cloneConfig.setRelationTypeToOldTaxon(relationType);
|
63
|
|
64
|
UpdateResult result = service.cloneSubtree(cloneConfig);
|
65
|
return postExecute(result.getCdmEntity());
|
66
|
}
|
67
|
|
68
|
@Override
|
69
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
70
|
return null;
|
71
|
}
|
72
|
|
73
|
@Override
|
74
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
75
|
return null;
|
76
|
}
|
77
|
|
78
|
}
|