airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: adding order to pre,post,env,module ld commands
Date Thu, 22 Oct 2015 16:58:08 GMT
Repository: airavata
Updated Branches:
  refs/heads/master a2cd71e6b -> 30a918440


adding order to pre,post,env,module ld commands


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/30a91844
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/30a91844
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/30a91844

Branch: refs/heads/master
Commit: 30a918440a615747c58e8f7f89092e0ee5feb6e6
Parents: a2cd71e
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Thu Oct 22 12:58:00 2015 -0400
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Thu Oct 22 12:58:00 2015 -0400

----------------------------------------------------------------------
 .../client/samples/CancelExperiments.java       |  2 +-
 .../catalog/impl/ApplicationDeploymentImpl.java | 17 ++++++
 .../core/app/catalog/model/AppEnvironment.java  | 11 ++++
 .../core/app/catalog/model/ModuleLoadCmd.java   | 12 +++++
 .../core/app/catalog/model/PostJobCommand.java  | 11 ++++
 .../core/app/catalog/model/PreJobCommand.java   | 11 ++++
 .../resources/AppCatAbstractResource.java       |  1 +
 .../resources/AppEnvironmentResource.java       | 34 ++++++------
 .../resources/ModuleLoadCmdResource.java        | 17 ++++--
 .../resources/PostJobCommandResource.java       | 45 ++++++++--------
 .../resources/PreJobCommandResource.java        | 57 ++++++++++----------
 .../app/catalog/util/AppCatalogJPAUtils.java    |  4 ++
 12 files changed, 144 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CancelExperiments.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CancelExperiments.java
b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CancelExperiments.java
index be287d5..3c2824c 100644
--- a/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CancelExperiments.java
+++ b/airavata-api/airavata-client-sdks/java-client-samples/src/main/java/org/apache/airavata/client/samples/CancelExperiments.java
@@ -34,7 +34,7 @@ import java.lang.String;
 public class CancelExperiments {
 
     //FIXME: Read from a config file
-    public static final String THRIFT_SERVER_HOST = "localhost";
+    public static final String THRIFT_SERVER_HOST = "gw56.iu.xsede.org";
     public static final int THRIFT_SERVER_PORT = 8930;
     private final static Logger logger = LoggerFactory.getLogger(CreateLaunchExperiment.class);
     private static final String DEFAULT_USER = "default.registry.user";

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
index 0a8099f..dc506bc 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/impl/ApplicationDeploymentImpl.java
@@ -72,9 +72,12 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
 
             List<String> moduleLoadCmds = deploymentDescription.getModuleLoadCmds();
             if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){
+                int i=0;
                 for (String cmd : moduleLoadCmds){
+                    i++;
                     ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
                     cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
+                    cmdResource.setOrder(i);
                     cmdResource.setCmd(cmd);
                     cmdResource.save();
                 }
@@ -82,10 +85,13 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
 
             List<String> preJobCommands = deploymentDescription.getPreJobCommands();
             if (preJobCommands != null && !preJobCommands.isEmpty()){
+                int i=0;
                 for (String cmd : preJobCommands){
+                    i++;
                     PreJobCommandResource cmdResource = new PreJobCommandResource();
                     cmdResource.setAppDeploymentId(deploymentDescription.getAppDeploymentId());
                     cmdResource.setCommand(cmd);
+                    cmdResource.setOrder(i);
                     cmdResource.save();
                 }
             }
@@ -125,12 +131,15 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
             }
             List<SetEnvPaths> setEnvironment = deploymentDescription.getSetEnvironment();
             if (setEnvironment != null && !setEnvironment.isEmpty()){
+                int i=0;
                 for (SetEnvPaths path : setEnvironment){
+                    i++;
                     AppEnvironmentResource environmentResource = new AppEnvironmentResource();
                     environmentResource.setAppDeploymentResource(deploymentResource);
                     environmentResource.setName(path.getName());
                     environmentResource.setValue(path.getValue());
                     environmentResource.setDeploymentId(deploymentResource.getDeploymentId());
+                    environmentResource.setOrder(i);
                     environmentResource.save();
                 }
             }
@@ -176,7 +185,9 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
             cmdResource.remove(ids);
             List<String> moduleLoadCmds = updatedDeployment.getModuleLoadCmds();
             if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){
+                int i=0;
                 for (String cmd : moduleLoadCmds){
+                    i++;
                     ids = new HashMap<String, String>();
                     ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID,
deploymentId);
                     ids.put(AppCatAbstractResource.ModuleLoadCmdConstants.CMD, cmd);
@@ -186,6 +197,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
                     cmdResource.setCmd(cmd);
                     cmdResource.setAppDeploymentResource(existingDep);
                     cmdResource.setAppDeploymentId(deploymentId);
+                    cmdResource.setOrder(i);
                     cmdResource.save();
                 }
             }
@@ -196,7 +208,9 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
             preJobCommandResource.remove(ids);
             List<String> preJobCommands = updatedDeployment.getPreJobCommands();
             if (preJobCommands != null && !preJobCommands.isEmpty()){
+                int i=0;
                 for (String cmd : preJobCommands){
+                    i++;
                     ids = new HashMap<String, String>();
                     ids.put(AppCatAbstractResource.PreJobCommandConstants.DEPLOYMENT_ID,
deploymentId);
                     ids.put(AppCatAbstractResource.PreJobCommandConstants.COMMAND, cmd);
@@ -206,6 +220,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
                     preJobCommandResource.setCommand(cmd);
                     preJobCommandResource.setAppDeploymentResource(existingDep);
                     preJobCommandResource.setAppDeploymentId(deploymentId);
+                    preJobCommandResource.setOrder(i);
                     preJobCommandResource.save();
                 }
             }
@@ -281,6 +296,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
             ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
             environmentResource.remove(ids);
             if (setEnvironment != null && !setEnvironment.isEmpty()){
+                int i=0;
                 for (SetEnvPaths path : setEnvironment){
                     ids = new HashMap<String, String>();
                     ids.put(AppCatAbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID,
deploymentId);
@@ -292,6 +308,7 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
                     environmentResource.setName(path.getName());
                     environmentResource.setValue(path.getValue());
                     environmentResource.setDeploymentId(deploymentId);
+                    environmentResource.setOrder(i);
                     environmentResource.save();
                 }
             }

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/AppEnvironment.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/AppEnvironment.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/AppEnvironment.java
index 3d5a842..0f66647 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/AppEnvironment.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/AppEnvironment.java
@@ -38,6 +38,9 @@ public class AppEnvironment implements Serializable {
     @Column(name = "VALUE")
     private String value;
 
+    @Column(name = "ORDER")
+    private Integer order;
+
     @ManyToOne(cascade= CascadeType.MERGE)
     @JoinColumn(name = "DEPLOYMENT_ID")
     private ApplicationDeployment applicationDeployment;
@@ -73,4 +76,12 @@ public class AppEnvironment implements Serializable {
     public void setApplicationDeployment(ApplicationDeployment applicationDeployment) {
         this.applicationDeployment = applicationDeployment;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ModuleLoadCmd.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ModuleLoadCmd.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ModuleLoadCmd.java
index f8f9534..e2c248c 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ModuleLoadCmd.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/ModuleLoadCmd.java
@@ -37,6 +37,9 @@ public class ModuleLoadCmd implements Serializable {
     @Column(name = "APP_DEPLOYMENT_ID")
     private String appDeploymentId;
 
+    @Column(name = "ORDER")
+    private Integer order;
+
     @ManyToOne(cascade= CascadeType.MERGE)
     @JoinColumn(name = "APP_DEPLOYMENT_ID")
     private ApplicationDeployment applicationDeployment;
@@ -64,4 +67,13 @@ public class ModuleLoadCmd implements Serializable {
     public void setApplicationDeployment(ApplicationDeployment applicationDeployment) {
         this.applicationDeployment=applicationDeployment;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PostJobCommand.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PostJobCommand.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PostJobCommand.java
index 50471b0..7e5dd37 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PostJobCommand.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PostJobCommand.java
@@ -43,6 +43,9 @@ public class PostJobCommand implements Serializable {
     @Column(name = "COMMAND")
     private String command;
 
+    @Column(name = "ORDER")
+    private Integer order;
+
     @ManyToOne(cascade= CascadeType.MERGE)
     @JoinColumn(name = "APPDEPLOYMENT_ID")
     private ApplicationDeployment deployment;
@@ -70,4 +73,12 @@ public class PostJobCommand implements Serializable {
     public void setDeployment(ApplicationDeployment deployment) {
         this.deployment = deployment;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PreJobCommand.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PreJobCommand.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PreJobCommand.java
index 81a3c3f..f08f5ed 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PreJobCommand.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/model/PreJobCommand.java
@@ -43,6 +43,9 @@ public class PreJobCommand implements Serializable {
     @Column(name = "COMMAND")
     private String command;
 
+    @Column(name = "ORDER")
+    private Integer order;
+
     @ManyToOne(cascade= CascadeType.MERGE)
     @JoinColumn(name = "APPDEPLOYMENT_ID")
     private ApplicationDeployment applicationDeployment;
@@ -70,4 +73,12 @@ public class PreJobCommand implements Serializable {
     public void setApplicationDeployment(ApplicationDeployment applicationDeployment) {
         this.applicationDeployment = applicationDeployment;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
index ec669d2..3707f79 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppCatAbstractResource.java
@@ -375,6 +375,7 @@ public abstract class AppCatAbstractResource implements AppCatalogResource
{
     public final class ModuleLoadCmdConstants {
         public static final String CMD = "cmd";
         public static final String APP_DEPLOYMENT_ID = "appDeploymentId";
+        public static final String ORDER = "order";
     }
 
     // Workflow Table

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
index ba4975a..f94b5bf 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/AppEnvironmentResource.java
@@ -34,16 +34,14 @@ import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 public class AppEnvironmentResource extends AppCatAbstractResource {
     private final static Logger logger = LoggerFactory.getLogger(AppEnvironmentResource.class);
     private String deploymentId;
     private String name;
     private String value;
+    private Integer order;
     private AppDeploymentResource appDeploymentResource;
 
     public String getDeploymentId() {
@@ -78,6 +76,14 @@ public class AppEnvironmentResource extends AppCatAbstractResource {
         this.appDeploymentResource = appDeploymentResource;
     }
 
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
+
     @Override
     public void remove(Object identifier) throws AppCatalogException {
         HashMap<String, String> ids;
@@ -160,8 +166,8 @@ public class AppEnvironmentResource extends AppCatAbstractResource {
             Query q;
             AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APP_ENVIRONMENT);
             List results;
-            if (fieldName.equals(AppEnvironmentConstants.DEPLOYMENT_ID)) {
-                generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, value);
+            if (fieldName.equals(AppEnvironmentConstants.DEPLOYMENT_ID) || fieldName.equals(AppEnvironmentConstants.NAME))
{
+                generator.setParameter(fieldName, value);
                 q = generator.selectQuery(em);
                 results = q.getResultList();
                 if (results.size() != 0) {
@@ -171,20 +177,10 @@ public class AppEnvironmentResource extends AppCatAbstractResource {
                                 (AppEnvironmentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT,
appEnvironment);
                         appEnvironmentList.add(resource);
                     }
+                    Collections.sort(appEnvironmentList,
+                            (o1, o2) -> ((AppEnvironmentResource) o1).getOrder() - ((AppEnvironmentResource)
o2).getOrder());
                 }
-            } else if (fieldName.equals(AppEnvironmentConstants.NAME)) {
-                generator.setParameter(AppEnvironmentConstants.NAME, value);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        AppEnvironment appEnvironment = (AppEnvironment) result;
-                        AppEnvironmentResource resource =
-                                (AppEnvironmentResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APP_ENVIRONMENT,
appEnvironment);
-                        appEnvironmentList.add(resource);
-                    }
-                }
-            }else {
+            } else {
                 em.getTransaction().commit();
                 em.close();
                 logger.error("Unsupported field name for App Environment resource.", new
IllegalArgumentException());

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
index 43c6106..5e42bba 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/ModuleLoadCmdResource.java
@@ -34,15 +34,13 @@ import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 public class ModuleLoadCmdResource extends AppCatAbstractResource {
     private final static Logger logger = LoggerFactory.getLogger(ModuleLoadCmdResource.class);
     private String cmd;
     private String appDeploymentId;
+    private Integer order;
     private AppDeploymentResource appDeploymentResource;
 
     @Override
@@ -133,6 +131,8 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
                     ModuleLoadCmdResource moduleLoadCmdResource = (ModuleLoadCmdResource)
AppCatalogJPAUtils.getResource(AppCatalogResourceType.MODULE_LOAD_CMD, moduleLoadCmd);
                     moduleLoadCmdResources.add(moduleLoadCmdResource);
                 }
+                Collections.sort(moduleLoadCmdResources,
+                        (o1, o2) -> ((ModuleLoadCmdResource)o1).getOrder()- ((ModuleLoadCmdResource)o2).getOrder());
             } else {
                 em.getTransaction().commit();
                 em.close();
@@ -222,6 +222,7 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
             }
             moduleLoadCmd.setCmd(getCmd());
             moduleLoadCmd.setAppDeploymentId(getAppDeploymentId());
+            moduleLoadCmd.setOrder(order);
             ApplicationDeployment applicationDeployment = em.find(ApplicationDeployment.class,
getAppDeploymentId());
             moduleLoadCmd.setApplicationDeployment(applicationDeployment);
             if (existingModuleLoadCmd == null) {
@@ -295,6 +296,14 @@ public class ModuleLoadCmdResource extends AppCatAbstractResource {
     public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
         this.appDeploymentResource=appDeploymentResource;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
 }
 
 

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
index e9d770b..24c3bbc 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PostJobCommandResource.java
@@ -32,16 +32,14 @@ import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 public class PostJobCommandResource extends AppCatAbstractResource {
     private final static Logger logger = LoggerFactory.getLogger(PostJobCommandResource.class);
 
     private String appDeploymentId;
     private String command;
+    private Integer order;
 
     private AppDeploymentResource appDeploymentResource;
 
@@ -121,7 +119,7 @@ public class PostJobCommandResource extends AppCatAbstractResource {
     }
 
     public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException
{
-        List<AppCatalogResource> gsiSSHPostJobCommandResources = new ArrayList<AppCatalogResource>();
+        List<AppCatalogResource> postJobCommandResources = new ArrayList<AppCatalogResource>();
         EntityManager em = null;
         try {
             em = AppCatalogJPAUtils.getEntityManager();
@@ -129,21 +127,8 @@ public class PostJobCommandResource extends AppCatAbstractResource {
             Query q;
             AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(POST_JOBCOMMAND);
             List results;
-            if (fieldName.equals(PostJobCommandConstants.DEPLOYMENT_ID)) {
-                generator.setParameter(PostJobCommandConstants.DEPLOYMENT_ID, value);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        PostJobCommand postJobCommand = (PostJobCommand) result;
-                        PostJobCommandResource postJobCommandResource =
-                                (PostJobCommandResource) AppCatalogJPAUtils.getResource(
-                                        AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
-                        gsiSSHPostJobCommandResources.add(postJobCommandResource);
-                    }
-                }
-            } else if (fieldName.equals(PostJobCommandConstants.COMMAND)) {
-                generator.setParameter(PostJobCommandConstants.COMMAND, value);
+            if (fieldName.equals(PostJobCommandConstants.DEPLOYMENT_ID) || fieldName.equals(PostJobCommandConstants.COMMAND))
{
+                generator.setParameter(fieldName, value);
                 q = generator.selectQuery(em);
                 results = q.getResultList();
                 if (results.size() != 0) {
@@ -152,14 +137,16 @@ public class PostJobCommandResource extends AppCatAbstractResource {
                         PostJobCommandResource postJobCommandResource =
                                 (PostJobCommandResource) AppCatalogJPAUtils.getResource(
                                         AppCatalogResourceType.POST_JOBCOMMAND, postJobCommand);
-                        gsiSSHPostJobCommandResources.add(postJobCommandResource);
+                        postJobCommandResources.add(postJobCommandResource);
                     }
+                    Collections.sort(postJobCommandResources,
+                            (o1, o2) -> ((PostJobCommandResource) o1).getOrder() - ((PostJobCommandResource)
o2).getOrder());
                 }
             } else {
                 em.getTransaction().commit();
                 em.close();
-                logger.error("Unsupported field name for GSISSH Post Job Command Resource.",
new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported field name for GSISSH Post
Job Command Resource.");
+                logger.error("Unsupported field name for Post Job Command Resource.", new
IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for Post Job Command
Resource.");
             }
             em.getTransaction().commit();
             em.close();
@@ -174,7 +161,7 @@ public class PostJobCommandResource extends AppCatAbstractResource {
                 em.close();
             }
         }
-        return gsiSSHPostJobCommandResources;
+        return postJobCommandResources;
     }
 
     @Override
@@ -252,12 +239,14 @@ public class PostJobCommandResource extends AppCatAbstractResource {
             if (existingPostJobCommand !=  null){
                 existingPostJobCommand.setDeploymentId(appDeploymentId);
                 existingPostJobCommand.setCommand(command);
+                existingPostJobCommand.setOrder(order);
                 existingPostJobCommand.setDeployment(deployment);
                 em.merge(existingPostJobCommand);
             }else {
                 PostJobCommand postJobCommand = new PostJobCommand();
                 postJobCommand.setDeploymentId(appDeploymentId);
                 postJobCommand.setCommand(command);
+                postJobCommand.setOrder(order);
                 postJobCommand.setDeployment(deployment);
                 em.persist(postJobCommand);
             }
@@ -330,4 +319,12 @@ public class PostJobCommandResource extends AppCatAbstractResource {
     public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
         this.appDeploymentResource = appDeploymentResource;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
index fcd494b..2f7facd 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/resources/PreJobCommandResource.java
@@ -32,16 +32,14 @@ import org.slf4j.LoggerFactory;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 public class PreJobCommandResource extends AppCatAbstractResource {
     private final static Logger logger = LoggerFactory.getLogger(PreJobCommandResource.class);
 
     private String appDeploymentId;
     private String command;
+    private Integer order;
 
     private AppDeploymentResource appDeploymentResource;
 
@@ -121,7 +119,7 @@ public class PreJobCommandResource extends AppCatAbstractResource {
     }
 
     public List<AppCatalogResource> get(String fieldName, Object value) throws AppCatalogException
{
-        List<AppCatalogResource> gsiSSHPreJobResources = new ArrayList<AppCatalogResource>();
+        List<AppCatalogResource> preJobCommandResources = new ArrayList<AppCatalogResource>();
         EntityManager em = null;
         try {
             em = AppCatalogJPAUtils.getEntityManager();
@@ -129,21 +127,8 @@ public class PreJobCommandResource extends AppCatAbstractResource {
             Query q;
             AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(PRE_JOBCOMMAND);
             List results;
-            if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID)) {
-                generator.setParameter(PreJobCommandConstants.DEPLOYMENT_ID, value);
-                q = generator.selectQuery(em);
-                results = q.getResultList();
-                if (results.size() != 0) {
-                    for (Object result : results) {
-                        PreJobCommand preJobCommand = (PreJobCommand) result;
-                        PreJobCommandResource preJobCommandResource =
-                                (PreJobCommandResource) AppCatalogJPAUtils.getResource(
-                                        AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
-                        gsiSSHPreJobResources.add(preJobCommandResource);
-                    }
-                }
-            } else if (fieldName.equals(PreJobCommandConstants.COMMAND)) {
-                generator.setParameter(PreJobCommandConstants.COMMAND, value);
+            if (fieldName.equals(PreJobCommandConstants.DEPLOYMENT_ID) || fieldName.equals(PreJobCommandConstants.COMMAND))
{
+                generator.setParameter(fieldName, value);
                 q = generator.selectQuery(em);
                 results = q.getResultList();
                 if (results.size() != 0) {
@@ -152,14 +137,16 @@ public class PreJobCommandResource extends AppCatAbstractResource {
                         PreJobCommandResource preJobCommandResource =
                                 (PreJobCommandResource) AppCatalogJPAUtils.getResource(
                                         AppCatalogResourceType.PRE_JOBCOMMAND, preJobCommand);
-                        gsiSSHPreJobResources.add(preJobCommandResource);
+                        preJobCommandResources.add(preJobCommandResource);
                     }
+                    Collections.sort(preJobCommandResources,
+                            (o1, o2) -> ((PreJobCommandResource) o1).getOrder() - ((PreJobCommandResource)
o2).getOrder());
                 }
             } else {
                 em.getTransaction().commit();
                 em.close();
-                logger.error("Unsupported field name for GSISSH Pre Job Command Resource.",
new IllegalArgumentException());
-                throw new IllegalArgumentException("Unsupported field name for GSISSH Pre
Job Command Resource.");
+                logger.error("Unsupported field name for Pre Job Command Resource.", new
IllegalArgumentException());
+                throw new IllegalArgumentException("Unsupported field name for Pre Job Command
Resource.");
             }
             em.getTransaction().commit();
             em.close();
@@ -174,7 +161,7 @@ public class PreJobCommandResource extends AppCatAbstractResource {
                 em.close();
             }
         }
-        return gsiSSHPreJobResources;
+        return preJobCommandResources;
     }
 
     @Override
@@ -242,22 +229,24 @@ public class PreJobCommandResource extends AppCatAbstractResource {
         EntityManager em = null;
         try {
             em = AppCatalogJPAUtils.getEntityManager();
-            PreJobCommand existingGSIsshPreJobCommand = em.find(PreJobCommand.class,
+            PreJobCommand existingPreJobCommand = em.find(PreJobCommand.class,
                     new PreJobCommandPK(appDeploymentId, command));
             em.close();
 
             em = AppCatalogJPAUtils.getEntityManager();
             em.getTransaction().begin();
             ApplicationDeployment deployment = em.find(ApplicationDeployment.class, appDeploymentId);
-            if (existingGSIsshPreJobCommand !=  null){
-                existingGSIsshPreJobCommand.setDeploymentId(appDeploymentId);
-                existingGSIsshPreJobCommand.setCommand(command);
-                existingGSIsshPreJobCommand.setApplicationDeployment(deployment);
-                em.merge(existingGSIsshPreJobCommand);
+            if (existingPreJobCommand !=  null){
+                existingPreJobCommand.setDeploymentId(appDeploymentId);
+                existingPreJobCommand.setCommand(command);
+                existingPreJobCommand.setApplicationDeployment(deployment);
+                existingPreJobCommand.setOrder(order);
+                em.merge(existingPreJobCommand);
             }else {
                 PreJobCommand preJobCommand = new PreJobCommand();
                 preJobCommand.setDeploymentId(appDeploymentId);
                 preJobCommand.setCommand(command);
+                preJobCommand.setOrder(order);
                 preJobCommand.setApplicationDeployment(deployment);
                 em.persist(preJobCommand);
             }
@@ -330,4 +319,12 @@ public class PreJobCommandResource extends AppCatAbstractResource {
     public void setAppDeploymentResource(AppDeploymentResource appDeploymentResource) {
         this.appDeploymentResource = appDeploymentResource;
     }
+
+    public Integer getOrder() {
+        return order;
+    }
+
+    public void setOrder(Integer order) {
+        this.order = order;
+    }
 }

http://git-wip-us.apache.org/repos/asf/airavata/blob/30a91844/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
----------------------------------------------------------------------
diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
index 33ce626..08422ad 100644
--- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
+++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/app/catalog/util/AppCatalogJPAUtils.java
@@ -574,6 +574,7 @@ public class AppCatalogJPAUtils {
         if (o != null) {
             resource.setAppDeploymentId(o.getDeploymentId());
             resource.setCommand(o.getCommand());
+            resource.setOrder(o.getOrder());
             resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getApplicationDeployment()));
         }
         return resource;
@@ -584,6 +585,7 @@ public class AppCatalogJPAUtils {
         if (o != null){
             resource.setAppDeploymentId(o.getDeploymentId());
             resource.setCommand(o.getCommand());
+            resource.setOrder(o.getOrder());
             resource.setAppDeploymentResource((AppDeploymentResource) createApplicationDeployment(o.getDeployment()));
         }
         return resource;
@@ -756,6 +758,7 @@ public class AppCatalogJPAUtils {
             resource.setDeploymentId(o.getDeploymentID());
             resource.setName(o.getName());
             resource.setValue(o.getValue());
+            resource.setOrder(o.getOrder());
             resource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
         }
         return resource;
@@ -912,6 +915,7 @@ public class AppCatalogJPAUtils {
         if (o != null){
             moduleLoadCmdResource.setCmd(o.getCmd());
             moduleLoadCmdResource.setAppDeploymentId(o.getAppDeploymentId());
+            moduleLoadCmdResource.setOrder(o.getOrder());
             moduleLoadCmdResource.setAppDeploymentResource((AppDeploymentResource)createApplicationDeployment(o.getApplicationDeployment()));
         }
         return moduleLoadCmdResource;


Mime
View raw message