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
|
/** {@inheritDoc} */
|
61
|
@Override
|
62
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
63
|
throws ExecutionException {
|
64
|
bind();
|
65
|
monitor.worked(20);
|
66
|
|
67
|
if(classification.getReference() == null){
|
68
|
Reference reference = ReferenceFactory.newGeneric();
|
69
|
reference.setTitleCache(classification.getTitleCache(), true);
|
70
|
classification.setReference(reference);
|
71
|
}
|
72
|
|
73
|
CdmStore.getService(IClassificationService.class).saveOrUpdate(classification);
|
74
|
|
75
|
monitor.worked(40);
|
76
|
|
77
|
return postExecute(classification);
|
78
|
}
|
79
|
|
80
|
/** {@inheritDoc} */
|
81
|
@Override
|
82
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
83
|
throws ExecutionException {
|
84
|
return null;
|
85
|
}
|
86
|
|
87
|
/** {@inheritDoc} */
|
88
|
@Override
|
89
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
90
|
throws ExecutionException {
|
91
|
return null;
|
92
|
}
|
93
|
}
|