From 95b5e5e2e678f27cfa60c7718f44ed4ce6110def Mon Sep 17 00:00:00 2001 From: John-Vaughan <114492829+John-Vaughan@users.noreply.github.com> Date: Fri, 1 Mar 2024 16:25:40 +0000 Subject: [PATCH] Fix/john/correct id forengee (#587) --- src/BL/Models/EgressSubmission.cs | 19 +++ src/BL/Models/ViewModels/ReviewFiles.cs | 4 + .../20240301145645_tesid.Designer.cs | 132 +++++++++++++++++ .../Migrations/20240301145645_tesid.cs | 28 ++++ .../20240301152250_addName.Designer.cs | 135 ++++++++++++++++++ .../Migrations/20240301152250_addName.cs | 28 ++++ .../ApplicationDbContextModelSnapshot.cs | 9 +- .../Views/Data/GetAllEgresses.cshtml | 6 +- .../Views/Data/GetEgress.cshtml | 2 +- src/TRE-API/DoAgentWork.cs | 46 ++---- src/TRE-API/Services/SubmissionHelper.cs | 4 +- 11 files changed, 369 insertions(+), 44 deletions(-) create mode 100644 src/Data-Egress-API/Migrations/20240301145645_tesid.Designer.cs create mode 100644 src/Data-Egress-API/Migrations/20240301145645_tesid.cs create mode 100644 src/Data-Egress-API/Migrations/20240301152250_addName.Designer.cs create mode 100644 src/Data-Egress-API/Migrations/20240301152250_addName.cs diff --git a/src/BL/Models/EgressSubmission.cs b/src/BL/Models/EgressSubmission.cs index bc056c3dd..0b4564819 100644 --- a/src/BL/Models/EgressSubmission.cs +++ b/src/BL/Models/EgressSubmission.cs @@ -22,6 +22,10 @@ public class EgressSubmission public string? Reviewer { get; set; } public virtual List Files { get; set; } + public string? tesId { get; set; } + + public string? Name { get; set; } + public string EgressStatusDisplay { get @@ -33,5 +37,20 @@ public string EgressStatusDisplay return displayAttribute?.Name ?? Status.ToString(); } } + + public string EgressID + { + get + { + if (string.IsNullOrEmpty(tesId)) + { + return SubmissionId; + } + else + { + return tesId; + } + } + } } } diff --git a/src/BL/Models/ViewModels/ReviewFiles.cs b/src/BL/Models/ViewModels/ReviewFiles.cs index 871d91d3b..8f5e1e7cd 100644 --- a/src/BL/Models/ViewModels/ReviewFiles.cs +++ b/src/BL/Models/ViewModels/ReviewFiles.cs @@ -13,5 +13,9 @@ public class ReviewFiles public List Files { get; set; } + public string tesId { get; set; } + + public string Name { get; set; } + } } diff --git a/src/Data-Egress-API/Migrations/20240301145645_tesid.Designer.cs b/src/Data-Egress-API/Migrations/20240301145645_tesid.Designer.cs new file mode 100644 index 000000000..b4f031c1c --- /dev/null +++ b/src/Data-Egress-API/Migrations/20240301145645_tesid.Designer.cs @@ -0,0 +1,132 @@ +// +using System; +using Data_Egress_API.Repositories.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Data_Egress_API.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240301145645_tesid")] + partial class tesid + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.13") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true) + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("BL.Models.EgressFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EgressSubmissionId") + .HasColumnType("integer"); + + b.Property("LastUpdate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Reviewer") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EgressSubmissionId"); + + b.ToTable("EgressFiles"); + }); + + modelBuilder.Entity("BL.Models.EgressSubmission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Completed") + .HasColumnType("timestamp with time zone"); + + b.Property("OutputBucket") + .HasColumnType("text"); + + b.Property("Reviewer") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SubmissionId") + .HasColumnType("text"); + + b.Property("tesId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("EgressSubmissions"); + }); + + modelBuilder.Entity("BL.Models.KeycloakCredentials", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CredentialType") + .HasColumnType("integer"); + + b.Property("PasswordEnc") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("KeycloakCredentials"); + }); + + modelBuilder.Entity("BL.Models.EgressFile", b => + { + b.HasOne("BL.Models.EgressSubmission", "EgressSubmission") + .WithMany("Files") + .HasForeignKey("EgressSubmissionId"); + + b.Navigation("EgressSubmission"); + }); + + modelBuilder.Entity("BL.Models.EgressSubmission", b => + { + b.Navigation("Files"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Data-Egress-API/Migrations/20240301145645_tesid.cs b/src/Data-Egress-API/Migrations/20240301145645_tesid.cs new file mode 100644 index 000000000..07dcbe0b6 --- /dev/null +++ b/src/Data-Egress-API/Migrations/20240301145645_tesid.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Data_Egress_API.Migrations +{ + /// + public partial class tesid : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "SubFolder", + table: "EgressSubmissions", + newName: "tesId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "tesId", + table: "EgressSubmissions", + newName: "SubFolder"); + } + } +} diff --git a/src/Data-Egress-API/Migrations/20240301152250_addName.Designer.cs b/src/Data-Egress-API/Migrations/20240301152250_addName.Designer.cs new file mode 100644 index 000000000..6666baf8f --- /dev/null +++ b/src/Data-Egress-API/Migrations/20240301152250_addName.Designer.cs @@ -0,0 +1,135 @@ +// +using System; +using Data_Egress_API.Repositories.DbContexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Data_Egress_API.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240301152250_addName")] + partial class addName + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.13") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true) + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("BL.Models.EgressFile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EgressSubmissionId") + .HasColumnType("integer"); + + b.Property("LastUpdate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Reviewer") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("EgressSubmissionId"); + + b.ToTable("EgressFiles"); + }); + + modelBuilder.Entity("BL.Models.EgressSubmission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Completed") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("OutputBucket") + .HasColumnType("text"); + + b.Property("Reviewer") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SubmissionId") + .HasColumnType("text"); + + b.Property("tesId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("EgressSubmissions"); + }); + + modelBuilder.Entity("BL.Models.KeycloakCredentials", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CredentialType") + .HasColumnType("integer"); + + b.Property("PasswordEnc") + .IsRequired() + .HasColumnType("text"); + + b.Property("UserName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("KeycloakCredentials"); + }); + + modelBuilder.Entity("BL.Models.EgressFile", b => + { + b.HasOne("BL.Models.EgressSubmission", "EgressSubmission") + .WithMany("Files") + .HasForeignKey("EgressSubmissionId"); + + b.Navigation("EgressSubmission"); + }); + + modelBuilder.Entity("BL.Models.EgressSubmission", b => + { + b.Navigation("Files"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Data-Egress-API/Migrations/20240301152250_addName.cs b/src/Data-Egress-API/Migrations/20240301152250_addName.cs new file mode 100644 index 000000000..419760ae4 --- /dev/null +++ b/src/Data-Egress-API/Migrations/20240301152250_addName.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Data_Egress_API.Migrations +{ + /// + public partial class addName : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Name", + table: "EgressSubmissions", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Name", + table: "EgressSubmissions"); + } + } +} diff --git a/src/Data-Egress-API/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Data-Egress-API/Migrations/ApplicationDbContextModelSnapshot.cs index 9ee097e57..04d3f4d1e 100644 --- a/src/Data-Egress-API/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Data-Egress-API/Migrations/ApplicationDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.11") + .HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("Proxies:ChangeTracking", false) .HasAnnotation("Proxies:CheckEquality", false) .HasAnnotation("Proxies:LazyLoading", true) @@ -66,6 +66,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Completed") .HasColumnType("timestamp with time zone"); + b.Property("Name") + .HasColumnType("text"); + b.Property("OutputBucket") .HasColumnType("text"); @@ -75,10 +78,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Status") .HasColumnType("integer"); - b.Property("SubFolder") + b.Property("SubmissionId") .HasColumnType("text"); - b.Property("SubmissionId") + b.Property("tesId") .HasColumnType("text"); b.HasKey("Id"); diff --git a/src/Data-Egress-UI/Views/Data/GetAllEgresses.cshtml b/src/Data-Egress-UI/Views/Data/GetAllEgresses.cshtml index 5a9ea54d3..d9171d145 100644 --- a/src/Data-Egress-UI/Views/Data/GetAllEgresses.cshtml +++ b/src/Data-Egress-UI/Views/Data/GetAllEgresses.cshtml @@ -28,7 +28,7 @@ Submission ID - Project + Submission Name Number of Files Status @@ -41,12 +41,12 @@

- @egressSubmission.SubmissionId + @egressSubmission.EgressID

- Project Name + @egressSubmission.Name @egressSubmission.Files.Count diff --git a/src/Data-Egress-UI/Views/Data/GetEgress.cshtml b/src/Data-Egress-UI/Views/Data/GetEgress.cshtml index a395434a5..e071e3930 100644 --- a/src/Data-Egress-UI/Views/Data/GetEgress.cshtml +++ b/src/Data-Egress-UI/Views/Data/GetEgress.cshtml @@ -9,7 +9,7 @@
-

Egress Request: #@Model.SubmissionId

+

Egress Request: #@Model.EgressID name @Model.Name

@Model.EgressStatusDisplay diff --git a/src/TRE-API/DoAgentWork.cs b/src/TRE-API/DoAgentWork.cs index 9430c1554..bbd07daf6 100644 --- a/src/TRE-API/DoAgentWork.cs +++ b/src/TRE-API/DoAgentWork.cs @@ -14,38 +14,9 @@ using Hangfire; using System.Net.Http.Headers; using System.Text; -using System.Security.Policy; -using Microsoft.EntityFrameworkCore; - -using System.Threading.Tasks; -using TRE_API.Repositories.DbContexts; -using TRE_API.Services; -using BL.Services; -using Microsoft.AspNetCore.SignalR; -using Castle.Components.DictionaryAdapter.Xml; -using Microsoft.Extensions.Configuration; -using BL.Models; -using BL.Models.APISimpleTypeReturns; -using BL.Models.Enums; -using BL.Models.ViewModels; -using BL.Models.Tes; -using BL.Rabbit; -using Microsoft.Extensions.DependencyInjection; -using EasyNetQ; -using Newtonsoft.Json; -using Serilog; -using Microsoft.Extensions.Hosting; -using Hangfire; -using System.Net.Http.Headers; -using System.Text; -using System.Security.Policy; -using Microsoft.EntityFrameworkCore; -using System.Threading.Tasks; using TRE_API.Repositories.DbContexts; using TRE_API.Services; using BL.Services; -using Microsoft.AspNetCore.SignalR; -using Newtonsoft.Json.Linq; using TREAgent.Repositories; using System.Net.Http.Json; using TRE_API.Models; @@ -58,7 +29,7 @@ namespace TRE_API public interface IDoAgentWork { void Execute(); - Task CheckTESK(string taskID, int subId, string tesId, string outputBucket); + Task CheckTESK(string taskID, int subId, string tesId, string outputBucket, string NameTes); void ClearJob(string jobname); Task testing(string toRun, string Role); } @@ -180,13 +151,13 @@ public async Task testing(string toRun, string Role) { var stringdata = JsonConvert.SerializeObject(tesMessage); Log.Information("{Function} tesMessage is not null runhing CreateTESK {tesMessage}", "Execute", stringdata); - CreateTESK(stringdata, 99, "123COOOLLL", OutputBucket); + CreateTESK(stringdata, 99, "123COOOLLL", OutputBucket, "cool DEBUG NAME"); } } - public string CreateTESK(string jsonContent, int subId, string tesId, string outputBucket) + public string CreateTESK(string jsonContent, int subId, string tesId, string outputBucket, string Tesname) { Log.Information("{Function} {jsonContent} runhing CreateTESK ", "CreateTESK", jsonContent); @@ -236,7 +207,7 @@ public string CreateTESK(string jsonContent, int subId, string tesId, string out var responseObj = JsonConvert.DeserializeObject(responseBody); string id = responseObj.id; - RecurringJob.AddOrUpdate(id, a => a.CheckTESK(id, subId, tesId, outputBucket), + RecurringJob.AddOrUpdate(id, a => a.CheckTESK(id, subId, tesId, outputBucket, Tesname), Cron.MinuteInterval(1)); _dbContext.Add(new TeskAudit() { message = jsonContent, teskid = tesId, subid = subId.ToString() }); @@ -258,7 +229,7 @@ class ResponseModel public string id { get; set; } } - public async Task CheckTESK(string taskID, int subId, string tesId, string outputBucket) + public async Task CheckTESK(string taskID, int subId, string tesId, string outputBucket, string NameTes) { try { @@ -429,7 +400,9 @@ public async Task CheckTESK(string taskID, int subId, string tesId, string outpu _subHelper.FilesReadyForReview(new ReviewFiles() { SubId = subId.ToString(), - Files = files + Files = files, + tesId = tesId.ToString(), + Name = NameTes }, outputBucketGood); } @@ -676,7 +649,8 @@ public void Execute() { var stringdata = JsonConvert.SerializeObject(tesMessage); Log.Information("{Function} tesMessage is not null runhing CreateTESK {tesMessage}", "Execute", stringdata); - CreateTESK(stringdata, aSubmission.Id, aSubmission.TesId, OutputBucket); + + CreateTESK(stringdata, aSubmission.Id, aSubmission.TesId, OutputBucket, tesMessage.Name); } } diff --git a/src/TRE-API/Services/SubmissionHelper.cs b/src/TRE-API/Services/SubmissionHelper.cs index e9401b4d5..b97acd37d 100644 --- a/src/TRE-API/Services/SubmissionHelper.cs +++ b/src/TRE-API/Services/SubmissionHelper.cs @@ -267,7 +267,9 @@ public BoolReturn FilesReadyForReview(ReviewFiles review, string Bucketname) SubmissionId = review.SubId, OutputBucket = Bucketname, Status = EgressStatus.NotCompleted, - Files = new List() + Files = new List(), + tesId = review.tesId, + Name = review.Name, }; foreach (var reviewFile in review.Files)