323f9175655e45d2059eb88d68f8b6e4e2a0d141
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / store / operations / ChangeSynonymToConceptOperation.java
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.store.operations;
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.model.name.TaxonNameBase;
19 import eu.etaxonomy.cdm.model.taxon.Synonym;
20 import eu.etaxonomy.cdm.model.taxon.Taxon;
21 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
22
23 /**
24 * @author p.ciardelli
25 * @created 21.01.2009
26 * @version 1.0
27 * @author n.hoffmann
28 */
29 public class ChangeSynonymToConceptOperation extends AbstractPostOperation {
30 private Synonym synonym;
31 private TaxonRelationshipType taxonRelationshipType;
32
33 public ChangeSynonymToConceptOperation(String label,
34 IUndoContext undoContext, Taxon taxon, Synonym synonym, TaxonRelationshipType taxonRelationshipType, IPostOperationEnabled postOperationEnabled) {
35 super(label, undoContext, taxon, postOperationEnabled);
36
37 this.taxonRelationshipType = taxonRelationshipType;
38 this.synonym = synonym;
39
40 }
41
42 /* (non-Javadoc)
43 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
44 */
45 @Override
46 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
47 throws ExecutionException {
48
49 // Get name from synonym
50 TaxonNameBase<?, ?> synonymName = synonym.getName();
51
52 // remove synonym from taxon
53 taxon.removeSynonym(synonym);
54
55 // Create a taxon with synonym name
56 Taxon fromTaxon = Taxon.NewInstance(synonymName, null);
57
58 // Add taxon relation
59 fromTaxon.addTaxonRelation(taxon, taxonRelationshipType, null, null);
60
61 // TaxonRelationshipType.
62 // logger.warn("Not yet implemented.");
63
64 return postExecute(fromTaxon);
65 }
66
67 /* (non-Javadoc)
68 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
69 */
70 @Override
71 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
72 throws ExecutionException {
73 return null;
74 }
75
76 /* (non-Javadoc)
77 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 */
79 @Override
80 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
81 throws ExecutionException {
82 return null;
83 }
84 }