76c72b8209392df72eeddf83f4b6592822ad1d27
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / SaveClassificationOperation.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.operations;
12
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.api.conversation.IConversationEnabled;
20 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
21 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
22 import eu.etaxonomy.cdm.model.taxon.TaxonomicTree;
23 import eu.etaxonomy.taxeditor.store.CdmStore;
24
25 /**
26 * <p>SaveClassificationOperation class.</p>
27 *
28 * @author n.hoffmann
29 * @created 23.06.2009
30 * @version 1.0
31 */
32 public class SaveClassificationOperation extends AbstractPersistentPostOperation {
33
34 private TaxonomicTree classification;
35
36 /**
37 * <p>Constructor for SaveClassificationOperation.</p>
38 *
39 * @param label a {@link java.lang.String} object.
40 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
41 * @param classification a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
42 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
43 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
44 */
45 public SaveClassificationOperation(String label, IUndoContext undoContext, TaxonomicTree classification,
46 IPostOperationEnabled postOperationEnabled,
47 IConversationEnabled conversationEnabled) {
48 super(label, undoContext, postOperationEnabled, conversationEnabled);
49
50 this.classification = classification;
51
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 */
57 /** {@inheritDoc} */
58 @Override
59 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
60 throws ExecutionException {
61 bind();
62 monitor.worked(20);
63
64 if(classification.getReference() == null){
65 ReferenceBase reference = ReferenceFactory.newGeneric();
66 reference.setTitleCache(classification.getTitleCache());
67 classification.setReference(reference);
68 }
69
70 CdmStore.getTaxonTreeService().saveOrUpdate(classification);
71
72 monitor.worked(40);
73
74 return postExecute(classification);
75 }
76
77 /* (non-Javadoc)
78 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
79 */
80 /** {@inheritDoc} */
81 @Override
82 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
83 throws ExecutionException {
84 // TODO Auto-generated method stub
85 return null;
86 }
87
88 /* (non-Javadoc)
89 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 */
91 /** {@inheritDoc} */
92 @Override
93 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
94 throws ExecutionException {
95 // TODO Auto-generated method stub
96 return null;
97 }
98 }