Project

General

Profile

Download (2.87 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.navigator.operation;
10

    
11
import java.util.HashSet;
12
import java.util.Set;
13
import java.util.UUID;
14

    
15
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.IProgressMonitor;
17

    
18
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
19
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
20
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
21
import eu.etaxonomy.cdm.api.service.UpdateResult;
22
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
23
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
24

    
25

    
26
/**
27
 * @author cmathew
28
 * @date 17 Jun 2015
29
 *
30
 */
31
public class RemotingChangeAcceptedTaxonToSynonymOperation extends RemotingCdmUpdateOperation {
32

    
33
    private Set<UUID> oldTaxonNodeUuids = new HashSet();
34
    private final UUID newAcceptedTaxonNodeUuid;
35

    
36

    
37
    private final static String LABEL = Messages.RemotingChangeAcceptedTaxonToSynonymOperation_CHANGE_OP;
38

    
39
    /**
40
     * @param label
41
     */
42
    public RemotingChangeAcceptedTaxonToSynonymOperation(Object source,
43
            boolean async,
44
            Set<UUID> oldTaxonNodeUuids,
45
            UUID newAcceptedTaxonNodeUuid) {
46
        super(LABEL, Action.Update, source, async);
47
        this.oldTaxonNodeUuids.addAll(oldTaxonNodeUuids);
48
        this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid;
49
    }
50
    
51
    /**
52
     * @param label
53
     */
54
    public RemotingChangeAcceptedTaxonToSynonymOperation(Object source,
55
            boolean async,
56
            UUID oldTaxonNodeUuid,
57
            UUID newAcceptedTaxonNodeUuid) {
58
        super(LABEL, Action.Update, source, async);
59
        this.oldTaxonNodeUuids.add(oldTaxonNodeUuid);
60
        this.newAcceptedTaxonNodeUuid = newAcceptedTaxonNodeUuid;
61
    }
62

    
63
    /* (non-Javadoc)
64
     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
65
     */
66
    @Override
67
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
68
    	if (this.oldTaxonNodeUuids.size() == 1){
69
    		return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNodeUuids.iterator().next(),
70
                    newAcceptedTaxonNodeUuid,
71
                    null,
72
                    null,
73
                    null);
74
    	}else{
75
    		return CdmApplicationState.getService(ITaxonNodeService.class).makeTaxonNodeSynonymsOfAnotherTaxonNode(oldTaxonNodeUuids,
76
                    newAcceptedTaxonNodeUuid,
77
                    null,
78
                    null,
79
                    null);
80
    	}
81
        
82
    }
83

    
84
}
(5-5/11)