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 66cd806..c636800 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 @@ -61,6 +61,7 @@ public List getConcepts(Filter filter, Pageable pageable) { 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, @@ -95,6 +96,7 @@ public Optional getConcept(String dataset, String conceptPath) { 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, @@ -215,6 +217,7 @@ WITH RECURSIVE nodes AS ( 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, meta_description.VALUE AS description, diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptResultSetUtil.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptResultSetUtil.java index d5ecbef..54eedd8 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptResultSetUtil.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptResultSetUtil.java @@ -20,7 +20,7 @@ public CategoricalConcept mapCategorical(ResultSet rs) throws SQLException { rs.getString("concept_path"), rs.getString("name"), rs.getString("display"), rs.getString("dataset"), rs.getString("description"), rs.getString("values") == null ? List.of() : parseValues(rs.getString("values")), - rs.getBoolean("allowFiltering"), + rs.getBoolean("allowFiltering"), rs.getString("studyAcronym"), null, null ); @@ -32,6 +32,7 @@ public ContinuousConcept mapContinuous(ResultSet rs) throws SQLException { rs.getString("display"), rs.getString("dataset"), rs.getString("description"), rs.getBoolean("allowFiltering"), parseMin(rs.getString("values")), parseMax(rs.getString("values")), + rs.getString("studyAcronym"), null ); } diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/CategoricalConcept.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/CategoricalConcept.java index 0a9334b..7c4ee16 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/CategoricalConcept.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/CategoricalConcept.java @@ -10,7 +10,7 @@ public record CategoricalConcept( String conceptPath, String name, String display, String dataset, String description, - List values, boolean allowFiltering, + List values, boolean allowFiltering, String studyAcronym, @Nullable List children, @@ -28,17 +28,20 @@ public record CategoricalConcept( public CategoricalConcept( String conceptPath, String name, String display, String dataset, String description, List values, - boolean allowFiltering, @Nullable List children, @Nullable Map meta + boolean allowFiltering, String studyAcronym, @Nullable List children, @Nullable Map meta ) { - this(conceptPath, name, display, dataset, description, values, allowFiltering, children, meta, null, null); + this(conceptPath, name, display, dataset, description, values, allowFiltering, studyAcronym, children, meta, null, null); } public CategoricalConcept(CategoricalConcept core, Map meta) { - this(core.conceptPath, core.name, core.display, core.dataset, core.description, core.values, core.allowFiltering, core.children, meta); + this( + core.conceptPath, core.name, core.display, core.dataset, core.description, core.values, + core.allowFiltering, core.studyAcronym, core.children, meta + ); } public CategoricalConcept(String conceptPath, String dataset) { - this(conceptPath, "", "", dataset, "", List.of(), false, List.of(), null); + this(conceptPath, "", "", dataset, "", List.of(), false, "", List.of(), null); } @@ -50,20 +53,22 @@ public ConceptType type() { @Override public CategoricalConcept withChildren(List children) { - return new CategoricalConcept(conceptPath, name, display, dataset, description, values, allowFiltering, children, meta); + return new CategoricalConcept( + conceptPath, name, display, dataset, description, values, allowFiltering, studyAcronym, children, meta + ); } @Override public Concept withTable(Concept table) { return new CategoricalConcept( - conceptPath, name, display, dataset, description, values, allowFiltering, children, meta, table, study + conceptPath, name, display, dataset, description, values, allowFiltering, studyAcronym, children, meta, table, study ); } @Override public Concept withStudy(Concept study) { return new CategoricalConcept( - conceptPath, name, display, dataset, description, values, allowFiltering, children, meta, table, study + conceptPath, name, display, dataset, description, values, allowFiltering, studyAcronym, children, meta, table, study ); } diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/Concept.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/Concept.java index 80538fa..c57f222 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/Concept.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/Concept.java @@ -44,6 +44,8 @@ public sealed interface Concept */ String dataset(); + String studyAcronym(); + /** * @return The type of this concept */ diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptShell.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptShell.java index 41b909e..c75e8ee 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptShell.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptShell.java @@ -17,6 +17,11 @@ public String display() { return "Shell. Not for external use."; } + @Override + public String studyAcronym() { + return "Shell. Not for external use."; + } + @Override public ConceptType type() { return ConceptType.Continuous; diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ContinuousConcept.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ContinuousConcept.java index 14725f1..b23d134 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ContinuousConcept.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ContinuousConcept.java @@ -11,7 +11,7 @@ public record ContinuousConcept( String conceptPath, String name, String display, String dataset, String description, boolean allowFiltering, - @Nullable Integer min, @Nullable Integer max, + @Nullable Integer min, @Nullable Integer max, String studyAcronym, Map meta, @Nullable List children, @@ -25,24 +25,30 @@ public record ContinuousConcept( public ContinuousConcept( String conceptPath, String name, String display, String dataset, String description, boolean allowFiltering, - @Nullable Integer min, @Nullable Integer max, Map meta, @Nullable List children + @Nullable Integer min, @Nullable Integer max, String studyAcronym, Map meta, @Nullable List children ) { - this(conceptPath, name, display, dataset, description, allowFiltering, min, max, meta, children, null, null); + this( + conceptPath, name, display, dataset, description, allowFiltering, + min, max, studyAcronym, meta, children, null, null + ); } public ContinuousConcept(ContinuousConcept core, Map meta) { - this(core.conceptPath, core.name, core.display, core.dataset, core.description, core.allowFiltering, core.min, core.max, meta, core.children); + this( + core.conceptPath, core.name, core.display, core.dataset, core.description, core.allowFiltering, + core.min, core.max, core.studyAcronym, meta, core.children + ); } public ContinuousConcept(String conceptPath, String dataset) { - this(conceptPath, "", "", dataset, "", true, null, null, null, List.of()); + this(conceptPath, "", "", dataset, "", true, null, null, "", null, List.of()); } public ContinuousConcept( String conceptPath, String name, String display, String dataset, String description, boolean allowFiltering, - @Nullable Integer min, @Nullable Integer max, Map meta + @Nullable Integer min, @Nullable Integer max, String studyAcronym, Map meta ) { - this(conceptPath, name, display, dataset, description, allowFiltering, min, max, meta, null); + this(conceptPath, name, display, dataset, description, allowFiltering, min, max, studyAcronym, meta, null); } @JsonProperty("type") @@ -53,20 +59,24 @@ public ConceptType type() { @Override public ContinuousConcept withChildren(List children) { - return new ContinuousConcept(conceptPath, name, display, dataset, description, allowFiltering, min, max, meta, children); + return new ContinuousConcept( + conceptPath, name, display, dataset, description, allowFiltering, min, max, studyAcronym, meta, children + ); } @Override public Concept withTable(Concept table) { return new ContinuousConcept( - conceptPath, name, display, dataset, description, allowFiltering, min, max, meta, children, table, study + conceptPath, name, display, dataset, description, allowFiltering, + min, max, studyAcronym, meta, children, table, study ); } @Override public Concept withStudy(Concept study) { return new ContinuousConcept( - conceptPath, name, display, dataset, description, allowFiltering, min, max, meta, children, table, study + conceptPath, name, display, dataset, description, allowFiltering, + min, max, studyAcronym, meta, children, table, study ); } diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptControllerTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptControllerTest.java index 4250de2..c5005d2 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptControllerTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptControllerTest.java @@ -33,9 +33,9 @@ class ConceptControllerTest { @Test void shouldListConcepts() { List expected = List.of( - new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, null, Map.of()), - new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), Map.of()), - new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, Map.of()) + new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, "", null, Map.of()), + new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of()), + new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, "", Map.of()) ); Filter filter = new Filter( List.of(new Facet("questionare", "Questionare", "?", "Questionare", 1, null, "category", null)), @@ -55,7 +55,7 @@ void shouldListConcepts() { @Test void shouldGetConceptDetails() { CategoricalConcept expected = - new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), Map.of()); + new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of()); Mockito.when(conceptService.conceptDetail("my_dataset", "/foo//bar")) .thenReturn(Optional.of(expected)); @@ -78,11 +78,11 @@ void shouldNotGetConceptDetails() { @Test void shouldGetConceptTree() { Concept fooBar = - new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), Map.of()); + new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of()); Concept fooBaz = - new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, Map.of()); + new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, "", Map.of()); CategoricalConcept foo = - new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, List.of(fooBar, fooBaz), Map.of()); + new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, "", List.of(fooBar, fooBaz), Map.of()); Mockito.when(conceptService.conceptTree("my_dataset", "/foo", 1)) .thenReturn(Optional.of(foo)); @@ -96,11 +96,11 @@ void shouldGetConceptTree() { @Test void shouldGetNotConceptTreeForLargeDepth() { Concept fooBar = - new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), Map.of()); + new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of()); Concept fooBaz = - new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, Map.of()); + new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, "", Map.of()); CategoricalConcept foo = - new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, List.of(fooBar, fooBaz), Map.of()); + new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, "", List.of(fooBar, fooBaz), Map.of()); Mockito.when(conceptService.conceptTree("my_dataset", "/foo", 1)) .thenReturn(Optional.of(foo)); @@ -114,11 +114,11 @@ void shouldGetNotConceptTreeForLargeDepth() { @Test void shouldGetNotConceptTreeForNegativeDepth() { Concept fooBar = - new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), Map.of()); + new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of()); Concept fooBaz = - new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, Map.of()); + new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, "", Map.of()); CategoricalConcept foo = - new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, List.of(fooBar, fooBaz), Map.of()); + new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, "", List.of(fooBar, fooBaz), Map.of()); Mockito.when(conceptService.conceptTree("my_dataset", "/foo", -1)) .thenReturn(Optional.of(foo)); @@ -131,11 +131,11 @@ void shouldGetNotConceptTreeForNegativeDepth() { @Test void shouldNotGetConceptTreeWhenConceptDNE() { Concept fooBar = - new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), Map.of()); + new CategoricalConcept("/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of()); Concept fooBaz = - new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, Map.of()); + new ContinuousConcept("/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, "", Map.of()); CategoricalConcept foo = - new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, List.of(fooBar, fooBaz), Map.of()); + new CategoricalConcept("/foo", "foo", "Foo", "my_dataset", "foo!", List.of(), true, "", List.of(fooBar, fooBaz), Map.of()); Mockito.when(conceptService.conceptTree("my_dataset", "/foo", 1)) .thenReturn(Optional.of(foo)); @@ -148,11 +148,11 @@ void shouldNotGetConceptTreeWhenConceptDNE() { @Test void shouldDumpConcepts() { Concept fooBar = new CategoricalConcept( - "/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, List.of(), + "/foo//bar", "bar", "Bar", "my_dataset", "foo!", List.of("a", "b"), true, "", List.of(), Map.of("key", "value") ); Concept fooBaz = new ContinuousConcept( - "/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, + "/foo//baz", "baz", "Baz", "my_dataset", "foo!", true, 0, 100, "", Map.of("key", "value") ); List concepts = List.of(fooBar, fooBaz); 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 1f9fe95..95682df 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 @@ -56,8 +56,8 @@ void shouldListAllConcepts() { void shouldListFirstTwoConcepts() { List actual = subject.getConcepts(new Filter(List.of(), "", List.of()), Pageable.ofSize(2).first()); List expected = List.of( - new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, null), - new CategoricalConcept("\\Variant Data Type\\Low coverage WGS\\", "Low coverage WGS", "Low coverage WGS", "1", "Low coverage WGS", List.of("TRUE"), true, null, null) + new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, "FHS", null), + new CategoricalConcept("\\Variant Data Type\\Low coverage WGS\\", "Low coverage WGS", "Low coverage WGS", "1", "Low coverage WGS", List.of("TRUE"), true, "GIC", null, null) ); Assertions.assertEquals(expected, actual); @@ -67,8 +67,8 @@ void shouldListFirstTwoConcepts() { void shouldListNextTwoConcepts() { List actual = subject.getConcepts(new Filter(List.of(), "", List.of()), Pageable.ofSize(2).first().next()); List expected = List.of( - new CategoricalConcept("\\phs002385\\RACEG\\", "RACEG", "RACEG", "phs002385", "Race (regrouped)", List.of("Not Reported"), true, null, null), - new CategoricalConcept("\\Variant Data Type\\Low coverage WGS\\", "Low coverage WGS", "Low coverage WGS", "1", "Low coverage WGS", List.of("TRUE"), true, null, null) + new CategoricalConcept("\\phs002385\\RACEG\\", "RACEG", "RACEG", "phs002385", "Race (regrouped)", List.of("Not Reported"), true, "HCT_for_SCD", null, null), + new CategoricalConcept("\\Variant Data Type\\Low coverage WGS\\", "Low coverage WGS", "Low coverage WGS", "1", "Low coverage WGS", List.of("TRUE"), true, "GIC", null, null) ); Assertions.assertEquals(expected, actual); @@ -79,9 +79,9 @@ void shouldFilterConceptsByFacet() { List actual = subject.getConcepts(new Filter(List.of(new Facet("phs000007", "", "", "", 1, null, "study_ids_dataset_ids", null)), "", List.of()), Pageable.unpaged()); List expected = List.of( - new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "phv00004260", "FM219", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 1, null), - new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, null), - new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", true, 0, 5, null) + new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "phv00004260", "FM219", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 1, "FHS", null), + new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, "FHS", null), + new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", true, 0, 5, "FHS", null) ); Assertions.assertEquals(expected, actual); @@ -91,9 +91,9 @@ void shouldFilterConceptsByFacet() { void shouldFilterBySearch() { List actual = subject.getConcepts(new Filter(List.of(), "COLA", List.of()), Pageable.unpaged()); List expected = List.of( - new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "phv00004260", "FM219", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 1, null), - new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, null), - new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", true, 0, 5, null) + new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "phv00004260", "FM219", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 1, "FHS", null), + new ContinuousConcept("\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, "FHS", null), + new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", true, 0, 5, "FHS", null) ); Assertions.assertEquals(expected, actual); @@ -104,8 +104,8 @@ void shouldFilterByBothSearchAndFacet() { List actual = subject.getConcepts(new Filter(List.of(new Facet("phs002715", "", "", "", 1, null, "study_ids_dataset_ids", null)), "phs002715", List.of()), Pageable.unpaged()); List expected = List.of( - new CategoricalConcept("\\phs002715\\age\\", "AGE_CATEGORY", "age", "phs002715", "Participant's age (category)", List.of("21"), true, null, null), - new CategoricalConcept("\\phs002715\\nsrr_ever_smoker\\", "nsrr_ever_smoker", "nsrr_ever_smoker", "phs002715", "Smoker status", List.of("yes"), true, null, null) + new CategoricalConcept("\\phs002715\\age\\", "AGE_CATEGORY", "age", "phs002715", "Participant's age (category)", List.of("21"), true, "NSRR CFS", null, null), + new CategoricalConcept("\\phs002715\\nsrr_ever_smoker\\", "nsrr_ever_smoker", "nsrr_ever_smoker", "phs002715", "Smoker status", List.of("yes"), true, "NSRR CFS", null, null) ); Assertions.assertEquals(expected, actual); @@ -127,7 +127,7 @@ void shouldGetCountWithFilter() { @Test void shouldGetDetailForConcept() { ContinuousConcept expected = - new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", true, 0, 5, null); + new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "phv00008849", "D080", "phs000007", "# 12 OZ CUPS OF CAFFEINATED COLA/DAY", true, 0, 5, "FHS", null); Optional actual = subject.getConcept("phs000007", "\\phs000007\\pht000033\\phv00008849\\D080\\"); Assertions.assertEquals(Optional.of(expected), actual); @@ -153,8 +153,8 @@ void shouldNotGetConceptThatDNE() { @Test void shouldGetMetaForMultipleConcepts() { List concepts = List.of( - new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "", "", "phs000007", "", true, null, null, Map.of()), - new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "", "", "phs000007", "", true, null, null, Map.of()) + new ContinuousConcept("\\phs000007\\pht000022\\phv00004260\\FM219\\", "", "", "phs000007", "", true, null, null, "FHS", Map.of()), + new ContinuousConcept("\\phs000007\\pht000033\\phv00008849\\D080\\", "", "", "phs000007", "", true, null, null, "FHS", Map.of()) ); Map> actual = subject.getConceptMetaForConcepts(concepts); @@ -236,7 +236,7 @@ void shouldReturnEmptyForNegativeDepth() { @Test void shouldGetStigmatizingConcept() { Optional actual = subject.getConcept("phs002385", "\\phs002385\\TXNUM\\"); - ContinuousConcept expected = new ContinuousConcept("\\phs002385\\TXNUM\\", "TXNUM", "TXNUM", "phs002385", "Transplant Number", false, 0, 0, Map.of()); + ContinuousConcept expected = new ContinuousConcept("\\phs002385\\TXNUM\\", "TXNUM", "TXNUM", "phs002385", "Transplant Number", false, 0, 0, "HCT_for_SCD", Map.of()); Assertions.assertTrue(actual.isPresent()); Assertions.assertEquals(expected, actual.get()); diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceIntegrationTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceIntegrationTest.java index 36f55d3..915cfae 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceIntegrationTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceIntegrationTest.java @@ -48,14 +48,14 @@ void shouldGetDetails() { CategoricalConcept table = new CategoricalConcept( "\\phs000007\\pht000021\\", "pht000021", "ex0_19s", "phs000007", "Clinic Exam, Original Cohort Exam 19", - List.of(), true, null, Map.of("description", "Clinic Exam, Original Cohort Exam 19"), null, null + List.of(), true, "FHS", null, Map.of("description", "Clinic Exam, Original Cohort Exam 19"), null, null ); CategoricalConcept study = new CategoricalConcept( - "\\phs000007\\", "", "", "phs000007", null, List.of(), true, null, Map.of(), null, null + "\\phs000007\\", "", "", "phs000007", null, List.of(), true, "FHS", null, Map.of(), null, null ); ContinuousConcept expected = new ContinuousConcept( "\\phs000007\\pht000021\\phv00003844\\FL200\\", "phv00003844", "FL200", "phs000007", - "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, + "# 12 OZ CUPS OF CAFFEINATED COLA / DAY", true, 0, 3, "FHS", Map.of( "unique_identifier", "no", "stigmatizing", "no", diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceTest.java index 81fceff..b8865a3 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/ConceptServiceTest.java @@ -33,7 +33,7 @@ class ConceptServiceTest { @Test void shouldListConcepts() { List expected = List.of( - new CategoricalConcept("A", "a", "A", "invalid.invalid", null, List.of(), true, null, null) + new CategoricalConcept("A", "a", "A", "invalid.invalid", null, List.of(), true, "", null, null) ); Filter filter = new Filter(List.of(), "", List.of()); Pageable page = Pageable.ofSize(10).first(); @@ -58,7 +58,7 @@ void shouldCountConcepts() { @Test void shouldShowDetailForContinuous() { - ContinuousConcept concept = new ContinuousConcept("path", "", "", "dataset", null, true, 0, 1, null); + ContinuousConcept concept = new ContinuousConcept("path", "", "", "dataset", null, true, 0, 1, "", null); Map meta = Map.of("MIN", "0", "MAX", "1", "stigmatizing", "true"); Mockito.when(repository.getConcept("dataset", "path")) .thenReturn(Optional.of(concept)); @@ -75,7 +75,7 @@ void shouldShowDetailForContinuous() { @Test void shouldShowDetailForCategorical() { - CategoricalConcept concept = new CategoricalConcept("path", "", "", "dataset", null, List.of("a"), true, List.of(), null); + CategoricalConcept concept = new CategoricalConcept("path", "", "", "dataset", null, List.of("a"), true, "", List.of(), null); Map meta = Map.of("VALUES", "a", "stigmatizing", "true"); Mockito.when(repository.getConcept("dataset", "path")) .thenReturn(Optional.of(concept)); @@ -93,11 +93,11 @@ void shouldShowDetailForCategorical() { @Test void shouldShowDetailForMultiple() { ConceptShell shellA = new ConceptShell("pathA", "dataset"); - CategoricalConcept conceptA = new CategoricalConcept("pathA", "", "", "dataset", null, List.of("a"), true, List.of(), null); + CategoricalConcept conceptA = new CategoricalConcept("pathA", "", "", "dataset", null, List.of("a"), true, "", List.of(), null); Map metaA = Map.of("VALUES", "a", "stigmatizing", "true"); ConceptShell shellB = new ConceptShell("pathB", "dataset"); - ContinuousConcept conceptB = new ContinuousConcept("pathB", "", "", "dataset", null, true, 0, 1, null); + ContinuousConcept conceptB = new ContinuousConcept("pathB", "", "", "dataset", null, true, 0, 1, "", null); Map metaB = Map.of("MIN", "0", "MAX", "1", "stigmatizing", "true"); Map> metas = Map.of(shellA, metaA, shellB, metaB); diff --git a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptTest.java b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptTest.java index 5ce368d..c4121e4 100644 --- a/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptTest.java +++ b/src/test/java/edu/harvard/dbmi/avillach/dictionary/concept/model/ConceptTest.java @@ -14,7 +14,7 @@ class ConceptTest { @Test void shouldRoundTrip() throws JsonProcessingException { - Concept expected = new CategoricalConcept("/foo//bar", "bar", "Bar", "study_a", null, List.of("a", "b"), true, List.of(), Map.of()); + Concept expected = new CategoricalConcept("/foo//bar", "bar", "Bar", "study_a", null, List.of("a", "b"), true, "", List.of(), Map.of()); String json = objectMapper.writeValueAsString(expected); Concept actual = objectMapper.readValue(json, Concept.class); @@ -37,7 +37,7 @@ void shouldReadCategorical() throws JsonProcessingException { } """; - CategoricalConcept expected = new CategoricalConcept("/foo//bar", "bar", "Bar", "study_a", null, List.of("a", "b"), true, null, Map.of()); + CategoricalConcept expected = new CategoricalConcept("/foo//bar", "bar", "Bar", "study_a", null, List.of("a", "b"), true, "", null, Map.of()); Concept actual = new ObjectMapper().readValue(json, Concept.class); Assertions.assertEquals(expected, actual); @@ -60,7 +60,7 @@ void shouldReadContinuous() throws JsonProcessingException { } """; - ContinuousConcept expected = new ContinuousConcept("/foo//baz", "baz", "Baz", "study_a", null, true, 0, 1, Map.of()); + ContinuousConcept expected = new ContinuousConcept("/foo//baz", "baz", "Baz", "study_a", null, true, 0, 1, "", Map.of()); Concept actual = new ObjectMapper().readValue(json, Concept.class); Assertions.assertEquals(expected, actual); @@ -70,12 +70,12 @@ void shouldReadContinuous() throws JsonProcessingException { @Test void shouldIncludeTypeInList() throws JsonProcessingException { List concepts = List.of( - new ContinuousConcept("/foo//baz", "baz", "Baz", "study_a", null, true, 0, 1, Map.of()), - new CategoricalConcept("/foo//bar", "bar", "Bar", "study_a", null, List.of("a", "b"), true, null, Map.of()) + new ContinuousConcept("/foo//baz", "baz", "Baz", "study_a", null, true, 0, 1, "", Map.of()), + new CategoricalConcept("/foo//bar", "bar", "Bar", "study_a", null, List.of("a", "b"), true, "", null, Map.of()) ); String actual = new ObjectMapper().writeValueAsString(concepts); - String expected = "[{\"conceptPath\":\"/foo//baz\",\"name\":\"baz\",\"display\":\"Baz\",\"dataset\":\"study_a\",\"description\":null,\"allowFiltering\":true,\"min\":0,\"max\":1,\"meta\":{},\"children\":null,\"table\":null,\"study\":null,\"type\":\"Continuous\"},{\"conceptPath\":\"/foo//bar\",\"name\":\"bar\",\"display\":\"Bar\",\"dataset\":\"study_a\",\"description\":null,\"values\":[\"a\",\"b\"],\"allowFiltering\":true,\"children\":null,\"meta\":{},\"table\":null,\"study\":null,\"type\":\"Categorical\"}]"; + String expected = "[{\"conceptPath\":\"/foo//baz\",\"name\":\"baz\",\"display\":\"Baz\",\"dataset\":\"study_a\",\"description\":null,\"allowFiltering\":true,\"min\":0,\"max\":1,\"studyAcronym\":\"\",\"meta\":{},\"children\":null,\"table\":null,\"study\":null,\"type\":\"Continuous\"},{\"conceptPath\":\"/foo//bar\",\"name\":\"bar\",\"display\":\"Bar\",\"dataset\":\"study_a\",\"description\":null,\"values\":[\"a\",\"b\"],\"allowFiltering\":true,\"studyAcronym\":\"\",\"children\":null,\"meta\":{},\"table\":null,\"study\":null,\"type\":\"Categorical\"}]"; Assertions.assertEquals(expected, actual); }