airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: updating the search projects API method
Date Mon, 27 Jun 2016 22:58:47 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop 7a636a4e5 -> aedabdb32


updating the search projects API method


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

Branch: refs/heads/develop
Commit: aedabdb322fab68cd9432fcf3475eccaba02d52d
Parents: 7a636a4
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Mon Jun 27 18:58:43 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Mon Jun 27 18:58:43 2016 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 20 +++++++++++++-------
 .../catalog/impl/ProjectRegistry.java           |  4 ++--
 .../catalog/resources/WorkerResource.java       | 15 +++++++++++++--
 3 files changed, 28 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/aedabdb3/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 ab33786..a274641 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
@@ -74,7 +74,6 @@ import org.apache.airavata.registry.core.app.catalog.resources.*;
 import org.apache.airavata.registry.core.app.catalog.util.AppCatalogThriftConversion;
 import org.apache.airavata.registry.core.experiment.catalog.ExpCatResourceUtils;
 import org.apache.airavata.registry.core.experiment.catalog.impl.RegistryFactory;
-import org.apache.airavata.registry.core.experiment.catalog.model.ExperimentSummary;
 import org.apache.airavata.registry.cpi.*;
 import org.apache.airavata.registry.cpi.utils.Constants;
 import org.apache.thrift.TException;
@@ -802,7 +801,6 @@ public class AiravataServerHandler implements Airavata.Iface {
             List<Project> projects = new ArrayList<Project>();
             experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
             Map<String, String> regFilters = new HashMap<String, String>();
-            regFilters.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
             regFilters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
             for(Map.Entry<ProjectSearchFields, String> entry : filters.entrySet())
             {
@@ -812,8 +810,18 @@ public class AiravataServerHandler implements Airavata.Iface {
                     regFilters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION,
entry.getValue());
                 }
             }
-            List<Object> results = experimentCatalog.search(ExperimentCatalogModelType.PROJECT,
regFilters, limit, offset,
-                    Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
+
+            //FIXME - These accessible IDs should come from grouper
+            Map<String, String> temp = new HashMap();
+            temp.put(Constants.FieldConstants.ProjectConstants.OWNER, userName);
+            temp.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, gatewayId);
+            List<Object> allUserProjects = experimentCatalog.search(ExperimentCatalogModelType.PROJECT,
temp, -1,
+                    0, Constants.FieldConstants.ProjectConstants.CREATION_TIME, ResultOrderType.DESC);
+            List<String> accessibleProjIds = new ArrayList<>();
+            allUserProjects.stream().forEach(e->accessibleProjIds.add(((Project) e).getProjectID()));
+
+            List<Object> results = experimentCatalog.searchAllAccessible(ExperimentCatalogModelType.PROJECT,
accessibleProjIds,
+                    regFilters, limit, offset, Constants.FieldConstants.ProjectConstants.CREATION_TIME,
ResultOrderType.DESC);
             for (Object object : results) {
                 projects.add((Project)object);
             }
@@ -871,8 +879,6 @@ public class AiravataServerHandler implements Airavata.Iface {
             List<ExperimentSummaryModel> summaries = new ArrayList<ExperimentSummaryModel>();
             experimentCatalog = RegistryFactory.getExperimentCatalog(gatewayId);
             Map<String, String> regFilters = new HashMap();
-            //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())
             {
@@ -893,7 +899,7 @@ public class AiravataServerHandler implements Airavata.Iface {
                 }
             }
 
-            //FIXME
+            //FIXME - These accessible IDs should come from grouper
             Map<String, String> temp = new HashMap();
             temp.put(Constants.FieldConstants.ExperimentConstants.USER_NAME, userName);
             temp.put(Constants.FieldConstants.ExperimentConstants.GATEWAY_ID, gatewayId);

http://git-wip-us.apache.org/repos/asf/airavata/blob/aedabdb3/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
index 8861b68..9e16daa 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/ProjectRegistry.java
@@ -247,7 +247,7 @@ public class ProjectRegistry {
                     }
                 }
                 List<ProjectResource> projectResources = workerResource
-                        .searchProjects(fil, limit, offset, orderByIdentifier, resultOrderType);
+                        .searchProjects(fil, null, limit, offset, orderByIdentifier, resultOrderType);
                 if (projectResources != null && !projectResources.isEmpty()){
                     for (ProjectResource pr : projectResources){
                         projects.add(ThriftDataModelConversion.getProject(pr));
@@ -294,7 +294,7 @@ public class ProjectRegistry {
                     }
                 }
                 List<ProjectResource> projectResources = workerResource
-                        .searchProjects(fil, limit, offset, orderByIdentifier, resultOrderType);
+                        .searchProjects(fil, accessibleIds, limit, offset, orderByIdentifier,
resultOrderType);
                 if (projectResources != null && !projectResources.isEmpty()){
                     for (ProjectResource pr : projectResources){
                         projects.add(ThriftDataModelConversion.getProject(pr));

http://git-wip-us.apache.org/repos/asf/airavata/blob/aedabdb3/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 5fdc265..dec4e7f 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
@@ -508,12 +508,23 @@ public class WorkerResource extends AbstractExpCatResource {
      * @return
      * @throws org.apache.airavata.registry.cpi.RegistryException
      */
-    public List<org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource>
searchProjects(Map<String, String> filters, int limit,
-                                                int offset, Object orderByIdentifier, ResultOrderType
resultOrderType) throws RegistryException {
+    public List<org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource>
searchProjects(
+            Map<String, String> filters, List<String> accessibleIds, int limit,
int offset, Object orderByIdentifier,
+            ResultOrderType resultOrderType) throws RegistryException {
+
         List<org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource>
result = new ArrayList<org.apache.airavata.registry.core.experiment.catalog.resources.ProjectResource>();
         EntityManager em = null;
         try {
             String query = "SELECT DISTINCT p from Project p WHERE ";
+
+            // FIXME There is a performance bottleneck for using IN clause. Try using temporary
tables ?
+            if(accessibleIds != null){
+                query += " p.projectId IN (";
+                for(String id : accessibleIds)
+                    query += ("'" + id + "'" + ",");
+                query = query.substring(0, query.length()-1) + ") AND ";
+            }
+
             if (filters != null && filters.size() != 0) {
                 for (String field : filters.keySet()) {
                     String filterVal = filters.get(field);


Mime
View raw message