diff --git a/aspnetcore/src/ApiModels/Publication/Publication.cs b/aspnetcore/src/ApiModels/Publication/Publication.cs index 2410dd7..672d454 100644 --- a/aspnetcore/src/ApiModels/Publication/Publication.cs +++ b/aspnetcore/src/ApiModels/Publication/Publication.cs @@ -283,4 +283,14 @@ public class Publication /// Modification time /// public DateTime? Modified { get; set; } + + /// + /// Combined information of co-publications based on national publication data collection + /// + public string? CoPublicationID { get; set; } + + /// + /// Publication information sent by individual organisations related to co-publications as part of national publication data collection + /// + public List? OrgPublicationIDs { get; set; } } \ No newline at end of file diff --git a/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs b/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs index 2bd7eb9..48e46c1 100644 --- a/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs +++ b/aspnetcore/src/ApiModels/Query/GetPublicationsQueryParameters.cs @@ -184,4 +184,16 @@ public class GetPublicationsQueryParameters : PaginationQueryParameters /// /// public string? ModifiedTo { get; set; } + + /// + /// If the selection is true, publication information sent by individual organisations related to co-publications as part of national publication data collection will be returned. Not returned by default. + /// + /// + public bool? ShowOrganisationPartofCoPublication { get; set; } + + /// + /// If the selection is true, combined information of co-publications based on national publication data collection will be filtered out. Returned by default. + /// + /// + public bool? HideCoPublications { get; set; } } \ No newline at end of file diff --git a/aspnetcore/src/ElasticService/ElasticSearchExtensions.cs b/aspnetcore/src/ElasticService/ElasticSearchExtensions.cs index 72780da..34d954b 100644 --- a/aspnetcore/src/ElasticService/ElasticSearchExtensions.cs +++ b/aspnetcore/src/ElasticService/ElasticSearchExtensions.cs @@ -36,8 +36,10 @@ private static ConnectionSettings GetConnectionSettings(IConfiguration configura { var elasticSearchClusterUrl = configuration["ElasticSearch:Url"] ?? throw new InvalidOperationException("ElasticSearch url missing."); + // https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/configuration-options.html var connectionSettings = new ConnectionSettings(new Uri(elasticSearchClusterUrl)) - .DefaultFieldNameInferrer(i => i); // This forces elastic to store .Net objects using type names, instead of camel casing. This enables using nameof when referring to fields. + .DefaultFieldNameInferrer(i => i) // This forces elastic to store .Net objects using type names, instead of camel casing. This enables using nameof when referring to fields. + .MaximumRetries(5); if (Debugger.IsAttached) { diff --git a/aspnetcore/src/ElasticService/ElasticSearchIndexService.cs b/aspnetcore/src/ElasticService/ElasticSearchIndexService.cs index 59a5e9e..d1d0d01 100644 --- a/aspnetcore/src/ElasticService/ElasticSearchIndexService.cs +++ b/aspnetcore/src/ElasticService/ElasticSearchIndexService.cs @@ -8,7 +8,7 @@ public class ElasticSearchIndexService : IElasticSearchIndexService private readonly IElasticClient _elasticClient; private readonly ILogger _logger; - private const int BatchSize = 2000; + private const int BatchSize = 1500; public ElasticSearchIndexService(IElasticClient elasticClient, ILogger logger) { diff --git a/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs b/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs index faa2362..1f7b9a8 100644 --- a/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs +++ b/aspnetcore/src/ElasticService/ElasticSearchQueryGenerators/PublicationQueryGenerator.cs @@ -150,6 +150,20 @@ private static IEnumerable, QueryCont { var filters = new List, QueryContainer>>(); + if (parameters.ShowOrganisationPartofCoPublication is null || (bool)parameters.ShowOrganisationPartofCoPublication == false) + { + filters.Add(t => + t.Term(s => s.Field(f => f.IsOrgPublication) + .Value(false))); + } + + if (parameters.HideCoPublications is not null && (bool)parameters.HideCoPublications == true) + { + filters.Add(t => + t.Term(s => s.Field(f => f.IsCoPublication) + .Value(false))); + } + if (parameters.CreatedFrom is not null) { filters.Add(x => x diff --git a/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs b/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs index 389d4a0..9d5dc8c 100644 --- a/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs +++ b/aspnetcore/src/ElasticService/SearchParameters/PublicationSearchParameters.cs @@ -55,4 +55,8 @@ public class PublicationSearchParameters public string? ModifiedFrom { get; set; } public string? ModifiedTo { get; set; } + + public bool? ShowOrganisationPartofCoPublication { get; set; } + + public bool? HideCoPublications { get; set; } } \ No newline at end of file diff --git a/aspnetcore/src/Indexer/Indexer.cs b/aspnetcore/src/Indexer/Indexer.cs index 26f7e46..5c8ed9c 100644 --- a/aspnetcore/src/Indexer/Indexer.cs +++ b/aspnetcore/src/Indexer/Indexer.cs @@ -148,7 +148,7 @@ private async Task IndexEntities(string indexName, IIndexRepository repository, */ int skipAmount = 0; - int takeAmount = 50000; + int takeAmount = 30000; int numOfResults = 0; int processedCount = 0; diff --git a/aspnetcore/src/Repositories/Maps/PublicationProfile.cs b/aspnetcore/src/Repositories/Maps/PublicationProfile.cs index e180455..7826bbc 100644 --- a/aspnetcore/src/Repositories/Maps/PublicationProfile.cs +++ b/aspnetcore/src/Repositories/Maps/PublicationProfile.cs @@ -28,6 +28,7 @@ public PublicationProfile() .ForMember(dst => dst.ApcPaymentYear, opt =>opt.MapFrom(src => (DateTime?)(src.ApcPaymentYear.HasValue ? new DateTime(src.ApcPaymentYear.Value,1,1,0,0,0,DateTimeKind.Utc) : null))) .ForMember(dst => dst.AuthorsText, opt => opt.MapFrom(src => src.AuthorsText)) .ForMember(dst => dst.DatabaseContributions, opt => opt.MapFrom(src => src.FactContributions)) + .ForMember(dst => dst.OrgPublicationDatabaseContributionDTOs, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation)) .ForMember(dst => dst.Format, opt => opt.MapFrom(src => src.PublicationTypeCode2Navigation)) .ForMember(dst => dst.ParentPublicationType, opt => opt.MapFrom(src => src.ParentPublicationTypeCodeNavigation)) .ForMember(dst => dst.DatabasePeerReviewed, opt => opt.MapFrom(src => src.PeerReviewed)) @@ -55,8 +56,11 @@ public PublicationProfile() .ForMember(dst => dst.Doi, opt => opt.MapFrom(src => src.Doi)) .ForMember(dst => dst.DoiHandle, opt => opt.MapFrom(src => src.DoiHandle)) .ForMember(dst => dst.FieldsOfScience, opt => opt.MapFrom(src => src.FactDimReferencedataFieldOfSciences.Select(f => f.DimReferencedata))) + .ForMember(dst => dst.OrgPublicationFieldsOfScienceDTOs, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation)) .ForMember(dst => dst.FieldsOfArt, opt => opt.MapFrom(src => src.DimReferencedataNavigation)) + .ForMember(dst => dst.OrgPublicationFieldsOfArtDTOs, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation)) .ForMember(dst => dst.Keywords, opt => opt.MapFrom(src => src.DimKeywords)) + .ForMember(dst => dst.OrgPublicationKeywordDTOs, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation)) .ForMember(dst => dst.InternationalPublication, opt => opt.MapFrom(src => src.InternationalPublication != 9 ? src.InternationalPublication == 1 : (bool?)null)) // 0 = kotim. 1 ulkom. 9 = ei tietoa. .ForMember(dst => dst.Country, opt => opt.MapFrom(src => src.PublicationCountryCodeNavigation)) .ForMember(dst => dst.Language, opt => opt.MapFrom(src => src.LanguageCodeNavigation)) @@ -69,6 +73,7 @@ public PublicationProfile() .ForMember(dst => dst.Preprint, opt => opt.MapFrom(src => src.DimLocallyReportedPubInfos.Where(i => i.SelfArchivedType == PreprintType))) .ForMember(dst => dst.SelfArchived, opt => opt.MapFrom(src => src.DimLocallyReportedPubInfos.Where(i => i.SelfArchivedType == SelfArchivedType))) .ForMember(dst => dst.ArtPublicationTypeCategory, opt => opt.MapFrom(src => src.DimReferencedata)) + .ForMember(dst => dst.OrgPublicationArtPublicatonTypeCategoryDTOs, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation)) .ForMember(dst => dst.Abstract, opt => opt.MapFrom(src => src.Abstract)) .ForMember(dst => dst.Created, opt => opt.MapFrom(src => src.Created)) .ForMember(dst => dst.Modified, opt => opt.MapFrom(src => src.Modified)) @@ -78,7 +83,10 @@ public PublicationProfile() .ForMember(dst => dst.Authors, opt => opt.Ignore()) // Handled during in memory operations in the index repository .ForMember(dst => dst.PeerReviewed, opt => opt.Ignore()) // Handled during in memory operations in the index repository .ForMember(dst => dst.ParentPublication, opt => opt.Ignore()) // Handled during in memory operations in the index repository - ; + .ForMember(dst => dst.IsOrgPublication, opt => opt.MapFrom(src => src.DimPublicationId != null && src.DimPublicationId > 0)) // Publication is an organization publication, when DimPublicationId references co-publication. This property is used in query filter. + .ForMember(dst => dst.IsCoPublication, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation.Count > 0)) // Publication is a co-publication, when InverseDimPublicationNavigation references one or more organization publications. This property is used in query filter. + .ForMember(dst => dst.CoPublicationID, opt => opt.MapFrom(src => src.DimPublicationId != null && src.DimPublicationId > 0 ? src.DimPublicationNavigation.PublicationId : null)) + .ForMember(dst => dst.OrgPublicationIDs, opt => opt.MapFrom(src => src.InverseDimPublicationNavigation.Select(t => t.PublicationId))); CreateProjection() .AddTransform(s => string.IsNullOrWhiteSpace(s) ? null : s) @@ -133,6 +141,26 @@ public PublicationProfile() .ForMember(dst => dst.ArtPublicationRole, opt => opt.MapFrom(src => src.DimReferencedataActorRole)) .ForMember(dst => dst.ContributionType, opt => opt.MapFrom(src => src.ContributionType)); + CreateProjection() + .ForMember(dst => dst.Id, opt => opt.MapFrom(src => src.Id)) + .ForMember(dst => dst.DatabaseContributions, opt => opt.MapFrom(src => src.FactContributions)); + + CreateProjection() + .ForMember(dst => dst.Id, opt => opt.MapFrom(src => src.Id)) + .ForMember(dst => dst.Keywords, opt => opt.MapFrom(src => src.DimKeywords)); + + CreateProjection() + .ForMember(dst => dst.Id, opt => opt.MapFrom(src => src.Id)) + .ForMember(dst => dst.ArtPublicationTypeCategories, opt => opt.MapFrom(src => src.DimReferencedata)); + + CreateProjection() + .ForMember(dst => dst.Id, opt => opt.MapFrom(src => src.Id)) + .ForMember(dst => dst.FieldsOfScience, opt => opt.MapFrom(src => src.FactDimReferencedataFieldOfSciences.Select(f => f.DimReferencedata))); + + CreateProjection() + .ForMember(dst => dst.Id, opt => opt.MapFrom(src => src.Id)) + .ForMember(dst => dst.FieldsOfArt, opt => opt.MapFrom(src => src.DimReferencedataNavigation)); + CreateProjection() .AddTransform(s => string.IsNullOrWhiteSpace(s) ? null : s) .ForMember(dst => dst.NameId, opt => opt.MapFrom(src => src.Id)) diff --git a/aspnetcore/src/Repositories/PublicationIndexRepository.cs b/aspnetcore/src/Repositories/PublicationIndexRepository.cs index 316d392..a58f684 100644 --- a/aspnetcore/src/Repositories/PublicationIndexRepository.cs +++ b/aspnetcore/src/Repositories/PublicationIndexRepository.cs @@ -3,7 +3,6 @@ using CSC.PublicApi.DatabaseContext; using CSC.PublicApi.Service.Models; using CSC.PublicApi.Service.Models.Publication; -using Elasticsearch.Net; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Caching.Memory; using Publication = CSC.PublicApi.Service.Models.Publication.Publication; @@ -81,7 +80,54 @@ public override List PerformInMemoryOperations(List entities) public override object PerformInMemoryOperation(object entity) { Publication publication = (Publication)entity; - + + // Add data from OrgPublication DTOs, which hold data collected from publications related to a co-publication (yhteisjulkaisu/osajulkaisu) + if (publication.OrgPublicationDatabaseContributionDTOs != null && publication.OrgPublicationDatabaseContributionDTOs.Count > 0) + { + List databaseContributions = new(); + foreach (OrgPublicationDatabaseContributionDTO op in publication.OrgPublicationDatabaseContributionDTOs.AsEnumerable().ToList()) + { + databaseContributions.AddRange(op.DatabaseContributions); + } + publication.DatabaseContributions.AddRange(databaseContributions.DistinctBy(x => x.Name)); + } + if (publication.OrgPublicationKeywordDTOs != null && publication.OrgPublicationKeywordDTOs.Count > 0) + { + List keywords = new(); + foreach (OrgPublicationKeywordDTO kw in publication.OrgPublicationKeywordDTOs.AsEnumerable().ToList()) + { + keywords.AddRange(kw.Keywords); + } + publication.Keywords.AddRange(keywords.DistinctBy(x => x.Value)); + } + if (publication.OrgPublicationArtPublicatonTypeCategoryDTOs != null && publication.OrgPublicationArtPublicatonTypeCategoryDTOs.Count > 0) + { + List artPublicationTypeCategories = new(); + foreach (OrgPublicationArtPublicatonTypeCategoryDTO ap in publication.OrgPublicationArtPublicatonTypeCategoryDTOs.AsEnumerable().ToList()) + { + artPublicationTypeCategories.AddRange(ap.ArtPublicationTypeCategories); + } + publication.ArtPublicationTypeCategory.AddRange(artPublicationTypeCategories.DistinctBy(x => x.Code)); + } + if (publication.OrgPublicationFieldsOfScienceDTOs != null && publication.OrgPublicationFieldsOfScienceDTOs.Count > 0) + { + List fieldsOfScience = new(); + foreach (OrgPublicationFieldsOfScienceDTO fs in publication.OrgPublicationFieldsOfScienceDTOs.AsEnumerable().ToList()) + { + fieldsOfScience.AddRange(fs.FieldsOfScience); + } + publication.FieldsOfScience.AddRange(fieldsOfScience.DistinctBy(x => x.Code)); + } + if (publication.OrgPublicationFieldsOfArtDTOs != null && publication.OrgPublicationFieldsOfArtDTOs.Count > 0) + { + List fieldsOfArt = new(); + foreach (OrgPublicationFieldsOfArtDTO fa in publication.OrgPublicationFieldsOfArtDTOs.AsEnumerable().ToList()) + { + fieldsOfArt.AddRange(fa.FieldsOfArt); + } + publication.FieldsOfArt.AddRange(fieldsOfArt.DistinctBy(x => x.Code)); + } + HandleIssnAndIsbn(publication); HandleEmptyCollections(publication); HandleOrganizations(publication); diff --git a/aspnetcore/src/Service.Models/Publication/OrgPublicationArtPublicatonTypeCategoryDTO.cs b/aspnetcore/src/Service.Models/Publication/OrgPublicationArtPublicatonTypeCategoryDTO.cs new file mode 100644 index 0000000..5aaecb5 --- /dev/null +++ b/aspnetcore/src/Service.Models/Publication/OrgPublicationArtPublicatonTypeCategoryDTO.cs @@ -0,0 +1,9 @@ +namespace CSC.PublicApi.Service.Models.Publication; + +// DTO used when collecting ArtPublicationTypeCategories from OrgPublications (yhteisjulkaisu/osajulkaisu). +public class OrgPublicationArtPublicatonTypeCategoryDTO +{ + public string? Id { get; set; } + + public List? ArtPublicationTypeCategories { get; set; } +} \ No newline at end of file diff --git a/aspnetcore/src/Service.Models/Publication/OrgPublicationDatabaseContributionDTO.cs b/aspnetcore/src/Service.Models/Publication/OrgPublicationDatabaseContributionDTO.cs new file mode 100644 index 0000000..c789b7a --- /dev/null +++ b/aspnetcore/src/Service.Models/Publication/OrgPublicationDatabaseContributionDTO.cs @@ -0,0 +1,9 @@ +namespace CSC.PublicApi.Service.Models.Publication; + +// DTO used when collecting DatabaseContributions from OrgPublications (yhteisjulkaisu/osajulkaisu). +public class OrgPublicationDatabaseContributionDTO +{ + public string? Id { get; set; } + + public List? DatabaseContributions { get; set; } +} \ No newline at end of file diff --git a/aspnetcore/src/Service.Models/Publication/OrgPublicationFieldsOfArtDTO.cs b/aspnetcore/src/Service.Models/Publication/OrgPublicationFieldsOfArtDTO.cs new file mode 100644 index 0000000..bc77b0e --- /dev/null +++ b/aspnetcore/src/Service.Models/Publication/OrgPublicationFieldsOfArtDTO.cs @@ -0,0 +1,9 @@ +namespace CSC.PublicApi.Service.Models.Publication; + +// DTO used when collecting fields of art from OrgPublications (yhteisjulkaisu/osajulkaisu). +public class OrgPublicationFieldsOfArtDTO +{ + public string? Id { get; set; } + + public List? FieldsOfArt { get; set; } +} \ No newline at end of file diff --git a/aspnetcore/src/Service.Models/Publication/OrgPublicationFieldsOfScienceDTO copy.cs b/aspnetcore/src/Service.Models/Publication/OrgPublicationFieldsOfScienceDTO copy.cs new file mode 100644 index 0000000..c7f96ef --- /dev/null +++ b/aspnetcore/src/Service.Models/Publication/OrgPublicationFieldsOfScienceDTO copy.cs @@ -0,0 +1,9 @@ +namespace CSC.PublicApi.Service.Models.Publication; + +// DTO used when collecting fields of science from OrgPublications (yhteisjulkaisu/osajulkaisu). +public class OrgPublicationFieldsOfScienceDTO +{ + public string? Id { get; set; } + + public List? FieldsOfScience { get; set; } +} \ No newline at end of file diff --git a/aspnetcore/src/Service.Models/Publication/OrgPublicationKeywordDTO.cs b/aspnetcore/src/Service.Models/Publication/OrgPublicationKeywordDTO.cs new file mode 100644 index 0000000..fbfaeb6 --- /dev/null +++ b/aspnetcore/src/Service.Models/Publication/OrgPublicationKeywordDTO.cs @@ -0,0 +1,9 @@ +namespace CSC.PublicApi.Service.Models.Publication; + +// DTO used when collecting Keywords from OrgPublications (yhteisjulkaisu/osajulkaisu). +public class OrgPublicationKeywordDTO +{ + public string? Id { get; set; } + + public List? Keywords { get; set; } +} \ No newline at end of file diff --git a/aspnetcore/src/Service.Models/Publication/Publication.cs b/aspnetcore/src/Service.Models/Publication/Publication.cs index 00548b3..890c141 100644 --- a/aspnetcore/src/Service.Models/Publication/Publication.cs +++ b/aspnetcore/src/Service.Models/Publication/Publication.cs @@ -259,6 +259,26 @@ public class Publication /// public DateTime? Modified { get; set; } + /// + /// Onko julkaisu yhteisjulkaisu + /// + public bool IsCoPublication { get; set; } + + /// + /// Onko julkaisu osajulkaisu + /// + public bool IsOrgPublication { get; set; } + + /// + /// Osajulkaisun yhteisjulkaisu + /// + public string? CoPublicationID { get; set; } + + /// + /// Yhteisjulkaisuun liittyvät osajulkaisut + /// + public List? OrgPublicationIDs { get; set; } + [Ignore] public string? Isbn1 { get; set; } @@ -274,6 +294,21 @@ public class Publication [Ignore] public List? DatabaseContributions { get; set; } + [Ignore] + public List? OrgPublicationDatabaseContributionDTOs { get; set; } + + [Ignore] + public List? OrgPublicationKeywordDTOs { get; set; } + + [Ignore] + public List? OrgPublicationArtPublicatonTypeCategoryDTOs { get; set; } + + [Ignore] + public List? OrgPublicationFieldsOfScienceDTOs { get; set; } + + [Ignore] + public List? OrgPublicationFieldsOfArtDTOs { get; set; } + [Ignore] public bool? DatabasePeerReviewed { get; set; } diff --git a/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs b/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs index 7350ea9..5fb7b97 100644 --- a/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs +++ b/aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs @@ -39,6 +39,148 @@ public void ProjectTo_DimPublication_ShouldBeMappedToPublication() result.Should().BeEquivalentTo(model, options => options); } + [Fact] + public void ProjectTo_DimPublication_ShouldBeMappedToPublication_Not_IsOrgPublication_When_DimPublicationId_Null() + { + // Arrange + var entity = GetEntity(); + entity.DimPublicationId = null; + var model = GetModel(); + model.IsOrgPublication = false; + + // Act + var result = Act_Map(entity); + + // Assert + result.Should().BeEquivalentTo(model, options => options); + } + + [Fact] + public void ProjectTo_DimPublication_ShouldBeMappedToPublication_Not_IsOrgPublication_When_DimPublicationId_MinusOne() + { + // Arrange + var entity = GetEntity(); + entity.DimPublicationId = -1; + var model = GetModel(); + model.IsOrgPublication = false; + + // Act + var result = Act_Map(entity); + + // Assert + result.Should().BeEquivalentTo(model, options => options); + } + +/* + [Fact] + public void ProjectTo_DimPublication_ShouldBeMappedToPublication_IsOrgPublication_IsCoPublication() + { + // Arrange + var entity_coPublication = GetEntity(); + var entity_orgPublication = GetEntity(); + // Entity - Yhteisjulkaisu + entity_coPublication.PublicationId = "co-publication id"; + entity_coPublication.Id = 1; + entity_coPublication.InverseDimPublicationNavigation.Add(entity_orgPublication); + // Entity - Osajulkaisu + entity_orgPublication.PublicationId = "org publication id"; + entity_orgPublication.DimPublicationNavigation = entity_coPublication; + entity_orgPublication.DimPublicationId = entity_coPublication.Id; + // Model - Yhteisjulkaisu + var model_coPublication = GetModel(); + model_coPublication.Id = "co-publication id"; + model_coPublication.IsCoPublication = true; + model_coPublication.IsOrgPublication = false; + model_coPublication.OrgPublicationIDs = new List { "org publication id" }; + model_coPublication.OrgPublicationDTOs = new List { + new OrgPublicationDTO { + Id = "org publication id", + DatabaseContributions = new () { + new CSC.PublicApi.Service.Models.Publication.FactContribution() { + ArtPublicationRole = new () { + Code = + "roleCode", + NameEn = + "roleNameEn", + NameFi = + "roleNameFi", + NameSv = + "roleNameSv" + }, + ContributionType = "publication_author_organization", + Name = new() + { + FirstNames = + "personFirstName", + LastName = + "personLastName", + NameId = 23, + Orcid = + "pidContent" + }, + OrganizationId = 42 + }, + new CSC.PublicApi.Service.Models.Publication.FactContribution() { + ArtPublicationRole = null, + ContributionType = + "publication_organization", + Name = null, + OrganizationId = 41 + }, + } + } + }; + // Model - Osajulkaisu + var model_orgPublication = GetModel(); + model_orgPublication.Id = "org publication id"; + model_orgPublication.IsCoPublication = false; + model_orgPublication.IsOrgPublication = true; + model_orgPublication.CoPublicationID = "co-publication id"; + + // Act + var resultCoPublication = Act_Map(entity_coPublication); + var resultOrgPublication = Act_Map(entity_orgPublication); + + // Assert + resultCoPublication.Should().BeEquivalentTo(model_coPublication, options => options); + resultOrgPublication.Should().BeEquivalentTo(model_orgPublication, options => options); + } +*/ +/* + [Fact] + public void ProjectTo_DimPublication_ShouldBeMappedToPublication_MainPublication_Lists_CoPublications() + { + // Arrange + // Yhteisjulkaisu + var entity_mainPublication = GetEntity(); + entity_mainPublication.PublicationId = "yhteisjulkaisu"; + entity_mainPublication.Id = 1; + // Osajulkaisu 1 + var entity_coPublication1 = GetEntity(); + entity_coPublication1.PublicationId = "osajulkaisu1"; + entity_coPublication1.DimPublicationNavigation = entity_mainPublication; + entity_coPublication1.DimPublicationId = 1; + entity_mainPublication.InverseDimPublicationNavigation.Add(entity_coPublication1); + // Osajulkaisu 2 + var entity_coPublication2 = GetEntity(); + entity_coPublication2.PublicationId = "osajulkaisu2"; + entity_coPublication2.DimPublicationNavigation = entity_mainPublication; + entity_coPublication2.DimPublicationId = 1; + entity_mainPublication.InverseDimPublicationNavigation.Add(entity_coPublication2); + + var model = GetModel(); + model.Id = "yhteisjulkaisu"; + model.IsMainPublication = true; + model.IsCoPublication = false; + model.OrgPublicationIDs = new List { "osajulkaisu1", "osajulkaisu2" }; + + // Act + var result = Act_Map(entity_mainPublication); + + // Assert + result.Should().BeEquivalentTo(model, options => options); + } +*/ private Publication Act_Map(DimPublication dbEntity) { var entityQueryable = new List @@ -505,8 +647,15 @@ private Publication GetModel() NameSv = "publisherOpenAccessCodeSv", NameEn = "publisherOpenAccessCodeEn" }, + CoPublicationID = null, + OrgPublicationIDs = new List {}, Created = new DateTime(2023, 3, 10, 10, 43, 00), - Modified = new DateTime(2023, 3, 10, 10, 44, 00) + Modified = new DateTime(2023, 3, 10, 10, 44, 00), + OrgPublicationDatabaseContributionDTOs = new(), + OrgPublicationArtPublicatonTypeCategoryDTOs = new(), + OrgPublicationFieldsOfArtDTOs = new(), + OrgPublicationFieldsOfScienceDTOs = new(), + OrgPublicationKeywordDTOs = new() }; } } \ No newline at end of file diff --git a/aspnetcore/test/Interface.Tests/Maps/PublicationProfileTest.cs b/aspnetcore/test/Interface.Tests/Maps/PublicationProfileTest.cs index b3925b7..6e2426a 100644 --- a/aspnetcore/test/Interface.Tests/Maps/PublicationProfileTest.cs +++ b/aspnetcore/test/Interface.Tests/Maps/PublicationProfileTest.cs @@ -294,6 +294,7 @@ private static object GetServiceModel() NameEn = "artPublicationTypeNameEn" } }, + OrgPublicationIDs = new List {}, Created = new DateTime(2023, 3, 10, 10, 43, 00), Modified = new DateTime(2023, 3, 10, 10, 44, 00) }; @@ -495,6 +496,7 @@ private static object GetApiModel() NameEn = "artPublicationTypeNameEn" } }, + OrgPublicationIDs = new(), Created = new DateTime(2023, 3, 10, 10, 43, 00), Modified = new DateTime(2023, 3, 10, 10, 44, 00) };