[ https://issues.apache.org/jira/browse/AIRAVATA-2728?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16459057#comment-16459057 ]
ASF GitHub Bot commented on AIRAVATA-2728: ------------------------------------------ tilaks26 commented on a change in pull request #191: [AIRAVATA-2728] Refactoring Experiment Catalog Implementation URL: https://github.com/apache/airavata/pull/191#discussion_r185109529 ########## 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) { Review comment: Removed the for loop. ---------------------------------------------------------------- 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: us...@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)