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.apache.log4j.Logger;
|
13
|
import org.eclipse.core.commands.ExecutionException;
|
14
|
import org.eclipse.core.commands.operations.IUndoContext;
|
15
|
import org.eclipse.core.runtime.IAdaptable;
|
16
|
import org.eclipse.core.runtime.IProgressMonitor;
|
17
|
import org.eclipse.core.runtime.IStatus;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
20
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
21
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
22
|
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
23
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
24
|
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
|
25
|
|
26
|
/**
|
27
|
* @author p.ciardelli
|
28
|
* @created 15.01.2009
|
29
|
* @version 1.0
|
30
|
* @author n.hoffmann
|
31
|
*/
|
32
|
public class ChangeConceptToSynonymOperation extends
|
33
|
AbstractPostOperation {
|
34
|
private static final Logger logger = Logger
|
35
|
.getLogger(ChangeConceptToSynonymOperation.class);
|
36
|
|
37
|
private Taxon concept;
|
38
|
|
39
|
private HomotypicalGroup homotypicalGroup;
|
40
|
|
41
|
public ChangeConceptToSynonymOperation(String label,
|
42
|
IUndoContext undoContext, Taxon taxon, Taxon concept, HomotypicalGroup homotypicalGroup,
|
43
|
IPostOperationEnabled editor) {
|
44
|
super(label, undoContext, taxon, editor);
|
45
|
|
46
|
this.concept = concept;
|
47
|
this.homotypicalGroup = homotypicalGroup;
|
48
|
}
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
52
|
*/
|
53
|
@Override
|
54
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
55
|
throws ExecutionException {
|
56
|
|
57
|
// Create new synonym using concept name
|
58
|
TaxonNameBase synonymName = concept.getName();
|
59
|
Synonym synonym = Synonym.NewInstance(synonymName, taxon.getSec());
|
60
|
|
61
|
// Remove concept relation from taxon
|
62
|
taxon.removeTaxon(concept, TaxonRelationshipType.MISAPPLIED_NAME_FOR());
|
63
|
|
64
|
|
65
|
|
66
|
taxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF());
|
67
|
|
68
|
if(homotypicalGroup != null){
|
69
|
// Add synonym to homotypical group
|
70
|
homotypicalGroup.addTypifiedName(synonymName);
|
71
|
}
|
72
|
|
73
|
return postExecute(synonym);
|
74
|
}
|
75
|
|
76
|
/* (non-Javadoc)
|
77
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
78
|
*/
|
79
|
@Override
|
80
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
81
|
throws ExecutionException {
|
82
|
// TODO redo for change misapplied name ...
|
83
|
return null;
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
88
|
*/
|
89
|
@Override
|
90
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
91
|
throws ExecutionException {
|
92
|
// TODO undo for change misapplied name ...
|
93
|
return null;
|
94
|
}
|
95
|
}
|