airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1382168 - /incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/GatewayResource.java
Date Fri, 07 Sep 2012 20:51:27 GMT
Author: lahiru
Date: Fri Sep  7 20:51:27 2012
New Revision: 1382168

URL: http://svn.apache.org/viewvc?rev=1382168&view=rev
Log:
updating gatewayResource class

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

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=1382168&r1=1382167&r2=1382168&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  7 20:51:27 2012
@@ -93,12 +93,14 @@ public class GatewayResource extends Abs
             q.setParameter("proj_name", name);
             q.setParameter("gate_name", gatewayName);
             q.executeUpdate();
-        } else if (type == ResourceType.USER) {
-            Query q = em.createQuery("Delete p FROM Users p WHERE p.user_name = :usr_name
and p.gateway_name = :gate_name");
-            q.setParameter("usr_name", name);
-            q.setParameter("gate_name", gatewayName);
-            q.executeUpdate();
-        } else if (type == ResourceType.PUBLISHED_WORKFLOW) {
+        }
+//        else if (type == ResourceType.USER) {
+//            Query q = em.createQuery("Delete p FROM Users p WHERE p.user_name = :usr_name
and p.gateway_name = :gate_name");
+//            q.setParameter("usr_name", name);
+//            q.setParameter("gate_name", gatewayName);
+//            q.executeUpdate();
+//        }
+        else if (type == ResourceType.PUBLISHED_WORKFLOW) {
             Query q = em.createQuery("Delete p FROM Published_Workflow p WHERE p.publish_workflow_name
= :pub_workflow_id and p.gateway_name = :gate_name");
             q.setParameter("pub_workflow_id", name);
             q.setParameter("gate_name", gatewayName);
@@ -115,6 +117,11 @@ public class GatewayResource extends Abs
             q.setParameter("service_desc_id", name);
             q.setParameter("gate_name", gatewayName);
             q.executeUpdate();
+        }else if(type == ResourceType.EXPERIMENT){
+            Query q = em.createQuery("Delete p FROM Experiment p WHERE p.experiment_ID =
:exp_id and p.gateway_name = :gate_name");
+            q.setParameter("exp_id", name);
+            q.setParameter("gate_name", gatewayName);
+            q.executeUpdate();
         }
 
 //        else if (type == ResourceType.APPLICATION_DESCRIPTOR) {
@@ -134,17 +141,18 @@ public class GatewayResource extends Abs
 
     public Resource get(ResourceType type, Object name) {
         begin();
-        if (type == ResourceType.PROJECT) {
-            Query q = em.createQuery("SELECT p FROM Project p WHERE p.project_name = :proj_name
and p.gateway_name =:gate_name");
-            q.setParameter("proj_name", name);
-            q.setParameter("gate_name", gatewayName);
-            Project eproject = (Project) q.getSingleResult();
-            ProjectResource projectResource = new ProjectResource(eproject.getProject_ID());
-            projectResource.setName(eproject.getProject_name());
-            end();
-            return projectResource;
-        } else if (type == ResourceType.USER) {
-            Query q = em.createQuery("SELECT p FROM Users p WHERE p.user_name = :username
and p.gateway_name =:gate_name");
+//        if (type == ResourceType.PROJECT) {
+//            Query q = em.createQuery("SELECT p FROM Project p WHERE p.project_name = :proj_name
and p.gateway_name =:gate_name");
+//            q.setParameter("proj_name", name);
+//            q.setParameter("gate_name", gatewayName);
+//            Project eproject = (Project) q.getSingleResult();
+//            ProjectResource projectResource = new ProjectResource(eproject.getProject_ID());
+//            projectResource.setName(eproject.getProject_name());
+//            end();
+//            return projectResource;
+//        } else
+            if (type == ResourceType.USER) {
+            Query q = em.createQuery("SELECT p FROM Gateway_Worker p WHERE p.user_name =
:username and p.gateway_name =:gate_name");
             q.setParameter("username", name);
             q.setParameter("gate_name", gatewayName);
             Users eUser = (Users) q.getSingleResult();
@@ -207,8 +215,9 @@ public class GatewayResource extends Abs
             experimentResource.setGatewayName(gatewayName);
             experimentResource.setSubmittedDate(experiment.getSubmitted_date());
             return experimentResource;
+        } else {
+                return null;
         }
-
     }
 
     public List<Resource> getMe(Object[] keys) {
@@ -231,7 +240,8 @@ public class GatewayResource extends Abs
                     resourceList.add(projectResource);
                 }
             }
-        } else if (type == ResourceType.USER) {
+        }
+        else if (type == ResourceType.USER) {
             Query q = em.createQuery("SELECT p FROM Users p WHERE p.gateway_name =:gate_name");
             q.setParameter("gate_name", gatewayName);
             List results = q.getResultList();
@@ -244,7 +254,8 @@ public class GatewayResource extends Abs
                     resourceList.add(userResource);
                 }
             }
-        } else if (type == ResourceType.PUBLISHED_WORKFLOW) {
+        }
+        else if (type == ResourceType.PUBLISHED_WORKFLOW) {
             Query q = em.createQuery("SELECT p FROM Published_Workflow p WHERE p.gateway_name
=:gate_name");
             q.setParameter("gate_name", gatewayName);
             List results = q.getResultList();
@@ -330,16 +341,22 @@ public class GatewayResource extends Abs
         end();
     }
 
+    public void save(boolean isAppendable) {
+         throw new UnsupportedOperationException();
+    }
+
     public boolean isExists(ResourceType type, Object name) {
         begin();
-        if (type == ResourceType.PROJECT) {
-            Query q = em.createQuery("SELECT p FROM Project p WHERE p.gateway_name =:gate_name
and p.project_name =:proj_name");
-            q.setParameter("gate_name", gatewayName);
-            q.setParameter("proj_name", name);
-            Project project = (Project) q.getSingleResult();
-            return project != null;
-        } else if (type == ResourceType.USER) {
-            Query q = em.createQuery("SELECT p FROM Users p WHERE p.gateway_name =:gate_name
and p.user_name =:usr_name");
+//        if (type == ResourceType.PROJECT) {
+//            Query q = em.createQuery("SELECT p FROM Project p WHERE p.gateway_name =:gate_name
and p.project_name =:proj_name");
+//            q.setParameter("gate_name", gatewayName);
+//            q.setParameter("proj_name", name);
+//            Project project = (Project) q.getSingleResult();
+//            return project != null;
+//        } else
+
+        if (type == ResourceType.USER) {
+            Query q = em.createQuery("SELECT p FROM Gateway_Worker p WHERE p.gateway_name
=:gate_name and p.user_name =:usr_name");
             q.setParameter("gate_name", gatewayName);
             q.setParameter("usr_name", name);
             Users users = (Users) q.getSingleResult();
@@ -368,6 +385,12 @@ public class GatewayResource extends Abs
             q.setParameter("app_desc_name", name);
             Application_Descriptor applicationDescriptor = (Application_Descriptor) q.getSingleResult();
             return applicationDescriptor != null;
+        } else if (type == ResourceType.EXPERIMENT) {
+            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.gateway_name =:gate_name
and p.experiment_ID =:ex_ID");
+            q.setParameter("gate_name", gatewayName);
+            q.setParameter("ex_ID", name);
+            Experiment experiment = (Experiment) q.getSingleResult();
+            return experiment != null;
         }
         end();
         return false;



Mime
View raw message