Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSCTTV-3715-originalPublicationId #116

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aspnetcore/src/ApiModels/Publication/Publication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class Publication
/// Publication ID
/// </summary>
public string? Id { get; set; }

/// <summary>
/// Julkaisun organisaatiotunnus
/// </summary>
public string? OriginalPublicationId { get; set; }

/// <summary>
/// Name of the publication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public class GetPublicationsQueryParameters : PaginationQueryParameters
/// <see cref="Publication.Name"/>
public string? Name { get; set; }

/// <summary>
/// The field originalPublicationId is exactly equal to the text.
/// </summary>
/// <see cref="Publication.OriginalPublicationId"/>
public string? OriginalPublicationId { get; set; }

/// <summary>
/// The field publicationYear is exactly equal to the text.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ private static IEnumerable<Func<QueryContainerDescriptor<Publication>, 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))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class PublicationSearchParameters
{
public string? OriginalPublicationId { get; set; }

public string? Name { get; set; }

public string? PublicationYear { get; set; }
Expand Down
1 change: 1 addition & 0 deletions aspnetcore/src/Repositories/Maps/PublicationProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public PublicationProfile()
CreateProjection<DimPublication, Publication>()
.AddTransform<string?>(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)))
Expand Down
6 changes: 6 additions & 0 deletions aspnetcore/src/Service.Models/Publication/Publication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public class Publication
[Keyword]
public string? Id { get; set; }

/// <summary>
/// Julkaisun organisaatiotunnus
/// </summary>
[Keyword]
public string? OriginalPublicationId { get; set; }

/// <summary>
/// Julkaisun nimi
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static DimPublication GetEntity()
{
Id = 1,
PublicationId = "publicationId",
OriginalPublicationId = "abc123",
PublicationName = "nameFi",
PublicationYear = 2021,
ReportingYear = 2022,
Expand Down Expand Up @@ -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),
Expand Down
Loading