#5247 Use updated entities
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / operation / RemotingCdmMergeOperation.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.operation;
11
12 import org.eclipse.core.runtime.IAdaptable;
13 import org.eclipse.core.runtime.IProgressMonitor;
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16
17 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
18 import eu.etaxonomy.cdm.model.common.CdmBase;
19
20 /**
21 * @author cmathew
22 * @date 21 Jul 2015
23 *
24 */
25 public abstract class RemotingCdmMergeOperation extends RemotingCdmOperation {
26
27 private CdmBase mergedCdmEntity;
28
29 public RemotingCdmMergeOperation(String label, Action action, Object source, boolean async) {
30 super(label, action, source, async);
31 }
32 /* (non-Javadoc)
33 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
34 */
35 @Override
36 protected boolean doExecute(IProgressMonitor monitor, IAdaptable info) {
37 try {
38 mergedCdmEntity = doMergeExecute(monitor, info);
39 } catch (Exception e) {
40 throw new RuntimeException(e);
41 }
42 return true;
43 }
44
45 protected abstract CdmBase doMergeExecute(IProgressMonitor monitor, IAdaptable info) throws Exception;
46
47 @Override
48 protected void postExecute(boolean success) {
49 if(success && mergedCdmEntity != null) {
50 fireDataChangeEvent(mergedCdmEntity);
51 }
52
53 }
54 /* (non-Javadoc)
55 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmOperation#onComplete(boolean)
56 */
57 @Override
58 protected IStatus onComplete(boolean success) {
59 return Status.OK_STATUS;
60 }
61
62 }