GenomicDataInfrastructure / gdi-userportal-dataset-discovery-service

0 stars 1 forks source link

Feat: alphanumeric + variant filters #133

Closed admy7 closed 1 month ago

admy7 commented 1 month ago

Summary by Sourcery

Implement alphanumeric filters to enhance dataset querying capabilities, refactor the facet system to a filter-based approach, and update tests and documentation accordingly.

New Features:

Enhancements:

Tests:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request implements significant changes to the filtering and facet handling in the discovery service, transitioning from a facet-based approach to a more flexible filter-based system. The changes include updates to the API, data models, and the introduction of new strategies for handling different types of filters, particularly for Beacon integration.

Sequence diagram for filter retrieval process

sequenceDiagram
    actor User
    participant Client
    participant FilterController
    participant RetrieveFiltersQuery
    participant FilterBuilder
    User->>Client: Request filters
    Client->>FilterController: GET /api/v1/filters
    FilterController->>RetrieveFiltersQuery: execute(accessToken)
    RetrieveFiltersQuery->>FilterBuilder: build(accessToken)
    FilterBuilder-->>RetrieveFiltersQuery: List of Filters
    RetrieveFiltersQuery-->>FilterController: List of Filters
    FilterController-->>Client: Response with Filters
    Client-->>User: Display Filters

ER diagram for updated filter data model

erDiagram
    DATASET_SEARCH_QUERY_FACET {
        STRING source
        STRING type
        STRING key
        STRING value
        STRING operator
        STRING entries
    }
    FILTER {
        STRING source
        STRING type
        STRING key
        STRING label
        STRING values
        STRING operators
        STRING entries
    }
    DATASET_SEARCH_QUERY_FACET ||--o{ FILTER : "maps to"
    FILTER ||--o{ VALUE_LABEL : "has"
    FILTER ||--o{ FILTER_ENTRY : "has"
    VALUE_LABEL {
        STRING label
        STRING value
    }
    FILTER_ENTRY {
        STRING id
        STRING label
    }

Updated class diagram for filter handling

classDiagram
    class DatasetSearchQueryFacet {
        - String source
        - FilterType type
        - String key
        - String value
        - Operator operator
        - List~QueryEntry~ entries
    }
    class FilterType {
        <<enumeration>>
        DROPDOWN
        FREE_TEXT
        ENTRIES
    }
    class Operator {
        <<enumeration>>
        EQUALS
        GREATER_THAN
        LESS_THAN
        DIFFERENT
        CONTAINS
    }
    class QueryEntry {
        - String label
        - String value
    }
    class Filter {
        - String source
        - FilterType type
        - String key
        - String label
        - List~ValueLabel~ values
        - List~Operator~ operators
        - List~FilterEntry~ entries
    }
    class ValueLabel {
        - String label
        - String value
    }
    class FilterEntry {
        - String id
        - String label
    }
    DatasetSearchQueryFacet --> FilterType
    DatasetSearchQueryFacet --> Operator
    DatasetSearchQueryFacet --> QueryEntry
    Filter --> FilterType
    Filter --> ValueLabel
    Filter --> Operator
    Filter --> FilterEntry

File-Level Changes

Change Details Files
Renamed and restructured facet-related components to filter-related components
  • Renamed 'Facet' to 'Filter' in various classes and interfaces
  • Updated API endpoints from '/search-facets' to '/filters'
  • Refactored 'FacetsBuilder' interface to 'FilterBuilder'
  • Renamed 'RetrieveFacetsQuery' to 'RetrieveFiltersQuery'
src/main/openapi/discovery.yaml
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/application/ports/FilterBuilder.java
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/application/usecases/RetrieveFiltersQuery.java
Introduced new filter types and strategies for Beacon integration
  • Created 'FilterType' enum with DROPDOWN, FREE_TEXT, and ENTRIES types
  • Implemented 'OntologyFilterStrategy' for handling ontology-based filters
  • Implemented 'AlphanumericFilterStrategy' for free-text filters
  • Implemented 'VariantFilterStrategy' for handling genetic variant filters
  • Created 'FilterStrategyContext' to manage different filter strategies
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/beacon/strategies/OntologyFilterStrategy.java
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/beacon/strategies/AlphanumericFilterStrategy.java
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/beacon/strategies/VariantFilterStrategy.java
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/beacon/strategies/FilterStrategyContext.java
Updated Beacon integration to support new filter system
  • Refactored 'BeaconIndividualsRequestMapper' to handle new filter types
  • Updated 'BeaconFilterBuilder' to use new filter strategies
  • Modified Beacon API models to support new filter structure
src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/beacon/persistence/BeaconIndividualsRequestMapper.java
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/beacon/BeaconFilterBuilder.java
src/main/openapi/beacon.yaml
Updated CKAN integration to support new filter system
  • Refactored 'CkanFacetsQueryBuilder' to 'CkanFilterBuilder'
  • Updated CKAN-related classes to use new filter structure
src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/ckan/CkanFilterBuilder.java
src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/persistence/CkanFacetsQueryBuilder.java
Updated and added tests for new filter system
  • Renamed and updated existing facet-related tests to filter-related tests
  • Added new tests for filter strategies and builders
  • Updated integration tests to reflect new API structure
src/test/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/quarkus/RetrieveFiltersTest.java
src/test/java/io/github/genomicdatainfrastructure/discovery/filters/application/usecases/RetrieveFiltersQueryTest.java
src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/CkanFacetsQueryBuilderTest.java

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
brunopacheco1 commented 1 month ago

@admy7 thanks for you patience. Let's wait the frontend change a bit and merge both at the same time.