Skip to content

Commit

Permalink
fix: review comments and int test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sulejman Karisik authored and Sulejman Karisik committed Apr 17, 2024
1 parent dbe6377 commit 06aa887
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ public DatasetsSearchResponse search(DatasetSearchQuery query, String accessToke
return datasetsSearchService.search(query, accessToken);
}

var resultsets = queryOnBeaconIfThereAreBeaconFilters(beaconAuthorization, query);
var resultSets = queryOnBeaconIfThereAreBeaconFilters(beaconAuthorization, query);

var datasetsSearchResponse = queryOnCkanIfThereIsNoBeaconFilterOrResultsetsIsNotEmpty(
accessToken,
query,
resultsets
resultSets
);

return enhanceDatasetsResponse(beaconAuthorization, datasetsSearchResponse, resultsets);
return enhanceDatasetsResponse(beaconAuthorization, datasetsSearchResponse, resultSets);
}

private String retrieveBeaconAuthorization(String accessToken) {
Expand Down Expand Up @@ -174,38 +174,38 @@ private DatasetSearchQuery enhanceQueryFacets(

private DatasetsSearchResponse enhanceDatasetsResponse(
String beaconAuthorization,
DatasetsSearchResponse datasetsSearchReponse,
DatasetsSearchResponse datasetsSearchResponse,
List<BeaconResultSet> resultSets
) {
var facetGroupCount = new HashMap<String, Integer>();
facetGroupCount.put(BEACON_FACET_GROUP, resultSets.size());
if (isNotEmpty(datasetsSearchReponse.getFacetGroupCount())) {
facetGroupCount.putAll(datasetsSearchReponse.getFacetGroupCount());
if (isNotEmpty(datasetsSearchResponse.getFacetGroupCount())) {
facetGroupCount.putAll(datasetsSearchResponse.getFacetGroupCount());
}

var facetGroups = new ArrayList<FacetGroup>();
facetGroups.add(beaconFilteringTermsService.listFilteringTerms(beaconAuthorization));
if (isNotEmpty(datasetsSearchReponse.getFacetGroups())) {
facetGroups.addAll(datasetsSearchReponse.getFacetGroups());
if (isNotEmpty(datasetsSearchResponse.getFacetGroups())) {
facetGroups.addAll(datasetsSearchResponse.getFacetGroups());
}

var results = List.<SearchedDataset>of();
if (isNotEmpty(datasetsSearchReponse.getResults())) {
if (isNotEmpty(datasetsSearchResponse.getResults())) {
var recordCounts = resultSets.stream()
.collect(toMap(
BeaconResultSet::getId,
BeaconResultSet::getResultsCount
));

results = datasetsSearchReponse.getResults()
results = datasetsSearchResponse.getResults()
.stream()
.map(it -> it.toBuilder()
.recordsCount(recordCounts.get(it.getIdentifier()))
.build())
.toList();
}

return datasetsSearchReponse.toBuilder()
return datasetsSearchResponse.toBuilder()
.facetGroupCount(facetGroupCount)
.facetGroups(facetGroups)
.results(results)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public RetrievedDataset from(CkanPackage ckanPackage) {
.accessRights(value(ckanPackage.getAccessRights()))
.conformsTo(values(ckanPackage.getConformsTo()))
.provenance(ckanPackage.getProvenance())
.spatial(value(ckanPackage.getSpatial()))
.spatial(value(ckanPackage.getSpatialUri()))
.distributions(distributions(ckanPackage))
.keywords(keywords(ckanPackage))
.build();
Expand Down
2 changes: 1 addition & 1 deletion src/main/openapi/ckan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ components:
$ref: "#/components/schemas/CkanValueLabel"
provenance:
type: string
spatial:
spatial_uri:
$ref: "#/components/schemas/CkanValueLabel"
resources:
type: array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void can_search_datasets_with_beacon_filters() {
.post("/api/v1/datasets/search")
.then()
.statusCode(200)
.body("count", equalTo(1))
.body("count", equalTo(1167))
.body("results[0].recordsCount", equalTo(64));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void can_parse() {
.name("conforms")
.build()))
.provenance("provenance")
.spatial(CkanValueLabel.builder()
.spatialUri(CkanValueLabel.builder()
.displayName("spatial")
.name("uri")
.build())
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/mappings/package_search.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
],
"creator_user_id": "f2687934-1127-4c61-ab21-982cb91d7c80",
"id": "0ddd7a13-ee11-4e5d-bbff-34e04a6a7949",
"identifier": "brainmriwml_vu",
"identifier": "27866022694497975",
"isopen": false,
"language": [
{
Expand Down

0 comments on commit 06aa887

Please sign in to comment.