airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject airavata git commit: fixing errors application interface update method
Date Wed, 12 Nov 2014 18:59:45 GMT
Repository: airavata
Updated Branches:
  refs/heads/safekeeping 10f54a2e8 -> 4b3dca789


fixing errors application interface update method


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

Branch: refs/heads/safekeeping
Commit: 4b3dca789228c9b842fd21883020cd939bc67379
Parents: 10f54a2
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Wed Nov 12 13:59:21 2014 -0500
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Wed Nov 12 13:59:21 2014 -0500

----------------------------------------------------------------------
 .../data/impl/ApplicationInterfaceImpl.java     | 34 ++++++++++++++++----
 .../resources/AppModuleMappingResource.java     | 27 +++++++++++++++-
 .../resources/ApplicationInputResource.java     |  8 ++++-
 .../resources/ApplicationOutputResource.java    |  8 ++++-
 4 files changed, 67 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/4b3dca78/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationInterfaceImpl.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationInterfaceImpl.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationInterfaceImpl.java
index 48ddfa0..e68bbc5 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationInterfaceImpl.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/ApplicationInterfaceImpl.java
@@ -166,15 +166,25 @@ public class ApplicationInterfaceImpl implements ApplicationInterface
{
             existingInterface.setAppName(updatedInterface.getApplicationName());
             existingInterface.save();
 
+            // remove existing modules before adding
+            Map<String, String> ids = new HashMap<String, String>();
+            ids.put(AbstractResource.AppModuleMappingConstants.INTERFACE_ID, interfaceId);
+            AppModuleMappingResource moduleMappingResource = new AppModuleMappingResource();
+            moduleMappingResource.remove(ids);
             List<String> applicationModules = updatedInterface.getApplicationModules();
             if (applicationModules != null && !applicationModules.isEmpty()){
                 for (String moduleId : applicationModules){
                     AppModuleResource appModuleResource = new AppModuleResource();
-                    AppModuleMappingResource moduleMappingResource = new AppModuleMappingResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    moduleMappingResource = new AppModuleMappingResource();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.AppModuleMappingConstants.MODULE_ID, moduleId);
                     ids.put(AbstractResource.AppModuleMappingConstants.INTERFACE_ID, interfaceId);
-                    AppModuleMappingResource existingMapping = (AppModuleMappingResource)moduleMappingResource.get(ids);
+                    AppModuleMappingResource existingMapping;
+                    if (!moduleMappingResource.isExists(ids)){
+                          existingMapping = new AppModuleMappingResource();
+                    } else {
+                        existingMapping = (AppModuleMappingResource)moduleMappingResource.get(ids);
+                    }
                     existingMapping.setInterfaceId(interfaceId);
                     existingMapping.setModuleId(moduleId);
                     existingMapping.setModuleResource((AppModuleResource)appModuleResource.get(moduleId));
@@ -183,11 +193,16 @@ public class ApplicationInterfaceImpl implements ApplicationInterface
{
                 }
             }
 
+            // remove existing application inputs
+            ApplicationInputResource inputResource = new ApplicationInputResource();
+            ids = new HashMap<String, String>();
+            ids.put(AbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
+            inputResource.remove(ids);
             List<InputDataObjectType> applicationInputs = updatedInterface.getApplicationInputs();
             if (applicationInputs != null && !applicationInputs.isEmpty()){
                 for (InputDataObjectType input : applicationInputs){
-                    ApplicationInputResource inputResource = new ApplicationInputResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    inputResource = new ApplicationInputResource();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.AppInputConstants.INTERFACE_ID, interfaceId);
                     ids.put(AbstractResource.AppInputConstants.INPUT_KEY, input.getName());
                     if (inputResource.isExists(ids)){
@@ -206,11 +221,16 @@ public class ApplicationInterfaceImpl implements ApplicationInterface
{
                 }
             }
 
+            // remove existing app outputs before adding
+            ApplicationOutputResource outputResource = new ApplicationOutputResource();
+            ids = new HashMap<String, String>();
+            ids.put(AbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
+            outputResource.remove(ids);
             List<OutputDataObjectType> applicationOutputs = updatedInterface.getApplicationOutputs();
             if (applicationOutputs != null && !applicationOutputs.isEmpty()){
                 for (OutputDataObjectType output : applicationOutputs){
-                    ApplicationOutputResource outputResource = new ApplicationOutputResource();
-                    Map<String, String> ids = new HashMap<String, String>();
+                    outputResource = new ApplicationOutputResource();
+                    ids = new HashMap<String, String>();
                     ids.put(AbstractResource.AppOutputConstants.INTERFACE_ID, interfaceId);
                     ids.put(AbstractResource.AppOutputConstants.OUTPUT_KEY, output.getName());
                     if (outputResource.isExists(ids)){

http://git-wip-us.apache.org/repos/asf/airavata/blob/4b3dca78/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleMappingResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleMappingResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleMappingResource.java
index 2b904ad..eb2ff13 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleMappingResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleMappingResource.java
@@ -95,7 +95,32 @@ public class AppModuleMappingResource extends AbstractResource {
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
             generator.setParameter(AppModuleMappingConstants.INTERFACE_ID, ids.get(AppModuleMappingConstants.INTERFACE_ID));
-            generator.setParameter(AppModuleMappingConstants.MODULE_ID, ids.get(AppModuleMappingConstants.MODULE_ID));
+            if (ids.get(AppModuleMappingConstants.MODULE_ID) != null){
+                generator.setParameter(AppModuleMappingConstants.MODULE_ID, ids.get(AppModuleMappingConstants.MODULE_ID));
+            }
+            Query q = generator.deleteQuery(em);
+            q.executeUpdate();
+            em.getTransaction().commit();
+            em.close();
+        } catch (ApplicationSettingsException e) {
+            logger.error(e.getMessage(), e);
+            throw new AppCatalogException(e);
+        } finally {
+            if (em != null && em.isOpen()) {
+                if (em.getTransaction().isActive()){
+                    em.getTransaction().rollback();
+                }
+                em.close();
+            }
+        }
+    }
+
+    public void removeAll() throws AppCatalogException {
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator= new AppCatalogQueryGenerator(APP_MODULE_MAPPING);
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();

http://git-wip-us.apache.org/repos/asf/airavata/blob/4b3dca78/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationInputResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationInputResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationInputResource.java
index 45fd313..75bcd4c 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationInputResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationInputResource.java
@@ -67,7 +67,9 @@ public class ApplicationInputResource extends AbstractResource {
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_INPUT);
             generator.setParameter(AppInputConstants.INTERFACE_ID, ids.get(AppInputConstants.INTERFACE_ID));
-            generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
+            if (ids.get(AppInputConstants.INPUT_KEY) != null){
+                generator.setParameter(AppInputConstants.INPUT_KEY, ids.get(AppInputConstants.INPUT_KEY));
+            }
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();
@@ -85,6 +87,10 @@ public class ApplicationInputResource extends AbstractResource {
         }
     }
 
+    public void removeAll() throws AppCatalogException {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     public Resource get(Object identifier) throws AppCatalogException {
         HashMap<String, String> ids;
         if (identifier instanceof Map) {

http://git-wip-us.apache.org/repos/asf/airavata/blob/4b3dca78/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationOutputResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationOutputResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationOutputResource.java
index 0efd3b9..a25bae6 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationOutputResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/ApplicationOutputResource.java
@@ -62,7 +62,9 @@ public class ApplicationOutputResource extends AbstractResource {
             em.getTransaction().begin();
             AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_OUTPUT);
             generator.setParameter(AppOutputConstants.INTERFACE_ID, ids.get(AppOutputConstants.INTERFACE_ID));
-            generator.setParameter(AppOutputConstants.OUTPUT_KEY, ids.get(AppOutputConstants.OUTPUT_KEY));
+            if (ids.get(AppOutputConstants.OUTPUT_KEY) != null) {
+                generator.setParameter(AppOutputConstants.OUTPUT_KEY, ids.get(AppOutputConstants.OUTPUT_KEY));
+            }
             Query q = generator.deleteQuery(em);
             q.executeUpdate();
             em.getTransaction().commit();
@@ -80,6 +82,10 @@ public class ApplicationOutputResource extends AbstractResource {
         }
     }
 
+    public void removeAll() throws AppCatalogException {
+        //To change body of implemented methods use File | Settings | File Templates.
+    }
+
     public Resource get(Object identifier) throws AppCatalogException {
         HashMap<String, String> ids;
         if (identifier instanceof Map) {


Mime
View raw message