Project

General

Profile

Download (3.21 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

    
18
import eu.etaxonomy.cdm.api.service.ITaxonService;
19
import eu.etaxonomy.cdm.api.service.UpdateResult;
20
import eu.etaxonomy.cdm.model.taxon.Synonym;
21
import eu.etaxonomy.cdm.model.taxon.Taxon;
22
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
23
import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
24
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25
import eu.etaxonomy.taxeditor.store.CdmStore;
26

    
27
/**
28
 * <p>ChangeSynonymToConceptOperation class.</p>
29
 *
30
 * @author p.ciardelli
31
 * @author n.hoffmann
32
 * @created 21.01.2009
33
 */
34
public class ChangeSynonymToConceptOperation extends AbstractPostTaxonOperation {
35
	private final Synonym synonym;
36
	private final TaxonRelationshipType taxonRelationshipType;
37

    
38
	/**
39
	 * <p>Constructor for ChangeSynonymToConceptOperation.</p>
40
	 *
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 synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
45
	 * @param taxonRelationshipType a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType} object.
46
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47
	 */
48
	public ChangeSynonymToConceptOperation(String label,
49
			IUndoContext undoContext, Taxon taxon, Synonym synonym, TaxonRelationshipType taxonRelationshipType, IPostOperationEnabled postOperationEnabled) {
50
		super(label, undoContext, taxon, postOperationEnabled);
51

    
52
		this.taxonRelationshipType = taxonRelationshipType;
53
		this.synonym = synonym;
54

    
55
	}
56

    
57
	@Override
58
	public IStatus execute(IProgressMonitor monitor, IAdaptable info)
59
			throws ExecutionException {
60

    
61
//		// Get name from synonym
62
//		TaxonNameBase<?, ?> synonymName = synonym.getName();
63
//
64
//		// remove synonym from taxon
65
//		taxon.removeSynonym(synonym);
66
//
67
//		// Create a taxon with synonym name
68
//		Taxon fromTaxon = Taxon.NewInstance(synonymName, null);
69
//
70
//		// Add taxon relation
71
//		fromTaxon.addTaxonRelation(taxon, taxonRelationshipType, null, null);
72

    
73
		monitor.worked(20);
74
		UpdateResult result = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, element, taxonRelationshipType, null, null);
75
    	Taxon fromTaxon = (Taxon)result.getCdmEntity();
76
		monitor.worked(40);
77

    
78
//		TaxonRelationshipType.
79
//		logger.warn("Not yet implemented.");
80

    
81
		return postExecute(fromTaxon);
82
	}
83

    
84
	@Override
85
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
86
			throws ExecutionException {
87
		return null;
88
	}
89

    
90
	@Override
91
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
92
			throws ExecutionException {
93
		return null;
94
	}
95
}
(6-6/15)