From 694b25c999074b1034800c56892d552cec70d6c6 Mon Sep 17 00:00:00 2001 From: Serafeim Chatzopoulos Date: Wed, 12 Jun 2024 19:03:45 +0300 Subject: [PATCH] Add relHostingDataSourceId filter for research products --- .../eu/openaire/api/dto/request/ResearchProductsRequest.java | 3 +++ .../api/mappers/query/ResearchProductsRequestMapper.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java b/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java index 0667af2..48ebed7 100644 --- a/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java +++ b/src/main/java/eu/openaire/api/dto/request/ResearchProductsRequest.java @@ -130,6 +130,9 @@ public class ResearchProductsRequest { @Parameter(description = "Retrieve research products connected to a project that has the given funding identifier", array = @ArraySchema(schema = @Schema(type = "string"))) private String[] relProjectFundingStreamId; + @Parameter(description = "Retrieve research products hosted by the data source (with OpenAIRE id)", array = @ArraySchema(schema = @Schema(type = "string"))) + private String[] relHostingDataSourceId; + @Min(value = 1) @Parameter(description = "Page number of the results", schema = @Schema(defaultValue = "1", type = "integer")) private int page = 1; diff --git a/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java b/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java index 7271b50..16c223d 100644 --- a/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java +++ b/src/main/java/eu/openaire/api/mappers/query/ResearchProductsRequestMapper.java @@ -54,6 +54,7 @@ public interface ResearchProductsRequestMapper { Map.entry("hasProjectRel", "relprojectid:[* TO *]"), Map.entry("relProjectFundingShortName", "relfundershortname:(%s)"), Map.entry("relProjectFundingStreamId", "relfundinglevel0_name:(%s) OR relfundinglevel1_name:(%s) OR relfundinglevel2_name:(%s)"), + Map.entry("relHostingDataSourceId", "resulthostingdatasourceid:(%s)"), // only for publications Map.entry("instanceType", "instancetypename:(%s)"), @@ -193,6 +194,10 @@ public interface ResearchProductsRequestMapper { fqList.add(String.format(solrFieldMapping.get("relProjectFundingStreamId"), relProjectFundingStreamId, relProjectFundingStreamId, relProjectFundingStreamId)); } + if (!Utils.isNullOrEmpty(src.getRelHostingDataSourceId())) { + fqList.add(String.format(solrFieldMapping.get("relHostingDataSourceId"), Utils.escapeAndJoin(src.getRelHostingDataSourceId(), "OR", false))); + } + // Only for publications if (!Utils.isNullOrEmpty(src.getInstanceType())) { fqList.add(String.format(solrFieldMapping.get("instanceType"), Utils.escapeAndJoin(src.getInstanceType(), "OR", false)));