+// $Id$
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.navigation.operation;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.IUndoContext;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+
+import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.IClassificationService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
+import eu.etaxonomy.cdm.model.reference.Reference;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
+import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ *
+ * @author pplitzner
+ *
+ */
+public class CloneClassificationOperation extends AbstractPersistentPostOperation {
+
+ private final Classification classification;
+
+ private final IClassificationService service;
+
+ private String classificationName;
+
+ private Reference sec;
+
+ private TaxonRelationshipType relationType;
+
+ public CloneClassificationOperation(String label, IUndoContext undoContext, Classification classification,
+ String classificationName, Reference sec, TaxonRelationshipType relationType,
+ IPostOperationEnabled postOperationEnabled,
+ IConversationEnabled conversationEnabled) {
+ super(label, undoContext, postOperationEnabled, conversationEnabled);
+
+ this.classification = classification;
+ this.classificationName = classificationName;
+ this.sec = sec;
+ this.relationType = relationType;
+ this.service = CdmStore.getService(IClassificationService.class);
+
+ }
+
+ @Override
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+
+ UpdateResult result = service.cloneClassification(classification.getUuid(), classificationName, sec, relationType);
+ return postExecute(result.getCdmEntity());
+ }
+
+ @Override
+ public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+ @Override
+ public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ return null;
+ }
+
+}