3 * Copyright (C) 2015 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.navigation
.navigator
.operation
;
12 import java
.util
.HashSet
;
14 import java
.util
.UUID
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
20 import eu
.etaxonomy
.cdm
.api
.application
.CdmChangeEvent
.Action
;
21 import eu
.etaxonomy
.cdm
.api
.service
.UpdateResult
;
22 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Classification
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
26 import eu
.etaxonomy
.taxeditor
.operation
.RemotingCdmUpdateOperation
;
33 public class RemotingDeleteTaxonNodeOperation
extends RemotingCdmUpdateOperation
{
35 private final static String LABEL
= "Delete Taxon Node operation";
37 private final Set
<ITaxonTreeNode
> treeNodes
;
38 private final TaxonDeletionConfigurator config
;
46 public RemotingDeleteTaxonNodeOperation(Object source
,
48 Set
<ITaxonTreeNode
> treeNodes
,
49 TaxonDeletionConfigurator config
) {
50 super(LABEL
, Action
.Delete
, source
, async
);
51 this.treeNodes
= treeNodes
;
56 * @see eu.etaxonomy.taxeditor.operation.RemotingCdmUpdateOperation#doUpdateExecute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59 protected UpdateResult
doUpdateExecute(IProgressMonitor monitor
, IAdaptable info
) throws Exception
{
62 if(treeNodes
.size() == 1) {
63 // when single node this is either a taxon or a classification
64 ITaxonTreeNode node
= treeNodes
.iterator().next();
65 if(node
instanceof TaxonNode
) {
66 return CdmApplicationState
.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNode(((TaxonNode
)node
).getUuid(), config
);
67 } else if(node
instanceof Classification
) {
68 entityType
= Classification
.class;
69 return CdmApplicationState
.getCurrentAppConfig().getClassificationService().delete(((Classification
)node
).getUuid());
72 // when list we assume all are taxon nodes
73 Set
<UUID
> treeNodeUuids
= new HashSet
<UUID
>();
74 ITaxonTreeNode entity
= null;
75 for(ITaxonTreeNode treeNode
: treeNodes
) {
79 treeNodeUuids
.add(treeNode
.getUuid());
82 return CdmApplicationState
.getCurrentAppConfig().getTaxonNodeService().deleteTaxonNodes(treeNodeUuids
, new TaxonDeletionConfigurator());