airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chath...@apache.org
Subject [28/44] git commit: adding API method to getAllModules
Date Wed, 05 Nov 2014 18:30:16 GMT
adding API method to getAllModules


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

Branch: refs/heads/gfac_appcatalog_int
Commit: 91f5de5ce3fd100daf2f53a27ea5e23da209d97d
Parents: ede66ed
Author: Chathuri Wimalasena <kamalasini@gmail.com>
Authored: Tue Nov 4 16:28:01 2014 -0500
Committer: Chathuri Wimalasena <kamalasini@gmail.com>
Committed: Tue Nov 4 16:28:01 2014 -0500

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   | 11 +++++++-
 .../appcatalog/cpi/ApplicationInterface.java    |  2 ++
 .../data/impl/ApplicationInterfaceImpl.java     | 16 +++++++++++
 .../data/resources/AppModuleResource.java       | 28 +++++++++++++++++++-
 4 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/91f5de5c/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
----------------------------------------------------------------------
diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
index e72bfbb..a760015 100644
--- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
+++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java
@@ -1453,7 +1453,16 @@ public class AiravataServerHandler implements Airavata.Iface {
 
     @Override
     public List<ApplicationModule> getAllModules() throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
-        return null;
+        try {
+            appCatalog = AppCatalogFactory.getAppCatalog();
+            return appCatalog.getApplicationInterface().getAllApplicationModules();
+        } catch (AppCatalogException e) {
+            logger.error("Error while retrieving all application modules...", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while retrieving all application modules. More info
: " + e.getMessage());
+            throw exception;
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/airavata/blob/91f5de5c/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java
b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java
index dc12d8f..76e99a3 100644
--- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java
+++ b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/ApplicationInterface.java
@@ -86,6 +86,8 @@ public interface ApplicationInterface {
      */
     List<ApplicationModule> getApplicationModules(Map<String, String> filters)
throws AppCatalogException;
 
+    List<ApplicationModule> getAllApplicationModules() throws AppCatalogException;
+
     /**
      * This method will return a list of application interfaces according to given search
criteria
      * @param filters map should be provided as the field name and it's value

http://git-wip-us.apache.org/repos/asf/airavata/blob/91f5de5c/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 87be3b6..48ddfa0 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
@@ -276,6 +276,22 @@ public class ApplicationInterfaceImpl implements ApplicationInterface
{
     }
 
     @Override
+    public List<ApplicationModule> getAllApplicationModules() throws AppCatalogException
{
+        List<ApplicationModule> applicationModules = new ArrayList<ApplicationModule>();
+        try {
+            AppModuleResource resource = new AppModuleResource();
+            List<Resource> resources = resource.getAll();
+            if (resources != null && !resources.isEmpty()){
+                applicationModules = AppCatalogThriftConversion.getAppModules(resources);
+            }
+        }catch (Exception e){
+            logger.error("Error while retrieving compute resource list...", e);
+            throw new AppCatalogException(e);
+        }
+        return applicationModules;
+    }
+
+    @Override
     public List<ApplicationInterfaceDescription> getApplicationInterfaces(Map<String,
String> filters) throws AppCatalogException {
         List<ApplicationInterfaceDescription> appInterfaces = new ArrayList<ApplicationInterfaceDescription>();
         try {

http://git-wip-us.apache.org/repos/asf/airavata/blob/91f5de5c/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleResource.java
----------------------------------------------------------------------
diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleResource.java
b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleResource.java
index a04de85..eabbef3 100644
--- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleResource.java
+++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/resources/AppModuleResource.java
@@ -193,7 +193,33 @@ public class AppModuleResource extends AbstractResource {
 
     @Override
     public List<Resource> getAll() throws AppCatalogException {
-        return null;
+        List<Resource> appModuleResources = new ArrayList<Resource>();
+        EntityManager em = null;
+        try {
+            em = AppCatalogJPAUtils.getEntityManager();
+            em.getTransaction().begin();
+            AppCatalogQueryGenerator generator = new AppCatalogQueryGenerator(APPLICATION_MODULE);
+            Query q = generator.selectQuery(em);
+            List<?> results = q.getResultList();
+            for (Object result : results) {
+                ApplicationModule module = (ApplicationModule) result;
+                AppModuleResource appModuleResource = (AppModuleResource) AppCatalogJPAUtils.getResource(AppCatalogResourceType.APPLICATION_MODULE,
module);
+                appModuleResources.add(appModuleResource);
+            }
+            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();
+            }
+        }
+        return appModuleResources;
     }
 
     @Override


Mime
View raw message