255849b4495ab9e497cf27446a474cd37780f4b1
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / test / java / eu / etaxonomy / taxeditor / store / operations / RemotingTestUpdateOperation.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.store.operations;
11
12 import org.eclipse.core.runtime.IAdaptable;
13 import org.eclipse.core.runtime.IProgressMonitor;
14
15 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
16 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
17 import eu.etaxonomy.cdm.api.service.ITestService;
18 import eu.etaxonomy.cdm.api.service.UpdateResult;
19 import eu.etaxonomy.cdm.api.service.dto.CdmEntityIdentifier;
20 import eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation;
21
22 /**
23 * @author cmathew
24 * @date 26 Jun 2015
25 *
26 */
27 public class RemotingTestUpdateOperation extends RemotingCdmUpdateOperation {
28
29 private static String LABEL = "Test Operation";
30
31 private UpdateResult result;
32 private Exception exception;
33 private CdmEntityIdentifier cei;
34
35
36 /**
37 * @param label
38 * @param action
39 * @param source
40 * @param async
41 */
42 public RemotingTestUpdateOperation(UpdateResult result,
43 Object source,
44 boolean async) {
45 super(LABEL, Action.Update, source, async);
46 this.result = result;
47 }
48
49 public RemotingTestUpdateOperation(Exception exception,
50 Object source,
51 boolean async) {
52 super(LABEL, Action.Update, source, async);
53 this.exception = exception;
54 }
55
56 public RemotingTestUpdateOperation(CdmEntityIdentifier cei,
57 Object source,
58 boolean async) {
59 super(LABEL, Action.Update, source, async);
60 this.cei = cei;
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 ITestService testService = CdmApplicationState.getTestService();
69 if(result != null) {
70 return testService.returnResult(result);
71 } else if(exception != null) {
72 return testService.throwException(exception);
73 }
74 return null;
75 }
76
77 }