Skip to content

Commit

Permalink
Merge pull request #117 from CSCfi/qa
Browse files Browse the repository at this point in the history
CSCTTV-3715 originalPublicationId
  • Loading branch information
sarkikos authored Feb 14, 2024
2 parents d67c0a1 + 35df308 commit 237214f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
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

0 comments on commit 237214f

Please sign in to comment.