From 716ba89c4e523b2c65196bfe8e7c9118efe12d0b Mon Sep 17 00:00:00 2001 From: Thomas Sundvoll <35451859+tsundvoll@users.noreply.github.com> Date: Thu, 12 Dec 2024 14:44:48 +0100 Subject: [PATCH] Set inspection id from isar response --- backend/api/Database/Models/Inspection.cs | 6 ++++++ .../Services/Models/IsarMissionDefinition.cs | 9 --------- .../Services/Models/IsarStartMissionResponse.cs | 17 +++++++++-------- backend/api/Services/Models/IsarTask.cs | 2 ++ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/backend/api/Database/Models/Inspection.cs b/backend/api/Database/Models/Inspection.cs index e3d738af1..8bcd2a34b 100644 --- a/backend/api/Database/Models/Inspection.cs +++ b/backend/api/Database/Models/Inspection.cs @@ -47,6 +47,7 @@ public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bo { Id = useEmptyID ? "" : Guid.NewGuid().ToString(); IsarTaskId = useEmptyID ? "" : copy.IsarTaskId; + IsarInspectionId = useEmptyID ? "" : copy.IsarInspectionId; Status = inspectionStatus ?? copy.Status; InspectionType = copy.InspectionType; VideoDuration = copy.VideoDuration; @@ -64,6 +65,10 @@ public Inspection(Inspection copy, InspectionStatus? inspectionStatus = null, bo // ReSharper disable once AutoPropertyCanBeMadeGetOnly.Local public string IsarTaskId { get; set; } = Guid.NewGuid().ToString(); + [Required] + [MaxLength(200)] + public string IsarInspectionId { get; set; } = Guid.NewGuid().ToString(); + [Required] public Position InspectionTarget { get; set; } @@ -126,6 +131,7 @@ public void UpdateWithIsarInfo(IsarTask isarTask) ) }; IsarTaskId = isarTask.IsarTaskId; + if (isarTask.IsarInspectionId != null) { IsarInspectionId = isarTask.IsarInspectionId; } } public void UpdateStatus(IsarTaskStatus isarStatus) diff --git a/backend/api/Services/Models/IsarMissionDefinition.cs b/backend/api/Services/Models/IsarMissionDefinition.cs index 7d4347488..e6aa5f4be 100644 --- a/backend/api/Services/Models/IsarMissionDefinition.cs +++ b/backend/api/Services/Models/IsarMissionDefinition.cs @@ -10,9 +10,6 @@ namespace Api.Services.Models /// public struct IsarMissionDefinition { - [JsonPropertyName("id")] - public string? Id { get; set; } - [JsonPropertyName("name")] public string? Name { get; set; } @@ -30,14 +27,12 @@ public struct IsarMissionDefinition public IsarMissionDefinition(List tasks) { - Id = null; Name = null; Tasks = tasks; } public IsarMissionDefinition(MissionRun missionRun, bool includeStartPose = false) { - Id = missionRun.IsarMissionId; Name = missionRun.Name; Tasks = missionRun.Tasks.Select(task => new IsarTaskDefinition(task, missionRun)).ToList(); StartPose = includeStartPose && missionRun.Area.Deck.DefaultLocalizationPose != null ? new IsarPose(missionRun.Area.Deck.DefaultLocalizationPose.Pose) : null; @@ -80,9 +75,6 @@ public IsarTaskDefinition(MissionTask missionTask, MissionRun missionRun) public struct IsarInspectionDefinition { - [JsonPropertyName("id")] - public string? Id { get; set; } - [JsonPropertyName("type")] public string Type { get; set; } @@ -97,7 +89,6 @@ public struct IsarInspectionDefinition public IsarInspectionDefinition(Inspection inspection, MissionRun missionRun) { - Id = inspection.Id; Type = inspection.InspectionType.ToString(); InspectionTarget = inspection.InspectionTarget != null ? new IsarPosition( inspection.InspectionTarget.X, diff --git a/backend/api/Services/Models/IsarStartMissionResponse.cs b/backend/api/Services/Models/IsarStartMissionResponse.cs index 2c3063f79..16dbae617 100644 --- a/backend/api/Services/Models/IsarStartMissionResponse.cs +++ b/backend/api/Services/Models/IsarStartMissionResponse.cs @@ -1,30 +1,31 @@ using System.Text.Json.Serialization; -#nullable disable + namespace Api.Services.Models { public class IsarStartMissionResponse { [JsonPropertyName("id")] - public string MissionId { get; set; } + public required string MissionId { get; set; } [JsonPropertyName("tasks")] - public IList Tasks { get; set; } + public required IList Tasks { get; set; } } public class IsarTaskResponse { [JsonPropertyName("id")] - public string IsarTaskId { get; set; } + public required string IsarTaskId { get; set; } [JsonPropertyName("tag_id")] - public string TagId { get; set; } + public required string TagId { get; set; } + + [JsonPropertyName("inspection_id")] + public string? IsarInspectionId { get; set; } [JsonPropertyName("type")] - public string TaskType { get; set; } + public required string TaskType { get; set; } - [JsonPropertyName("task_action_id")] - public string TaskActionId { get; set; } } } diff --git a/backend/api/Services/Models/IsarTask.cs b/backend/api/Services/Models/IsarTask.cs index cd98ee82e..7ff14fbcc 100644 --- a/backend/api/Services/Models/IsarTask.cs +++ b/backend/api/Services/Models/IsarTask.cs @@ -4,6 +4,8 @@ public class IsarTask(IsarTaskResponse taskResponse) { public string IsarTaskId { get; } = taskResponse.IsarTaskId; + public string? IsarInspectionId { get; } = taskResponse.IsarInspectionId; + public IsarTaskStatus TaskStatus { get; } = IsarTaskStatus.NotStarted; public IsarTaskType TaskType { get; } = TaskTypeFromString(taskResponse.TaskType);