airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1383473 - in /incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa: model/ resources/ utils/
Date Tue, 11 Sep 2012 16:35:48 GMT
Author: lahiru
Date: Tue Sep 11 16:35:48 2012
New Revision: 1383473

URL: http://svn.apache.org/viewvc?rev=1383473&view=rev
Log: (empty)

Modified:
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Application_Descriptor.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Host_Descriptor.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Published_Workflow.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Service_Descriptor.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/User_Workflow.java
    incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.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/utils/QueryGenerator.java

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Application_Descriptor.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Application_Descriptor.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Application_Descriptor.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Application_Descriptor.java
Tue Sep 11 16:35:48 2012
@@ -42,7 +42,7 @@ public class Application_Descriptor {
     private Gateway gateway;
 
     @ManyToOne
-    @JoinColumn(name = "user_name")
+    @JoinColumn(name = "updated_user", referencedColumnName = "user_name")
     private Users user;
 
     public String getApplication_descriptor_ID() {

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Host_Descriptor.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Host_Descriptor.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Host_Descriptor.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Host_Descriptor.java
Tue Sep 11 16:35:48 2012
@@ -31,12 +31,12 @@ public class Host_Descriptor {
     private String gateway_name;
     private String host_descriptor_xml;
 
-    @ManyToOne
+    @ManyToOne(cascade=CascadeType.PERSIST)
     @JoinColumn(name = "gateway_name")
     private Gateway gateway;
 
-    @ManyToOne
-    @JoinColumn(name = "user_name")
+    @ManyToOne (cascade=CascadeType.PERSIST)
+    @JoinColumn(name = "updated_user", referencedColumnName = "user_name")
     private Users user;
 
     public String getHost_descriptor_ID() {

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Published_Workflow.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Published_Workflow.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Published_Workflow.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Published_Workflow.java
Tue Sep 11 16:35:48 2012
@@ -48,7 +48,7 @@ public class Published_Workflow {
     private String path;
 
     @ManyToOne
-    @JoinColumn(name = "user_name")
+    @JoinColumn(name = "created_user", referencedColumnName = "user_name")
     private Users user;
 
     public String getPublish_workflow_name() {

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Service_Descriptor.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Service_Descriptor.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Service_Descriptor.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/Service_Descriptor.java
Tue Sep 11 16:35:48 2012
@@ -36,8 +36,8 @@ public class Service_Descriptor {
     @JoinColumn(name = "gateway_name")
     private Gateway gateway;
 
-    @ManyToOne
-    @JoinColumn(name = "user_name")
+//    @ManyToOne
+    @JoinColumn(name = "updated_user", referencedColumnName = "user_name")
     private Users user;
 
     public String getService_descriptor_ID() {

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/User_Workflow.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/User_Workflow.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/User_Workflow.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/model/User_Workflow.java
Tue Sep 11 16:35:48 2012
@@ -42,7 +42,7 @@ public class User_Workflow {
     private Gateway gateway;
 
     @ManyToOne
-    @JoinColumn(name = "user_name")
+    @JoinColumn(name = "owner", referencedColumnName = "user_name")
     private Users user;
 
     private String path;

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.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/AbstractResource.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/AbstractResource.java
Tue Sep 11 16:35:48 2012
@@ -144,12 +144,16 @@ public abstract class AbstractResource i
     }
 
     protected void begin() {
+        if(em == null){
+            factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
+            em = factory.createEntityManager();
+        }
         em.getTransaction().begin();
     }
 
     protected void end() {
         em.getTransaction().commit();
-        em.close();
+//        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=1383473&r1=1383472&r2=1383473&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
Tue Sep 11 16:35:48 2012
@@ -389,59 +389,86 @@ public class GatewayResource extends Abs
     public boolean isExists(ResourceType type, Object name) {
         begin();
         Query q;
+        Number count;
         QueryGenerator generator;
         switch (type){
             case USER:
-                generator = new QueryGenerator(GATEWAY_WORKER);
-                generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
-                generator.setParameter(GatewayWorkerConstants.USERNAME, name);
-                q = generator.selectQuery(em);
-                Gateway_Worker gatewayWorker = (Gateway_Worker) q.getSingleResult();
+                q = em.createQuery("SELECT COUNT(p.user_name) FROM Gateway_Worker p WHERE
p.gateway_name =:gate_name and p.user_name =:userName");
+                q.setParameter("gate_name", gatewayName);
+                q.setParameter("userName",name);
+                count = (Number) q.getSingleResult();
                 end();
-                return gatewayWorker != null;
+                return count.intValue() != 0;
+//                generator = new QueryGenerator(GATEWAY_WORKER);
+//                generator.setParameter(GatewayWorkerConstants.GATEWAY_NAME, gatewayName);
+//                generator.setParameter(GatewayWorkerConstants.USERNAME, name);
+//                q = generator.selectQuery(em);
+//                Gateway_Worker gatewayWorker = (Gateway_Worker) q.getSingleResult();
+//                end();
+//                return gatewayWorker != null;
             case PUBLISHED_WORKFLOW:
-                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
-                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
-                generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME,
name);
-                q = generator.selectQuery(em);
-                Published_Workflow publishedWrkflow = (Published_Workflow) q.getSingleResult();
+                q = em.createQuery("SELECT COUNT(p.publish_workflow_name) FROM Published_Workflow
p WHERE p.gateway_name =:gate_name and p.publish_workflow_name =:pub_wf_name");
+                q.setParameter("gate_name", gatewayName);
+                q.setParameter("pub_wf_name",name);
+                count = (Number) q.getSingleResult();
                 end();
-                return publishedWrkflow != null;
+                return count.intValue() != 0;
+//                generator = new QueryGenerator(PUBLISHED_WORKFLOW);
+//                generator.setParameter(PublishedWorkflowConstants.GATEWAY_NAME, gatewayName);
+//                generator.setParameter(PublishedWorkflowConstants.PUBLISH_WORKFLOW_NAME,
name);
+//                q = generator.selectQuery(em);
+//                Published_Workflow publishedWrkflow = (Published_Workflow) q.getSingleResult();
+//                end();
+//                return publishedWrkflow != null;
             case HOST_DESCRIPTOR:
-//                q = em.createQuery("SELECT p FROM Host_Descriptor p WHERE p.gateway_name
=:gate_ID and p.host_descriptor_ID =:host_desc_name");
-//                q.setParameter("gate_ID", gatewayName);
-//                q.setParameter("host_desc_name",name);
-                generator = new QueryGenerator(HOST_DESCRIPTOR);
-                generator.setParameter(HostDescriptorConstants.GATEWAY_NAME, gatewayName);
-                generator.setParameter(HostDescriptorConstants.HOST_DESC_ID, name);
-                q = generator.selectQuery(em);
-                Host_Descriptor hostDescriptor = (Host_Descriptor) q.getSingleResult();
+                q = em.createQuery("SELECT COUNT(p.host_descriptor_ID) FROM Host_Descriptor
p WHERE p.gateway_name =:gate_name and p.host_descriptor_ID =:host_desc_name");
+                q.setParameter("gate_name", gatewayName);
+                q.setParameter("host_desc_name",name);
+                count = (Number) q.getSingleResult();
                 end();
-                return hostDescriptor != null;
+                return count.intValue() != 0;
             case SERVICE_DESCRIPTOR:
-                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
-                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
-                generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
-                q = generator.selectQuery(em);
-                Service_Descriptor serviceDescriptor = (Service_Descriptor) q.getSingleResult();
+                q = em.createQuery("SELECT COUNT(p.service_descriptor_ID) FROM Service_Descriptor
p WHERE p.gateway_name =:gate_name and p.service_descriptor_ID =:service_desc_name");
+                q.setParameter("gate_name", gatewayName);
+                q.setParameter("service_desc_name",name);
+                count = (Number) q.getSingleResult();
                 end();
-                return serviceDescriptor != null;
+                return count.intValue() != 0;
+//                generator = new QueryGenerator(SERVICE_DESCRIPTOR);
+//                generator.setParameter(ServiceDescriptorConstants.GATEWAY_NAME, gatewayName);
+//                generator.setParameter(ServiceDescriptorConstants.SERVICE_DESC_ID, name);
+//                q = generator.selectQuery(em);
+//                Service_Descriptor serviceDescriptor = (Service_Descriptor) q.getSingleResult();
+//                end();
+//                return serviceDescriptor != null;
             case APPLICATION_DESCRIPTOR:
-                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
-                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
-                generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID,
name);
-                q = generator.selectQuery(em);
-                Application_Descriptor applicationDescriptor = (Application_Descriptor) q.getSingleResult();
+                q = em.createQuery("SELECT COUNT(p.service_descriptor_ID) FROM Service_Descriptor
p WHERE p.gateway_name =:gate_name and p.service_descriptor_ID =:service_desc_name");
+                q.setParameter("gate_name", gatewayName);
+                q.setParameter("service_desc_name",name);
+                count = (Number) q.getSingleResult();
                 end();
-                return applicationDescriptor != null;
+                return count.intValue() != 0;
+//                generator = new QueryGenerator(APPLICATION_DESCRIPTOR);
+//                generator.setParameter(ApplicationDescriptorConstants.GATEWAY_NAME, gatewayName);
+//                generator.setParameter(ApplicationDescriptorConstants.APPLICATION_DESC_ID,
name);
+//                q = generator.selectQuery(em);
+//                Application_Descriptor applicationDescriptor = (Application_Descriptor)
q.getSingleResult();
+//                end();
+//                return applicationDescriptor != null;
             case EXPERIMENT:
-                generator = new QueryGenerator(EXPERIMENT);
-                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
-                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
-                q = generator.selectQuery(em);
-                Experiment experiment = (Experiment) q.getSingleResult();
+                q = em.createQuery("SELECT COUNT(p.experiment_ID) FROM Experiment p WHERE
p.gateway_name =:gate_name and p.experiment_ID =:exp_name");
+                q.setParameter("gate_name", gatewayName);
+                q.setParameter("exp_name",name);
+                count = (Number) q.getSingleResult();
                 end();
-                return experiment != null;
+                return count.intValue() != 0;
+//                generator = new QueryGenerator(EXPERIMENT);
+//                generator.setParameter(ExperimentConstants.GATEWAY_NAME, gatewayName);
+//                generator.setParameter(ExperimentConstants.EXPERIMENT_ID, name);
+//                q = generator.selectQuery(em);
+//                Experiment experiment = (Experiment) q.getSingleResult();
+//                end();
+//                return experiment != null;
             default:
                 end();
                 throw new IllegalArgumentException("Unsupported resource type for gateway
resource.");

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java?rev=1383473&r1=1383472&r2=1383473&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/utils/QueryGenerator.java
Tue Sep 11 16:35:48 2012
@@ -60,9 +60,15 @@ public class QueryGenerator {
 	}
 	
 	public Query selectQuery(EntityManager entityManager){
-		String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
-		return generateQueryWithParameters(entityManager, queryString);
-	}
+        String queryString="SELECT "+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
+        return generateQueryWithParameters(entityManager, queryString);
+    }
+
+//    public Query countQuery(EntityManager entityManager){
+//        SELECT COUNT(p.host_descriptor_ID) FROM Host_Descriptor p WHERE p.gateway_name
=:gate_ID and p.host_descriptor_ID =:host_desc_name")
+//        String queryString="SELECT COUNT("+ SELECT_OBJ + " FROM " +getTableName()+" "+TABLE_OBJ;
+//        return generateQueryWithParameters(entityManager, queryString);
+//    }
 	
 	public Query deleteQuery(EntityManager entityManager){
 		String queryString="Delete FROM "+getTableName()+" "+TABLE_OBJ;



Mime
View raw message