You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2017/12/22 18:35:58 UTC

[airavata] 01/06: Added GatewayResourceProfile Repository

This is an automated email from the ASF dual-hosted git repository.

smarru pushed a commit to branch registry-refactoring
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit a4acd74c14eb06a85d06e278c5fc1985aecbc352
Author: Sachin Kariyattin <sa...@gmail.com>
AuthorDate: Mon Dec 18 15:11:45 2017 -0500

    Added GatewayResourceProfile Repository
---
 modules/registry-refactoring/pom.xml               |  5 ++
 .../entities/appcatalog/GatewayProfileEntity.java  | 13 ++--
 .../core/repositories/AbstractRepository.java      |  6 ++
 .../appcatalog/GwyResourceProfileRepository.java   | 70 ++++++++++++++++++++++
 4 files changed, 87 insertions(+), 7 deletions(-)

diff --git a/modules/registry-refactoring/pom.xml b/modules/registry-refactoring/pom.xml
index b794349..7f1180a 100644
--- a/modules/registry-refactoring/pom.xml
+++ b/modules/registry-refactoring/pom.xml
@@ -69,6 +69,11 @@
             <version>4.12</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.apache.airavata</groupId>
+            <artifactId>airavata-commons</artifactId>
+            <version>0.17-SNAPSHOT</version>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java
index ea92602..4dbb95a 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/entities/appcatalog/GatewayProfileEntity.java
@@ -43,8 +43,8 @@ public class GatewayProfileEntity implements Serializable {
     @Column(name = "CREATION_TIME")
     private Timestamp creationTime;
 
-    @Column(name = "CS_TOKEN")
-    private String csToken;
+    @Column(name = "CREDENTIAL_STORE_TOKEN")
+    private String credentialStoreToken;
 
     @Column(name = "IDENTITY_SERVER_PWD_CRED_TOKEN")
     private String identityServerPwdCredToken;
@@ -55,7 +55,6 @@ public class GatewayProfileEntity implements Serializable {
     @Column(name = "UPDATE_TIME")
     private Timestamp updateTime;
 
-
     public GatewayProfileEntity() {
     }
 
@@ -75,12 +74,12 @@ public class GatewayProfileEntity implements Serializable {
         this.creationTime = creationTime;
     }
 
-    public String getCsToken() {
-        return csToken;
+    public String getCredentialStoreToken() {
+        return credentialStoreToken;
     }
 
-    public void setCsToken(String csToken) {
-        this.csToken = csToken;
+    public void setCredentialStoreToken(String credentialStoreToken) {
+        this.credentialStoreToken = credentialStoreToken;
     }
 
     public String getIdentityServerPwdCredToken() {
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java
index a83928d..29d6f85 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/AbstractRepository.java
@@ -95,4 +95,10 @@ public abstract class AbstractRepository<T, E, Id> {
         resultSet.stream().forEach(rs -> gatewayList.add(mapper.map(rs, thriftGenericClass)));
         return gatewayList;
     }
+
+    public boolean isExists(Id id) {
+        return get(id) != null;
+    }
+
+
 }
\ No newline at end of file
diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GwyResourceProfileRepository.java b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GwyResourceProfileRepository.java
new file mode 100644
index 0000000..98bc194
--- /dev/null
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/GwyResourceProfileRepository.java
@@ -0,0 +1,70 @@
+package org.apache.airavata.registry.core.repositories.appcatalog;
+
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.model.appcatalog.gatewayprofile.GatewayResourceProfile;
+import org.apache.airavata.registry.core.entities.appcatalog.GatewayProfileEntity;
+import org.apache.airavata.registry.core.repositories.AbstractRepository;
+import org.apache.airavata.registry.core.utils.JPAUtils;
+import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
+import org.dozer.Mapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class GwyResourceProfileRepository extends AbstractRepository<GatewayResourceProfile, GatewayProfileEntity, String>{
+
+    private final static Logger logger = LoggerFactory.getLogger(GwyResourceProfileRepository.class);
+
+    public GwyResourceProfileRepository(Class<GatewayResourceProfile> thriftGenericClass, Class<GatewayProfileEntity> dbEntityGenericClass) {
+        super(thriftGenericClass, dbEntityGenericClass);
+    }
+
+    public String addGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) {
+            return updateGatewayResourceProfile(gatewayResourceProfile);
+    }
+
+    public String updateGatewayResourceProfile(GatewayResourceProfile gatewayResourceProfile) {
+        Mapper mapper = ObjectMapperSingleton.getInstance();
+        GatewayProfileEntity gatewayProfileEntity = mapper.map(gatewayResourceProfile, GatewayProfileEntity.class);
+        gatewayProfileEntity.setUpdateTime(AiravataUtils.getCurrentTimestamp());
+        GatewayProfileEntity persistedCopy = JPAUtils.execute(entityManager -> entityManager.merge(gatewayProfileEntity));
+
+        //TODO ComputeResourcePreference
+        //TODO StoragePreference
+
+        return persistedCopy.getGatewayId();
+
+    }
+
+    public GatewayResourceProfile getGatewayProfile(String gatewayId) {
+        //TODO ComputeResourcePreference
+        //TODO StoragePreference
+    }
+
+    public boolean removeGatewayResourceProfile(String gatewayId) {
+        // TODO - Call from handler
+    }
+
+    public boolean isGatewayResourceProfileExists(String gatewayId) {
+        // TODO - Call isExists from handler
+    }
+
+    public List<String> getGatewayProfileIds(String gatewayName) {
+        // TODO - Not used anywhere (dev list??)
+    }
+
+    public List<GatewayResourceProfile> getAllGatewayProfiles() {
+
+        String queryString = "SELECT * FROM GATEWAY_PROFILE";
+
+        List<GatewayResourceProfile> gatewayResourceProfileList = select(queryString,-1, 0);
+
+        //TODO ComputeResourcePreference
+        //TODO StoragePreference
+    }
+
+
+
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@airavata.apache.org" <co...@airavata.apache.org>.