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
.operations
;
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
.model
.reference
.ReferenceBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
24 * <p>DeleteMisapplicationOperation class.</p>
30 public class DeleteMisapplicationOperation
extends AbstractPostOperation
{
32 private Taxon misapplication
;
34 private ReferenceBase
<?
> citation
;
36 private String microcitation
;
39 * <p>Constructor for DeleteMisapplicationOperation.</p>
41 * @param label a {@link java.lang.String} object.
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
44 * @param misapplication a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
45 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
47 public DeleteMisapplicationOperation(String label
, IUndoContext undoContext
,
48 Taxon taxon
, Taxon misapplication
, IPostOperationEnabled postOperationEnabled
) {
49 super(label
, undoContext
, taxon
, postOperationEnabled
);
51 this.misapplication
= misapplication
;
55 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
60 throws ExecutionException
{
62 // Find misapplication relation, save citation information
63 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
64 if (relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
65 && relationship
.getFromTaxon().equals(misapplication
)) {
66 citation
= relationship
.getCitation();
67 microcitation
= relationship
.getCitationMicroReference();
72 // Remove misapplied name relation from taxon
73 taxon
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
76 return postExecute(null);
80 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
84 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
86 return execute(monitor
, info
);
90 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
94 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
95 throws ExecutionException
{
97 taxon
.addMisappliedName(misapplication
, citation
, microcitation
);
99 return postExecute(misapplication
);