Return-Path: X-Original-To: apmail-incubator-airavata-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-airavata-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E4B8AD186 for ; Thu, 6 Sep 2012 19:30:17 +0000 (UTC) Received: (qmail 99776 invoked by uid 500); 6 Sep 2012 19:30:17 -0000 Delivered-To: apmail-incubator-airavata-commits-archive@incubator.apache.org Received: (qmail 99725 invoked by uid 500); 6 Sep 2012 19:30:17 -0000 Mailing-List: contact airavata-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: airavata-dev@incubator.apache.org Delivered-To: mailing list airavata-commits@incubator.apache.org Received: (qmail 99718 invoked by uid 99); 6 Sep 2012 19:30:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 19:30:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Sep 2012 19:30:14 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 083B1238899C; Thu, 6 Sep 2012 19:29:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1381724 - in /incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa: ResourceType.java impl/AiravataJPARegistry.java resources/ServiceDescriptorResource.java Date: Thu, 06 Sep 2012 19:29:29 -0000 To: airavata-commits@incubator.apache.org From: lahiru@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120906192930.083B1238899C@eris.apache.org> Author: lahiru Date: Thu Sep 6 19:29:29 2012 New Revision: 1381724 URL: http://svn.apache.org/viewvc?rev=1381724&view=rev Log: adding more implementation methods. Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.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/ServiceDescriptorResource.java Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java?rev=1381724&r1=1381723&r2=1381724&view=diff ============================================================================== --- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java (original) +++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/ResourceType.java Thu Sep 6 19:29:29 2012 @@ -29,5 +29,6 @@ public enum ResourceType { USER_WORKFLOW, HOST_DESCRIPTOR, APPLICATION_DESCRIPTOR, - EXPERIMENT + EXPERIMENT, + CONFIGURATION } 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=1381724&r1=1381723&r2=1381724&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 Thu Sep 6 19:29:29 2012 @@ -23,19 +23,28 @@ package org.apache.airavata.persistance. import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription; import org.apache.airavata.commons.gfac.type.HostDescription; import org.apache.airavata.commons.gfac.type.ServiceDescription; +import org.apache.airavata.persistance.registry.jpa.Resource; +import org.apache.airavata.persistance.registry.jpa.ResourceType; import org.apache.airavata.persistance.registry.jpa.model.Configuration; import org.apache.airavata.persistance.registry.jpa.model.Host_Descriptor; +import org.apache.airavata.persistance.registry.jpa.resources.ApplicationDescriptorResource; +import org.apache.airavata.persistance.registry.jpa.resources.GatewayResource; +import org.apache.airavata.persistance.registry.jpa.resources.HostDescriptorResource; +import org.apache.airavata.persistance.registry.jpa.resources.ServiceDescriptorResource; import org.apache.airavata.registry.api.*; +import org.apache.xmlbeans.XmlException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.Query; import java.net.URI; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; public class AiravataJPARegistry extends AiravataRegistry2{ + private final static Logger logger = LoggerFactory.getLogger(AiravataJPARegistry.class); + private static final String PERSISTENCE_UNIT_NAME = "airavata_registry"; private EntityManagerFactory factory; @@ -184,28 +193,33 @@ public class AiravataJPARegistry extends // DescriptorRegistry Implementation public void addHostDescriptor(HostDescription descriptor) { //todo how to fill other data - EntityManager em = factory.createEntityManager(); - em.getTransaction().begin(); - Host_Descriptor host_descriptor = new Host_Descriptor(); -// host_descriptor.set; -// host_descriptor.setExpire_date((java.sql.Date) expire); - host_descriptor.setHost_descriptor_xml(descriptor.toXML()); - em.persist(host_descriptor); - em.getTransaction().commit(); - em.close(); - //To change body of implemented methods use File | Settings | File Templates. + GatewayResource gatewayResource = new GatewayResource(); + HostDescriptorResource resource = (HostDescriptorResource)gatewayResource.create(ResourceType.HOST_DESCRIPTOR); + resource.setContent(descriptor.toXML()); + //todo fix the IDs to Names +// resource.setGatewayID(getGateway().getGatewayName()); +// resource.setUserID(getUser().getUserName()); + resource.save(); } public void updateHostDescriptor(HostDescription descriptor) { - //To change body of implemented methods use File | Settings | File Templates. + addHostDescriptor(descriptor); } public HostDescription getHostDescriptor(String hostName) { + GatewayResource gatewayResource = new GatewayResource(); + Resource resource = gatewayResource.get(ResourceType.HOST_DESCRIPTOR, hostName); + try { + return HostDescription.fromXML(((HostDescriptorResource)resource).getContent()); + } catch (XmlException e) { + logger.error("Error parsing Host Descriptor"); + } return null; //To change body of implemented methods use File | Settings | File Templates. } public void removeHostDescriptor(String hostName) { - //To change body of implemented methods use File | Settings | File Templates. + GatewayResource gatewayResource = new GatewayResource(); + gatewayResource.remove(ResourceType.HOST_DESCRIPTOR, hostName); } public ResourceMetadata getHostDescriptorMetadata(String hostName) { @@ -213,19 +227,34 @@ public class AiravataJPARegistry extends } public void addServiceDescriptor(ServiceDescription descriptor) { - //To change body of implemented methods use File | Settings | File Templates. + //todo how to fill other data + GatewayResource gatewayResource = new GatewayResource(); + ServiceDescriptorResource resource = (ServiceDescriptorResource)gatewayResource.create(ResourceType.SERVICE_DESCRIPTOR); + resource.setContent(descriptor.toXML()); + //todo fix the IDs to Names +// resource.setGatewayID(getGateway().getGatewayName()); +// resource.setUserID(getUser().getUserName()); + resource.save(); } public void updateServiceDescriptor(ServiceDescription descriptor) { - //To change body of implemented methods use File | Settings | File Templates. + addServiceDescriptor(descriptor); } public ServiceDescription getServiceDescriptor(String serviceName) { - return null; //To change body of implemented methods use File | Settings | File Templates. + GatewayResource gatewayResource = new GatewayResource(); + Resource resource = gatewayResource.get(ResourceType.SERVICE_DESCRIPTOR, serviceName); + try { + return ServiceDescription.fromXML(((ServiceDescriptorResource) resource).getContent()); + } catch (XmlException e) { + logger.error("Error parsing Host Descriptor"); + } + return null; } public void removeServiceDescriptor(String serviceName) { - //To change body of implemented methods use File | Settings | File Templates. + GatewayResource gatewayResource = new GatewayResource(); + gatewayResource.remove(ResourceType.SERVICE_DESCRIPTOR, serviceName); } public ResourceMetadata getServiceDescriptorMetadata(String serviceName) { @@ -233,37 +262,69 @@ public class AiravataJPARegistry extends } public void addApplicationDescriptor(ServiceDescription serviceDescription, HostDescription hostDescriptor, ApplicationDeploymentDescription descriptor) { - //To change body of implemented methods use File | Settings | File Templates. + addApplicationDescriptor(serviceDescription.getType().getName(),hostDescriptor.getType().getHostName(),descriptor); } public void addApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor) { + GatewayResource gatewayResource = new GatewayResource(); + ApplicationDescriptorResource resource = (ApplicationDescriptorResource)gatewayResource.create(ResourceType.APPLICATION_DESCRIPTOR); + resource.setContent(descriptor.toXML()); + resource.setHostDescName(hostName); + resource.setServiceDescName(serviceName); + //todo fix the IDs to Names +// resource.setGatewayID(getGateway().getGatewayName()); +// resource.setUserID(getUser().getUserName()); + resource.save(); //To change body of implemented methods use File | Settings | File Templates. } public void udpateApplicationDescriptor(ServiceDescription serviceDescription, HostDescription hostDescriptor, ApplicationDeploymentDescription descriptor) { - //To change body of implemented methods use File | Settings | File Templates. + addApplicationDescriptor(serviceDescription,hostDescriptor,descriptor); } public void updateApplicationDescriptor(String serviceName, String hostName, ApplicationDeploymentDescription descriptor) { - //To change body of implemented methods use File | Settings | File Templates. + addApplicationDescriptor(serviceName,hostName,descriptor); } public ApplicationDeploymentDescription getApplicationDescriptors(String serviceName, String hostname) { + //todo finish implementation + GatewayResource gatewayResource = new GatewayResource(); + ApplicationDescriptorResource resource = (ApplicationDescriptorResource)gatewayResource.create(ResourceType.APPLICATION_DESCRIPTOR); + resource.setHostDescName(hostname); + resource.setServiceDescName(serviceName); +// resource.get() +// gatewayResource. return null; //To change body of implemented methods use File | Settings | File Templates. } public Map getApplicationDescriptors(String serviceName) { - return null; //To change body of implemented methods use File | Settings | File Templates. + GatewayResource gatewayResource = new GatewayResource(); + ServiceDescriptorResource resource = (ServiceDescriptorResource)gatewayResource.get(ResourceType.SERVICE_DESCRIPTOR,serviceName); + resource.setServiceDescName(serviceName); + List resources = resource.get(ResourceType.APPLICATION_DESCRIPTOR); + HashMap stringApplicationDescriptorResourceHashMap = + new HashMap(); + for(Resource applicationDescriptorResource:resources){ + try { + stringApplicationDescriptorResourceHashMap.put(resource.getServiceDescName(), + ApplicationDeploymentDescription.fromXML(((ApplicationDescriptorResource)applicationDescriptorResource).getContent())); + } catch (XmlException e) { + logger.error("Error parsing Application Descriptor"); + } + } + return stringApplicationDescriptorResourceHashMap; //To change body of implemented methods use File | Settings | File Templates. } public void removeApplicationDescriptor(String serviceName, String hostName, String applicationName) { - //To change body of implemented methods use File | Settings | File Templates. + } public ResourceMetadata getApplicationDescriptorMetadata(String serviceName, String hostName, String applicationName) { return null; //To change body of implemented methods use File | Settings | File Templates. } + + public void addWorkspaceProject(WorkspaceProject project) { //To change body of implemented methods use File | Settings | File Templates. } Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.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/ServiceDescriptorResource.java?rev=1381724&r1=1381723&r2=1381724&view=diff ============================================================================== --- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java (original) +++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/ServiceDescriptorResource.java Thu Sep 6 19:29:29 2012 @@ -167,4 +167,8 @@ public class ServiceDescriptorResource e } return false; } + + public void setServiceDescName(String serviceDescName) { + this.serviceDescName = serviceDescName; + } }