airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata] branch group-based-auth updated: AIRAVATA-2842 Fix for JOIN that resulted in multiple App Modules
Date Tue, 17 Jul 2018 14:04:27 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/group-based-auth by this push:
     new 637709f  AIRAVATA-2842 Fix for JOIN that resulted in multiple App Modules
637709f is described below

commit 637709f80f1a023e64ae8e190d95dac52a4e45d6
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Tue Jul 17 10:02:24 2018 -0400

    AIRAVATA-2842 Fix for JOIN that resulted in multiple App Modules
    
    Switched SQL JOIN to EXISTS clause so that multiples of the same App
    Modules aren't returned when an App Modules has multiple accessible
    deployments.
---
 .../airavata/registry/core/utils/QueryConstants.java     |  7 ++++---
 .../appcatalog/ApplicationInterfaceRepositoryTest.java   | 16 ++++++++++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
index b7f895c..fa3a704 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@ -58,9 +58,10 @@ public interface QueryConstants {
     String FIND_APPLICATION_MODULES_FOR_APPLICATION_MODULE_NAME = "SELECT AM FROM " + ApplicationModuleEntity.class.getSimpleName()
+ " AM " +
             "WHERE AM.appModuleName LIKE :" + DBConstants.ApplicationModule.APPLICATION_MODULE_NAME;
     String FIND_ACCESSIBLE_APPLICATION_MODULES = "SELECT AM FROM " + ApplicationModuleEntity.class.getSimpleName()
+ " AM " +
-            ", " + ApplicationDeploymentEntity.class.getSimpleName() + " AD WHERE AM.appModuleId
= AD.appModuleId AND AM.gatewayId LIKE :" +
-            DBConstants.ApplicationModule.GATEWAY_ID + " AND AD.appDeploymentId IN :" + DBConstants.ApplicationDeployment.ACCESSIBLE_APPLICATION_DEPLOYMENT_IDS
+
-            " AND AD.computeHostId IN :" + DBConstants.ApplicationDeployment.ACCESSIBLE_COMPUTE_HOST_IDS;
+            "WHERE AM.gatewayId LIKE :" + DBConstants.ApplicationModule.GATEWAY_ID + " AND
" +
+            "EXISTS (SELECT 1 FROM " + ApplicationDeploymentEntity.class.getSimpleName()
+ " AD " +
+            "WHERE AM.appModuleId = AD.appModuleId AND AD.appDeploymentId IN :" + DBConstants.ApplicationDeployment.ACCESSIBLE_APPLICATION_DEPLOYMENT_IDS
+
+            " AND AD.computeHostId IN :" + DBConstants.ApplicationDeployment.ACCESSIBLE_COMPUTE_HOST_IDS
+ ")";
 
     // Application Interface Queries
     String FIND_APPLICATION_INTERFACES_FOR_GATEWAY_ID = "SELECT AI FROM " + ApplicationInterfaceEntity.class.getSimpleName()
+ " AI " +
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
index 77b7e87..18968bc 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepositoryTest.java
@@ -36,12 +36,10 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
 import java.util.*;
 
+import static org.junit.Assert.assertEquals;
+
 public class ApplicationInterfaceRepositoryTest extends TestBase {
 
     private static final Logger logger = LoggerFactory.getLogger(ApplicationInterfaceRepositoryTest.class);
@@ -387,6 +385,16 @@ public class ApplicationInterfaceRepositoryTest extends TestBase {
         appModuleList = applicationInterfaceRepository.getAccessibleApplicationModules(gatewayId,
deploymentIds, compHostIds);
         assertEquals(1, appModuleList.size());
         assertEquals(moduleId1, appModuleList.get(0).getAppModuleId());
+
+        deploymentIds = new ArrayList<>();
+        deploymentIds.add(deploymentId1);
+        deploymentIds.add(deploymentId2);
+        compHostIds = new ArrayList<>();
+        compHostIds.add(computeResourceId1);
+        compHostIds.add(computeResourceId2);
+        appModuleList = applicationInterfaceRepository.getAccessibleApplicationModules(gatewayId,
deploymentIds, compHostIds);
+        assertEquals(1, appModuleList.size());
+        assertEquals(moduleId1, appModuleList.get(0).getAppModuleId());
     }
 
     @Test


Mime
View raw message