2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
12 import org
.eclipse
.core
.commands
.ExecutionException
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.IAdaptable
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
18 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
19 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
20 import eu
.etaxonomy
.cdm
.api
.service
.config
.NameDeletionConfigurator
;
21 import eu
.etaxonomy
.cdm
.api
.service
.config
.TaxonDeletionConfigurator
;
22 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
25 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
26 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
30 * <p>DeleteMisapplicationOperation class.</p>
36 public class DeleteMisapplicationOperation
extends AbstractPostTaxonOperation
{
38 private final Taxon misapplication
;
40 private Reference
<?
> citation
;
42 private String microcitation
;
45 * <p>Constructor for DeleteMisapplicationOperation.</p>
47 * @param label a {@link java.lang.String} object.
48 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
49 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
50 * @param misapplication a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
51 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
53 public DeleteMisapplicationOperation(String label
, IUndoContext undoContext
,
54 Taxon taxon
, Taxon misapplication
, IPostOperationEnabled postOperationEnabled
) {
55 super(label
, undoContext
, taxon
, postOperationEnabled
);
57 this.misapplication
= misapplication
;
61 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
65 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
66 throws ExecutionException
{
68 // Find misapplication relation, save citation information
70 // for (TaxonRelationship relationship : element.getTaxonRelations()) {
71 // if (relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())
72 // && relationship.getFromTaxon().equals(misapplication)) {
73 // citation = relationship.getCitation();
74 // microcitation = relationship.getCitationMicroReference();
79 // Remove misapplied name relation from taxon
80 element
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
81 ICdmApplicationConfiguration controller
;
83 controller
= CdmStore
.getCurrentApplicationConfiguration();
85 ITaxonService service
= controller
.getTaxonService();
86 TaxonDeletionConfigurator config
= new TaxonDeletionConfigurator();
87 NameDeletionConfigurator nameConfig
= new NameDeletionConfigurator();
88 nameConfig
.setRemoveAllNameRelationships(true);
89 config
.setNameDeletionConfig(nameConfig
);
90 service
.deleteTaxon(misapplication
.getUuid(), config
, null);
93 return postExecute(null);
97 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
101 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
102 throws ExecutionException
{
103 return execute(monitor
, info
);
107 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
111 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
112 throws ExecutionException
{
114 element
.addMisappliedName(misapplication
, citation
, microcitation
);
116 return postExecute(misapplication
);