airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From samin...@apache.org
Subject svn commit: r1382139 - in /incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa: JPAResourceAccessor.java ResourceUtils.java
Date Fri, 07 Sep 2012 19:56:09 GMT
Author: samindaw
Date: Fri Sep  7 19:56:09 2012
New Revision: 1382139

URL: http://svn.apache.org/viewvc?rev=1382139&view=rev
Log:
add few more config methods

Modified:
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java?rev=1382139&r1=1382138&r2=1382139&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/JPAResourceAccessor.java
Fri Sep  7 19:56:09 2012
@@ -46,7 +46,4 @@ public class JPAResourceAccessor {
 		prj.setName(name);
 		return prj;
 	}
-	public ConfigurationResource getConfiguration(String key){
-		new ConfigurationResource(configID)
-	}
 }

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java?rev=1382139&r1=1382138&r2=1382139&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
Fri Sep  7 19:56:09 2012
@@ -128,14 +128,10 @@ public class ResourceUtils {
         em.getTransaction().begin();
         Query q = em.createQuery("SELECT p FROM Configuration p WHERE p.config_key = :confKey");
         q.setParameter("confKey", configKey);
-        List resultList = q.getResultList();
+        List<?> resultList = q.getResultList();
         if (resultList.size() != 0) {
             for (Object result : resultList) {
-                Configuration configuration = (Configuration) result;
-                ConfigurationResource configurationResource = new ConfigurationResource();
-                configurationResource.setConfigKey(configuration.getConfig_key());
-                configurationResource.setConfigVal(configuration.getConfig_val());
-                configurationResource.setExpireDate(configuration.getExpire_date());
+                ConfigurationResource configurationResource = createConfigurationResourceObject(result);
                 list.add(configurationResource);
             }
         }
@@ -144,6 +140,32 @@ public class ResourceUtils {
         return list;
     }
 
+    public static ConfigurationResource getConfiguration(String configKey){
+    	List<ConfigurationResource> configurations = getConfigurations(configKey);
+    	return (configurations!=null && configurations.size()>0)? configurations.get(0):null;
+    }
+    
+    public static boolean isConfigurationExist(String configKey){
+    	List<ConfigurationResource> configurations = getConfigurations(configKey);
+    	return (configurations!=null && configurations.size()>0);
+    }
+    
+    public static ConfigurationResource createConfiguration(String configKey){
+    	ConfigurationResource config = new ConfigurationResource();
+    	config.setConfigKey(configKey);
+    	return config;
+    }
+    
+	private static ConfigurationResource createConfigurationResourceObject(
+			Object result) {
+		Configuration configuration = (Configuration) result;
+		ConfigurationResource configurationResource = new ConfigurationResource();
+		configurationResource.setConfigKey(configuration.getConfig_key());
+		configurationResource.setConfigVal(configuration.getConfig_val());
+		configurationResource.setExpireDate(configuration.getExpire_date());
+		return configurationResource;
+	}
+
     public static void removeConfiguration(String configkey, String configValue){
 
     }



Mime
View raw message