Merge branch 'develop' into LibrAlign
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / operation / CloneClassificationOperation.java
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.IClassificationService;
19 import eu.etaxonomy.cdm.api.service.UpdateResult;
20 import eu.etaxonomy.cdm.model.reference.Reference;
21 import eu.etaxonomy.cdm.model.taxon.Classification;
22 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
24 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25 import eu.etaxonomy.taxeditor.store.CdmStore;
26
27 /**
28 *
29 * @author pplitzner
30 *
31 */
32 public class CloneClassificationOperation extends AbstractPersistentPostOperation {
33
34 private final Classification classification;
35
36 private final IClassificationService service;
37
38 private String classificationName;
39
40 private Reference sec;
41
42 private TaxonRelationshipType relationType;
43
44 public CloneClassificationOperation(String label, IUndoContext undoContext, Classification classification,
45 String classificationName, Reference sec, TaxonRelationshipType relationType,
46 IPostOperationEnabled postOperationEnabled,
47 IConversationEnabled conversationEnabled) {
48 super(label, undoContext, postOperationEnabled, conversationEnabled);
49
50 this.classification = classification;
51 this.classificationName = classificationName;
52 this.sec = sec;
53 this.relationType = relationType;
54 this.service = CdmStore.getService(IClassificationService.class);
55
56 }
57
58 @Override
59 public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
60
61 UpdateResult result = service.cloneClassification(classification.getUuid(), classificationName, sec, relationType);
62 return postExecute(result.getCdmEntity());
63 }
64
65 @Override
66 public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
67 return null;
68 }
69
70 @Override
71 public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
72 return null;
73 }
74
75 }