3 * Copyright (C) 2013 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.
10 package eu
.etaxonomy
.taxeditor
.operation
;
12 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.core
.runtime
.Status
;
17 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
18 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
19 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
26 public abstract class AbstractPostOperation
<T
extends ICdmBase
> extends AbstractOperation
{
30 * A reference to the {@link ICdmBase} element the concrete operation is working on
37 protected IPostOperationEnabled postOperationEnabled
;
39 private ICdmEntitySessionEnabled cdmEntitySessionEnabled
;
43 * <p>Constructor for AbstractPostOperation.</p>
45 * @param label a {@link java.lang.String} object.
46 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
48 protected AbstractPostOperation(String label
, IUndoContext undoContext
) {
50 addContext(undoContext
);
54 * <p>Constructor for AbstractPostOperation.</p>
56 * @param label a {@link java.lang.String} object.
57 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
58 * @param element a {@link ICdmBase} object on which this operation is working.
60 public AbstractPostOperation(String label
, IUndoContext undoContext
, T element
) {
61 this(label
, undoContext
);
62 this.element
= element
;
68 * @param postOperationEnabled
70 public AbstractPostOperation(String label
, IUndoContext undoContext
,
71 T element
, IPostOperationEnabled postOperationEnabled
) {
72 this(label
, undoContext
);
73 this.element
= element
;
74 this.postOperationEnabled
= postOperationEnabled
;
77 public AbstractPostOperation(String label
, IUndoContext undoContext
,
78 T element
, IPostOperationEnabled postOperationEnabled
,
79 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
80 this(label
, undoContext
);
81 this.element
= element
;
82 this.postOperationEnabled
= postOperationEnabled
;
83 this.cdmEntitySessionEnabled
= cdmEntitySessionEnabled
;
87 * This method will try to call the post operation on a possibly registered
88 * IPostOperationEnabled implementor. Objects that were affected by the operation
89 * may be passed to the registered IPostOperationEnabled implementor.
91 * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
92 * @return a {@link org.eclipse.core.runtime.IStatus} object.
94 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
96 if(postOperationEnabled
!= null){
97 return postOperationEnabled
.postOperation(objectAffectedByOperation
) ? Status
.OK_STATUS
: Status
.CANCEL_STATUS
;
99 return Status
.OK_STATUS
;
103 * <p>Getter for the field <code>postOperationEnabled</code>.</p>
105 * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
107 public IPostOperationEnabled
getPostOperationEnabled() {
108 return postOperationEnabled
;
111 // protected IStatus updateSession(CdmBase clientObjectAffectedByOperation, UpdateResult updateResult) {
112 // Set<CdmBase> affectedObjects;
113 // if(updateResult == null) {
114 // affectedObjects = new HashSet<CdmBase>();
116 // affectedObjects = updateResult.getUpdatedObjects();
119 // if(cdmEntitySessionEnabled != null) {
120 // cdmEntitySessionEnabled.getCdmEntitySession().update(clientObjectAffectedByOperation, affectedObjects);
122 // return Status.OK_STATUS;
125 // protected IStatus updateSession(UUID uuid) {
127 // if(cdmEntitySessionEnabled != null) {
128 // CdmBase cdmBase = cdmEntitySessionEnabled.getCdmEntitySession().remoteLoad(CdmStore.getService(IService.class),uuid);
129 // cdmEntitySessionEnabled.getCdmEntitySession().update(null, cdmBase);
131 // return Status.OK_STATUS;
134 public ICdmEntitySessionEnabled
getCdmEntitySessionEnabled() {
135 return cdmEntitySessionEnabled
;