ref #6190 removing svn property place holder in first line of code - java files
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / operation / CreateClassification.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.navigation.operation;
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.api.service.IClassificationService;
20 import eu.etaxonomy.cdm.model.reference.Reference;
21 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
22 import eu.etaxonomy.cdm.model.taxon.Classification;
23 import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
24 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
25 import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
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 final 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 ICdmEntitySessionEnabled cdmEntitiySessionEnabled) {
53 super(label, undoContext, postOperationEnabled, conversationEnabled, cdmEntitiySessionEnabled);
54
55 this.classification = classification;
56
57 }
58
59 /** {@inheritDoc} */
60 @Override
61 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
62 throws ExecutionException {
63 bind();
64 monitor.worked(20);
65
66 if(classification.getReference() == null){
67 Reference reference = ReferenceFactory.newGeneric();
68 reference.setTitle(classification.getTitleCache());
69 classification.setReference(reference);
70 }
71
72 CdmStore.getService(IClassificationService.class).saveOrUpdate(classification);
73
74 monitor.worked(40);
75
76 return postExecute(classification);
77 }
78
79 /** {@inheritDoc} */
80 @Override
81 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
82 throws ExecutionException {
83 return null;
84 }
85
86 /** {@inheritDoc} */
87 @Override
88 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
89 throws ExecutionException {
90 return null;
91 }
92 }