2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.taxeditor
.operation
;
12 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
13 import org
.eclipse
.core
.runtime
.Assert
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
16 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
17 import eu
.etaxonomy
.cdm
.persistence
.dto
.TaxonNodeDto
;
18 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
21 * Superclass for all operation that have to be committed imediately after execution.
23 * Note: You have to call the {@link #bind()} method in the {@link #execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)},
24 * {@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)}
25 * methods so the correct persistence context gets bound.
31 public abstract class AbstractPersistentPostOperation
extends AbstractPostTaxonOperation
{
32 private final IConversationEnabled conversationEnabled
;
34 protected TaxonNodeDto parentNode
;
37 * <p>Constructor for AbstractPersistentPostOperation.</p>
39 * @param label a {@link java.lang.String} object.
40 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
41 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
42 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
44 protected AbstractPersistentPostOperation(String label
, IUndoContext undoContext
,
45 IPostOperationEnabled postOperationEnabled
,
46 IConversationEnabled conversationEnabled
) {
47 this(label
, undoContext
, postOperationEnabled
, conversationEnabled
, null);
51 * <p>Constructor for AbstractPersistentPostOperation.</p>
53 * @param label a {@link java.lang.String} object.
54 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
55 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
56 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
58 protected AbstractPersistentPostOperation(String label
, IUndoContext undoContext
,
59 IPostOperationEnabled postOperationEnabled
,
60 IConversationEnabled conversationEnabled
,
61 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
62 super(label
, undoContext
, postOperationEnabled
, cdmEntitySessionEnabled
);
63 this.conversationEnabled
= conversationEnabled
;
67 * <p>Constructor for AbstractPersistentPostOperation.</p>
69 * @param label a {@link java.lang.String} object.
70 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
71 * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
72 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
73 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
75 public AbstractPersistentPostOperation(String label
,
76 IUndoContext undoContext
, TaxonNodeDto taxonNode
,
77 IPostOperationEnabled postOperationEnabled
,
78 IConversationEnabled conversationEnabled
,
79 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
80 super(label
, undoContext
, taxonNode
, postOperationEnabled
, cdmEntitySessionEnabled
);
81 this.conversationEnabled
= conversationEnabled
;
86 * <p>Constructor for AbstractPersistentPostOperation.</p>
88 * @param label a {@link java.lang.String} object.
89 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
90 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
91 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
92 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
94 public AbstractPersistentPostOperation(String label
,
95 IUndoContext undoContext
,
96 IPostOperationEnabled postOperationEnabled
,
97 IConversationEnabled conversationEnabled
,
98 ICdmEntitySessionEnabled cdmEntitySessionEnabled
, TaxonNodeDto parentNode
) {
99 super(label
, undoContext
, postOperationEnabled
, cdmEntitySessionEnabled
);
100 this.parentNode
= parentNode
;
101 this.conversationEnabled
= conversationEnabled
;
106 * @see eu.etaxonomy.taxeditor.operations.AbstractPostOperation#postExecute(eu.etaxonomy.cdm.model.common.CdmBase)
110 protected IStatus
postExecute(Object objectAffectedByOperation
) {
111 Assert
.isNotNull(conversationEnabled
, "Operation has to have a valid conversation attached.");
114 if (!conversationEnabled
.getConversationHolder().isClosed()){
115 conversationEnabled
.getConversationHolder().bind();
116 conversationEnabled
.getConversationHolder().commit(true);
118 IStatus status
= super.postExecute(objectAffectedByOperation
);
124 * Binds the conversation that was attached to this operation.
127 conversationEnabled
.getConversationHolder().bind();
128 if(getCdmEntitySessionEnabled() != null && getCdmEntitySessionEnabled().getCdmEntitySession()!=null) {
129 getCdmEntitySessionEnabled().getCdmEntitySession().bind();