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
.store
.operations
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
15 import org
.eclipse
.core
.runtime
.IAdaptable
;
16 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
17 import org
.eclipse
.core
.runtime
.IStatus
;
19 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
29 public class DeleteMisapplicationOperation
extends AbstractPostOperation
{
30 private static final Logger logger
= Logger
31 .getLogger(DeleteMisapplicationOperation
.class);
33 private Taxon misapplication
;
35 private ReferenceBase citation
;
37 private String microcitation
;
39 public DeleteMisapplicationOperation(String label
, IUndoContext undoContext
,
40 Taxon taxon
, Taxon misapplication
, IPostOperationEnabled postOperationEnabled
) {
41 super(label
, undoContext
, taxon
, postOperationEnabled
);
43 this.misapplication
= misapplication
;
47 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
50 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
51 throws ExecutionException
{
53 // Find misapplication relation, save citation information
54 for (TaxonRelationship relationship
: taxon
.getTaxonRelations()) {
55 if (relationship
.getType().equals(TaxonRelationshipType
.MISAPPLIED_NAME_FOR())
56 && relationship
.getFromTaxon().equals(misapplication
)) {
57 citation
= relationship
.getCitation();
58 microcitation
= relationship
.getCitationMicroReference();
62 // Remove misapplied name relation from taxon
63 taxon
.removeTaxon(misapplication
, TaxonRelationshipType
.MISAPPLIED_NAME_FOR());
65 return postExecute(null);
69 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
72 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
73 throws ExecutionException
{
74 return execute(monitor
, info
);
78 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
81 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
82 throws ExecutionException
{
84 taxon
.addMisappliedName(misapplication
, citation
, microcitation
);
86 return postExecute(misapplication
);