Project

General

Profile

Download (4.03 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9

    
10
package eu.etaxonomy.taxeditor.editor.name.operation;
11

    
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;
17
import org.eclipse.ui.IWorkbenchPage;
18

    
19
import eu.etaxonomy.cdm.api.application.ICdmRepository;
20
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
21
import eu.etaxonomy.cdm.api.service.ITaxonService;
22
import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
23
import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
24
import eu.etaxonomy.cdm.model.reference.Reference;
25
import eu.etaxonomy.cdm.model.taxon.Taxon;
26
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
27
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
28
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
29
import eu.etaxonomy.taxeditor.store.CdmStore;
30

    
31
/**
32
 * <p>DeleteMisapplicationOperation class.</p>
33
 *
34
 * @author p.ciardelli
35
 * @created 16.01.2009
36
 */
37
public class DeleteMisapplicationOperation extends DeleteTaxonBaseOperation {
38

    
39
	private final Taxon misapplication;
40

    
41
	private Reference citation;
42

    
43
	private String microcitation;
44

    
45
	/**
46
	 * <p>Constructor for DeleteMisapplicationOperation.</p>
47
	 *
48
	 * @param label a {@link java.lang.String} object.
49
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
50
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
51
	 * @param misapplication a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
52
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
53
	 */
54
	public DeleteMisapplicationOperation(String label, IUndoContext undoContext, TaxonBaseDeletionConfigurator configurator,
55
            Taxon taxon, Taxon misapplication, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled,ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
56
		//super(label, undoContext, taxon, postOperationEnabled);
57
	    super(label, undoContext, configurator, postOperationEnabled, conversationEnabled, cdmEntitySessionEnabled);
58
		this.misapplication = misapplication;
59
		this.element = taxon;
60
	}
61

    
62
	/* (non-Javadoc)
63
	 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
64
	 */
65
	/** {@inheritDoc} */
66
	@Override
67
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
68
			throws ExecutionException {
69

    
70
		// Find misapplication relation, save citation information
71

    
72
//		for (TaxonRelationship relationship : element.getTaxonRelations()) {
73
//			if (relationship.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())
74
//					&& relationship.getFromTaxon().equals(misapplication)) {
75
//				citation = relationship.getCitation();
76
//				microcitation = relationship.getCitationMicroReference();
77
//			}
78
//		}
79
		monitor.worked(20);
80

    
81
		// Remove misapplied name relation from taxon
82
		element.removeTaxon(misapplication, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
83
		ICdmRepository controller;
84

    
85
		controller = CdmStore.getCurrentApplicationConfiguration();
86

    
87
		ITaxonService service = controller.getTaxonService();
88

    
89
		result = service.deleteTaxon(misapplication.getUuid(), (TaxonDeletionConfigurator)configurator, null);
90
		monitor.worked(40);
91

    
92
		return postExecute(null);
93
	}
94

    
95
	/** {@inheritDoc} */
96
	@Override
97
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
98
			throws ExecutionException {
99
		return execute(monitor, info);
100
	}
101

    
102
	/** {@inheritDoc} */
103
	@Override
104
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
105
			throws ExecutionException {
106

    
107
		element.addMisappliedName(misapplication, citation, microcitation);
108

    
109

    
110
		return postExecute(misapplication);
111
	}
112
}
(12-12/19)