This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/airavata.git
commit 59f74f2258339cb92d2e7d74558988692de63810 Author: Marcus Christie <[email protected]> AuthorDate: Fri Jan 15 16:40:15 2021 -0500 AIRAVATA-3401 Fixing name of status field on ExperimentSummary --- .../expcatalog/ExperimentSummaryRepository.java | 12 ++++++------ .../airavata/registry/core/utils/DBConstants.java | 2 +- .../expcatalog/ExperimentSummaryRepositoryTest.java | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepository.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepository.java index 69c4dc3..5db3792 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepository.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepository.java @@ -103,11 +103,11 @@ public class ExperimentSummaryRepository extends ExpCatAbstractRepository<Experi query += "ES.executionId LIKE :" + DBConstants.Experiment.EXECUTION_ID + " AND "; } - if (filters.get(DBConstants.ExperimentStatus.STATE) != null) { + if (filters.get(DBConstants.ExperimentSummary.EXPERIMENT_STATUS) != 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.experimentStatus LIKE :" + DBConstants.ExperimentStatus.STATE + " AND "; + String state = ExperimentState.valueOf(filters.get(DBConstants.ExperimentSummary.EXPERIMENT_STATUS)).toString(); + queryParameters.put(DBConstants.ExperimentSummary.EXPERIMENT_STATUS, state); + query += "ES.experimentStatus LIKE :" + DBConstants.ExperimentSummary.EXPERIMENT_STATUS + " AND "; } if (filters.get(DBConstants.ExperimentSummary.FROM_DATE) != null @@ -260,8 +260,8 @@ public class ExperimentSummaryRepository extends ExpCatAbstractRepository<Experi if (experimentState != null) { logger.debug("Filter Experiments by Experiment State"); - queryParameters.put(DBConstants.Experiment.EXPERIMENT_STATE, experimentState); - query += "ES.experimentStatus LIKE :" + DBConstants.Experiment.EXPERIMENT_STATE + " AND "; + queryParameters.put(DBConstants.ExperimentSummary.EXPERIMENT_STATUS, experimentState); + query += "ES.experimentStatus LIKE :" + DBConstants.ExperimentSummary.EXPERIMENT_STATUS + " AND "; } if (gatewayId != null) { diff --git a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java index b5e887f..dd3abd8 100644 --- a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java +++ b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java @@ -116,7 +116,6 @@ public class DBConstants { public static final String CREATION_TIME = "creationTime"; public static final String RESOURCE_HOST_ID = "resourceHostId"; public static final String ACCESSIBLE_EXPERIMENT_IDS = "accessibleExperimentIds"; - public static final String EXPERIMENT_STATE = "experimentState"; } public final class ExperimentStatus { @@ -140,6 +139,7 @@ public class DBConstants { } public static class ExperimentSummary { + public static final String EXPERIMENT_STATUS = "experimentStatus"; public static final String FROM_DATE = "fromDate"; public static final String TO_DATE = "toDate"; } diff --git a/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepositoryTest.java b/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepositoryTest.java index 0d3e6f4..1b0c415 100644 --- a/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepositoryTest.java +++ b/modules/registry/registry-core/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ExperimentSummaryRepositoryTest.java @@ -207,6 +207,24 @@ public class ExperimentSummaryRepositoryTest extends TestBase{ assertTrue(experimentStatistics.getCreatedExperimentCount() == 1); assertTrue(experimentStatistics.getRunningExperimentCount() == 1); + // Test searchAllAccessibleExperiments with status filtering + // Only CREATED status + filters = new HashMap<>(); + filters.put(DBConstants.Experiment.GATEWAY_ID, gatewayId); + filters.put(DBConstants.ExperimentSummary.EXPERIMENT_STATUS, ExperimentState.CREATED.name()); + experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments( + allExperimentIds, filters, -1, 0, + DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC); + assertEquals("should return only one CREATED exp", 1, experimentSummaryModelList.size()); + assertEquals(experimentIdOne, experimentSummaryModelList.get(0).getExperimentId()); + // Only EXECUTING status + filters.put(DBConstants.ExperimentSummary.EXPERIMENT_STATUS, ExperimentState.EXECUTING.name()); + experimentSummaryModelList = experimentSummaryRepository.searchAllAccessibleExperiments( + allExperimentIds, filters, -1, 0, + DBConstants.Experiment.CREATION_TIME, ResultOrderType.ASC); + assertEquals("should return only one EXECUTING exp", 1, experimentSummaryModelList.size()); + assertEquals(experimentIdTwo, experimentSummaryModelList.get(0).getExperimentId()); + // Experiment 2 is EXECUTING and should be the only one returned experimentStatistics = experimentSummaryRepository.getAccessibleExperimentStatistics(Collections.singletonList(experimentIdTwo), filters); assertTrue(experimentStatistics.getAllExperimentCount() == 1);
