From de8a8e6cbe28f55a2f208aa039d8e2a4098e1fa1 Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:17:01 -0500 Subject: [PATCH 1/8] Updated schema file for adding study id Updated schema file for adding study id --- src/main/resources/schema.graphqls | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/schema.graphqls b/src/main/resources/schema.graphqls index 904c289..884c34e 100644 --- a/src/main/resources/schema.graphqls +++ b/src/main/resources/schema.graphqls @@ -17,6 +17,8 @@ type Run @key(fields: "runId") { commandLine: String engineParameters: EngineParameters tasks(taskId: String, state: String, tag: String): [Task] + producedAnalyses(filter: RunsFilter): [Analysis] @fetch(from: "producedAnalyses") + inputAnalyses(filter: RunsFilter): [Analysis] @requires(fields: "parameters") @fetch(from: "inputAnalyses") } type EngineParameters { @@ -75,6 +77,7 @@ input RunsFilter { state: String repository: String analysisId: String + studyId: String } input TasksFilter { @@ -94,6 +97,7 @@ directive @fetch(from : String!) on FIELD_DEFINITION type Analysis @key(fields: "analysisId") @extends { analysisId: ID! @external + studyId: String! @external inputForRuns(filter: RunsFilter): [Run] } From 34737aca9438c6255cf63b9997437d62264bd312 Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:18:39 -0500 Subject: [PATCH 2/8] Updated Data fetcher code to incorporate study id filter Updated Data fetcher code to incorporate study id filter --- .../search/graphql/fetchers/EntityDataFetchers.java | 5 +++-- .../workflow/search/graphql/fetchers/RunDataFetchers.java | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java index 46c5aad..bc32c12 100644 --- a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java +++ b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java @@ -62,8 +62,9 @@ public AsyncDataFetcher getDataFetcher() { } if (ANALYSIS_ENTITY.equals(values.get("__typename"))) { final Object analysisId = values.get("analysisId"); - if (analysisId instanceof String) { - return Mono.just(new Analysis((String) analysisId)); + final Object studyId = values.get("studyId"); + if (analysisId instanceof String && studyId instanceof String) { + return Mono.just(new Analysis((String) analysisId, (String) studyId)); } } if (WORKFLOW_ENTITY.equals(values.get("__typename"))) { diff --git a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java index 941cab8..d2b35e0 100644 --- a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java +++ b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java @@ -21,6 +21,7 @@ import static com.google.common.base.Strings.isNullOrEmpty; import static java.util.stream.Collectors.toUnmodifiableList; import static org.icgc_argo.workflow.search.model.SearchFields.ANALYSIS_ID; +import static org.icgc_argo.workflow.search.model.SearchFields.STUDY_ID; import static org.icgc_argo.workflow.search.util.Converter.asImmutableMap; import static org.icgc_argo.workflow.search.util.JacksonUtils.convertValue; @@ -108,17 +109,21 @@ public AsyncDataFetcher> getNestedRunInAnalysisDataFetcher() { return environment -> { val analysis = (Analysis) environment.getSource(); val analysisId = analysis.getAnalysisId(); + val studyId = analysis.getStudyId(); ImmutableMap filter = asImmutableMap(environment.getArgument("filter")); val filerAnalysisId = filter.getOrDefault(ANALYSIS_ID, analysisId); + val filterStudyId = filter.getOrDefault(STUDY_ID, studyId); // short circuit here since can't find runs for invalid analysisId - if (isNullOrEmpty(analysisId) || !analysisId.equals(filerAnalysisId)) { + if ((isNullOrEmpty(analysisId) || !analysisId.equals(filerAnalysisId)) + && (isNullOrEmpty(studyId) || !analysisId.equals(filterStudyId))) { return Mono.empty(); } Map mergedFilter = new HashMap<>(filter); mergedFilter.put(ANALYSIS_ID, analysisId); + mergedFilter.put(STUDY_ID, studyId); // Need to cast to get appropriate jackson annotation (camelCase property naming) return runService.getRuns(mergedFilter, null); From 89add77b25d5e0b3bc0af471f0bf2fa224e50f2d Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:20:23 -0500 Subject: [PATCH 3/8] Updated Search fields with study id Updated Search fields with study id --- .../java/org/icgc_argo/workflow/search/model/SearchFields.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/icgc_argo/workflow/search/model/SearchFields.java b/src/main/java/org/icgc_argo/workflow/search/model/SearchFields.java index abdf62a..36349e1 100644 --- a/src/main/java/org/icgc_argo/workflow/search/model/SearchFields.java +++ b/src/main/java/org/icgc_argo/workflow/search/model/SearchFields.java @@ -40,4 +40,5 @@ public class SearchFields { public static final String ANALYSIS_ID = "analysisId"; public static final String CPUS = "cpus"; public static final String MEMORY = "memory"; + public static final String STUDY_ID = "studyId"; } From b4430c45e9547e7901fc0936015638a98ed5cb8c Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:21:26 -0500 Subject: [PATCH 4/8] Updated Analysis with study id field Updated Analysis with study id field --- .../org/icgc_argo/workflow/search/model/graphql/Analysis.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java b/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java index 9774640..0d8914b 100644 --- a/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java +++ b/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java @@ -37,6 +37,8 @@ public class Analysis { private String analysisId; + private String studyId; + @SneakyThrows public static Analysis parse(@NonNull Map sourceMap) { return MAPPER.convertValue(sourceMap, Analysis.class); From 7aa342a08618059d6d1658b4ac08eba0350c8d0f Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:22:51 -0500 Subject: [PATCH 5/8] Updated Run repository to include study id related fields Updated Run repository to include study id related fields --- .../workflow/search/repository/RunRepository.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java b/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java index 7a1ad02..b5ba19d 100644 --- a/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java +++ b/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java @@ -59,6 +59,13 @@ public class RunRepository { "parameters.analysis_id", "parameters.normal_aln_analysis_id", "parameters.tumour_aln_analysis_id"); + + private static final List STUDY_SEARCH_FIELDS = + List.of( + "parameters.study_id", + "parameters.normal_aln_study_id", + "parameters.tumour_aln_study_id"); + private static final Map>> QUERY_RESOLVER = argumentPathMap(); @@ -182,6 +189,13 @@ private static Map>> argumentPa q.minimumShouldMatch("100%"); return q; }) + .put( + STUDY_ID, + value -> { + val q = new MultiMatchQueryBuilder(value, STUDY_SEARCH_FIELDS.toArray(String[]::new)); + q.minimumShouldMatch("100%"); + return q; + }) .put(REPOSITORY, RunRepository::repositoryQueryFunc) .build(); } From 6099573739ebe4a1882c237ad8fce2854a590292 Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:46:37 -0500 Subject: [PATCH 6/8] Updated Data fetchers code based on the review comments Updated Data fetchers code based on the review comments --- .../search/graphql/fetchers/EntityDataFetchers.java | 6 +++--- .../workflow/search/graphql/fetchers/RunDataFetchers.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java index bc32c12..5195438 100644 --- a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java +++ b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/EntityDataFetchers.java @@ -62,9 +62,9 @@ public AsyncDataFetcher getDataFetcher() { } if (ANALYSIS_ENTITY.equals(values.get("__typename"))) { final Object analysisId = values.get("analysisId"); - final Object studyId = values.get("studyId"); - if (analysisId instanceof String && studyId instanceof String) { - return Mono.just(new Analysis((String) analysisId, (String) studyId)); + final Object studyId = values.get("studyId"); + if (analysisId instanceof String || studyId instanceof String) { + return Mono.just(new Analysis((String) analysisId, (String) studyId); } } if (WORKFLOW_ENTITY.equals(values.get("__typename"))) { diff --git a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java index d2b35e0..b88f72a 100644 --- a/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java +++ b/src/main/java/org/icgc_argo/workflow/search/graphql/fetchers/RunDataFetchers.java @@ -117,7 +117,7 @@ public AsyncDataFetcher> getNestedRunInAnalysisDataFetcher() { // short circuit here since can't find runs for invalid analysisId if ((isNullOrEmpty(analysisId) || !analysisId.equals(filerAnalysisId)) - && (isNullOrEmpty(studyId) || !analysisId.equals(filterStudyId))) { + && (isNullOrEmpty(studyId) || !studyId.equals(filterStudyId))) { return Mono.empty(); } From bd6e4c3799fbc4e5cf4db48837ae040a6bcd93e7 Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Wed, 8 Mar 2023 10:47:29 -0500 Subject: [PATCH 7/8] Updated Run repository code based on the review comments Updated Run repository code based on the review comments --- .../workflow/search/repository/RunRepository.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java b/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java index b5ba19d..dde806a 100644 --- a/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java +++ b/src/main/java/org/icgc_argo/workflow/search/repository/RunRepository.java @@ -60,11 +60,7 @@ public class RunRepository { "parameters.normal_aln_analysis_id", "parameters.tumour_aln_analysis_id"); - private static final List STUDY_SEARCH_FIELDS = - List.of( - "parameters.study_id", - "parameters.normal_aln_study_id", - "parameters.tumour_aln_study_id"); + private static final String STUDY_SEARCH_FIELD ="parameters.study_id"; private static final Map>> QUERY_RESOLVER = argumentPathMap(); @@ -192,8 +188,7 @@ private static Map>> argumentPa .put( STUDY_ID, value -> { - val q = new MultiMatchQueryBuilder(value, STUDY_SEARCH_FIELDS.toArray(String[]::new)); - q.minimumShouldMatch("100%"); + val q = new TermQueryBuilder(value, STUDY_SEARCH_FIELD); return q; }) .put(REPOSITORY, RunRepository::repositoryQueryFunc) From 8fbde2b9a8df7d1077f5486bc63909daf70b7f61 Mon Sep 17 00:00:00 2001 From: Azher2Ali <121898125+Azher2Ali@users.noreply.github.com> Date: Thu, 9 Mar 2023 14:23:51 -0500 Subject: [PATCH 8/8] Updated null check for analysisId and studyId Updated null check for analysisId and studyId --- .../workflow/search/model/graphql/Analysis.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java b/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java index 0d8914b..e10450b 100644 --- a/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java +++ b/src/main/java/org/icgc_argo/workflow/search/model/graphql/Analysis.java @@ -29,7 +29,6 @@ import lombok.SneakyThrows; @Data -@AllArgsConstructor @JsonIgnoreProperties(ignoreUnknown = true) @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) public class Analysis { @@ -39,8 +38,23 @@ public class Analysis { private String studyId; + public Analysis(String analysisId, String studyId) { + if (null!=analysisId) { + this.analysisId = analysisId; + } else { + this.analysisId = ""; + } + if (null!=studyId) { + this.studyId = studyId; + } else { + this.studyId = ""; + } + } + @SneakyThrows public static Analysis parse(@NonNull Map sourceMap) { return MAPPER.convertValue(sourceMap, Analysis.class); } + + }