airavata-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AIRAVATA-2728) Refactoring Experiment Catalog Implementation
Date Mon, 30 Apr 2018 19:38:01 GMT

    [ https://issues.apache.org/jira/browse/AIRAVATA-2728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16458939#comment-16458939
] 

ASF GitHub Bot commented on AIRAVATA-2728:
------------------------------------------

machristie commented on a change in pull request #191: [AIRAVATA-2728] Refactoring Experiment
Catalog Implementation
URL: https://github.com/apache/airavata/pull/191#discussion_r185081177
 
 

 ##########
 File path: modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepository.java
 ##########
 @@ -0,0 +1,265 @@
+package org.apache.airavata.registry.core.repositories.expcatalog;
+
+import org.apache.airavata.model.experiment.ExperimentStatistics;
+import org.apache.airavata.model.experiment.ExperimentSummaryModel;
+import org.apache.airavata.model.status.ExperimentState;
+import org.apache.airavata.registry.core.entities.expcatalog.ExperimentSummaryEntity;
+import org.apache.airavata.registry.core.utils.DBConstants;
+import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.ResultOrderType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExperimentSummaryRepository extends ExpCatAbstractRepository<ExperimentSummaryModel,
ExperimentSummaryEntity, String> {
+    private final static Logger logger = LoggerFactory.getLogger(ExperimentRepository.class);
+
+    public ExperimentSummaryRepository() { super(ExperimentSummaryModel.class, ExperimentSummaryEntity.class);
}
+
+    public List<ExperimentSummaryModel> searchExperiments(Map<String, String>
filters, int limit,
+                                                          int offset, Object orderByIdentifier,
ResultOrderType resultOrderType) throws RegistryException {
+        return searchAllAccessibleExperiments(null, filters, limit, offset, orderByIdentifier,
resultOrderType);
+    }
+
+    public List<ExperimentSummaryModel> searchAllAccessibleExperiments(List<String>
accessibleExperimentIds, Map<String, String> filters, int limit,
+                                                                       int offset, Object
orderByIdentifier, ResultOrderType resultOrderType) throws RegistryException {
+        String query = "SELECT ES FROM " + ExperimentSummaryEntity.class.getSimpleName()
+ " ES WHERE ";
+        Map<String, Object> queryParameters = new HashMap<>();
+
+        if (filters != null && !filters.isEmpty()) {
+
+            for (String field : filters.keySet()) {
+
+                if (field.equals(DBConstants.Experiment.USER_NAME)) {
+                    logger.debug("Filter Experiments by User");
+                    queryParameters.put(DBConstants.Experiment.USER_NAME, filters.get(field));
+                    query += "ES.userName LIKE :" + DBConstants.Experiment.USER_NAME + "
AND ";
+                }
+
+                else if (field.equals(DBConstants.Experiment.GATEWAY_ID)) {
+                    logger.debug("Filter Experiments by Gateway ID");
+                    queryParameters.put(DBConstants.Experiment.GATEWAY_ID, filters.get(field));
+                    query += "ES.gatewayId LIKE :" + DBConstants.Experiment.GATEWAY_ID +
" AND ";
+                }
+
+                else if (field.equals(DBConstants.Experiment.PROJECT_ID)) {
+                    logger.debug("Filter Experiments by Project ID");
+                    queryParameters.put(DBConstants.Experiment.PROJECT_ID, filters.get(field));
+                    query += "ES.projectId LIKE :" + DBConstants.Experiment.PROJECT_ID +
" AND ";
+                }
+
+                else if (field.equals(DBConstants.Experiment.EXPERIMENT_NAME)) {
+                    logger.debug("Filter Experiments by Name");
+                    queryParameters.put(DBConstants.Experiment.EXPERIMENT_NAME, filters.get(field));
+                    query += "ES.name LIKE :" + DBConstants.Experiment.EXPERIMENT_NAME +
" AND ";
+                }
+
+                else if (field.equals(DBConstants.Experiment.DESCRIPTION)) {
+                    logger.debug("Filter Experiments by Description");
+                    queryParameters.put(DBConstants.Experiment.DESCRIPTION, filters.get(field));
+                    query += "ES.description LIKE :" + DBConstants.Experiment.DESCRIPTION
+ " AND ";
+                }
+
+                else if (field.equals(DBConstants.Experiment.EXECUTION_ID)) {
+                    logger.debug("Filter Experiments by Execution ID");
+                    queryParameters.put(DBConstants.Experiment.EXECUTION_ID, filters.get(field));
+                    query += "ES.executionId LIKE :" + DBConstants.Experiment.EXECUTION_ID
+ " AND ";
+                }
+
+            }
+
+        }
+
+        if (filters.get(DBConstants.ExperimentStatus.STATE) != null) {
+            logger.debug("Filter Experiments by State");
+            String state = ExperimentState.valueOf(filters.get(DBConstants.ExperimentStatus.STATE)).toString();
+            queryParameters.put(DBConstants.ExperimentStatus.STATE, state);
+            query += "ES.state LIKE :" + DBConstants.ExperimentStatus.STATE + " AND ";
+        }
+
+        if (filters.get(DBConstants.ExperimentSummary.FROM_DATE) != null
+                && filters.get(DBConstants.ExperimentSummary.TO_DATE) != null) {
+
+            Timestamp fromDate = Timestamp.valueOf(filters.get(DBConstants.ExperimentSummary.FROM_DATE));
+            Timestamp toDate = Timestamp.valueOf(filters.get(DBConstants.ExperimentSummary.TO_DATE));
+
+            if (toDate.after(fromDate)) {
+                logger.debug("Filter Experiments by CreationTime");
+                queryParameters.put(DBConstants.ExperimentSummary.FROM_DATE, fromDate);
+                queryParameters.put(DBConstants.ExperimentSummary.TO_DATE, toDate);
+                query += "ES.creationTime BETWEEN :" + DBConstants.ExperimentSummary.FROM_DATE
+ " AND :" + DBConstants.ExperimentSummary.TO_DATE + " AND ";
+            }
 
 Review comment:
   This should probably at least log an error if the fromDate comes after toDate.  Throwing
an IllegalArgumentException would work too. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Refactoring Experiment Catalog Implementation
> ---------------------------------------------
>
>                 Key: AIRAVATA-2728
>                 URL: https://issues.apache.org/jira/browse/AIRAVATA-2728
>             Project: Airavata
>          Issue Type: Improvement
>          Components: Registry API
>            Reporter: Sneha Tilak
>            Assignee: Sneha Tilak
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message