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 3562 ttv model update jufo class #106

Merged
merged 3 commits into from
Nov 24, 2023
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
74 changes: 53 additions & 21 deletions aspnetcore/src/DatabaseContext/ApiDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2808,6 +2808,8 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasColumnType("datetime")
.HasColumnName("created");

entity.Property(e => e.DimPublicationChannelId).HasColumnName("dim_publication_channel_id");

entity.Property(e => e.DimRegisteredDataSourceId).HasColumnName("dim_registered_data_source_id");

entity.Property(e => e.Doi)
Expand Down Expand Up @@ -2850,14 +2852,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMaxLength(4000)
.HasColumnName("journal_name");

entity.Property(e => e.JufoClassCode)
.HasMaxLength(255)
.HasColumnName("jufo_class_code");

entity.Property(e => e.JufoCode)
.HasMaxLength(255)
.HasColumnName("jufo_code");

entity.Property(e => e.JuuliAddress)
.HasMaxLength(4000)
.HasColumnName("juuli_address");
Expand All @@ -2876,10 +2870,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMaxLength(255)
.HasColumnName("open_access");

entity.Property(e => e.OpenAccessCode)
.HasMaxLength(255)
.HasColumnName("open_access_code");

entity.Property(e => e.OriginalPublicationId)
.HasMaxLength(255)
.HasColumnName("original_publication_id");
Expand Down Expand Up @@ -2934,9 +2924,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMaxLength(4000)
.HasColumnName("publisher_name");

entity.Property(e => e.PublisherOpenAccessCode)
.HasMaxLength(255)
.HasColumnName("publisher_open_access_code");
entity.Property(e => e.PublisherOpenAccessCode).HasColumnName("publisher_open_access_code");

entity.Property(e => e.Report).HasColumnName("report");

Expand Down Expand Up @@ -2967,6 +2955,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasForeignKey(d => d.ArticleTypeCode)
.HasConstraintName("article_type_code");

entity.HasOne(d => d.DimPublicationChannel)
.WithMany(p => p.DimPublications)
.HasForeignKey(d => d.DimPublicationChannelId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("publication_channel");

entity.HasOne(d => d.DimRegisteredDataSource)
.WithMany(p => p.DimPublications)
.HasForeignKey(d => d.DimRegisteredDataSourceId)
Expand Down Expand Up @@ -3007,6 +3001,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasForeignKey(d => d.PublicationTypeCode2)
.HasConstraintName("publication_type_code2");

entity.HasOne(d => d.PublisherOpenAccessCodeNavigation)
.WithMany(p => p.DimPublicationPublisherOpenAccessCodeNavigations)
.HasForeignKey(d => d.PublisherOpenAccessCode)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("publisher_open_access");

entity.HasOne(d => d.TargetAudienceCodeNavigation)
.WithMany(p => p.DimPublicationTargetAudienceCodeNavigations)
.HasForeignKey(d => d.TargetAudienceCode)
Expand Down Expand Up @@ -3046,13 +3046,29 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasMaxLength(4000)
.HasColumnName("channel_name_anylang");

entity.Property(e => e.Created)
.HasColumnType("datetime")
.HasColumnName("created");

entity.Property(e => e.JufoCode)
.HasMaxLength(255)
.HasColumnName("jufo_code");

entity.Property(e => e.Modified)
.HasColumnType("datetime")
.HasColumnName("modified");

entity.Property(e => e.PublisherNameText)
.HasMaxLength(4000)
.HasColumnName("publisher_name_text");

entity.Property(e => e.SourceDescription)
.HasMaxLength(255)
.HasColumnName("source_description");

entity.Property(e => e.SourceId)
.HasMaxLength(255)
.HasColumnName("source_id");
});

modelBuilder.Entity<DimPurpose>(entity =>
Expand Down Expand Up @@ -4767,28 +4783,44 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<FactJufoClassCodesForPubChannel>(entity =>
{
entity.HasKey(e => new { e.DimPublicationChannelId, e.DimReferencedataId, e.Year })
.HasName("PK__fact_juf__0E099E4B39813744");
entity.HasKey(e => new { e.DimPublicationChannelId, e.JufoClasses, e.Year })
.HasName("PK__fact_juf__5280C574D130FC62");

entity.ToTable("fact_jufo_class_codes_for_pub_channels");

entity.Property(e => e.DimPublicationChannelId).HasColumnName("dim_publication_channel_id");

entity.Property(e => e.DimReferencedataId).HasColumnName("dim_referencedata_id");
entity.Property(e => e.JufoClasses).HasColumnName("jufo_classes");

entity.Property(e => e.Year).HasColumnName("year");

entity.Property(e => e.Created)
.HasColumnType("datetime")
.HasColumnName("created");

entity.Property(e => e.Modified)
.HasColumnType("datetime")
.HasColumnName("modified");

entity.Property(e => e.SourceDescription)
.HasMaxLength(255)
.HasColumnName("source_description");

entity.Property(e => e.SourceId)
.HasMaxLength(255)
.HasColumnName("source_id");

entity.HasOne(d => d.DimPublicationChannel)
.WithMany(p => p.FactJufoClassCodesForPubChannels)
.HasForeignKey(d => d.DimPublicationChannelId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("jufo_classes");

entity.HasOne(d => d.DimReferencedata)
entity.HasOne(d => d.JufoClassesNavigation)
.WithMany(p => p.FactJufoClassCodesForPubChannels)
.HasForeignKey(d => d.DimReferencedataId)
.HasForeignKey(d => d.JufoClasses)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FKfact_jufo_876058");
.HasConstraintName("FKfact_jufo_216849");
});

modelBuilder.Entity<FactUpkeep>(entity =>
Expand Down
8 changes: 4 additions & 4 deletions aspnetcore/src/DatabaseContext/Entities/DimPublication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public DimPublication()
public string? ArticleNumberText { get; set; }
public string? Isbn { get; set; }
public string? Isbn2 { get; set; }
public string? JufoCode { get; set; }
public string? JufoClassCode { get; set; }
public int PublicationCountryCode { get; set; }
public string? JournalName { get; set; }
public string? Issn { get; set; }
Expand All @@ -49,7 +47,6 @@ public DimPublication()
public bool GovermentCollaboration { get; set; }
public bool OtherCollaboration { get; set; }
public int LanguageCode { get; set; }
public string? OpenAccessCode { get; set; }
public bool SpecialStateSubsidy { get; set; }
public bool? BusinessCollaboration { get; set; }
public string? DoiHandle { get; set; }
Expand All @@ -74,17 +71,20 @@ public DimPublication()
public DateTime? Modified { get; set; }
public int DimRegisteredDataSourceId { get; set; }
public string? OpenAccess { get; set; }
public string? PublisherOpenAccessCode { get; set; }
public int PublisherOpenAccessCode { get; set; }
public string? Abstract { get; set; }
public int DimPublicationChannelId { get; set; }

public virtual DimReferencedatum? ArticleTypeCodeNavigation { get; set; }
public virtual DimPublicationChannel DimPublicationChannel { get; set; } = null!;
public virtual DimRegisteredDataSource DimRegisteredDataSource { get; set; } = null!;
public virtual DimReferencedatum LanguageCodeNavigation { get; set; } = null!;
public virtual DimReferencedatum LicenseCodeNavigation { get; set; } = null!;
public virtual DimReferencedatum? ParentPublicationTypeCodeNavigation { get; set; }
public virtual DimReferencedatum PublicationCountryCodeNavigation { get; set; } = null!;
public virtual DimReferencedatum? PublicationTypeCode2Navigation { get; set; }
public virtual DimReferencedatum PublicationTypeCodeNavigation { get; set; } = null!;
public virtual DimReferencedatum PublisherOpenAccessCodeNavigation { get; set; } = null!;
public virtual DimReferencedatum? TargetAudienceCodeNavigation { get; set; }
public virtual DimReferencedatum ThesisTypeCodeNavigation { get; set; } = null!;
public virtual ICollection<DimLocallyReportedPubInfo> DimLocallyReportedPubInfos { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public partial class DimPublicationChannel
public DimPublicationChannel()
{
DimPids = new HashSet<DimPid>();
DimPublications = new HashSet<DimPublication>();
DimResearchActivities = new HashSet<DimResearchActivity>();
FactJufoClassCodesForPubChannels = new HashSet<FactJufoClassCodesForPubChannel>();
}
Expand All @@ -16,8 +17,13 @@ public DimPublicationChannel()
public string? JufoCode { get; set; }
public string? ChannelNameAnylang { get; set; }
public string? PublisherNameText { get; set; }
public string SourceId { get; set; } = null!;
public string? SourceDescription { get; set; }
public DateTime? Created { get; set; }
public DateTime? Modified { get; set; }

public virtual ICollection<DimPid> DimPids { get; set; }
public virtual ICollection<DimPublication> DimPublications { get; set; }
public virtual ICollection<DimResearchActivity> DimResearchActivities { get; set; }
public virtual ICollection<FactJufoClassCodesForPubChannel> FactJufoClassCodesForPubChannels { get; set; }
}
Expand Down
2 changes: 2 additions & 0 deletions aspnetcore/src/DatabaseContext/Entities/DimReferencedatum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public DimReferencedatum()
DimPublicationPublicationCountryCodeNavigations = new HashSet<DimPublication>();
DimPublicationPublicationTypeCode2Navigations = new HashSet<DimPublication>();
DimPublicationPublicationTypeCodeNavigations = new HashSet<DimPublication>();
DimPublicationPublisherOpenAccessCodeNavigations = new HashSet<DimPublication>();
DimPublicationTargetAudienceCodeNavigations = new HashSet<DimPublication>();
DimPublicationThesisTypeCodeNavigations = new HashSet<DimPublication>();
DimResearchDatasetDimReferencedataAvailabilityNavigations = new HashSet<DimResearchDataset>();
Expand Down Expand Up @@ -83,6 +84,7 @@ public DimReferencedatum()
public virtual ICollection<DimPublication> DimPublicationPublicationCountryCodeNavigations { get; set; }
public virtual ICollection<DimPublication> DimPublicationPublicationTypeCode2Navigations { get; set; }
public virtual ICollection<DimPublication> DimPublicationPublicationTypeCodeNavigations { get; set; }
public virtual ICollection<DimPublication> DimPublicationPublisherOpenAccessCodeNavigations { get; set; }
public virtual ICollection<DimPublication> DimPublicationTargetAudienceCodeNavigations { get; set; }
public virtual ICollection<DimPublication> DimPublicationThesisTypeCodeNavigations { get; set; }
public virtual ICollection<DimResearchDataset> DimResearchDatasetDimReferencedataAvailabilityNavigations { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ namespace CSC.PublicApi.DatabaseContext.Entities
public partial class FactJufoClassCodesForPubChannel
{
public int DimPublicationChannelId { get; set; }
public int DimReferencedataId { get; set; }
public int JufoClasses { get; set; }
public int Year { get; set; }
public string SourceId { get; set; } = null!;
public string? SourceDescription { get; set; }
public DateTime? Created { get; set; }
public DateTime? Modified { get; set; }

public virtual DimPublicationChannel DimPublicationChannel { get; set; } = null!;
public virtual DimReferencedatum DimReferencedata { get; set; } = null!;
public virtual DimReferencedatum JufoClassesNavigation { get; set; } = null!;
}
}
7 changes: 3 additions & 4 deletions aspnetcore/src/Repositories/Maps/PublicationProfile.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CSC.PublicApi.DatabaseContext.Entities;
using CSC.PublicApi.Service.Models;
using CSC.PublicApi.Service.Models.Publication;
using Microsoft.Data.SqlClient;
using FactContribution = CSC.PublicApi.Service.Models.Publication.FactContribution;
using Name = CSC.PublicApi.Service.Models.Publication.Name;
using Profile = AutoMapper.Profile;
Expand Down Expand Up @@ -45,13 +44,13 @@ public PublicationProfile()
.ForMember(dst => dst.ParentPublicationName, opt => opt.MapFrom(src => src.ParentPublicationName))
.ForMember(dst => dst.ParentPublicationPublisher, opt => opt.MapFrom(src => src.ParentPublicationPublisher))
.ForMember(dst => dst.OpenAccess, opt => opt.MapFrom(src => src.OpenAccess != "9" ? src.OpenAccess : null))
.ForMember(dst => dst.PublisherOpenAccess, opt => opt.MapFrom(src => src.PublisherOpenAccessCode != "9" ? src.PublisherOpenAccessCode : null))
.ForMember(dst => dst.PublisherOpenAccess, opt => opt.MapFrom(src => src.PublisherOpenAccessCodeNavigation.CodeValue != "9" ? src.PublisherOpenAccessCodeNavigation : null))
.ForMember(dst => dst.Isbn1, opt => opt.MapFrom(src => src.Isbn))
.ForMember(dst => dst.Isbn2, opt => opt.MapFrom(src => src.Isbn2))
.ForMember(dst => dst.PublisherName, opt => opt.MapFrom(src => src.PublisherName))
.ForMember(dst => dst.PublisherLocation, opt => opt.MapFrom(src => src.PublisherLocation))
.ForMember(dst => dst.JufoCode, opt => opt.MapFrom(src => src.JufoCode))
.ForMember(dst => dst.JufoClass, opt => opt.MapFrom(src => src.JufoClassCode))
.ForMember(dst => dst.JufoCode, opt => opt.MapFrom(src => src.DimPublicationChannel.JufoCode))
.ForMember(dst => dst.JufoClass, opt => opt.MapFrom(src => src.DimPublicationChannel.FactJufoClassCodesForPubChannels.First().JufoClassesNavigation))
.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)))
Expand Down
51 changes: 45 additions & 6 deletions aspnetcore/test/Indexer.Tests/Maps/PublicationProfileTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,28 @@ private Publication Act_Map(DimPublication dbEntity)

private static DimPublication GetEntity()
{
return new DimPublication
DimPublicationChannel dimPublicationChannel = new()
{
JufoCode = "jufoCode",
ChannelNameAnylang = "channelNameAnylang",
PublisherNameText = "publisherNameText",
};

FactJufoClassCodesForPubChannel factJufoClassCodesForPubChannel = new()
{
DimPublicationChannel = dimPublicationChannel,
JufoClassesNavigation = new DimReferencedatum
{
CodeValue = "jufoClassCode",
NameFi = "jufoClassNameFi",
NameEn = "jufoClassNameEn",
NameSv = "jufoClassNameSv"
},
Year = 2023
};
dimPublicationChannel.FactJufoClassCodesForPubChannels.Add(factJufoClassCodesForPubChannel);

DimPublication dimPublication = new()
{
Id = 1,
PublicationId = "publicationId",
Expand Down Expand Up @@ -84,7 +105,6 @@ private static DimPublication GetEntity()
NameSv = "targetAudienceNameSv",
NameEn = "targetAudienceNameEn"
},
//PublicationTypeCode = "publicationTypeCode",
PublicationTypeCodeNavigation = new DimReferencedatum
{
CodeValue = "publicationTypeCode",
Expand All @@ -106,8 +126,14 @@ private static DimPublication GetEntity()
Isbn2 = "isbn2",
PublisherName = "publisherName",
PublisherLocation = "publisherLocation",
JufoCode = "jufoCode",
JufoClassCode = "jufoClassCode",
DimPublicationChannel = dimPublicationChannel,
PublisherOpenAccessCodeNavigation = new DimReferencedatum
{
CodeValue = "publisherOpenAccessCode",
NameFi = "publisherOpenAccessCodeFi",
NameSv = "publisherOpenAccessCodeSv",
NameEn = "publisherOpenAccessCodeEn"
},
Doi = "doi",
DoiHandle = "doiHandle",
DimKeywords = new List<DimKeyword>
Expand Down Expand Up @@ -187,6 +213,7 @@ private static DimPublication GetEntity()
NameSv = "languageCodeSv",
NameEn = "languageCodeEn"
},
InternationalPublication = 1,
InternationalCollaboration = true,
BusinessCollaboration = true,
ApcFeeEur = 123.4m,
Expand Down Expand Up @@ -262,6 +289,8 @@ private static DimPublication GetEntity()
Created = new DateTime(2023, 3, 10, 10, 43, 00),
Modified = new DateTime(2023, 3, 10, 10, 44, 00)
};

return dimPublication;
}

private Publication GetModel()
Expand Down Expand Up @@ -320,7 +349,10 @@ private Publication GetModel()
JufoCode = "jufoCode",
JufoClass = new ReferenceData
{
Code = "jufoClassCode"
Code = "jufoClassCode",
NameFi = "jufoClassNameFi",
NameEn = "jufoClassNameEn",
NameSv = "jufoClassNameSv"
},
Doi = "doi",
DoiHandle = "doiHandle",
Expand Down Expand Up @@ -387,7 +419,7 @@ private Publication GetModel()
NameSv = "languageCodeSv",
NameEn = "languageCodeEn"
},
InternationalPublication = false,
InternationalPublication = true,
InternationalCollaboration = true,
BusinessCollaboration = true,
ApcFeeEur = 123.4m,
Expand Down Expand Up @@ -464,6 +496,13 @@ private Publication GetModel()
NameEn = "artPublicationTypeNameEn"
}
},
PublisherOpenAccess = new ReferenceData
{
Code = "publisherOpenAccessCode",
NameFi = "publisherOpenAccessCodeFi",
NameSv = "publisherOpenAccessCodeSv",
NameEn = "publisherOpenAccessCodeEn"
},
Created = new DateTime(2023, 3, 10, 10, 43, 00),
Modified = new DateTime(2023, 3, 10, 10, 44, 00)
};
Expand Down
Loading