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