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