2 * Copyright (C) 2015 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.navigation
.operation
;
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
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
18 import eu
.etaxonomy
.cdm
.api
.service
.config
.SubtreeCloneConfigurator
;
19 import eu
.etaxonomy
.cdm
.api
.service
.IClassificationService
;
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
;
31 public class CloneClassificationOperation
extends AbstractPersistentPostOperation
{
33 private final Classification classification
;
35 private final IClassificationService service
;
37 private String classificationName
;
39 private Reference sec
;
41 private TaxonRelationshipType relationType
;
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
);
49 this.classification
= classification
;
50 this.classificationName
= classificationName
;
52 this.relationType
= relationType
;
53 this.service
= CdmStore
.getService(IClassificationService
.class);
57 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
59 SubtreeCloneConfigurator cloneConfig
= SubtreeCloneConfigurator
.NewBaseInstance(
60 classification
.getRootNode().getUuid(), classificationName
);
61 cloneConfig
.setTaxonSecundum(sec
);
62 cloneConfig
.setRelationTypeToOldTaxon(relationType
);
64 UpdateResult result
= service
.cloneClassification(cloneConfig
);
65 return postExecute(result
.getCdmEntity());
69 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{
74 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
) throws ExecutionException
{