Project

General

Profile

Download (2.21 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.navigation.l10n.Messages;
20
import eu.etaxonomy.taxeditor.operation.CdmUpdateOperation;
21
import eu.etaxonomy.taxeditor.store.CdmStore;
22

    
23
/**
24
 * @author cmathew
25
 * @date 29 Jun 2015
26
 *
27
 */
28
public class UpdatePolytomousKeyAllNodesOperation extends CdmUpdateOperation {
29

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

    
43
    }
44

    
45
    public UpdatePolytomousKeyAllNodesOperation(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 = Messages.RemotingUpdatePolytomousKeyAllNodesOperation_UPDATE_OP;
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
}
(4-4/4)