Repository: airavata
Updated Branches:
  refs/heads/develop 4691113d7 -> c48982d75


AIRAVATA-2470 Returning all of requester's gateways


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

Branch: refs/heads/develop
Commit: c48982d75652690e50139fdb8aeff281191fb995
Parents: 4691113
Author: Marcus Christie <[email protected]>
Authored: Mon Jul 3 11:56:33 2017 -0400
Committer: Marcus Christie <[email protected]>
Committed: Mon Jul 3 11:56:33 2017 -0400

----------------------------------------------------------------------
 .../commons/repositories/AbstractRepository.java  | 18 ++++++++++++++++++
 .../repositories/TenantProfileRepository.java     |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/c48982d7/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/repositories/AbstractRepository.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/repositories/AbstractRepository.java
 
b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/repositories/AbstractRepository.java
index 7f80a96..b1c71b4 100644
--- 
a/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/repositories/AbstractRepository.java
+++ 
b/airavata-services/profile-service/profile-service-commons/src/main/java/org/apache/airavata/service/profile/commons/repositories/AbstractRepository.java
@@ -103,4 +103,22 @@ public abstract class AbstractRepository<T, E, Id> {
         resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, 
thriftGenericClass)));
         return resultList;
     }
+
+    public List<T> select(String query, Map<String, Object> queryParams) {
+        List resultSet = (List) JPAUtils.execute(entityManager -> {
+            Query jpaQuery = entityManager.createQuery(query);
+
+            for (Map.Entry<String, Object> entry : queryParams.entrySet()) {
+
+                jpaQuery.setParameter(entry.getKey(), entry.getValue());
+            }
+
+            return jpaQuery.getResultList();
+
+        });
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        List<T> resultList = new ArrayList<>();
+        resultSet.stream().forEach(rs -> resultList.add(mapper.map(rs, 
thriftGenericClass)));
+        return resultList;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/c48982d7/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
----------------------------------------------------------------------
diff --git 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
index a469ced..b9b470a 100644
--- 
a/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
+++ 
b/airavata-services/profile-service/profile-tenant-core/src/main/java/org/apache/airavata/service/profile/tenant/core/repositories/TenantProfileRepository.java
@@ -74,7 +74,7 @@ public class TenantProfileRepository extends 
AbstractRepository<Gateway, Gateway
         try {
             Map<String, Object> queryParam = new HashMap<String, Object>();
             queryParam.put(Gateway._Fields.REQUESTER_USERNAME.getFieldName(), 
requesterUsername);
-            List<Gateway> gatewayList = 
select(QueryConstants.GET_USER_GATEWAYS, 1, 0, queryParam);
+            List<Gateway> gatewayList = 
select(QueryConstants.GET_USER_GATEWAYS, queryParam);
             return gatewayList;
         } catch (Exception e){
             logger.error("Error while getting the user's gateways, reason: ", 
e);

Reply via email to