From 57d9884e96eb18418463911d8fcd790dd0f8cf0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Sa=CC=88rkikoski?= Date: Thu, 8 Feb 2024 09:22:44 +0200 Subject: [PATCH] CSCTTV-3715-originalPublicationId --- aspnetcore/src/ApiModels/Publication/Publication.cs | 5 +++++ .../src/ApiModels/Query/GetPublicationsQueryParameters.cs | 6 ++++++ .../PublicationQueryGenerator.cs | 7 +++++++ .../SearchParameters/PublicationSearchParameters.cs | 2 ++ aspnetcore/src/Repositories/Maps/PublicationProfile.cs | 1 + aspnetcore/src/Service.Models/Publication/Publication.cs | 6 ++++++ .../test/Indexer.Tests/Maps/PublicationProfileTest.cs | 2 ++ 7 files changed, 29 insertions(+) diff --git a/aspnetcore/src/ApiModels/Publication/Publication.cs b/aspnetcore/src/ApiModels/Publication/Publication.cs index 11b0e13..2410dd7 100644 --- a/aspnetcore/src/ApiModels/Publication/Publication.cs +++ b/aspnetcore/src/ApiModels/Publication/Publication.cs @@ -13,6 +13,11 @@ public class Publication /// Publication ID /// public string? Id { get; set; } + + /// + /// Julkaisun organisaatiotunnus + /// + public string? OriginalPublicationId { get; set; } /// /// Name of the publication diff --git a/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs b/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs index 0be3eed..2bd7eb9 100644 --- a/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs +++ b/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs @@ -14,6 +14,12 @@ public class GetPublicationsQueryParameters : PaginationQueryParameters /// public string? Name { get; set; } + /// + /// The field originalPublicationId is exactly equal to the text. + /// + /// + public string? OriginalPublicationId { get; set; } + /// /// The field publicationYear is exactly equal to the text. /// diff --git a/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs b/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs index dae433e..9336cf6 100644 --- a/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs +++ b/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs @@ -33,6 +33,13 @@ private static IEnumerable, QueryCont t.Match(query => query.Field(f => f.Name) .Query(parameters.Name))); } + + if (!string.IsNullOrWhiteSpace(parameters.OriginalPublicationId)) + { + subQueries.Add(t => + t.Match(query => query.Field(f => f.OriginalPublicationId) + .Query(parameters.OriginalPublicationId))); + } if (!string.IsNullOrWhiteSpace(parameters.AuthorsText)) { diff --git a/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs b/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs index f790625..389d4a0 100644 --- a/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs +++ b/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs @@ -2,6 +2,8 @@ public class PublicationSearchParameters { + public string? OriginalPublicationId { get; set; } + public string? Name { get; set; } public string? PublicationYear { get; set; } diff --git a/aspnetcore/src/Repositories/Maps/PublicationProfile.cs b/aspnetcore/src/Repositories/Maps/PublicationProfile.cs index f98c283..e180455 100644 --- a/aspnetcore/src/Repositories/Maps/PublicationProfile.cs +++ b/aspnetcore/src/Repositories/Maps/PublicationProfile.cs @@ -21,6 +21,7 @@ public PublicationProfile() CreateProjection() .AddTransform(s => string.IsNullOrWhiteSpace(s) ? null : s) .ForMember(dst => dst.Id, opt => opt.MapFrom(src => src.PublicationId)) + .ForMember(dst => dst.OriginalPublicationId, opt => opt.MapFrom(src => src.OriginalPublicationId)) .ForMember(dst => dst.Name, opt => opt.MapFrom(src => src.PublicationName)) .ForMember(dst => dst.PublicationYear, opt => opt.MapFrom(src => (DateTime?)(src.PublicationYear.HasValue ? new DateTime(src.PublicationYear.Value,1,1,0,0,0,DateTimeKind.Utc) : null))) .ForMember(dst => dst.ReportingYear, opt =>opt.MapFrom(src => (DateTime?)(src.ReportingYear.HasValue ? new DateTime(src.ReportingYear.Value,1,1,0,0,0,DateTimeKind.Utc) : null))) diff --git a/aspnetcore/src/Service.Models/Publication/Publication.cs b/aspnetcore/src/Service.Models/Publication/Publication.cs index 31a86a3..9a46d88 100644 --- a/aspnetcore/src/Service.Models/Publication/Publication.cs +++ b/aspnetcore/src/Service.Models/Publication/Publication.cs @@ -13,6 +13,12 @@ public class Publication [Keyword] public string? Id { get; set; } + /// + /// Julkaisun organisaatiotunnus + /// + [Keyword] + public string? OriginalPublicationId { get; set; } + /// /// Julkaisun nimi /// diff --git a/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs b/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs index 12cc341..7350ea9 100644 --- a/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs +++ b/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs @@ -57,6 +57,7 @@ private static DimPublication GetEntity() { Id = 1, PublicationId = "publicationId", + OriginalPublicationId = "abc123", PublicationName = "nameFi", PublicationYear = 2021, ReportingYear = 2022, @@ -295,6 +296,7 @@ private Publication GetModel() return new Publication { Id = "publicationId", + OriginalPublicationId = "abc123", Name = "nameFi", PublicationYear = new DateTime(2021, 1, 1), ReportingYear = new DateTime(2022, 1, 1),