airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject [10/13] airavata git commit: Adding searchExperiments methods to the Airavata API
Date Sun, 31 May 2015 21:23:21 GMT
Adding searchExperiments methods to the Airavata API


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

Branch: refs/heads/master
Commit: 7e67ca09e8d87c44163b8fc39f1deacfed9eb374
Parents: 5b1ee03
Author: Supun Nakandala <scnakandala@apache.org>
Authored: Sun May 31 14:54:28 2015 +0530
Committer: Supun Nakandala <scnakandala@apache.org>
Committed: Sun May 31 14:54:28 2015 +0530

----------------------------------------------------------------------
 .../server/handler/AiravataServerHandler.java   |    53 +
 .../java/org/apache/airavata/api/Airavata.java  | 15650 +++++++++--------
 .../main/resources/lib/airavata/Airavata.cpp    |  1339 +-
 .../src/main/resources/lib/airavata/Airavata.h  |   189 +
 .../lib/airavata/Airavata_server.skeleton.cpp   |     5 +
 .../resources/lib/Airavata/API/Airavata.php     |   911 +-
 .../lib/apache/airavata/api/Airavata-remote     |     7 +
 .../lib/apache/airavata/api/Airavata.py         |   667 +-
 .../airavataAPI.thrift                          |    22 +
 9 files changed, 11034 insertions(+), 7809 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/7e67ca09/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 fff3810..f34b361 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
@@ -928,6 +928,59 @@ public class AiravataServerHandler implements Airavata.Iface {
     }
 
     /**
+     * Search Experiments by using multiple filter criteria with pagination. Results will
be sorted
+     * based on creation time DESC
+     *
+     * @param gatewayId
+     *       Identifier of the requested gateway
+     * @param userName
+     *       Username of the requested user
+     * @param filters
+     *       map of multiple filter criteria. keys has to be camel case field values eg.
experimentName
+     * @param limit
+     *       Amount of results to be fetched
+     * @param offset
+     *       The starting point of the results to be fetched
+     */
+    @Override
+    public List<ExperimentSummary> searchExperiments(String gatewayId, String userName,
Map<String, String> filters, int limit, int offset) throws InvalidRequestException,
AiravataClientException, AiravataSystemException, TException {
+        if (!validateString(userName)){
+            logger.error("Username cannot be empty. Please provide a valid user..");
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Username cannot be empty. Please provide a valid user..");
+            throw exception;
+        }
+        if (!isGatewayExist(gatewayId)){
+            logger.error("Gateway does not exist.Please provide a valid gateway id...");
+            throw new AiravataSystemException(AiravataErrorType.INTERNAL_ERROR);
+        }
+        try {
+            if (!ResourceUtils.isUserExist(userName)){
+                logger.error("User does not exist in the system. Please provide a valid user..");
+                AiravataSystemException exception = new AiravataSystemException();
+                exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+                exception.setMessage("User does not exist in the system. Please provide a
valid user..");
+                throw exception;
+            }
+            List<ExperimentSummary> summaries = new ArrayList<ExperimentSummary>();
+            registry = RegistryFactory.getRegistry(gatewayId);
+            List<Object> results = registry.search(RegistryModelType.EXPERIMENT, filters,
limit,
+                    offset, Constants.FieldConstants.ExperimentConstants.CREATION_TIME, ResultOrderType.DESC);
+            for (Object object : results) {
+                summaries.add((ExperimentSummary) object);
+            }
+            return summaries;
+        }catch (Exception e) {
+            logger.error("Error while retrieving experiments", e);
+            AiravataSystemException exception = new AiravataSystemException();
+            exception.setAiravataErrorType(AiravataErrorType.INTERNAL_ERROR);
+            exception.setMessage("Error while retrieving experiments. More info : " + e.getMessage());
+            throw exception;
+        }
+    }
+
+    /**
      * Get all Experiments within a Project
      *
      * @param projectId


Mime
View raw message