airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shame...@apache.org
Subject [31/53] [abbrv] airavata git commit: testing where experiment id IN clause
Date Thu, 07 Jul 2016 19:30:17 GMT
testing where experiment id IN clause


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/4e53f23a
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/4e53f23a
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/4e53f23a

Branch: refs/heads/master
Commit: 4e53f23ae2eb30ab0c1f080c69cdc97836f94ad1
Parents: b34d8a4
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Mon Jun 27 17:54:42 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Mon Jun 27 17:54:42 2016 -0400

----------------------------------------------------------------------
 .../api/server/handler/AiravataServerHandler.java     | 14 +++++++++++---
 .../experiment/catalog/impl/ExperimentRegistry.java   |  8 ++++----
 .../experiment/catalog/resources/WorkerResource.java  | 11 ++++++++++-
 3 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/4e53f23a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index 8b4072f..94768b4 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -30,8 +30,8 @@ import org.apache.airavata.common.utils.AiravataUtils;
 import org.apache.airavata.common.utils.ServerSettings;
 import org.apache.airavata.credential.store.client.CredentialStoreClientFactory;
 import org.apache.airavata.credential.store.cpi.CredentialStoreService;
-import org.apache.airavata.credential.store.datamodel.SSHCredential;
 import org.apache.airavata.credential.store.datamodel.PasswordCredential;
+import org.apache.airavata.credential.store.datamodel.SSHCredential;
 import org.apache.airavata.credential.store.exception.CredentialStoreException;
 import org.apache.airavata.messaging.core.MessageContext;
 import org.apache.airavata.messaging.core.Publisher;
@@ -870,7 +870,8 @@ public class AiravataServerHandler implements Airavata.Iface {
             List<ExperimentSummaryModel> summaries = new ArrayList<ExperimentSummaryModel>();
             experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
             Map<String, String> regFilters = new HashMap();
-            regFilters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
+            //FIXME
+            //regFilters.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
             regFilters.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);
             for(Map.Entry<ExperimentSearchFields, String> entry : filters.entrySet())
             {
@@ -890,7 +891,14 @@ public class AiravataServerHandler implements Airavata.Iface {
                     regFilters.put(Constants.FieldConstants.ExperimentConstants.PROJECT_ID,
entry.getValue());
                 }
             }
-            List<Object> results = experimentCatalog.search(ExperimentCatalogModelType.EXPERIMENT,
regFilters, limit,
+
+            //FIXME
+            List<ExperimentModel> allUserExperiments = getUserExperiments(authzToken,
gatewayId, userName, -1, 0);
+            List<String> accessibleExpIds = new ArrayList<>();
+            allUserExperiments.stream().forEach(e->accessibleExpIds.add(e.getExperimentId()));
+
+            List<Object> results = experimentCatalog.searchAllAccessible(ExperimentCatalogModelType.EXPERIMENT,
+                    accessibleExpIds, regFilters, limit,
                     offset, Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
             for (Object object : results) {
                 summaries.add((ExperimentSummaryModel) object);

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e53f23a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
index 79e3c66..dd555b1 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ExperimentRegistry.java
@@ -1346,11 +1346,11 @@ public class ExperimentRegistry {
                 }
                 List<ExperimentSummaryResource> experimentSummaryResources;
                 if (fromTime != 0 && toTime != 0) {
-                    experimentSummaryResources = workerResource.searchExperiments(new Timestamp(fromTime),
new Timestamp(toTime), fil
+                    experimentSummaryResources = workerResource.searchExperiments(null, new
Timestamp(fromTime), new Timestamp(toTime), fil
                             ,limit , offset, orderByIdentifier, resultOrderType);
                 } else {
                     experimentSummaryResources = workerResource
-                            .searchExperiments(null, null, fil, limit, offset, orderByIdentifier,
resultOrderType);
+                            .searchExperiments(null, null, null, fil, limit, offset, orderByIdentifier,
resultOrderType);
                 }
                 if (experimentSummaryResources != null && !experimentSummaryResources.isEmpty())
{
                     for (ExperimentSummaryResource ex : experimentSummaryResources) {
@@ -1398,11 +1398,11 @@ public class ExperimentRegistry {
                 }
                 List<ExperimentSummaryResource> experimentSummaryResources;
                 if (fromTime != 0 && toTime != 0) {
-                    experimentSummaryResources = workerResource.searchExperiments(new Timestamp(fromTime),
new Timestamp(toTime), fil
+                    experimentSummaryResources = workerResource.searchExperiments(accessibleIds,
new Timestamp(fromTime), new Timestamp(toTime), fil
                             ,limit , offset, orderByIdentifier, resultOrderType);
                 } else {
                     experimentSummaryResources = workerResource
-                            .searchExperiments(null, null, fil, limit, offset, orderByIdentifier,
resultOrderType);
+                            .searchExperiments(accessibleIds, null, null, fil, limit, offset,
orderByIdentifier, resultOrderType);
                 }
                 if (experimentSummaryResources != null && !experimentSummaryResources.isEmpty())
{
                     for (ExperimentSummaryResource ex : experimentSummaryResources) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/4e53f23a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
index cf2f59b..bddeae4 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/resources/WorkerResource.java
@@ -588,13 +588,22 @@ public class WorkerResource extends AbstractExpCatResource {
      * @return
      * @throws org.apache.airavata.registry.cpi.RegistryException
      */
-    public List<ExperimentSummaryResource> searchExperiments(Timestamp fromTime, Timestamp
toTime, Map<String, String> filters, int limit,
+    public List<ExperimentSummaryResource> searchExperiments(List<String> accessibleIds,
Timestamp fromTime, Timestamp toTime, Map<String, String> filters, int limit,
                                                              int offset, Object orderByIdentifier,
ResultOrderType resultOrderType) throws RegistryException {
         List<ExperimentSummaryResource> result = new ArrayList();
         EntityManager em = null;
         try {
             String query = "SELECT e FROM ExperimentSummary e " +
                     "WHERE ";
+
+            // FIXME There is a performance bottleneck for using IN clause. Try using temporary
tables ?
+            if(accessibleIds != null){
+                query += " e.experimentId IN (";
+                for(String id : accessibleIds)
+                    query += (id + ",");
+                query = query.substring(0, query.length()-1) + ") ";
+            }
+
             if (filters.get(ExperimentStatusConstants.STATE) != null) {
                 String experimentState = ExperimentState.valueOf(filters.get(ExperimentStatusConstants.STATE)).toString();
                 query += "e.state='" + experimentState + "' AND ";


Mime
View raw message