ref #4867 Implement "Clone Classification" functionality
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / operation / CloneClassificationOperation.java
1 // $Id$
2 /**
3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.navigation.operation;
11
12 import org.eclipse.core.commands.ExecutionException;
13 import org.eclipse.core.commands.operations.IUndoContext;
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.conversation.IConversationEnabled;
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;
27
28 /**
29 *
30 * @author pplitzner
31 *
32 */
33 public class CloneClassificationOperation extends AbstractPersistentPostOperation {
34
35 private final Classification classification;
36
37 private final IClassificationService service;
38
39 private String classificationName;
40
41 private Reference sec;
42
43 private TaxonRelationshipType relationType;
44
45 public CloneClassificationOperation(String label, IUndoContext undoContext, Classification classification,
46 String classificationName, Reference sec, TaxonRelationshipType relationType,
47 IPostOperationEnabled postOperationEnabled,
48 IConversationEnabled conversationEnabled) {
49 super(label, undoContext, postOperationEnabled, conversationEnabled);
50
51 this.classification = classification;
52 this.classificationName = classificationName;
53 this.sec = sec;
54 this.relationType = relationType;
55 this.service = CdmStore.getService(IClassificationService.class);
56
57 }
58
59 @Override
60 public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
61
62 UpdateResult result = service.cloneClassification(classification.getUuid(), classificationName, sec, relationType);
63 return postExecute(result.getCdmEntity());
64 }
65
66 @Override
67 public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
68 return null;
69 }
70
71 @Override
72 public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
73 return null;
74 }
75
76 }