airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1384778 - in /incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa: ./ impl/ resources/
Date Fri, 14 Sep 2012 13:39:15 GMT
Author: lahiru
Date: Fri Sep 14 13:39:14 2012
New Revision: 1384778

URL: http://svn.apache.org/viewvc?rev=1384778&view=rev
Log:
applying patch from Chathuri for AIRAVATA-562

Modified:
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceUtils.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java?rev=1384778&r1=1384777&r2=1384778&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/Resource.java
Fri Sep 14 13:39:14 2012
@@ -23,16 +23,47 @@ package org.apache.airavata.persistance.
 import java.util.List;
 
 public interface Resource {
+    /**
+     * This method will create associate resource objects for the given resource type.
+     * @param type child resource type
+     * @return associate child resource
+     */
     Resource create(ResourceType type);
 
+    /**
+     * This method will remove the given child resource from the database
+     * @param type child resource type
+     * @param name child resource name
+     */
     void remove(ResourceType type, Object name);
 
+    /**
+     *  This method will return the given child resource from the database
+     * @param type child resource type
+     * @param name child resource name
+     * @return associate child resource
+     */
     Resource get(ResourceType type, Object name);
 
+    /**
+     * This method will list all the child resources for the given resource type
+     * @param type child resource type
+     * @return list of child resources of the given child resource type
+     */
     List<Resource> get(ResourceType type);
 
+    /**
+     * This method will save the resource to the database.
+     */
     void save();
-    
+
+    /**
+     * This method will check whether an entry from the given resource type and resource
name
+     * exists in the database
+     * @param type child resource type
+     * @param name child resource name
+     * @return whether the entry exists in the database or not
+     */
     boolean isExists(ResourceType type, Object name);
 
 }

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=1384778&r1=1384777&r2=1384778&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 14 13:39:14 2012
@@ -274,4 +274,45 @@ public class ResourceUtils {
     public static Lock getLock() {
         return lock;
     }
+
+    public static ApplicationDescriptorResource getApplicationDescriptorResource(String applicationDescName,
+                                                                          String gatewayName,
+                                                                          String hostDescName,
+                                                                          String serviceDescName){
+
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator queryGenerator = new QueryGenerator(AbstractResource.APPLICATION_DESCRIPTOR);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.GATEWAY_NAME,
gatewayName);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.APPLICATION_DESC_ID,
applicationDescName);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.HOST_DESC_ID,
hostDescName);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.SERVICE_DESC_ID,
serviceDescName);
+        Query q = queryGenerator.selectQuery(em);
+        Application_Descriptor applicationDescriptor = (Application_Descriptor) q.getSingleResult();
+        ApplicationDescriptorResource applicationDescriptorResource =
+                (ApplicationDescriptorResource) Utils.getResource(
+                        ResourceType.APPLICATION_DESCRIPTOR, applicationDescriptor);
+        em.getTransaction().commit();
+        em.close();
+        return applicationDescriptorResource;
+    }
+
+    public static void removeApplicationDescriptor(String gatewayName,
+                                                   String appDescName,
+                                                   String hostDescName,
+                                                   String serviceDescName){
+        EntityManager em = ResourceUtils.getEntityManager();
+        em.getTransaction().begin();
+        QueryGenerator queryGenerator = new QueryGenerator(AbstractResource.APPLICATION_DESCRIPTOR);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.GATEWAY_NAME,
gatewayName);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.APPLICATION_DESC_ID,
appDescName);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.HOST_DESC_ID,
hostDescName);
+        queryGenerator.setParameter(AbstractResource.ApplicationDescriptorConstants.SERVICE_DESC_ID,
serviceDescName);
+        Query q = queryGenerator.deleteQuery(em);
+        q.executeUpdate();
+        em.getTransaction().commit();
+        em.close();
+
+    }
+
 }

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java?rev=1384778&r1=1384777&r2=1384778&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/impl/AiravataJPARegistry.java
Fri Sep 14 13:39:14 2012
@@ -434,7 +434,8 @@ public class AiravataJPARegistry extends
 		if (!isApplicationDescriptorExists(serviceName,hostName,descriptor.getType().getApplicationName().getStringValue())){
         	throw new DescriptorDoesNotExistsException(applicationName);
         }
-        ApplicationDescriptorResource serviceDescriptorResource = gateway.getApplicationDescriptorResource(applicationName);
+        ApplicationDescriptorResource serviceDescriptorResource = ResourceUtils.getApplicationDescriptorResource(applicationName,
gateway.getGatewayName(),
+                hostName, serviceName);
         serviceDescriptorResource.setContent(descriptor.toXML());
         serviceDescriptorResource.save();
     }
@@ -450,10 +451,11 @@ public class AiravataJPARegistry extends
     
     public ApplicationDeploymentDescription getApplicationDescriptor(String serviceName,
String hostname, String applicationName)throws DescriptorDoesNotExistsException, MalformedDescriptorException,
RegistryException{
     	GatewayResource gateway = jpa.getGateway();
+        String appName = createAppName(serviceName, hostname, applicationName);
 		if (!isApplicationDescriptorExists(serviceName,hostname,applicationName)){
         	throw new DescriptorDoesNotExistsException(createAppName(serviceName, hostname,
applicationName));
         }
-        return createApplicationDescriptor(gateway.getApplicationDescriptorResource(createAppName(serviceName,
hostname, applicationName)));
+        return createApplicationDescriptor(ResourceUtils.getApplicationDescriptorResource(appName,gateway.getGatewayName(),hostname,
serviceName));
     }
     
     public ApplicationDeploymentDescription getApplicationDescriptors(String serviceName,
String hostname) throws MalformedDescriptorException {
@@ -491,9 +493,7 @@ public class AiravataJPARegistry extends
     	if (!isApplicationDescriptorExists(serviceName,hostName,applicationName)){
 			throw new DescriptorDoesNotExistsException(appName);
 		}
-        ApplicationDescriptorResource applicationDescriptorResource = (ApplicationDescriptorResource)gateway.create(ResourceType.APPLICATION_DESCRIPTOR);
-        String[] strings = {gateway.getGatewayName(), appName, hostName, serviceName};
-        applicationDescriptorResource.removeMe(strings);
+        ResourceUtils.removeApplicationDescriptor(gateway.getGatewayName(), appName, hostName,
serviceName);
     }
 
     public ResourceMetadata getApplicationDescriptorMetadata(String serviceName, String hostName,
String applicationName) throws UnimplementedRegistryOperationException {

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java?rev=1384778&r1=1384777&r2=1384778&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ApplicationDescriptorResource.java
Fri Sep 14 13:39:14 2012
@@ -166,19 +166,19 @@ public class ApplicationDescriptorResour
      *
      * @param keys primary keys of the Application_descriptor table
      */
-    public void removeMe(Object[] keys) {
-        EntityManager em = ResourceUtils.getEntityManager();
-        em.getTransaction().begin();
-        QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, keys[0]);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID, keys[1]);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, keys[2]);
-        queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, keys[3]);
-        Query q = queryGenerator.deleteQuery(em);
-        q.executeUpdate();
-        em.getTransaction().commit();
-        em.close();
-    }
+//    public void removeMe(Object[] keys) {
+//        EntityManager em = ResourceUtils.getEntityManager();
+//        em.getTransaction().begin();
+//        QueryGenerator queryGenerator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, keys[0]);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID,
keys[1]);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.HOST_DESC_ID, keys[2]);
+//        queryGenerator.setParameter(ApplicationDescriptorConstants.SERVICE_DESC_ID, keys[3]);
+//        Query q = queryGenerator.deleteQuery(em);
+//        q.executeUpdate();
+//        em.getTransaction().commit();
+//        em.close();
+//    }
 
     /**
      *

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java?rev=1384778&r1=1384777&r2=1384778&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
Fri Sep 14 13:39:14 2012
@@ -582,22 +582,22 @@ public class GatewayResource extends Abs
     	return hdr;
     }
 
-    /**
-     *
-     * @param descriptorName application descriptor name
-     * @return ApplicationDescriptorResource
-     */
-    public ApplicationDescriptorResource getApplicationDescriptorResource(String descriptorName){
-    	return (ApplicationDescriptorResource)get(ResourceType.APPLICATION_DESCRIPTOR,descriptorName);
-    }
+//    /**
+//     *
+//     * @param descriptorName application descriptor name
+//     * @return ApplicationDescriptorResource
+//     */
+//    public ApplicationDescriptorResource getApplicationDescriptorResource(String descriptorName){
+//    	return (ApplicationDescriptorResource)get(ResourceType.APPLICATION_DESCRIPTOR,descriptorName);
+//    }
 
     /**
      *
      * @param descriptorName  application descriptor name
      */
-    public void removeApplicationDescriptor(String descriptorName){
-    	remove(ResourceType.APPLICATION_DESCRIPTOR, descriptorName);
-    }
+//    public void removeApplicationDescriptor(String descriptorName){
+//    	remove(ResourceType.APPLICATION_DESCRIPTOR, descriptorName);
+//    }
 
     /**
      *

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java?rev=1384778&r1=1384777&r2=1384778&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/Utils.java
Fri Sep 14 13:39:14 2012
@@ -78,7 +78,7 @@ public class Utils {
      * @param o model type instance
      * @return corresponding resource object
      */
-    static Resource getResource(ResourceType type, Object o) {
+    public static Resource getResource(ResourceType type, Object o) {
         switch (type){
             case GATEWAY:
                 if (o instanceof Gateway) {



Mime
View raw message