Revision 3be6ef3e
Added by Niels Hoffmann over 13 years ago
taxeditor-store/src/main/java/eu/etaxonomy/taxeditor/operations/ChangeSynonymToAcceptedTaxonOperation.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.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.api.conversation.IConversationEnabled; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.ITreeNode; |
|
20 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
22 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
24 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
25 |
|
|
26 |
/** |
|
27 |
* Change the taxonomic parent of a given taxon. |
|
28 |
* |
|
29 |
* @author n.hoffmann |
|
30 |
* @created 16.01.2009 |
|
31 |
* @version 1.0 |
|
32 |
*/ |
|
33 |
public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPostOperation { |
|
34 |
|
|
35 |
private Taxon newTaxon; |
|
36 |
private Synonym synonym; |
|
37 |
private ITreeNode parentNode; |
|
38 |
|
|
39 |
private TaxonNode newNode; |
|
40 |
|
|
41 |
private Synonym[] synonymsInHomotypicalGroup; |
|
42 |
|
|
43 |
public ChangeSynonymToAcceptedTaxonOperation(String label, IUndoContext undoContext, |
|
44 |
Taxon taxon, ITreeNode parentNode, Synonym synonym, Synonym[] synonymsInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { |
|
45 |
super(label, undoContext, postOperationEnabled, conversationEnabled); |
|
46 |
|
|
47 |
this.taxon = taxon; |
|
48 |
this.parentNode = parentNode; |
|
49 |
this.synonym = synonym; |
|
50 |
this.synonymsInHomotypicalGroup = synonymsInHomotypicalGroup; |
|
51 |
} |
|
52 |
|
|
53 |
/* (non-Javadoc) |
|
54 |
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
55 |
*/ |
|
56 |
@Override |
|
57 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
|
58 |
throws ExecutionException { |
|
59 |
|
|
60 |
newTaxon = CdmStore.getTaxonService().changeSynonymToAcceptedTaxon(synonym, taxon); |
|
61 |
monitor.worked(20); |
|
62 |
|
|
63 |
// synonym.setSec(null); |
|
64 |
|
|
65 |
// TODO let user choose parent |
|
66 |
newNode = parentNode.addChildTaxon(newTaxon, null, null, null); |
|
67 |
|
|
68 |
if(synonymsInHomotypicalGroup != null){ |
|
69 |
Taxon taxon = newNode.getTaxon(); |
|
70 |
for (Synonym synonym : synonymsInHomotypicalGroup){ |
|
71 |
taxon.addHomotypicSynonym(synonym, null, null); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
75 |
monitor.worked(40); |
|
76 |
|
|
77 |
return postExecute(newNode); |
|
78 |
} |
|
79 |
|
|
80 |
/* (non-Javadoc) |
|
81 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) |
|
85 |
throws ExecutionException { |
|
86 |
return execute(monitor, info); |
|
87 |
} |
|
88 |
|
|
89 |
/* (non-Javadoc) |
|
90 |
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
91 |
*/ |
|
92 |
@Override |
|
93 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
|
94 |
throws ExecutionException { |
|
95 |
|
|
96 |
// TODO implement - biggest problem is that any window open for new taxon must be closed first |
|
97 |
StoreUtil.warn(this.getClass(), "Not yet implemented"); |
|
98 |
|
|
99 |
return postExecute(taxon); |
|
100 |
} |
|
101 |
|
|
102 |
} |
|
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.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.api.conversation.IConversationEnabled; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.ITreeNode; |
|
20 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
22 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
23 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
24 |
import eu.etaxonomy.taxeditor.store.StoreUtil; |
|
25 |
|
|
26 |
/** |
|
27 |
* Change the taxonomic parent of a given taxon. |
|
28 |
* |
|
29 |
* @author n.hoffmann |
|
30 |
* @created 16.01.2009 |
|
31 |
* @version 1.0 |
|
32 |
*/ |
|
33 |
public class ChangeSynonymToAcceptedTaxonOperation extends AbstractPersistentPostOperation { |
|
34 |
|
|
35 |
private Taxon newTaxon; |
|
36 |
private Synonym synonym; |
|
37 |
private ITreeNode parentNode; |
|
38 |
|
|
39 |
private TaxonNode newNode; |
|
40 |
|
|
41 |
private Synonym[] synonymsInHomotypicalGroup; |
|
42 |
|
|
43 |
/** |
|
44 |
* <p>Constructor for ChangeSynonymToAcceptedTaxonOperation.</p> |
|
45 |
* |
|
46 |
* @param label a {@link java.lang.String} object. |
|
47 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
48 |
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. |
|
49 |
* @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITreeNode} object. |
|
50 |
* @param synonym a {@link eu.etaxonomy.cdm.model.taxon.Synonym} object. |
|
51 |
* @param synonymsInHomotypicalGroup an array of {@link eu.etaxonomy.cdm.model.taxon.Synonym} objects. |
|
52 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object. |
|
53 |
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object. |
|
54 |
*/ |
|
55 |
public ChangeSynonymToAcceptedTaxonOperation(String label, IUndoContext undoContext, |
|
56 |
Taxon taxon, ITreeNode parentNode, Synonym synonym, Synonym[] synonymsInHomotypicalGroup, IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) { |
|
57 |
super(label, undoContext, postOperationEnabled, conversationEnabled); |
|
58 |
|
|
59 |
this.taxon = taxon; |
|
60 |
this.parentNode = parentNode; |
|
61 |
this.synonym = synonym; |
|
62 |
this.synonymsInHomotypicalGroup = synonymsInHomotypicalGroup; |
|
63 |
} |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
67 |
*/ |
|
68 |
/** {@inheritDoc} */ |
|
69 |
@Override |
|
70 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) |
|
71 |
throws ExecutionException { |
|
72 |
|
|
73 |
newTaxon = CdmStore.getTaxonService().changeSynonymToAcceptedTaxon(synonym, taxon); |
|
74 |
monitor.worked(20); |
|
75 |
|
|
76 |
// synonym.setSec(null); |
|
77 |
|
|
78 |
// TODO let user choose parent |
|
79 |
newNode = parentNode.addChildTaxon(newTaxon, null, null, null); |
|
80 |
|
|
81 |
if(synonymsInHomotypicalGroup != null){ |
|
82 |
Taxon taxon = newNode.getTaxon(); |
|
83 |
for (Synonym synonym : synonymsInHomotypicalGroup){ |
|
84 |
taxon.addHomotypicSynonym(synonym, null, null); |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
monitor.worked(40); |
|
89 |
|
|
90 |
return postExecute(newNode); |
|
91 |
} |
|
92 |
|
|
93 |
/* (non-Javadoc) |
|
94 |
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
95 |
*/ |
|
96 |
/** {@inheritDoc} */ |
|
97 |
@Override |
|
98 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) |
|
99 |
throws ExecutionException { |
|
100 |
return execute(monitor, info); |
|
101 |
} |
|
102 |
|
|
103 |
/* (non-Javadoc) |
|
104 |
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) |
|
105 |
*/ |
|
106 |
/** {@inheritDoc} */ |
|
107 |
@Override |
|
108 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) |
|
109 |
throws ExecutionException { |
|
110 |
|
|
111 |
// TODO implement - biggest problem is that any window open for new taxon must be closed first |
|
112 |
StoreUtil.warn(this.getClass(), "Not yet implemented"); |
|
113 |
|
|
114 |
return postExecute(taxon); |
|
115 |
} |
|
116 |
|
|
117 |
} |
Also available in: Unified diff
performed javacscript:fix and worked on documentation