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
.service
.ITaxonService
;
21 import eu
.etaxonomy
.cdm
.api
.service
.exception
.DataChangeNoRollbackException
;
22 import eu
.etaxonomy
.cdm
.model
.name
.HomotypicalGroup
;
23 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
24 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
25 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
26 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationship
;
27 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonRelationshipType
;
28 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
29 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
30 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
31 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
34 * <p>ChangeConceptToSynonymOperation class.</p>
41 public class ChangeConceptToSynonymOperation
extends
42 AbstractPostTaxonOperation
{
44 private Taxon concept
;
46 private HomotypicalGroup homotypicalGroup
;
48 private TaxonRelationship taxonRelationship
;
49 private TaxonRelationshipType oldRelationshipType
;
52 * <p>Constructor for ChangeConceptToSynonymOperation.</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 concept a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
58 * @param homotypicalGroup a {@link eu.etaxonomy.cdm.model.name.HomotypicalGroup} object.
59 * @param editor a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
61 public ChangeConceptToSynonymOperation(String label
,
62 IUndoContext undoContext
, Taxon taxon
, Taxon concept
, HomotypicalGroup homotypicalGroup
,
63 IPostOperationEnabled editor
) {
64 super(label
, undoContext
, taxon
, editor
);
66 Set
<TaxonRelationship
> taxonRelationships
= taxon
.getTaxonRelations(concept
);
68 if(taxonRelationships
.size() > 1){
69 MessagingUtils
.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " +
70 "accepted and the related taxon. This case is not handled by the software yet");
74 this.taxonRelationship
= taxonRelationships
.iterator().next();
75 this.oldRelationshipType
= taxonRelationship
.getType();
77 this.concept
= concept
;
78 this.homotypicalGroup
= homotypicalGroup
!= null ? homotypicalGroup
: HomotypicalGroup
.NewInstance();
83 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
86 // Create new synonym using concept name
87 TaxonNameBase
<?
, ?
> synonymName
= concept
.getName();
88 Synonym synonym
= null;
91 (Synonym
) CdmStore
.getService(ITaxonService
.class).changeRelatedTaxonToSynonym(concept
.getUuid(),
93 taxonRelationship
.getType(),
95 } catch (DataChangeNoRollbackException e
) {
96 // TODO Auto-generated catch block
101 return postExecute(synonym
);
106 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
107 throws ExecutionException
{
108 // TODO redo for change misapplied name ...
114 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
115 throws ExecutionException
{
116 // TODO undo for change misapplied name ...