Project

General

Profile

Download (2.1 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.store.operations;
10

    
11
import org.eclipse.core.runtime.IAdaptable;
12
import org.eclipse.core.runtime.IProgressMonitor;
13

    
14
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
15
import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
16
import eu.etaxonomy.cdm.api.service.ITestService;
17
import eu.etaxonomy.cdm.api.service.UpdateResult;
18
import eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier;
19
import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
20

    
21
/**
22
 * @author cmathew
23
 * @date 26 Jun 2015
24
 */
25
public class RemotingTestUpdateOperation extends RemotingCdmUpdateOperation {
26

    
27
    private static String LABEL = "Test Operation";
28

    
29
    private UpdateResult result;
30
    private Exception exception;
31
    private CdmEntityIdentifier cei;
32

    
33
    public RemotingTestUpdateOperation(UpdateResult result,
34
            Object source,
35
            boolean async) {
36
        super(LABEL, Action.Update, source, async);
37
        this.result = result;
38
    }
39

    
40
    public RemotingTestUpdateOperation(Exception exception,
41
            Object source,
42
            boolean async) {
43
        super(LABEL, Action.Update, source, async);
44
        this.exception = exception;
45
    }
46

    
47
    public RemotingTestUpdateOperation(CdmEntityIdentifier cei,
48
            Object source,
49
            boolean async) {
50
        super(LABEL, Action.Update, source, async);
51
        this.cei = cei;
52
    }
53

    
54
    @Override
55
    protected UpdateResult doUpdateExecute(IProgressMonitor monitor, IAdaptable info) throws Exception {
56
        ITestService testService = CdmApplicationState.getTestService();
57
        if(result != null) {
58
            return testService.returnResult(result);
59
        } else if(exception != null) {
60
            return testService.throwException(exception);
61
        } else if(cei != null) {
62
            return testService.addChild(cei);
63
        }
64
        return null;
65
    }
66

    
67
}
(2-2/2)