From 3289b01ba6eabe59e75afab94f086f553987bc4e Mon Sep 17 00:00:00 2001
From: brinn <brinn>
Date: Tue, 25 Sep 2012 10:10:31 +0000
Subject: [PATCH] Add progress reporting to two collection predicates used in
 performEntityOperation.

SVN: 26789
---
 .../predicate/DataSetUpdatesCollectionPredicate.java        | 6 ++++++
 .../predicate/SampleUpdatesCollectionPredicate.java         | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicate.java
index 524376b4168..a2fcbd15cdc 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicate.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/DataSetUpdatesCollectionPredicate.java
@@ -19,6 +19,8 @@ package ch.systemsx.cisd.openbis.generic.server.authorization.predicate;
 import java.util.ArrayList;
 import java.util.List;
 
+import ch.systemsx.cisd.common.conversation.context.ServiceConversationsThreadContext;
+import ch.systemsx.cisd.common.conversation.progress.IServiceConversationProgressListener;
 import ch.systemsx.cisd.common.exceptions.Status;
 import ch.systemsx.cisd.openbis.generic.server.authorization.IAuthorizationDataProvider;
 import ch.systemsx.cisd.openbis.generic.server.authorization.RoleWithIdentifier;
@@ -79,8 +81,11 @@ public class DataSetUpdatesCollectionPredicate extends
             return Status.OK;
         }
 
+        IServiceConversationProgressListener progressListener =
+                ServiceConversationsThreadContext.getProgressListener();
         List<TechId> techIds = new ArrayList<TechId>();
         List<SampleOwnerIdentifier> sampleIdentifiers = new ArrayList<SampleOwnerIdentifier>();
+        int index = 0;
         for (DataSetUpdatesDTO dataSetUpdates : value)
         {
             techIds.add(dataSetUpdates.getDatasetId());
@@ -100,6 +105,7 @@ public class DataSetUpdatesCollectionPredicate extends
             {
                 sampleIdentifiers.add(sampleIdentifier);
             }
+            progressListener.update("authorizeDatasetUpdates", value.size(), ++index);
         }
         Status result =
                 dataSetTechIdCollectionPredicate.doEvaluation(person, allowedRoles, techIds);
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicate.java
index 1c2ead5fe3e..9a0e11b45ee 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicate.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleUpdatesCollectionPredicate.java
@@ -19,6 +19,8 @@ package ch.systemsx.cisd.openbis.generic.server.authorization.predicate;
 import java.util.ArrayList;
 import java.util.List;
 
+import ch.systemsx.cisd.common.conversation.context.ServiceConversationsThreadContext;
+import ch.systemsx.cisd.common.conversation.progress.IServiceConversationProgressListener;
 import ch.systemsx.cisd.common.exceptions.Status;
 import ch.systemsx.cisd.openbis.generic.server.authorization.IAuthorizationDataProvider;
 import ch.systemsx.cisd.openbis.generic.server.authorization.RoleWithIdentifier;
@@ -76,9 +78,12 @@ public class SampleUpdatesCollectionPredicate extends AbstractPredicate<List<Sam
             return Status.OK;
         }
 
+        IServiceConversationProgressListener progressListener =
+                ServiceConversationsThreadContext.getProgressListener();
         List<TechId> techIds = new ArrayList<TechId>(value.size());
         List<SampleOwnerIdentifier> sampleIdentifiers =
                 new ArrayList<SampleOwnerIdentifier>(value.size());
+        int index = 0;
         for (SampleUpdatesDTO sampleUpdates : value)
         {
             TechId sampleId = sampleUpdates.getSampleIdOrNull();
@@ -100,6 +105,7 @@ public class SampleUpdatesCollectionPredicate extends AbstractPredicate<List<Sam
             {
                 sampleIdentifiers.add(sampleIdentifier);
             }
+            progressListener.update("authorizeSampleUpdates", value.size(), ++index);
         }
         Status result = sampleTechIdCollectionPredicate.doEvaluation(person, allowedRoles, techIds);
         if (result.isOK() == false)
-- 
GitLab