Merge branch 'hotfix/5.45.1'
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / descriptive / operation / MoveDescriptionToOtherTaxonOperation.java
1 /**
2 * Copyright (C) 2007 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
10 package eu.etaxonomy.taxeditor.editor.view.descriptive.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.service.IDescriptionService;
19 import eu.etaxonomy.cdm.model.description.TaxonDescription;
20 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
22 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
23 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
24 import eu.etaxonomy.taxeditor.store.CdmStore;
25
26 /**
27 * <p>MoveDescriptionToOtherTaxonOperation</p>
28 *
29 * @author a.kohlbecker
30 * @created Okt. 11, 2013
31 */
32 public class MoveDescriptionToOtherTaxonOperation extends
33 AbstractPersistentPostOperation {
34
35 private final TaxonNode newAcceptedTaxonNode;
36
37 private final TaxonDescription description;
38
39 private boolean setNameInSource;
40
41 /**
42 * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
43 *
44 * @param label a {@link java.lang.String} object.
45 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
46 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 * @param description a {@link TaxonDescription} object.
48 * @param targetTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
49 */
50 public MoveDescriptionToOtherTaxonOperation(String label,
51 IUndoContext undoContext,
52 TaxonDescription description,
53 TaxonNode targetTaxonNode,
54 IPostOperationEnabled postOperationEnabled,
55 ICdmEntitySessionEnabled cdmEntitySessionEnabled,
56 boolean setNameInSource) {
57 super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled); // FIXME is this the right constructor ???
58 this.description = description;
59 this.setNameInSource = setNameInSource;
60 this.newAcceptedTaxonNode = targetTaxonNode;
61 }
62
63
64 /* (non-Javadoc)
65 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66 */
67 /** {@inheritDoc} */
68 @Override
69 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
70 throws ExecutionException {
71 if (monitor != null){
72 monitor.worked(20);
73 }
74 bind();
75 CdmStore.getService(IDescriptionService.class).moveTaxonDescription(description.getUuid(), newAcceptedTaxonNode.getTaxon().getUuid(), setNameInSource);
76 if (monitor != null){
77 monitor.worked(40);
78 }
79
80 return postExecute(description);
81 }
82
83 /* (non-Javadoc)
84 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 */
86 /** {@inheritDoc} */
87 @Override
88 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
89 throws ExecutionException {
90 // TODO Auto-generated method stub
91 return null;
92 }
93
94 /* (non-Javadoc)
95 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
96 */
97 /** {@inheritDoc} */
98 @Override
99 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
100 throws ExecutionException {
101 // TODO Auto-generated method stub
102 return null;
103 }
104 }