From 52ede264f605e2e9c82637c5d10667bef3527271 Mon Sep 17 00:00:00 2001 From: Luke Sikina Date: Thu, 13 Mar 2025 16:03:41 -0400 Subject: [PATCH] [ALS-8396] When no meta exists, dont filter out var --- .../dictionary/concept/ConceptRepository.java | 19 +++++++++---------- .../concept/ConceptRepositoryTest.java | 6 ++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepository.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepository.java index a25dc2f..551eb2a 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepository.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepository.java @@ -4,6 +4,7 @@ import edu.harvard.dbmi.avillach.dictionary.filter.Filter; import edu.harvard.dbmi.avillach.dictionary.filter.QueryParamPair; import edu.harvard.dbmi.avillach.dictionary.util.MapExtractor; +import edu.harvard.dbmi.avillach.dictionary.util.QueryUtility; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Pageable; @@ -15,8 +16,6 @@ import java.util.Map; import java.util.Optional; -import static edu.harvard.dbmi.avillach.dictionary.util.QueryUtility.ALLOW_FILTERING_Q; - @Repository public class ConceptRepository { @@ -47,7 +46,7 @@ public ConceptRepository( public List getConcepts(Filter filter, Pageable pageable) { QueryParamPair filterQ = filterGen.generateFilterQuery(filter, pageable); - String sql = ALLOW_FILTERING_Q + ", " + filterQ.query() + String sql = QueryUtility.ALLOW_FILTERING_Q + ", " + filterQ.query() + """ SELECT concept_node.*, @@ -55,7 +54,7 @@ public List getConcepts(Filter filter, Pageable pageable) { ds.abbreviation AS studyAcronym, continuous_min.VALUE as min, continuous_max.VALUE as max, categorical_values.VALUE as values, - allow_filtering.allowFiltering AS allowFiltering, + coalesce(allow_filtering.allowFiltering, TRUE) AS allowFiltering, meta_description.VALUE AS description FROM concept_node @@ -82,7 +81,7 @@ public long countConcepts(Filter filter) { } public Optional getConcept(String dataset, String conceptPath) { - String sql = ALLOW_FILTERING_Q + String sql = QueryUtility.ALLOW_FILTERING_Q + """ SELECT concept_node.*, @@ -90,7 +89,7 @@ public Optional getConcept(String dataset, String conceptPath) { ds.abbreviation AS studyAcronym, continuous_min.VALUE as min, continuous_max.VALUE as max, categorical_values.VALUE as values, - allow_filtering.allowFiltering AS allowFiltering, + coalesce(allow_filtering.allowFiltering, TRUE) AS allowFiltering, meta_description.VALUE AS description FROM concept_node @@ -146,7 +145,7 @@ public Map> getConceptMetaForConcepts(List } public Optional getConceptTree(String dataset, String conceptPath, int depth) { - String sql = ALLOW_FILTERING_Q + String sql = QueryUtility.ALLOW_FILTERING_Q + """ , core_query AS ( WITH RECURSIVE nodes AS ( @@ -207,7 +206,7 @@ WITH RECURSIVE nodes AS ( continuous_min.VALUE AS min, continuous_max.VALUE AS max, categorical_values.VALUE AS values, meta_description.VALUE AS description, - allow_filtering.allowFiltering AS allowFiltering, + coalesce(allow_filtering.allowFiltering, TRUE) AS allowFiltering, core_query.depth AS depth FROM concept_node @@ -232,7 +231,7 @@ WITH RECURSIVE nodes AS ( public List getConceptsByPathWithMetadata(List conceptPaths) { - String sql = ALLOW_FILTERING_Q + ", " + String sql = QueryUtility.ALLOW_FILTERING_Q + ", " + """ filtered_concepts AS ( SELECT @@ -261,7 +260,7 @@ concept_node_meta.concept_node_id IN ( ds.abbreviation AS studyAcronym, continuous_min.VALUE as min, continuous_max.VALUE as max, categorical_values.VALUE as values, - allow_filtering.allowFiltering AS allowFiltering, + coalesce(allow_filtering.allowFiltering, TRUE) AS allowFiltering, meta_description.VALUE AS description, aggregated_meta.metadata AS metadata FROM diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java index 432ecfd..61d4722 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptRepositoryTest.java @@ -41,6 +41,12 @@ static void mySQLProperties(DynamicPropertyRegistry registry) { registry.add("spring.datasource.db", databaseContainer::getDatabaseName); } + @Test + void shouldMarkConceptThatHasNoStimatizedMetaAsAllowFiltering() { + Boolean actual = subject.getConcept("1", "\\Variant Data Type\\WGS\\").map(Concept::allowFiltering).get(); + Assertions.assertTrue(actual); + } + @Test void shouldListAllConcepts() { List actual = subject.getConcepts(new Filter(List.of(), "", List.of()), Pageable.unpaged());