implemented user management, fixes #803. Minor refactorings.
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / RemoveHomotypicalGroupBasionymOperation.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.model.name.TaxonNameBase;
19 import eu.etaxonomy.cdm.model.taxon.Synonym;
20 import eu.etaxonomy.cdm.model.taxon.Taxon;
21 import eu.etaxonomy.taxeditor.model.SynonymHelper;
22
23 /**
24 * @author p.ciardelli
25 * @created 15.01.2009
26 * @version 1.0
27 */
28 public class RemoveHomotypicalGroupBasionymOperation extends
29 AbstractPostOperation {
30
31 private Synonym synonym;
32
33 public RemoveHomotypicalGroupBasionymOperation(String text,
34 IUndoContext undoContext, Taxon taxon, Synonym synonym, IPostOperationEnabled postOperationEnabled) {
35 super(text, undoContext, taxon, postOperationEnabled);
36
37 this.synonym = synonym;
38 }
39
40 /* (non-Javadoc)
41 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
42 */
43 @Override
44 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
45 throws ExecutionException {
46
47 TaxonNameBase<?, ?> oldSynonymName = synonym.getName();
48 // TODO replace w method from cdmlib
49 SynonymHelper.removeGroupBasionym(oldSynonymName);
50
51 return postExecute(synonym);
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 */
57 @Override
58 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
59 throws ExecutionException {
60 return execute(monitor, info);
61 }
62
63 /* (non-Javadoc)
64 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
65 */
66 @Override
67 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
68 throws ExecutionException {
69 // TODO replace w method from cdmlib
70 // FIXME this is also old code: reimplement
71 SynonymHelper.setGroupBasionym(synonym.getName());
72
73 return postExecute(synonym);
74 }
75 }