3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.taxeditor
.operation
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.Assert
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
17 import eu
.etaxonomy
.cdm
.api
.conversation
.IConversationEnabled
;
18 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
19 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
20 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
21 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
24 * Superclass for all operation that have to be committed imediately after execution.
26 * Note: You have to call the {@link #bind()} method in the {@link #execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)},
27 * {@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)}
28 * methods so the correct persistence context gets bound.
34 public abstract class AbstractPersistentPostOperation
extends AbstractPostTaxonOperation
{
35 private final IConversationEnabled conversationEnabled
;
36 private final ICdmEntitySessionEnabled cdmEntitySessionEnabled
;
37 protected ITaxonTreeNode parentNode
;
40 * <p>Constructor for AbstractPersistentPostOperation.</p>
42 * @param label a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
45 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
47 protected AbstractPersistentPostOperation(String label
, IUndoContext undoContext
,
48 IPostOperationEnabled postOperationEnabled
,
49 IConversationEnabled conversationEnabled
,
50 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
51 super(label
, undoContext
, postOperationEnabled
);
52 this.conversationEnabled
= conversationEnabled
;
53 this.cdmEntitySessionEnabled
= cdmEntitySessionEnabled
;
57 * <p>Constructor for AbstractPersistentPostOperation.</p>
59 * @param label a {@link java.lang.String} object.
60 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
61 * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
62 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
63 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
65 public AbstractPersistentPostOperation(String label
,
66 IUndoContext undoContext
, TaxonNode taxonNode
,
67 IPostOperationEnabled postOperationEnabled
,
68 IConversationEnabled conversationEnabled
,
69 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
70 super(label
, undoContext
, taxonNode
, postOperationEnabled
);
71 this.conversationEnabled
= conversationEnabled
;
72 this.cdmEntitySessionEnabled
= cdmEntitySessionEnabled
;
76 * <p>Constructor for AbstractPersistentPostOperation.</p>
78 * @param label a {@link java.lang.String} object.
79 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
80 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
81 * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
82 * @param parentNode a {@link eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode} object.
84 public AbstractPersistentPostOperation(String label
,
85 IUndoContext undoContext
, ITaxonTreeNode parentNode
,
86 IPostOperationEnabled postOperationEnabled
,
87 IConversationEnabled conversationEnabled
,
88 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
89 super(label
, undoContext
, postOperationEnabled
);
90 this.parentNode
= parentNode
;
91 this.conversationEnabled
= conversationEnabled
;
92 this.cdmEntitySessionEnabled
= cdmEntitySessionEnabled
;
96 * @see eu.etaxonomy.taxeditor.operations.AbstractPostOperation#postExecute(eu.etaxonomy.cdm.model.common.CdmBase)
100 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
101 Assert
.isNotNull(conversationEnabled
, "Operation has to have a valid conversation attached.");
104 if (!conversationEnabled
.getConversationHolder().isClosed()){
105 conversationEnabled
.getConversationHolder().bind();
106 conversationEnabled
.getConversationHolder().commit(true);
108 if(cdmEntitySessionEnabled
!= null) {
109 cdmEntitySessionEnabled
.getCdmEntitySession().fireNotifications();
111 IStatus status
= super.postExecute(objectAffectedByOperation
);
117 * Binds the conversation that was attached to this operation.
120 conversationEnabled
.getConversationHolder().bind();