diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/applications/ports/DatasetsRepository.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/applications/ports/DatasetsRepository.java index 28175aa..54648ec 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/applications/ports/DatasetsRepository.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/applications/ports/DatasetsRepository.java @@ -11,6 +11,7 @@ public interface DatasetsRepository { List search(List datasetIds, + String returnFields, String sort, Integer rows, Integer start, diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/config/CkanConfiguration.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/config/CkanConfiguration.java new file mode 100644 index 0000000..f6347bb --- /dev/null +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/config/CkanConfiguration.java @@ -0,0 +1,8 @@ +package io.github.genomicdatainfrastructure.discovery.datasets.infra.ckan.config; + +public class CkanConfiguration { + public static final String CKAN_IDENTIFIER_FIELD = "identifier"; + public static final String CKAN_FACET_GROUP = "ckan"; + public static final String CKAN_FACET_LABEL = "DCAT-AP"; + public static final String SELECTED_FACETS = "[\"access_rights\",\"theme\",\"tags\",\"spatial_uri\",\"organization\",\"publisher_name\",\"res_format\"]"; +} diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetIdsCollector.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetIdsCollector.java index e528c40..87f1f7f 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetIdsCollector.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetIdsCollector.java @@ -15,6 +15,8 @@ import java.util.List; +import static io.github.genomicdatainfrastructure.discovery.datasets.infra.ckan.config.CkanConfiguration.CKAN_IDENTIFIER_FIELD; + @ApplicationScoped public class CkanDatasetIdsCollector implements DatasetIdsCollector { @@ -34,10 +36,11 @@ public List collect(DatasetSearchQuery query, String accessToken) { var response = ckanQueryApi.packageSearch( query.getQuery(), facetsQuery, - null, - null, - null, - null, + CKAN_IDENTIFIER_FIELD, + "", + 1000, + 0, + "", accessToken ); diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetsRepository.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetsRepository.java index f742932..7b089cc 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetsRepository.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanDatasetsRepository.java @@ -23,13 +23,13 @@ import java.util.List; import java.util.Objects; +import static io.github.genomicdatainfrastructure.discovery.datasets.infra.ckan.config.CkanConfiguration.CKAN_FACET_GROUP; +import static io.github.genomicdatainfrastructure.discovery.datasets.infra.ckan.config.CkanConfiguration.CKAN_IDENTIFIER_FIELD; import static java.util.Optional.ofNullable; @ApplicationScoped public class CkanDatasetsRepository implements DatasetsRepository { - private static final String CKAN_IDENTIFIER_FIELD = "identifier"; - private static final String CKAN_FACET_GROUP = "ckan"; private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern( "yyyy-MM-dd'T'HH:mm:ss.SSSSSS" ); @@ -45,6 +45,7 @@ public CkanDatasetsRepository( @Override public List search(List datasetIds, + String returnFields, String sort, Integer rows, Integer start, @@ -72,10 +73,11 @@ public List search(List datasetIds, var response = ckanQueryApi.packageSearch( "", facetsQuery, + returnFields, sort, rows, start, - null, + "", accessToken ); diff --git a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanFacetsBuilder.java b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanFacetsBuilder.java index 190a818..f452612 100644 --- a/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanFacetsBuilder.java +++ b/src/main/java/io/github/genomicdatainfrastructure/discovery/datasets/infra/ckan/persistence/CkanFacetsBuilder.java @@ -15,13 +15,12 @@ import java.util.List; import java.util.Map; +import static io.github.genomicdatainfrastructure.discovery.datasets.infra.ckan.config.CkanConfiguration.*; import static java.util.Optional.ofNullable; @ApplicationScoped public class CkanFacetsBuilder implements FacetsBuilder { - private static final String CKAN_FACET_GROUP = "ckan"; - private static final String SELECTED_FACETS = "[\"access_rights\",\"theme\",\"tags\",\"spatial_uri\",\"organization\",\"publisher_name\",\"res_format\"]"; private final CkanQueryApi ckanQueryApi; @@ -36,9 +35,10 @@ public FacetGroup build(DatasetSearchQuery query, String accessToken) { var response = ckanQueryApi.packageSearch( query.getQuery(), facetsQuery, + query.getFl(), query.getSort(), 0, - 0, + query.getStart(), SELECTED_FACETS, accessToken ); @@ -53,7 +53,7 @@ public FacetGroup build(DatasetSearchQuery query, String accessToken) { private FacetGroup facetGroup(Map facets) { return FacetGroup.builder() .key(CKAN_FACET_GROUP) - .label("DCAT-AP") + .label(CKAN_FACET_LABEL) .facets(facets.entrySet().stream() .map(this::facet) .toList()) diff --git a/src/main/openapi/ckan.yaml b/src/main/openapi/ckan.yaml index ac47439..0ad383b 100644 --- a/src/main/openapi/ckan.yaml +++ b/src/main/openapi/ckan.yaml @@ -30,6 +30,12 @@ paths: required: false schema: type: string + - name: fl + in: query + description: dataset fields to be returned + required: false + schema: + type: string - name: sort in: query description: Sorting of search results diff --git a/src/main/openapi/discovery.yaml b/src/main/openapi/discovery.yaml index 2643d2c..12a0421 100644 --- a/src/main/openapi/discovery.yaml +++ b/src/main/openapi/discovery.yaml @@ -166,6 +166,10 @@ components: title: Facets items: $ref: "#/components/schemas/DatasetSearchQueryFacet" + returnFields: + type: string + title: dataset fields to return + default: "*" sort: type: string title: Sorting of search results