airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: removing existing prepand commands, append commands before updating
Date Tue, 18 Nov 2014 19:25:13 GMT
Repository: airavata
Updated Branches:
  refs/heads/master eec20007b -> 791001f67


removing existing prepand commands, append commands before updating


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

Branch: refs/heads/master
Commit: 791001f670b94504fe975643b17d6ea6337c145b
Parents: eec2000
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Tue Nov 18 14:24:52 2014 -0500
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Tue Nov 18 14:24:52 2014 -0500

----------------------------------------------------------------------
 .../data/impl/ApplicationDeploymentImpl.java    | 34 +++++++++++++++-----
 .../data/resources/AppEnvironmentResource.java  |  5 ++-
 .../resources/LibraryApendPathResource.java     |  4 ++-
 .../resources/LibraryPrepandPathResource.java   |  4 ++-
 .../data/resources/ModuleLoadCmdResource.java   |  4 ++-
 5 files changed, 39 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/791001f6/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
index 1a3776f..f1f9ccf 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationDeploymentImpl.java
@@ -148,11 +148,15 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
 
             existingDep.save();
 
+            // remove existing module load commands
+            ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
+            Map<String, String> ids = new HashMap<String, String>();
+            ids.put(AbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
+            cmdResource.remove(ids);
             List<String> moduleLoadCmds = updatedDeployment.getModuleLoadCmds();
             if (moduleLoadCmds != null && !moduleLoadCmds.isEmpty()){
                 for (String cmd : moduleLoadCmds){
-                    ModuleLoadCmdResource cmdResource = new ModuleLoadCmdResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, deploymentId);
                     ids.put(AbstractResource.ModuleLoadCmdConstants.CMD, cmd);
                     if (cmdResource.isExists(ids)){
@@ -160,14 +164,20 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
                     }
                     cmdResource.setCmd(cmd);
                     cmdResource.setAppDeploymentResource(existingDep);
+                    cmdResource.setAppDeploymentId(deploymentId);
                     cmdResource.save();
                 }
             }
+
+            // remove existing lib prepand paths
+            LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
+            ids = new HashMap<String, String>();
+            ids.put(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
+            prepandPathResource.remove(ids);
             List<SetEnvPaths> libPrependPaths = updatedDeployment.getLibPrependPaths();
             if (libPrependPaths != null && !libPrependPaths.isEmpty()){
                 for (SetEnvPaths path : libPrependPaths){
-                    LibraryPrepandPathResource prepandPathResource = new LibraryPrepandPathResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.LibraryPrepandPathConstants.DEPLOYMENT_ID, deploymentId);
                     ids.put(AbstractResource.LibraryPrepandPathConstants.NAME, path.getName());
                     if (prepandPathResource.isExists(ids)){
@@ -182,10 +192,14 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
             }
 
             List<SetEnvPaths> libApendPaths = updatedDeployment.getLibAppendPaths();
+            // remove lib append paths
+            LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
+            ids = new HashMap<String, String>();
+            ids.put(AbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
+            apendPathResource.remove(ids);
             if (libApendPaths != null && !libApendPaths.isEmpty()){
                 for (SetEnvPaths path : libApendPaths){
-                    LibraryApendPathResource apendPathResource = new LibraryApendPathResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.LibraryApendPathConstants.DEPLOYMENT_ID, deploymentId);
                     ids.put(AbstractResource.LibraryApendPathConstants.NAME, path.getName());
                     if (apendPathResource.isExists(ids)){
@@ -200,10 +214,14 @@ public class ApplicationDeploymentImpl implements ApplicationDeployment
{
             }
 
             List<SetEnvPaths> setEnvironment = updatedDeployment.getSetEnvironment();
+            // remove existing setEnvPaths
+            AppEnvironmentResource environmentResource = new AppEnvironmentResource();
+            ids = new HashMap<String, String>();
+            ids.put(AbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
+            environmentResource.remove(ids);
             if (setEnvironment != null && !setEnvironment.isEmpty()){
                 for (SetEnvPaths path : setEnvironment){
-                    AppEnvironmentResource environmentResource = new AppEnvironmentResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.AppEnvironmentConstants.DEPLOYMENT_ID, deploymentId);
                     ids.put(AbstractResource.AppEnvironmentConstants.NAME, path.getName());
                     if (environmentResource.isExists(ids)){

http://git-wip-us.apache.org/repos/asf/airavata/blob/791001f6/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppEnvironmentResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppEnvironmentResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppEnvironmentResource.java
index e4cdf52..98f753f 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppEnvironmentResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppEnvironmentResource.java
@@ -93,7 +93,10 @@ public class AppEnvironmentResource extends AbstractResource {
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_ENVIRONMENT);
             generator.setParameter(AppEnvironmentConstants.DEPLOYMENT_ID, ids.get(AppEnvironmentConstants.DEPLOYMENT_ID));
-            generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
+            if (ids.get(AppEnvironmentConstants.NAME) != null){
+                generator.setParameter(AppEnvironmentConstants.NAME, ids.get(AppEnvironmentConstants.NAME));
+            }
+
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();

http://git-wip-us.apache.org/repos/asf/airavata/blob/791001f6/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryApendPathResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryApendPathResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryApendPathResource.java
index ee943a2..1f2286d 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryApendPathResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryApendPathResource.java
@@ -93,7 +93,9 @@ public class LibraryApendPathResource extends AbstractResource {
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_APEND_PATH);
             generator.setParameter(LibraryApendPathConstants.DEPLOYMENT_ID, ids.get(LibraryApendPathConstants.DEPLOYMENT_ID));
-            generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME));
+            if (ids.get(LibraryApendPathConstants.NAME) != null){
+                generator.setParameter(LibraryApendPathConstants.NAME, ids.get(LibraryApendPathConstants.NAME));
+            }
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();

http://git-wip-us.apache.org/repos/asf/airavata/blob/791001f6/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryPrepandPathResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryPrepandPathResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryPrepandPathResource.java
index 4f8890d..e4a9b33 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryPrepandPathResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/LibraryPrepandPathResource.java
@@ -93,7 +93,9 @@ public class LibraryPrepandPathResource extends AbstractResource {
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(LIBRARY_PREPAND_PATH);
             generator.setParameter(LibraryPrepandPathConstants.DEPLOYMENT_ID, ids.get(LibraryPrepandPathConstants.DEPLOYMENT_ID));
-            generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME));
+            if (ids.get(LibraryPrepandPathConstants.NAME) != null){
+                generator.setParameter(LibraryPrepandPathConstants.NAME, ids.get(LibraryPrepandPathConstants.NAME));
+            }
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();

http://git-wip-us.apache.org/repos/asf/airavata/blob/791001f6/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ModuleLoadCmdResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ModuleLoadCmdResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ModuleLoadCmdResource.java
index 90d59a2..99faacf 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ModuleLoadCmdResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ModuleLoadCmdResource.java
@@ -59,8 +59,10 @@ public class ModuleLoadCmdResource extends AbstractResource {
             em = AppCatalogJPAUtils.getEntityManager();
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(MODULE_LOAD_CMD);
-            generator.setParameter(ModuleLoadCmdConstants.CMD, ids.get(ModuleLoadCmdConstants.CMD));
             generator.setParameter(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID, ids.get(ModuleLoadCmdConstants.APP_DEPLOYMENT_ID));
+            if (ids.get(ModuleLoadCmdConstants.CMD) != null){
+                generator.setParameter(ModuleLoadCmdConstants.CMD, ids.get(ModuleLoadCmdConstants.CMD));
+            }
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();


Mime
View raw message