Project

General

Profile

Download (3.79 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
 * @version 1.0
34
 */
35
public class ChangeSynonymToConceptOperation extends AbstractPostTaxonOperation {
36
	private final Synonym synonym;
37
	private final TaxonRelationshipType taxonRelationshipType;
38

    
39
	/**
40
	 * <p>Constructor for ChangeSynonymToConceptOperation.</p>
41
	 *
42
	 * @param label a {@link java.lang.String} object.
43
	 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44
	 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
45
	 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
46
	 * @param taxonRelationshipType a {@link eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType} object.
47
	 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
48
	 */
49
	public ChangeSynonymToConceptOperation(String label,
50
			IUndoContext undoContext, Taxon taxon, Synonym synonym, TaxonRelationshipType taxonRelationshipType, IPostOperationEnabled postOperationEnabled) {
51
		super(label, undoContext, taxon, postOperationEnabled);
52

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

    
56
	}
57

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

    
66
//		// Get name from synonym
67
//		TaxonNameBase<?, ?> synonymName = synonym.getName();
68
//
69
//		// remove synonym from taxon
70
//		taxon.removeSynonym(synonym);
71
//
72
//		// Create a taxon with synonym name
73
//		Taxon fromTaxon = Taxon.NewInstance(synonymName, null);
74
//
75
//		// Add taxon relation
76
//		fromTaxon.addTaxonRelation(taxon, taxonRelationshipType, null, null);
77

    
78
		monitor.worked(20);
79
		UpdateResult result = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, element, taxonRelationshipType, null, null);
80
    	Taxon fromTaxon = (Taxon)result.getCdmEntity();
81
		monitor.worked(40);
82

    
83
//		TaxonRelationshipType.
84
//		logger.warn("Not yet implemented.");
85

    
86
		return postExecute(fromTaxon);
87
	}
88

    
89
	/* (non-Javadoc)
90
	 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
91
	 */
92
	/** {@inheritDoc} */
93
	@Override
94
	public IStatus redo(IProgressMonitor monitor, IAdaptable info)
95
			throws ExecutionException {
96
		return null;
97
	}
98

    
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
101
	 */
102
	/** {@inheritDoc} */
103
	@Override
104
	public IStatus undo(IProgressMonitor monitor, IAdaptable info)
105
			throws ExecutionException {
106
		return null;
107
	}
108
}
(6-6/19)