Skip to content

Commit

Permalink
Set inspection id from isar response
Browse files Browse the repository at this point in the history
  • Loading branch information
tsundvoll committed Dec 12, 2024
1 parent 37e3ee5 commit 716ba89
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
6 changes: 6 additions & 0 deletions backend/api/Database/Models/Inspection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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; }

Expand Down Expand Up @@ -126,6 +131,7 @@ public void UpdateWithIsarInfo(IsarTask isarTask)
)
};
IsarTaskId = isarTask.IsarTaskId;
if (isarTask.IsarInspectionId != null) { IsarInspectionId = isarTask.IsarInspectionId; }
}

public void UpdateStatus(IsarTaskStatus isarStatus)
Expand Down
9 changes: 0 additions & 9 deletions backend/api/Services/Models/IsarMissionDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ namespace Api.Services.Models
/// </summary>
public struct IsarMissionDefinition
{
[JsonPropertyName("id")]
public string? Id { get; set; }

[JsonPropertyName("name")]
public string? Name { get; set; }

Expand All @@ -30,14 +27,12 @@ public struct IsarMissionDefinition

public IsarMissionDefinition(List<IsarTaskDefinition> 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;
Expand Down Expand Up @@ -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; }

Expand All @@ -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,
Expand Down
17 changes: 9 additions & 8 deletions backend/api/Services/Models/IsarStartMissionResponse.cs
Original file line number Diff line number Diff line change
@@ -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<IsarTaskResponse> Tasks { get; set; }
public required IList<IsarTaskResponse> 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; }

}
}
2 changes: 2 additions & 0 deletions backend/api/Services/Models/IsarTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 716ba89

Please sign in to comment.