Merge branch 'release/3.12.0'
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / key / polytomous / operation / RemotingUpdatePolytomousKeyAllNodesOperation.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.key.polytomous.operation;
11
12 import java.util.UUID;
13
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.core.runtime.IProgressMonitor;
16
17 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
18 import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
19 import eu.etaxonomy.cdm.api.service.UpdateResult;
20 import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
21 import eu.etaxonomy.taxeditor.store.CdmStore;
22
23 /**
24 * @author cmathew
25 * @date 29 Jun 2015
26 *
27 */
28 public class RemotingUpdatePolytomousKeyAllNodesOperation extends RemotingCdmUpdateOperation {
29
30 private final UUID polytomousKeyUuid;
31 /**
32 * @param label
33 * @param action
34 * @param source
35 * @param async
36 */
37 public RemotingUpdatePolytomousKeyAllNodesOperation(Object source,
38 boolean async,
39 UUID polytomousKeyUuid) {
40 super(LABEL, Action.Update, source, async);
41 this.polytomousKeyUuid = polytomousKeyUuid;
42
43 }
44
45 public RemotingUpdatePolytomousKeyAllNodesOperation(Object source,
46 boolean async) {
47 super(LABEL, Action.Update, source, async);
48 // this implies that we have to update all nodes of all keys
49 this.polytomousKeyUuid = null;
50 }
51
52 private final static String LABEL = "Update All Polytomous Key Nodes operation";
53
54 /* (non-Javadoc)
55 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 */
57 @Override
58 protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
59 if(polytomousKeyUuid == null) {
60 return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings();
61 } else {
62 return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings(polytomousKeyUuid);
63 }
64 }
65
66 }