Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALS-8396] When no meta exists, dont filter out var #68

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -47,15 +46,15 @@ public ConceptRepository(

public List<Concept> 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.*,
ds.REF as dataset,
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
Expand All @@ -82,15 +81,15 @@ public long countConcepts(Filter filter) {
}

public Optional<Concept> getConcept(String dataset, String conceptPath) {
String sql = ALLOW_FILTERING_Q
String sql = QueryUtility.ALLOW_FILTERING_Q
+ """
SELECT
concept_node.*,
ds.REF as dataset,
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
Expand Down Expand Up @@ -146,7 +145,7 @@ public Map<Concept, Map<String, String>> getConceptMetaForConcepts(List<Concept>
}

public Optional<Concept> 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 (
Expand Down Expand Up @@ -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
Expand All @@ -232,7 +231,7 @@ WITH RECURSIVE nodes AS (


public List<Concept> getConceptsByPathWithMetadata(List<String> conceptPaths) {
String sql = ALLOW_FILTERING_Q + ", "
String sql = QueryUtility.ALLOW_FILTERING_Q + ", "
+ """
filtered_concepts AS (
SELECT
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Concept> actual = subject.getConcepts(new Filter(List.of(), "", List.of()), Pageable.unpaged());
Expand Down
Loading