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-3801 publication filtering by reference data code values #127

Merged
merged 3 commits into from
Apr 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
Original file line number Diff line number Diff line change
Expand Up @@ -231,18 +231,22 @@ private static IEnumerable<Func<QueryContainerDescriptor<Publication>, QueryCont
.Value(parameters.AuthorOrcId)));
}

if (parameters.TypeCode is not null)
// Searching with type code requires exact match.
if (!string.IsNullOrWhiteSpace(parameters.TypeCode))
{
filters.Add(t =>
t.Term(s => s.Field(f => f.Type)
.Value(parameters.TypeCode)));
filters.Add(t => t.Term(term => term
.Field(f => f.Type!.Code)
.Value(parameters.TypeCode)
));
}

if (parameters.PublisherOpenAccess is not null)

// Searching with publisher open access code requires exact match.
if (!string.IsNullOrWhiteSpace(parameters.PublisherOpenAccess))
{
filters.Add(t =>
t.Term(s => s.Field(f => f.PublisherOpenAccess)
.Value(parameters.PublisherOpenAccess)));
filters.Add(t => t.Term(term => term
.Field(f => f.PublisherOpenAccess!.Code)
.Value(parameters.PublisherOpenAccess)
));
}

if (parameters.Issn is not null)
Expand Down Expand Up @@ -274,11 +278,13 @@ private static IEnumerable<Func<QueryContainerDescriptor<Publication>, QueryCont
.Value(parameters.Doi)));
}

if (parameters.Status is not null)
// Searching with status requires exact match.
if (!string.IsNullOrWhiteSpace(parameters.Status))
{
filters.Add(t =>
t.Term(s => s.Field(f => f.Status)
.Value(parameters.Status)));
filters.Add(t => t.Term(term => term
.Field(f => f.Status!.Code)
.Value(parameters.Status)
));
}

return filters;
Expand Down
2 changes: 1 addition & 1 deletion aspnetcore/src/Interface/Maps/PublicationProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public PublicationProfile()
AllowNullDestinationValues = true;

CreateMap<GetPublicationsQueryParameters, PublicationSearchParameters>()
.ForMember(dst => dst.TypeCode, opt => opt.MapFrom(src => src.Type!.ToLower()));
.ForMember(dst => dst.TypeCode, opt => opt.MapFrom(src => src.Type!));

CreateMap<Service.Models.Publication.Publication, Publication>()
.ForMember(dst => dst.PublicationYear, opt => opt.MapFrom(src => src.PublicationYear.HasValue ? src.PublicationYear.Value.ToString(DateTimeYearFormat) : null))
Expand Down
1 change: 0 additions & 1 deletion aspnetcore/src/Service.Models/ReferenceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public class ReferenceData
{
[Keyword]
public string? Code { get; set; }

public string? NameFi { get; set; }
public string? NameSv { get; set; }
public string? NameEn { get; set; }
Expand Down
Loading