Project

General

Profile

Download (2.17 KB) Statistics
| Branch: | Tag: | Revision:
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.key.polytomous.operation;
10

    
11
import java.util.UUID;
12

    
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.core.runtime.IProgressMonitor;
15

    
16
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
17
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
18
import eu.etaxonomy.cdm.api.service.UpdateResult;
19
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
20
import eu.etaxonomy.taxeditor.store.CdmStore;
21

    
22
/**
23
 * @author cmathew
24
 * @date 29 Jun 2015
25
 *
26
 */
27
public class RemotingUpdatePolytomousKeyAllNodesOperation extends RemotingCdmUpdateOperation {
28

    
29
    private final UUID polytomousKeyUuid;
30
    /**
31
     * @param label
32
     * @param action
33
     * @param source
34
     * @param async
35
     */
36
    public RemotingUpdatePolytomousKeyAllNodesOperation(Object source,
37
            boolean async,
38
            UUID polytomousKeyUuid) {
39
        super(LABEL, Action.Update, source, async);
40
        this.polytomousKeyUuid = polytomousKeyUuid;
41

    
42
    }
43

    
44
    public RemotingUpdatePolytomousKeyAllNodesOperation(Object source,
45
            boolean async) {
46
        super(LABEL, Action.Update, source, async);
47
        // this implies that we have to update all nodes of all keys
48
        this.polytomousKeyUuid = null;
49
    }
50

    
51
    private final static String LABEL = "Update All Polytomous Key Nodes operation";
52

    
53
    /* (non-Javadoc)
54
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
55
     */
56
    @Override
57
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
58
        if(polytomousKeyUuid == null) {
59
            return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings();
60
        } else {
61
            return CdmStore.getService(IPolytomousKeyService.class).updateAllNodeNumberings(polytomousKeyUuid);
62
        }
63
    }
64

    
65
}
(4-4/4)