automated build configuration is on its way
[taxeditor.git] / taxeditor-editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / operation / 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.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.model.taxon.Synonym;
20 import eu.etaxonomy.cdm.model.taxon.Taxon;
21 import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
22 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
23 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
24 import eu.etaxonomy.taxeditor.store.CdmStore;
25
26 /**
27 * <p>ChangeSynonymToConceptOperation class.</p>
28 *
29 * @author p.ciardelli
30 * @author n.hoffmann
31 * @created 21.01.2009
32 * @version 1.0
33 */
34 public class ChangeSynonymToConceptOperation extends AbstractPostOperation {
35 private Synonym synonym;
36 private 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 /* (non-Javadoc)
58 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59 */
60 /** {@inheritDoc} */
61 @Override
62 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
63 throws ExecutionException {
64
65 // // Get name from synonym
66 // TaxonNameBase<?, ?> synonymName = synonym.getName();
67 //
68 // // remove synonym from taxon
69 // taxon.removeSynonym(synonym);
70 //
71 // // Create a taxon with synonym name
72 // Taxon fromTaxon = Taxon.NewInstance(synonymName, null);
73 //
74 // // Add taxon relation
75 // fromTaxon.addTaxonRelation(taxon, taxonRelationshipType, null, null);
76
77 monitor.worked(20);
78 Taxon fromTaxon = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, taxon, taxonRelationshipType, null, null);
79 monitor.worked(40);
80
81 // TaxonRelationshipType.
82 // logger.warn("Not yet implemented.");
83
84 return postExecute(fromTaxon);
85 }
86
87 /* (non-Javadoc)
88 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
89 */
90 /** {@inheritDoc} */
91 @Override
92 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
93 throws ExecutionException {
94 return null;
95 }
96
97 /* (non-Javadoc)
98 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
99 */
100 /** {@inheritDoc} */
101 @Override
102 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
103 throws ExecutionException {
104 return null;
105 }
106 }