diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/utils/CkanQueryOperatorMapper.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/utils/CkanQueryOperatorMapper.java index a46b271..106a612 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/utils/CkanQueryOperatorMapper.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/utils/CkanQueryOperatorMapper.java @@ -4,7 +4,7 @@ package io.github.genomicdatainfrastructure.discovery.datasets.infrastructure.ckan.utils; -import io.github.genomicdatainfrastructure.discovery.model.DatasetSearchQuery; +import io.github.genomicdatainfrastructure.discovery.model.QueryOperator; import lombok.experimental.UtilityClass; @UtilityClass @@ -13,7 +13,7 @@ public class CkanQueryOperatorMapper { private final String AND = " AND "; private final String OR = " OR "; - public String getOperator(DatasetSearchQuery.OperatorEnum operator) { - return DatasetSearchQuery.OperatorEnum.AND.equals(operator) ? AND : OR; + public String getOperator(QueryOperator operator) { + return QueryOperator.AND.equals(operator) ? AND : OR; } } diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/ckan/CkanFiltersRepository.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/ckan/CkanFiltersRepository.java index 224e3f6..341f22f 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/ckan/CkanFiltersRepository.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/filters/infrastructure/ckan/CkanFiltersRepository.java @@ -1,22 +1,18 @@ // SPDX-FileCopyrightText: 2024 PNED G.I.E. // // SPDX-License-Identifier: Apache-2.0 + package io.github.genomicdatainfrastructure.discovery.filters.infrastructure.ckan; import io.github.genomicdatainfrastructure.discovery.filters.application.ports.FiltersRepository; import io.github.genomicdatainfrastructure.discovery.filters.infrastructure.mapper.CkanFilterMapper; import io.github.genomicdatainfrastructure.discovery.model.ValueLabel; import io.github.genomicdatainfrastructure.discovery.remote.ckan.api.CkanQueryApi; -import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.CkanFacet; import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.PackageSearchRequest; -import io.github.genomicdatainfrastructure.discovery.remote.ckan.model.PackagesSearchResult; import jakarta.enterprise.context.ApplicationScoped; import org.eclipse.microprofile.rest.client.inject.RestClient; import java.util.List; -import java.util.Map; - -import static java.util.Optional.ofNullable; @ApplicationScoped public class CkanFiltersRepository implements FiltersRepository { diff --git a/src/main/openapi/discovery.yaml b/src/main/openapi/discovery.yaml index e1dc3d3..0398c56 100644 --- a/src/main/openapi/discovery.yaml +++ b/src/main/openapi/discovery.yaml @@ -203,9 +203,7 @@ components: operator: title: Ckan query operator type: string - enum: - - AND - - OR + $ref: "#/components/schemas/QueryOperator" default: OR DatasetSearchQueryFacet: type: object @@ -226,7 +224,7 @@ components: entries: type: array items: - $ref: '#/components/schemas/QueryEntry' + $ref: "#/components/schemas/QueryEntry" required: - source - type @@ -258,6 +256,15 @@ components: value: type: string title: value + required: + - key + - value + QueryOperator: + type: string + enum: + - OR + - AND + title: Query operator SearchedDataset: type: object properties: @@ -308,8 +315,6 @@ components: - id - title - description - - catalogue - - modifiedAt DatasetsSearchResponse: type: object properties: @@ -407,8 +412,6 @@ components: - id - title - description - - catalogue - - createdAt RetrievedDistribution: type: object properties: @@ -445,7 +448,6 @@ components: - id - title - description - - createdAt ValueLabel: properties: value: @@ -471,9 +473,6 @@ components: uri: type: string title: uri - identifier: - type: string - title: identifier required: - name - email @@ -494,9 +493,6 @@ components: identifier: type: string title: identifier - uri: - type: string - title: uri required: - name DatasetRelationEntry: @@ -555,6 +551,11 @@ components: items: $ref: "#/components/schemas/FilterEntry" title: entries + required: + - source + - type + - key + - label FilterEntry: properties: key: @@ -563,6 +564,9 @@ components: label: type: string title: label + required: + - key + - label ErrorResponse: properties: title: @@ -574,3 +578,6 @@ components: detail: type: string title: Error detail + required: + - title + - status diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/CkanFacetsQueryBuilderTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/CkanFacetsQueryBuilderTest.java index f71b5fa..ca9613e 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/CkanFacetsQueryBuilderTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/CkanFacetsQueryBuilderTest.java @@ -7,6 +7,7 @@ import io.github.genomicdatainfrastructure.discovery.model.DatasetSearchQuery; import io.github.genomicdatainfrastructure.discovery.datasets.infrastructure.ckan.persistence.CkanFacetsQueryBuilder; import io.github.genomicdatainfrastructure.discovery.model.FilterType; +import io.github.genomicdatainfrastructure.discovery.model.QueryOperator; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.NullSource; @@ -100,7 +101,7 @@ void canParse_withAndOperator(String value) { var query = new DatasetSearchQuery(); query.setFacets(facets); - query.setOperator(DatasetSearchQuery.OperatorEnum.AND); + query.setOperator(QueryOperator.AND); var expected = "field1:(\"value1\" AND \"value2\") AND field2:(\"value3\")"; var actual = CkanFacetsQueryBuilder.buildFacetQuery(query); @@ -169,7 +170,7 @@ void canParse_withOrOperator(String value) { var query = new DatasetSearchQuery(); query.setFacets(facets); - query.setOperator(DatasetSearchQuery.OperatorEnum.OR); + query.setOperator(QueryOperator.OR); var expected = "field1:(\"value1\" OR \"value2\") AND field2:(\"value3\")"; var actual = CkanFacetsQueryBuilder.buildFacetQuery(query); diff --git a/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/mapper/CkanDatasetsMapperTest.java b/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/mapper/CkanDatasetsMapperTest.java index 183aff1..2d97e64 100644 --- a/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/mapper/CkanDatasetsMapperTest.java +++ b/src/test/java/io/github/genomicdatainfrastructure/discovery/datasets/infrastructure/ckan/mapper/CkanDatasetsMapperTest.java @@ -87,7 +87,6 @@ void given_ckanPackage_should_be_mapped_to_expected_values() { .email("email") .url("url") .type("type") - .uri("uri") .build(), Agent.builder() .name("creatorName2") @@ -95,7 +94,6 @@ void given_ckanPackage_should_be_mapped_to_expected_values() { .email("email2") .url("url2") .type("type2") - .uri("uri2") .build() )) .publishers(List.of( @@ -105,7 +103,6 @@ void given_ckanPackage_should_be_mapped_to_expected_values() { .email("email") .url("url") .type("type") - .uri("uri") .build(), Agent.builder() .name("publisherName2") @@ -113,7 +110,6 @@ void given_ckanPackage_should_be_mapped_to_expected_values() { .email("email2") .url("url2") .type("type2") - .uri("uri2") .build() )) .accessRights(ValueLabel.builder() @@ -157,13 +153,11 @@ void given_ckanPackage_should_be_mapped_to_expected_values() { ContactPoint.builder() .name("Contact 1") .email("contact1@example.com") - .identifier("contact-identifier-1") .build(), ContactPoint.builder() .name("Contact 2") .email("contact2@example.com") .uri("http://example.com") - .identifier("contact-identifier-2") .build() )) .datasetRelationships(List.of( @@ -309,7 +303,6 @@ private static SearchedDataset buildSearchedDataset() { .email("email") .url("url") .identifier("publisherIdentifier") - .uri("uri") .type("type") .build(), Agent.builder() @@ -317,7 +310,6 @@ private static SearchedDataset buildSearchedDataset() { .email("email2") .url("url2") .identifier("publisherIdentifier2") - .uri("uri2") .type("type2") .build())) .themes(List.of(ValueLabel.builder()