2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.editor
.name
.operation
;
14 import org
.eclipse
.core
.commands
.ExecutionException
;
15 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
16 import org
.eclipse
.core
.runtime
.IAdaptable
;
17 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
18 import org
.eclipse
.core
.runtime
.IStatus
;
20 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
21 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
22 import eu
.etaxonomy
.cdm
.api
.service
.exception
.HomotypicalGroupChangeException
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
28 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
29 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPersistentPostOperation
;
30 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
31 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
32 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
35 * Change the taxonomic parent of a given taxon.
41 public class ChangeSynonymToAcceptedTaxonOperation
extends AbstractPersistentPostOperation
{
43 private Taxon newTaxon
;
44 private final Synonym synonym
;
45 private final ITaxonTreeNode parentNode
;
47 private TaxonNode newNode
;
49 //private final Set<TaxonNameBase> namesInHomotypicGroup;
52 * <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p>
54 * @param label a {@link java.lang.String} object.
55 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
56 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
57 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
58 * @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object.
59 * @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects.
60 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
61 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
63 public ChangeSynonymToAcceptedTaxonOperation(String label
,
64 IUndoContext undoContext
,
66 ITaxonTreeNode parentNode
,
68 Set
<TaxonNameBase
> namesInHomotypicalGroup
,
69 IPostOperationEnabled postOperationEnabled
,
70 IConversationEnabled conversationEnabled
,
71 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
72 super(label
, undoContext
, postOperationEnabled
, conversationEnabled
, cdmEntitySessionEnabled
);
75 this.parentNode
= parentNode
;
76 this.synonym
= synonym
;
77 //this.namesInHomotypicGroup = namesInHomotypicalGroup;
81 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
85 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
86 throws ExecutionException
{
89 newNode
= (TaxonNode
) CdmStore
.getService(ITaxonService
.class).changeSynonymToAcceptedTaxon(synonym
.getUuid(),
96 } catch (HomotypicalGroupChangeException e
) {
97 MessagingUtils
.warningDialog("Operation may lead to inconsistent data", getClass(), e
.getMessage());
98 return postExecute(null);
101 //newTaxon = (Taxon) CdmStore.getService(ITaxonService.class).merge(newTaxon);
102 //element.removeSynonym(synonym);
105 /*if(namesInHomotypicGroup != null){
106 Taxon taxon = newNode.getTaxon();
107 for (TaxonNameBase synonymName : namesInHomotypicGroup){
108 taxon.addHomotypicSynonymName(synonymName, null, null);
112 //newNode = CdmStore.getService(ITaxonNodeService.class).merge(newNode);
116 return postExecute(newNode
);
120 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
124 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
125 throws ExecutionException
{
126 return execute(monitor
, info
);
130 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
134 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
135 throws ExecutionException
{
137 // TODO implement - biggest problem is that any window open for new taxon must be closed first
138 MessagingUtils
.warn(this.getClass(), "Not yet implemented");
140 return postExecute(element
);