Merge branch 'develop' of wp5.e-taxonomy.eu:/var/git/taxeditor into remoting-4.0
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / operation / AbstractPostOperation.java
index 5b7c68ec8230074a7de6ef72c0fd5ae812bb3636..c313d1f0f9f236ea48bcc8c0e558ad82a5e8a84a 100644 (file)
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.Status;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.ICdmBase;
+import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
 
 /**
  * @author pplitzner
@@ -35,6 +36,8 @@ public abstract class AbstractPostOperation<T extends ICdmBase> extends Abstract
      */
     protected IPostOperationEnabled postOperationEnabled;
 
+    private ICdmEntitySessionEnabled cdmEntitySessionEnabled;
+
 
     /**
      * <p>Constructor for AbstractPostOperation.</p>
@@ -71,6 +74,15 @@ public abstract class AbstractPostOperation<T extends ICdmBase> extends Abstract
         this.postOperationEnabled = postOperationEnabled;
     }
 
+    public AbstractPostOperation(String label, IUndoContext undoContext,
+            T element, IPostOperationEnabled postOperationEnabled,
+            ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
+        this(label, undoContext);
+        this.element = element;
+        this.postOperationEnabled = postOperationEnabled;
+        this.cdmEntitySessionEnabled = cdmEntitySessionEnabled;
+    }
+
     /**
      * This method will try to call the post operation on a possibly registered
      * IPostOperationEnabled implementor. Objects that were affected by the operation
@@ -80,10 +92,11 @@ public abstract class AbstractPostOperation<T extends ICdmBase> extends Abstract
      * @return a {@link org.eclipse.core.runtime.IStatus} object.
      */
     protected IStatus postExecute(CdmBase objectAffectedByOperation) {
-       if(postOperationEnabled != null){
-               return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
-       }
-       return Status.OK_STATUS;
+
+        if(postOperationEnabled != null){
+            return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
+        }
+        return Status.OK_STATUS;
     }
 
     /**
@@ -92,7 +105,34 @@ public abstract class AbstractPostOperation<T extends ICdmBase> extends Abstract
      * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
      */
     public IPostOperationEnabled getPostOperationEnabled() {
-       return postOperationEnabled;
+        return postOperationEnabled;
+    }
+
+//    protected IStatus updateSession(CdmBase clientObjectAffectedByOperation, UpdateResult updateResult) {
+//        Set<CdmBase> affectedObjects;
+//        if(updateResult == null) {
+//            affectedObjects = new HashSet<CdmBase>();
+//        } else {
+//            affectedObjects = updateResult.getUpdatedObjects();
+//        }
+//
+//        if(cdmEntitySessionEnabled != null) {
+//            cdmEntitySessionEnabled.getCdmEntitySession().update(clientObjectAffectedByOperation, affectedObjects);
+//        }
+//        return Status.OK_STATUS;
+//    }
+//
+//    protected IStatus updateSession(UUID uuid) {
+//
+//        if(cdmEntitySessionEnabled != null) {
+//            CdmBase cdmBase = cdmEntitySessionEnabled.getCdmEntitySession().remoteLoad(CdmStore.getService(IService.class),uuid);
+//            cdmEntitySessionEnabled.getCdmEntitySession().update(null, cdmBase);
+//        }
+//        return Status.OK_STATUS;
+//    }
+
+    public ICdmEntitySessionEnabled getCdmEntitySessionEnabled() {
+        return cdmEntitySessionEnabled;
     }
 
 }
\ No newline at end of file