airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: fixing entity conversion issue
Date Wed, 19 Oct 2016 21:09:32 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop 2f6340623 -> adf1e62a4


fixing entity conversion issue


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

Branch: refs/heads/develop
Commit: adf1e62a408eeae66b99195de676199630d6a885
Parents: 2f63406
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Wed Oct 19 17:09:28 2016 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Wed Oct 19 17:09:28 2016 -0400

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |  7 ++--
 .../db/repositories/AbstractRepository.java     | 10 ------
 .../db/repositories/EntityRepository.java       | 35 +++++++++++++++++++-
 3 files changed, 37 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/adf1e62a/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 5570157..8668fb2 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
@@ -44,14 +44,14 @@ import org.apache.airavata.model.appcatalog.appdeployment.ApplicationDeploymentD
 import org.apache.airavata.model.appcatalog.appdeployment.ApplicationModule;
 import org.apache.airavata.model.appcatalog.appinterface.ApplicationInterfaceDescription;
 import org.apache.airavata.model.appcatalog.computeresource.*;
-import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
+import org.apache.airavata.model.appcatalog.credentialsummary.CredentialSummary;
 import org.apache.airavata.model.appcatalog.gatewayprofile.ComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
 import org.apache.airavata.model.appcatalog.gatewayprofile.StoragePreference;
 import org.apache.airavata.model.appcatalog.storageresource.StorageResourceDescription;
-import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
 import org.apache.airavata.model.appcatalog.userresourceprofile.UserComputeResourcePreference;
+import org.apache.airavata.model.appcatalog.userresourceprofile.UserResourceProfile;
 import org.apache.airavata.model.appcatalog.userresourceprofile.UserStoragePreference;
-import org.apache.airavata.model.appcatalog.credentialsummary.CredentialSummary;
 import org.apache.airavata.model.application.io.InputDataObjectType;
 import org.apache.airavata.model.application.io.OutputDataObjectType;
 import org.apache.airavata.model.commons.airavata_commonsConstants;
@@ -79,7 +79,6 @@ import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.registry.api.RegistryService;
 import org.apache.airavata.registry.api.client.RegistryServiceClientFactory;
 import org.apache.airavata.registry.api.exception.RegistryServiceException;
-import org.apache.airavata.sharing.registry.models.*;
 import org.apache.airavata.sharing.registry.server.SharingRegistryServerHandler;
 import org.apache.thrift.TException;
 import org.slf4j.Logger;

http://git-wip-us.apache.org/repos/asf/airavata/blob/adf1e62a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
index ed99f62..9f5a706 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/AbstractRepository.java
@@ -121,16 +121,6 @@ public abstract class AbstractRepository<T, E, Id> {
         return gatewayList;
     }
 
-    public List<T> selectFromNativeQuery(String queryString, int offset, int limit)
throws SharingRegistryException {
-        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
-        List resultSet = JPAUtils.execute(entityManager -> entityManager.createNativeQuery(queryString).setFirstResult(offset)
-                .setMaxResults(newLimit).getResultList());
-        Mapper mapper = ObjectMapperSingleton.getInstance();
-        List<T> gatewayList = new ArrayList<>();
-        resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
-        return gatewayList;
-    }
-
     public String getSelectQuery(Map<String, String> filters){
         String query = "SELECT DISTINCT p from " + dbEntityGenericClass.getSimpleName() +
" as p";
         if(filters != null && filters.size() != 0){

http://git-wip-us.apache.org/repos/asf/airavata/blob/adf1e62a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
index 0fb8b78..8c5c268 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
@@ -30,6 +30,8 @@ import org.apache.airavata.sharing.registry.models.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.sql.Clob;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -101,8 +103,39 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity,
E
                 }
             }
         }
+
         query = query.substring(0, query.length() - 5);
-        return selectFromNativeQuery(query, offset, limit);
+        final String nativeQuery = query;
+        int newLimit = limit < 0 ? DBConstants.SELECT_MAX_ROWS: limit;
+
+        List<Object[]> temp = JPAUtils.execute(entityManager -> entityManager.createNativeQuery(nativeQuery).setFirstResult(offset)
+                .setMaxResults(newLimit).getResultList());
+        List<Entity> resultSet = new ArrayList<>();
+
+        temp.stream().forEach(rs->{
+            Entity entity = new Entity();
+            entity.setEntityId((String)(rs[0]));
+            entity.setDomainId((String) (rs[1]));
+            entity.setEntityTypeId((String) (rs[2]));
+            entity.setOwnerId((String) (rs[3]));
+            entity.setParentEntityId((String) (rs[4]));
+            entity.setName((String) (rs[5]));
+            entity.setDescription((String)(rs[6]));
+            entity.setBinaryData((byte[]) (rs[7]));
+            if(rs[8] instanceof Clob){
+                Clob clob = (Clob)rs[8];
+                if(clob != null)
+                    entity.setFullText(clob.toString());
+            }else
+                entity.setFullText((String) (rs[8]));
+            entity.setOriginalEntityCreationTime((long)(rs[9]));
+            entity.setCreatedTime((long)(rs[10]));
+            entity.setUpdatedTime((long)(rs[11]));
+
+            resultSet.add(entity);
+        });
+
+        return resultSet;
     }
 
     public String getSelectQuery(Map<String, String> filters){


Mime
View raw message