2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
.operation
;
11 import java
.util
.UUID
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.eclipse
.core
.runtime
.Assert
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
18 import org
.eclipse
.core
.runtime
.Status
;
19 import org
.eclipse
.core
.runtime
.jobs
.Job
;
20 import org
.eclipse
.swt
.widgets
.Display
;
21 import org
.eclipse
.ui
.progress
.IProgressConstants
;
23 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationException
;
24 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
25 import eu
.etaxonomy
.cdm
.api
.application
.CdmChangeEvent
.Action
;
26 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonNodeService
;
27 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
28 import eu
.etaxonomy
.cdm
.api
.service
.config
.SecundumForSubtreeConfigurator
;
29 import eu
.etaxonomy
.cdm
.common
.monitor
.IRemotingProgressMonitor
;
30 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
31 import eu
.etaxonomy
.taxeditor
.navigation
.l10n
.Messages
;
32 import eu
.etaxonomy
.taxeditor
.operation
.IPostMoniteredOperationEnabled
;
33 import eu
.etaxonomy
.taxeditor
.operation
.RemotingCdmUpdateOperation
;
40 public class SetSecundumForSubtreeOperation
extends RemotingCdmUpdateOperation
implements IPostMoniteredOperationEnabled
{
42 private final static String LABEL
= Messages
.SetSecundumForSubtreeOperation_CHANGE_SEC_OP
;
43 private static final Logger logger
= Logger
44 .getLogger(SetSecundumForSubtreeOperation
.class);
46 SecundumForSubtreeConfigurator config
;
55 public SetSecundumForSubtreeOperation(Object source
,
58 SecundumForSubtreeConfigurator config
) {
59 super(LABEL
, Action
.Update
, source
, async
);
60 parentUuid
= taxonNodeUuid
;
62 this.updateResult
= new UpdateResult();
69 protected UpdateResult
doUpdateExecute(IProgressMonitor monitor
, IAdaptable info
) throws Exception
{
70 // runMoniteredOperation();
72 Job job
= createJob(monitor
);
74 job
.setProperty(IProgressConstants
.KEEP_PROPERTY
, true);
85 private Job
createJob(IProgressMonitor monitor
){
86 Assert
.isNotNull(config
, "Configuration may not be null");
88 final Display display
= Display
.getDefault();
90 Job job
= new Job(Messages
.SetSecundumForSubtreeOperation_SET_SEC_TASK
) {
94 protected IStatus
run(IProgressMonitor monitor
) {
97 // eu.etaxonomy.cdm.common.monitor.IProgressMonitor cdmMonitor = CdmProgressMonitorAdapter.CreateMonitor(monitor);
98 // config.setMonitor(cdmMonitor);
99 ITaxonNodeService taxonService
= CdmApplicationState
.getService(ITaxonNodeService
.class);
100 // taxonService.setSecundumForSubtree(config.getSubtreeUuid(), config.getNewSecundum(), config.isIncludeAcceptedTaxa(), config.isIncludeSynonyms(), config.isOverwriteExistingAccepted(), config.isOverwriteExistingSynonyms(), config.isIncludeSharedTaxa(), config.isEmptySecundumDetail(), null);
101 updateResult
= taxonService
.setSecundumForSubtree(config
);
103 // Display.getDefault().asyncExec(new Runnable() {
105 // public void run() {
106 // AbstractUtility.executeMoniteredOperation("Update: " + config.getClass().getSimpleName(),
110 // SetSecundumForSubtreeOperation.this,
115 } catch (CdmApplicationException e
) {
116 // TODO Auto-generated catch block
120 return Status
.OK_STATUS
;
128 public void runMoniteredOperation() {
129 ITaxonNodeService nodeService
;
131 nodeService
= CdmApplicationState
.getService(ITaxonNodeService
.class);
133 final UUID uuid
= nodeService
.monitSetSecundum(config
);
134 Display
.getDefault().asyncExec(new Runnable() {
137 AbstractUtility
.executeMoniteredOperation("Set Secundum Reference for Subtree: ",
141 SetSecundumForSubtreeOperation
.this,
145 } catch (CdmApplicationException e
) {
146 // TODO Auto-generated catch block
158 public void postOperation(IRemotingProgressMonitor monitor
) {
159 // TODO Auto-generated method stub