airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lah...@apache.org
Subject svn commit: r1381763 [2/2] - in /incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main: java/org/apache/airavata/persistance/registry/jpa/ java/org/apache/airavata/persistance/registry/jpa/model/ java/org/apache/airavata/persistance/...
Date Thu, 06 Sep 2012 21:23:59 GMT
Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.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/UserResource.java?rev=1381763&r1=1381762&r2=1381763&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserResource.java
Thu Sep  6 21:23:58 2012
@@ -31,23 +31,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 public class UserResource extends AbstractResource {
-    private int id = -1;
     private String userName;
     private String password;
-    private int gatewayID;
+    private String gatewayName;
     private ProjectResource projectResource;
 
     public UserResource() {
     }
 
-    public UserResource(int id) {
-        this.id = id;
-    }
-
-    public int getId() {
-        return id;
-    }
-
     public void setUserName(String userName) {
         this.userName = userName;
     }
@@ -56,24 +47,24 @@ public class UserResource extends Abstra
         return userName;
     }
 
-    public int getGatewayID() {
-        return gatewayID;
+    public String getGatewayName() {
+        return gatewayName;
     }
 
-    public void setGatewayID(int gatewayID) {
-        this.gatewayID = gatewayID;
+    public void setGatewayName(String gatewayName) {
+        this.gatewayName = gatewayName;
     }
 
     public Resource create(ResourceType type) {
         if (type == ResourceType.USER_WORKFLOW) {
             UserWorkflowResource userWorkflowResource = new UserWorkflowResource();
-            userWorkflowResource.setUserID(id);
+            userWorkflowResource.setUserName(userName);
 //            userWorkflowResource.setProjectID();
             return userWorkflowResource;
         } else if (type == ResourceType.EXPERIMENT) {
             ExperimentResource experimentResource = new ExperimentResource();
 //            experimentResource.setProjectID(id);
-            experimentResource.setUserID(id);
+            experimentResource.setUserName(userName);
             return experimentResource;
         } else {
             return null;
@@ -83,13 +74,13 @@ public class UserResource extends Abstra
     public void remove(ResourceType type, Object name) {
         begin();
         if (type == ResourceType.USER_WORKFLOW) {
-            Query q = em.createQuery("Delete p FROM User_Workflow p WHERE p.user_ID = :user_id
and p.user_workflow_name = :usrwf_name");
-            q.setParameter("user_id", id);
+            Query q = em.createQuery("Delete p FROM User_Workflow p WHERE p.user_name = :usr_name
and p.user_workflow_name = :usrwf_name");
+            q.setParameter("user_name", userName);
             q.setParameter("usrwf_name", name);
             q.executeUpdate();
         } else if (type == ResourceType.EXPERIMENT) {
-            Query q = em.createQuery("Delete p FROM Experiment p WHERE p.user_ID = :user_id
and p.experiment_ID = :ex_name");
-            q.setParameter("user_id", id);
+            Query q = em.createQuery("Delete p FROM Experiment p WHERE p.user_name = :usr_name
and p.experiment_ID = :ex_name");
+            q.setParameter("user_name", userName);
             q.setParameter("ex_name", name);
             q.executeUpdate();
         }
@@ -100,24 +91,23 @@ public class UserResource extends Abstra
     public Resource get(ResourceType type, Object name) {
         begin();
         if (type == ResourceType.USER_WORKFLOW) {
-            Query q = em.createQuery("SELECT p FROM User_Workflow p WHERE p.user_ID = :user_id
and p.user_workflow_name = :usrwf_name");
-            q.setParameter("user_id", id);
+            Query q = em.createQuery("SELECT p FROM User_Workflow p WHERE p.user_name = :usr_name
and p.user_workflow_name = :usrwf_name");
+            q.setParameter("user_name", userName);
             q.setParameter("usrwf_name", name);
             User_Workflow userWorkflow = (User_Workflow) q.getSingleResult();
-            UserWorkflowResource userWorkflowResource = new UserWorkflowResource(userWorkflow.getProject_ID(),
id, userWorkflow.getUser_workflow_name());
+            UserWorkflowResource userWorkflowResource = new UserWorkflowResource(userWorkflow.getProject_ID(),
userName, userWorkflow.getUser_workflow_name());
             userWorkflowResource.setContent(userWorkflow.getWorkflow_content());
             userWorkflowResource.setLastUpdateDate(userWorkflow.getLast_update_date());
             end();
             return userWorkflowResource;
         } else if (type == ResourceType.EXPERIMENT) {
-            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.user_ID = :user_id
and p.experiment_ID = :ex_name");
-            q.setParameter("user_id", id);
+            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.user_name = :usr_name
and p.experiment_ID = :ex_name");
+            q.setParameter("user_name", userName);
             q.setParameter("ex_name", name);
             Experiment experiment = (Experiment) q.getSingleResult();
             ExperimentResource experimentResource = new ExperimentResource(experiment.getExperiment_ID());
             experimentResource.setProjectID(experiment.getProject().getProject_ID());
             Users user = new Users();
-            user.setUser_ID(id);
             user.setUser_name(userName);
             user.setPassword(password);
             experiment.setUser(user);
@@ -133,28 +123,28 @@ public class UserResource extends Abstra
         List<Resource> resourceList = new ArrayList<Resource>();
         begin();
         if (type == ResourceType.USER_WORKFLOW) {
-            Query q = em.createQuery("SELECT p FROM User_Workflow p WHERE p.user_ID =:usr_ID");
-            q.setParameter("usr_ID", id);
+            Query q = em.createQuery("SELECT p FROM User_Workflow p WHERE p.user_name = :usr_name");
+            q.setParameter("user_name", userName);
             List results = q.getResultList();
             if (results.size() != 0) {
                 for (Object result : results) {
                     User_Workflow userWorkflow = (User_Workflow) result;
-                    UserWorkflowResource userWorkflowResource = new UserWorkflowResource(userWorkflow.getProject_ID(),
userWorkflow.getUser_ID(), userWorkflow.getUser_workflow_name());
+                    UserWorkflowResource userWorkflowResource = new UserWorkflowResource(userWorkflow.getProject_ID(),
userWorkflow.getUser_name(), userWorkflow.getUser_workflow_name());
                     userWorkflowResource.setContent(userWorkflow.getWorkflow_content());
                     userWorkflowResource.setLastUpdateDate(userWorkflow.getLast_update_date());
                     resourceList.add(userWorkflowResource);
                 }
             }
         } else if (type == ResourceType.EXPERIMENT) {
-            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.user_ID =:usr_ID");
-            q.setParameter("usr_ID", id);
+            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.user_name = :usr_name");
+            q.setParameter("user_name", userName);
             List results = q.getResultList();
             if (results.size() != 0) {
                 for (Object result : results) {
                     Experiment experiment = (Experiment) result;
                     ExperimentResource experimentResource = new ExperimentResource(experiment.getExperiment_ID());
                     experimentResource.setProjectID(experiment.getProject().getProject_ID());
-                    experimentResource.setUserID(experiment.getUser().getUser_ID());
+                    experimentResource.setUserName(experiment.getUser().getUser_name());
                     experimentResource.setSubmittedDate(experiment.getSubmitted_date());
                     resourceList.add(experimentResource);
                 }
@@ -171,9 +161,6 @@ public class UserResource extends Abstra
         user.setUser_name(userName);
         user.setPassword(password);
 
-        if (id != -1) {
-            user.setUser_ID(id);
-        }
         em.persist(user);
         end();
     }
@@ -181,16 +168,16 @@ public class UserResource extends Abstra
     public boolean isExists(ResourceType type, Object name) {
         begin();
         if (type == ResourceType.USER_WORKFLOW) {
-            Query q = em.createQuery("SELECT p FROM User_Workflow p WHERE p.gateway_ID =:gate_ID
and p.user_ID =:userID and p.user_workflow_name =:usr_wf_name");
-            q.setParameter("gate_ID", gatewayID);
-            q.setParameter("userID", id);
+            Query q = em.createQuery("SELECT p FROM User_Workflow p WHERE p.gateway_name
=:gate_name and p.user_name = :usr_name and p.user_workflow_name =:usr_wf_name");
+            q.setParameter("gate_name", gatewayName);
+            q.setParameter("user_name", userName);
             q.setParameter("usr_wf_name", name);
             User_Workflow userWorkflow = (User_Workflow) q.getSingleResult();
             return userWorkflow != null;
         } else if (type == ResourceType.EXPERIMENT) {
-            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.gateway_ID =:gate_ID
and p.user_ID =:userID and p.experiment_ID =:experimentID");
-            q.setParameter("gate_ID", gatewayID);
-            q.setParameter("userID", id);
+            Query q = em.createQuery("SELECT p FROM Experiment p WHERE p.gateway_name =:gate_name
and p.user_name = :usr_name and p.experiment_ID =:experimentID");
+            q.setParameter("gate_name", gatewayName);
+            q.setParameter("user_name", userName);
             q.setParameter("experimentID", name);
             Experiment experiment = (Experiment) q.getSingleResult();
             return experiment != null;

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.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/UserWorkflowResource.java?rev=1381763&r1=1381762&r2=1381763&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/java/org/apache/airavata/persistance/registry/jpa/resources/UserWorkflowResource.java
Thu Sep  6 21:23:58 2012
@@ -31,7 +31,7 @@ import java.util.List;
 
 public class UserWorkflowResource extends AbstractResource {
     private int projectID;
-    private int userID;
+    private String userName;
     private String name;
     private Date lastUpdateDate;
     private String content;
@@ -39,9 +39,9 @@ public class UserWorkflowResource extend
     public UserWorkflowResource() {
     }
 
-    public UserWorkflowResource(int projectID, int userID, String name) {
+    public UserWorkflowResource(int projectID, String userName, String name) {
         this.projectID = projectID;
-        this.userID = userID;
+        this.userName = userName;
         this.name = name;
     }
 
@@ -49,8 +49,8 @@ public class UserWorkflowResource extend
         return projectID;
     }
 
-    public int getUserID() {
-        return userID;
+    public String getUserName() {
+        return userName;
     }
 
     public String getName() {
@@ -77,8 +77,8 @@ public class UserWorkflowResource extend
         this.projectID = projectID;
     }
 
-    public void setUserID(int userID) {
-        this.userID = userID;
+    public void setUserName(String userName) {
+        this.userName = userName;
     }
 
     public void setName(String name) {
@@ -111,8 +111,8 @@ public class UserWorkflowResource extend
         project.setProject_ID(projectID);
         userWorkflow.setProject_ID(projectID);
         Users user = new Users();
-        user.setUser_ID(userID);
-        userWorkflow.setUser_ID(userID);
+        user.setUser_name(userName);
+        userWorkflow.setUser_name(userName);
         em.persist(userWorkflow);
         end();
     }

Modified: incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data.sql
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data.sql?rev=1381763&r1=1381762&r2=1381763&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data.sql
(original)
+++ incubator/airavata/trunk/modules/registry/airavata-jpa-registry/src/main/resources/data.sql
Thu Sep  6 21:23:58 2012
@@ -1,8 +1,7 @@
 create table Gateway
 (
-        gateway_ID int(11) NOT NULL AUTO_INCREMENT,
         gateway_name varchar(255),
-        PRIMARY KEY (gateway_ID)
+        PRIMARY KEY (gateway_name)
 );
 
 create table Configuration
@@ -16,102 +15,101 @@ create table Configuration
 
 create table Users
 (
-        user_ID int(11) NOT NULL AUTO_INCREMENT,
         user_name varchar(255),
         password varchar(255),
-        PRIMARY KEY(user_ID)
+        PRIMARY KEY(user_name)
 );
 
 create table Gateway_Worker
 (
-      gateway_ID int(11) ,
-      user_ID int(11),
-      PRIMARY KEY (gateway_ID, user_ID),
-      FOREIGN KEY (gateway_ID) REFERENCES Gateway(gateway_ID) ON DELETE CASCADE,
-      FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+      gateway_name varchar(255),
+      user_name varchar(255),
+      PRIMARY KEY (gateway_name, user_name),
+      FOREIGN KEY (gateway_name) REFERENCES Gateway(gateway_name) ON DELETE CASCADE,
+      FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 
 );
 
 create table Project
 (
        project_ID int(11) NOT NULL AUTO_INCREMENT,
-       gateway_ID  int(11),
-       user_ID int(11),
+       gateway_name varchar(255),
+       user_name varchar(255),
        project_name varchar(255),
        PRIMARY KEY(project_ID),
-       FOREIGN KEY (gateway_ID) REFERENCES Gateway(gateway_ID) ON DELETE CASCADE,
-       FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+       FOREIGN KEY (gateway_name) REFERENCES Gateway(gateway_name) ON DELETE CASCADE,
+       FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 );
 
 create table Published_Workflow
 (
-       gateway_ID int(11),
+       gateway_name varchar(255),
        publish_workflow_name varchar(255),
        version varchar(255),
        published_date DATE,
        workflow_content varchar(2000),
-       PRIMARY KEY(gateway_ID, publish_workflow_name),
-       FOREIGN KEY (gateway_ID) REFERENCES Gateway(gateway_ID) ON DELETE CASCADE
+       PRIMARY KEY(gateway_name, publish_workflow_name),
+       FOREIGN KEY (gateway_name) REFERENCES Gateway(gateway_name) ON DELETE CASCADE
 );
 
 create table User_Workflow
 (
        project_ID int(11),
-       user_ID int(11),
+       user_name varchar(255),
        user_workflow_name varchar(255),
        last_update_date DATE,
        workflow_content varchar(2000),
-       PRIMARY KEY(project_ID, user_ID, user_workflow_name),
+       PRIMARY KEY(project_ID, user_name, user_workflow_name),
        FOREIGN KEY (project_ID) REFERENCES Project(project_ID) ON DELETE CASCADE,
-       FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+       FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 );
 
 
 create table Host_Descriptor
 (
-       gateway_ID int(11),
-       user_ID int(11),
+       gateway_name varchar(255),
+       user_name varchar(255),
        host_descriptor_ID varchar(255),
        host_descriptor_xml varchar(2000),
        PRIMARY KEY(host_descriptor_ID),
-       FOREIGN KEY (gateway_ID) REFERENCES Gateway(gateway_ID) ON DELETE CASCADE,
-       FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+       FOREIGN KEY (gateway_name) REFERENCES Gateway(gateway_name) ON DELETE CASCADE,
+       FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 );
 
 create table Service_Descriptor
 (
-         gateway_ID int(11),
-         user_ID int(11),
+         gateway_name varchar(255),
+         user_name varchar(255),
          service_descriptor_ID varchar(255),
          service_descriptor_xml varchar(2000),
          PRIMARY KEY(service_descriptor_ID),
-         FOREIGN KEY (gateway_ID) REFERENCES Gateway(gateway_ID) ON DELETE CASCADE,
-         FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+         FOREIGN KEY (gateway_name) REFERENCES Gateway(gateway_name) ON DELETE CASCADE,
+         FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 );
 
 create table Application_Descriptor
 (
-         gateway_ID int(11),
-         user_ID int(11),
+         gateway_name varchar(255),
+         user_name varchar(255),
          application_descriptor_ID varchar(255),
          host_descriptor_ID varchar(255),
          service_descriptor_ID varchar(255),
          application_descriptor_xml varchar(2000),
          PRIMARY KEY(application_descriptor_ID),
-         FOREIGN KEY (gateway_ID) REFERENCES Gateway(gateway_ID) ON DELETE CASCADE,
+         FOREIGN KEY (gateway_name) REFERENCES Gateway(gateway_name) ON DELETE CASCADE,
          FOREIGN KEY (host_descriptor_ID) REFERENCES Host_Descriptor(host_descriptor_ID)
ON DELETE CASCADE,
          FOREIGN KEY (service_descriptor_ID) REFERENCES Service_Descriptor(service_descriptor_ID)
ON DELETE CASCADE,
-         FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+         FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 );
 
 create table Experiment
 (
           project_ID int(11),
-          user_ID int(11),
+          user_name varchar(255),
           experiment_ID varchar(255),
           submitted_date Date,
           PRIMARY KEY(experiment_ID),
           FOREIGN KEY (project_ID) REFERENCES Project(project_ID) ON DELETE CASCADE,
-          FOREIGN KEY (user_ID) REFERENCES Users(user_ID) ON DELETE CASCADE
+          FOREIGN KEY (user_name) REFERENCES Users(user_name) ON DELETE CASCADE
 );
 



Mime
View raw message