had to rename the packages to make them compliant with buckminster
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / operation / CreateClassification.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.navigation.operation;
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.api.service.IClassificationService;
21 import eu.etaxonomy.cdm.model.reference.Reference;
22 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23 import eu.etaxonomy.cdm.model.taxon.Classification;
24 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
25 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
26 import eu.etaxonomy.taxeditor.store.CdmStore;
27
28 /**
29 * <p>SaveClassificationOperation class.</p>
30 *
31 * @author n.hoffmann
32 * @created 23.06.2009
33 * @version 1.0
34 */
35 @Deprecated // we do not undo creation of elements
36 public class CreateClassification extends AbstractPersistentPostOperation {
37
38 private Classification classification;
39
40 /**
41 * <p>Constructor for SaveClassificationOperation.</p>
42 *
43 * @param label a {@link java.lang.String} object.
44 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
45 * @param classification a {@link eu.etaxonomy.cdm.model.taxon.TaxonomicTree} object.
46 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
47 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
48 */
49 public CreateClassification(String label, IUndoContext undoContext, Classification classification,
50 IPostOperationEnabled postOperationEnabled,
51 IConversationEnabled conversationEnabled) {
52 super(label, undoContext, postOperationEnabled, conversationEnabled);
53
54 this.classification = classification;
55
56 }
57
58 /* (non-Javadoc)
59 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 */
61 /** {@inheritDoc} */
62 @Override
63 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
64 throws ExecutionException {
65 bind();
66 monitor.worked(20);
67
68 if(classification.getReference() == null){
69 Reference reference = ReferenceFactory.newGeneric();
70 reference.setTitleCache(classification.getTitleCache());
71 classification.setReference(reference);
72 }
73
74 CdmStore.getService(IClassificationService.class).saveOrUpdate(classification);
75
76 monitor.worked(40);
77
78 return postExecute(classification);
79 }
80
81 /* (non-Javadoc)
82 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 */
84 /** {@inheritDoc} */
85 @Override
86 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
87 throws ExecutionException {
88 return null;
89 }
90
91 /* (non-Javadoc)
92 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 */
94 /** {@inheritDoc} */
95 @Override
96 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
97 throws ExecutionException {
98 return null;
99 }
100 }