2 * Copyright (C) 2015 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
.HashSet
;
13 import java
.util
.UUID
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
19 import eu
.etaxonomy
.cdm
.api
.application
.CdmChangeEvent
.Action
;
20 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 import eu
.etaxonomy
.taxeditor
.operation
.RemotingCdmUpdateOperation
;
32 public class RemotingDeleteTaxonNodeOperation
extends RemotingCdmUpdateOperation
{
34 private final static String LABEL
= "Delete Taxon Node operation";
36 private final Set
<ITaxonTreeNode
> treeNodes
;
37 private final TaxonDeletionConfigurator config
;
45 public RemotingDeleteTaxonNodeOperation(Object source
,
47 Set
<ITaxonTreeNode
> treeNodes
,
48 TaxonDeletionConfigurator config
) {
49 super(LABEL
, Action
.Delete
, source
, async
);
50 this.treeNodes
= treeNodes
;
55 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 protected UpdateResult
doUpdateExecute(IProgressMonitor monitor
, IAdaptable info
) throws Exception
{
61 if(treeNodes
.size() == 1) {
62 // when single node this is either a taxon or a classification
63 ITaxonTreeNode node
= treeNodes
.iterator().next();
64 if(node
instanceof TaxonNode
) {
65 return CdmApplicationState
.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNode(((TaxonNode
)node
).getUuid(), config
);
66 } else if(node
instanceof Classification
) {
67 entityType
= Classification
.class;
68 return CdmApplicationState
.getCurrentAppConfig().getClassificationService().delete(((Classification
)node
).getUuid());
71 // when list we assume all are taxon nodes
72 Set
<UUID
> treeNodeUuids
= new HashSet
<UUID
>();
73 ITaxonTreeNode entity
= null;
74 for(ITaxonTreeNode treeNode
: treeNodes
) {
78 treeNodeUuids
.add(treeNode
.getUuid());
81 return CdmApplicationState
.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNodes(treeNodeUuids
, new TaxonDeletionConfigurator());