1 |
e8409423
|
n.hoffmann
|
/**
|
2 |
|
|
* Copyright (C) 2007 EDIT
|
3 |
f6a8dc56
|
Patric Plitzner
|
* European Distributed Institute of Taxonomy
|
4 |
e8409423
|
n.hoffmann
|
* http://www.e-taxonomy.eu
|
5 |
f6a8dc56
|
Patric Plitzner
|
*
|
6 |
e8409423
|
n.hoffmann
|
* 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 |
35861667
|
n.hoffmann
|
package eu.etaxonomy.taxeditor.operation;
|
11 |
e8409423
|
n.hoffmann
|
|
12 |
|
|
import org.eclipse.core.commands.operations.IUndoContext;
|
13 |
3aa58b57
|
n.hoffmann
|
import org.eclipse.core.runtime.Assert;
|
14 |
e8409423
|
n.hoffmann
|
import org.eclipse.core.runtime.IStatus;
|
15 |
|
|
|
16 |
|
|
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
17 |
|
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
18 |
cedc4ff1
|
Katja Luther
|
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
|
19 |
2da4c7b2
|
Cherian Mathew
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
20 |
e8409423
|
n.hoffmann
|
|
21 |
|
|
/**
|
22 |
3aa58b57
|
n.hoffmann
|
* Superclass for all operation that have to be committed imediately after execution.
|
23 |
3be6ef3e
|
n.hoffmann
|
*
|
24 |
|
|
* Note: You have to call the {@link #bind()} method in the {@link #execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)},
|
25 |
3aa58b57
|
n.hoffmann
|
* {@link #undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)} and {@link #redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)}
|
26 |
|
|
* methods so the correct persistence context gets bound.
|
27 |
3be6ef3e
|
n.hoffmann
|
*
|
28 |
e8409423
|
n.hoffmann
|
* @author n.hoffmann
|
29 |
|
|
* @created 08.05.2009
|
30 |
|
|
* @version 1.0
|
31 |
|
|
*/
|
32 |
343457b6
|
Patric Plitzner
|
public abstract class AbstractPersistentPostOperation extends AbstractPostTaxonOperation {
|
33 |
2da4c7b2
|
Cherian Mathew
|
private final IConversationEnabled conversationEnabled;
|
34 |
c9285745
|
Cherian Mathew
|
|
35 |
cedc4ff1
|
Katja Luther
|
protected TaxonNodeDto parentNode;
|
36 |
f6a8dc56
|
Patric Plitzner
|
|
37 |
8ab62f50
|
Cherian Mathew
|
/**
|
38 |
|
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
39 |
|
|
*
|
40 |
|
|
* @param label a {@link java.lang.String} object.
|
41 |
|
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
42 |
|
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
43 |
|
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
44 |
|
|
*/
|
45 |
|
|
protected AbstractPersistentPostOperation(String label, IUndoContext undoContext,
|
46 |
|
|
IPostOperationEnabled postOperationEnabled,
|
47 |
|
|
IConversationEnabled conversationEnabled) {
|
48 |
|
|
this(label, undoContext, postOperationEnabled, conversationEnabled, null);
|
49 |
|
|
}
|
50 |
|
|
|
51 |
78140a75
|
n.hoffmann
|
/**
|
52 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
53 |
|
|
*
|
54 |
|
|
* @param label a {@link java.lang.String} object.
|
55 |
|
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
56 |
35861667
|
n.hoffmann
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
57 |
3be6ef3e
|
n.hoffmann
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
58 |
78140a75
|
n.hoffmann
|
*/
|
59 |
|
|
protected AbstractPersistentPostOperation(String label, IUndoContext undoContext,
|
60 |
|
|
IPostOperationEnabled postOperationEnabled,
|
61 |
2da4c7b2
|
Cherian Mathew
|
IConversationEnabled conversationEnabled,
|
62 |
|
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
63 |
c9285745
|
Cherian Mathew
|
super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled);
|
64 |
78140a75
|
n.hoffmann
|
this.conversationEnabled = conversationEnabled;
|
65 |
|
|
}
|
66 |
f6a8dc56
|
Patric Plitzner
|
|
67 |
e8409423
|
n.hoffmann
|
/**
|
68 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
69 |
|
|
*
|
70 |
|
|
* @param label a {@link java.lang.String} object.
|
71 |
|
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
72 |
|
|
* @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
|
73 |
35861667
|
n.hoffmann
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
74 |
3be6ef3e
|
n.hoffmann
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
75 |
e8409423
|
n.hoffmann
|
*/
|
76 |
|
|
public AbstractPersistentPostOperation(String label,
|
77 |
cedc4ff1
|
Katja Luther
|
IUndoContext undoContext, TaxonNodeDto taxonNode,
|
78 |
78140a75
|
n.hoffmann
|
IPostOperationEnabled postOperationEnabled,
|
79 |
2da4c7b2
|
Cherian Mathew
|
IConversationEnabled conversationEnabled,
|
80 |
|
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
81 |
c9285745
|
Cherian Mathew
|
super(label, undoContext, taxonNode, postOperationEnabled, cdmEntitySessionEnabled);
|
82 |
78140a75
|
n.hoffmann
|
this.conversationEnabled = conversationEnabled;
|
83 |
c9285745
|
Cherian Mathew
|
|
84 |
e8409423
|
n.hoffmann
|
}
|
85 |
f6a8dc56
|
Patric Plitzner
|
|
86 |
78140a75
|
n.hoffmann
|
/**
|
87 |
3be6ef3e
|
n.hoffmann
|
* <p>Constructor for AbstractPersistentPostOperation.</p>
|
88 |
|
|
*
|
89 |
|
|
* @param label a {@link java.lang.String} object.
|
90 |
|
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
91 |
35861667
|
n.hoffmann
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
92 |
3be6ef3e
|
n.hoffmann
|
* @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
|
93 |
f6a8dc56
|
Patric Plitzner
|
* @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
|
94 |
78140a75
|
n.hoffmann
|
*/
|
95 |
e8409423
|
n.hoffmann
|
public AbstractPersistentPostOperation(String label,
|
96 |
cedc4ff1
|
Katja Luther
|
IUndoContext undoContext,
|
97 |
78140a75
|
n.hoffmann
|
IPostOperationEnabled postOperationEnabled,
|
98 |
2da4c7b2
|
Cherian Mathew
|
IConversationEnabled conversationEnabled,
|
99 |
cedc4ff1
|
Katja Luther
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled, TaxonNodeDto parentNode) {
|
100 |
c9285745
|
Cherian Mathew
|
super(label, undoContext, postOperationEnabled, cdmEntitySessionEnabled);
|
101 |
78140a75
|
n.hoffmann
|
this.parentNode = parentNode;
|
102 |
e8409423
|
n.hoffmann
|
this.conversationEnabled = conversationEnabled;
|
103 |
c9285745
|
Cherian Mathew
|
|
104 |
e8409423
|
n.hoffmann
|
}
|
105 |
|
|
|
106 |
78140a75
|
n.hoffmann
|
/* (non-Javadoc)
|
107 |
|
|
* @see eu.etaxonomy.taxeditor.operations.AbstractPostOperation#postExecute(eu.etaxonomy.cdm.model.common.CdmBase)
|
108 |
|
|
*/
|
109 |
3be6ef3e
|
n.hoffmann
|
/** {@inheritDoc} */
|
110 |
f6a8dc56
|
Patric Plitzner
|
@Override
|
111 |
|
|
protected IStatus postExecute(CdmBase objectAffectedByOperation) {
|
112 |
3aa58b57
|
n.hoffmann
|
Assert.isNotNull(conversationEnabled, "Operation has to have a valid conversation attached.");
|
113 |
f6a8dc56
|
Patric Plitzner
|
|
114 |
2da4c7b2
|
Cherian Mathew
|
|
115 |
d43de9c0
|
Katja Luther
|
if (!conversationEnabled.getConversationHolder().isClosed()){
|
116 |
83117514
|
Katja Luther
|
conversationEnabled.getConversationHolder().bind();
|
117 |
d43de9c0
|
Katja Luther
|
conversationEnabled.getConversationHolder().commit(true);
|
118 |
|
|
}
|
119 |
b455bf12
|
n.hoffmann
|
IStatus status = super.postExecute(objectAffectedByOperation);
|
120 |
f6a8dc56
|
Patric Plitzner
|
|
121 |
e8409423
|
n.hoffmann
|
return status;
|
122 |
|
|
}
|
123 |
f6a8dc56
|
Patric Plitzner
|
|
124 |
3aa58b57
|
n.hoffmann
|
/**
|
125 |
|
|
* Binds the conversation that was attached to this operation.
|
126 |
|
|
*/
|
127 |
|
|
public void bind(){
|
128 |
f6a8dc56
|
Patric Plitzner
|
conversationEnabled.getConversationHolder().bind();
|
129 |
a86e2c4a
|
Patrick Plitzner
|
if(getCdmEntitySessionEnabled() != null && getCdmEntitySessionEnabled().getCdmEntitySession()!=null) {
|
130 |
c9285745
|
Cherian Mathew
|
getCdmEntitySessionEnabled().getCdmEntitySession().bind();
|
131 |
|
|
}
|
132 |
3aa58b57
|
n.hoffmann
|
}
|
133 |
e8409423
|
n.hoffmann
|
|
134 |
|
|
}
|