From b85914c516e0162c0a18e907ffab43b43791cf32 Mon Sep 17 00:00:00 2001 From: oysand Date: Wed, 20 Sep 2023 11:54:46 +0200 Subject: [PATCH] Remove default localization area from deck --- backend/api/Controllers/DeckController.cs | 50 - .../api/Database/Context/FlotillaDbContext.cs | 7 +- backend/api/Database/Models/Deck.cs | 5 - ...dDefaultLocalizationAreaToDeck.Designer.cs | 1133 ----------------- ...083418_AddDefaultLocalizationAreaToDeck.cs | 115 -- .../FlotillaDbContextModelSnapshot.cs | 188 ++- backend/api/Services/DeckService.cs | 2 +- 7 files changed, 89 insertions(+), 1411 deletions(-) delete mode 100644 backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.Designer.cs delete mode 100644 backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.cs diff --git a/backend/api/Controllers/DeckController.cs b/backend/api/Controllers/DeckController.cs index 118807a3a..b1a208552 100644 --- a/backend/api/Controllers/DeckController.cs +++ b/backend/api/Controllers/DeckController.cs @@ -16,14 +16,12 @@ public class DeckController : ControllerBase private readonly IPlantService _plantService; private readonly IMapService _mapService; - private readonly IAreaService _areaService; private readonly ILogger _logger; public DeckController( ILogger logger, IMapService mapService, - IAreaService areaService, IDeckService deckService, IInstallationService installationService, IPlantService plantService, @@ -32,7 +30,6 @@ IMissionDefinitionService missionDefinitionService { _logger = logger; _mapService = mapService; - _areaService = areaService; _deckService = deckService; _installationService = installationService; _plantService = plantService; @@ -177,53 +174,6 @@ public async Task> Create([FromBody] CreateDeckQuery deck) } } - /// - /// Set default localization area for a deck - /// - /// - /// This query sets the default localization area for a deck - /// - [HttpPost] - [Authorize(Roles = Role.Admin)] - [Route("{deckId}/{areaId}/set-default-localization-area")] - [ProducesResponseType(typeof(AreaResponse), StatusCodes.Status201Created)] - [ProducesResponseType(StatusCodes.Status400BadRequest)] - [ProducesResponseType(StatusCodes.Status401Unauthorized)] - [ProducesResponseType(StatusCodes.Status403Forbidden)] - [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> SetDefaultLocalizationArea( - [FromRoute] string deckId, - [FromRoute] string areaId - ) - { - _logger.LogInformation(@"Setting default localization area {AreaId} to deck {DeckId}", areaId, deckId); - var deck = await _deckService.ReadById(deckId); - if (deck == null) - return NotFound($"Could not find deck with id {deckId}"); - - var area = await _areaService.ReadById(areaId); - if (area == null) - return NotFound($"Could not find area with id {areaId}"); - - if (area.Deck == null) - return NotFound($"Area {areaId} is not linked to any deck"); - - if (area.Deck.Id != deckId) - return NotFound($"Area {areaId} is not linked to deck {deckId}"); - - try - { - deck.DefaultLocalizationArea = area; - var updatedDeck = await _deckService.Update(deck); - return Ok(updatedDeck); - } - catch (Exception e) - { - _logger.LogError(e, "Error while setting a default localization area"); - return StatusCode(StatusCodes.Status500InternalServerError); - } - } - /// /// Deletes the deck with the specified id from the database. /// diff --git a/backend/api/Database/Context/FlotillaDbContext.cs b/backend/api/Database/Context/FlotillaDbContext.cs index 175e8bc43..218dc2ff9 100644 --- a/backend/api/Database/Context/FlotillaDbContext.cs +++ b/backend/api/Database/Context/FlotillaDbContext.cs @@ -73,13 +73,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) poseBuilder.OwnsOne(pose => pose.Position); poseBuilder.OwnsOne(pose => pose.Orientation); }); - modelBuilder.Entity().HasOne(a => a.Deck); + modelBuilder.Entity().HasOne(a => a.Deck).WithMany(); modelBuilder.Entity().HasOne(a => a.Installation).WithMany(); modelBuilder.Entity().HasOne(a => a.Plant).WithMany(); modelBuilder.Entity().HasOne(d => d.Plant).WithMany(); - modelBuilder.Entity().HasOne(d => d.Installation).WithMany(); - modelBuilder.Entity().HasOne(d => d.DefaultLocalizationArea).WithOne(a => a.Deck); modelBuilder.Entity().HasOne(a => a.Installation).WithMany(); modelBuilder.Entity().OwnsOne(s => s.Pose, poseBuilder => @@ -95,12 +93,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity().HasIndex(a => new { a.InstallationCode }).IsUnique(); modelBuilder.Entity().HasIndex(a => new { a.PlantCode }).IsUnique(); - modelBuilder.Entity().HasOne(a => a.Deck).WithOne().OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity().HasOne(a => a.Deck).WithMany().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(a => a.Plant).WithMany().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(a => a.Installation).WithMany().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(d => d.Plant).WithMany().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(d => d.Installation).WithMany().OnDelete(DeleteBehavior.Restrict); - modelBuilder.Entity().HasOne(d => d.DefaultLocalizationArea).WithOne().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(p => p.Installation).WithMany().OnDelete(DeleteBehavior.Restrict); } diff --git a/backend/api/Database/Models/Deck.cs b/backend/api/Database/Models/Deck.cs index 67e1b10f9..054d0d553 100644 --- a/backend/api/Database/Models/Deck.cs +++ b/backend/api/Database/Models/Deck.cs @@ -14,11 +14,6 @@ public class Deck public virtual Installation Installation { get; set; } - public string? DefaultLocalizationAreaId { get; set; } - - [ForeignKey("DefaultLocalizationAreaId")] - public virtual Area? DefaultLocalizationArea { get; set; } - [Required] [MaxLength(200)] public string Name { get; set; } diff --git a/backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.Designer.cs b/backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.Designer.cs deleted file mode 100644 index a83c4956f..000000000 --- a/backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.Designer.cs +++ /dev/null @@ -1,1133 +0,0 @@ -// -using System; -using Api.Database.Context; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Api.Migrations -{ - [DbContext(typeof(FlotillaDbContext))] - [Migration("20230908083418_AddDefaultLocalizationAreaToDeck")] - partial class AddDefaultLocalizationAreaToDeck - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Api.Database.Models.Area", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("InstallationId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PlantId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("InstallationId"); - - b.HasIndex("PlantId"); - - b.ToTable("Areas"); - }); - - modelBuilder.Entity("Api.Database.Models.Deck", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b.Property("DefaultLocalizationAreaId") - .HasColumnType("nvarchar(450)"); - - b.Property("InstallationId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PlantId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("AreaId") - .IsUnique() - .HasFilter("[AreaId] IS NOT NULL"); - - b.HasIndex("DefaultLocalizationAreaId") - .IsUnique() - .HasFilter("[DefaultLocalizationAreaId] IS NOT NULL"); - - b.HasIndex("InstallationId"); - - b.HasIndex("PlantId"); - - b.ToTable("Decks"); - }); - - modelBuilder.Entity("Api.Database.Models.Installation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("InstallationCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.HasKey("Id"); - - b.HasIndex("InstallationCode") - .IsUnique(); - - b.ToTable("Installations"); - }); - - modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("InspectionFrequency") - .HasColumnType("time"); - - b.Property("InstallationCode") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("IsDeprecated") - .HasColumnType("bit"); - - b.Property("LastRunId") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("SourceId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("AreaId"); - - b.HasIndex("LastRunId"); - - b.HasIndex("SourceId"); - - b.ToTable("MissionDefinitions"); - }); - - modelBuilder.Entity("Api.Database.Models.MissionRun", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b.Property("Comment") - .HasMaxLength(1000) - .HasColumnType("nvarchar(1000)"); - - b.Property("Description") - .HasMaxLength(450) - .HasColumnType("nvarchar(450)"); - - b.Property("DesiredStartTime") - .HasColumnType("datetimeoffset"); - - b.Property("EndTime") - .HasColumnType("datetimeoffset"); - - b.Property("EstimatedDuration") - .HasColumnType("bigint"); - - b.Property("InstallationCode") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("IsarMissionId") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("MissionId") - .HasColumnType("nvarchar(max)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("RobotId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("StartTime") - .HasColumnType("datetimeoffset"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("StatusReason") - .HasMaxLength(450) - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("AreaId"); - - b.HasIndex("RobotId"); - - b.ToTable("MissionRuns"); - }); - - modelBuilder.Entity("Api.Database.Models.Plant", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("InstallationId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("PlantCode") - .IsRequired() - .HasMaxLength(10) - .HasColumnType("nvarchar(10)"); - - b.HasKey("Id"); - - b.HasIndex("InstallationId"); - - b.HasIndex("PlantCode") - .IsUnique(); - - b.ToTable("Plants"); - }); - - modelBuilder.Entity("Api.Database.Models.Robot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("BatteryLevel") - .HasColumnType("real"); - - b.Property("CurrentAreaId") - .HasColumnType("nvarchar(450)"); - - b.Property("CurrentInstallation") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("CurrentMissionId") - .HasColumnType("nvarchar(max)"); - - b.Property("Enabled") - .HasColumnType("bit"); - - b.Property("Host") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("IsarId") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("ModelId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Port") - .HasColumnType("int"); - - b.Property("PressureLevel") - .HasColumnType("real"); - - b.Property("SerialNumber") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("CurrentAreaId"); - - b.HasIndex("ModelId"); - - b.ToTable("Robots"); - }); - - modelBuilder.Entity("Api.Database.Models.RobotModel", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("AverageDurationPerTag") - .HasColumnType("real"); - - b.Property("BatteryWarningThreshold") - .HasColumnType("real"); - - b.Property("LowerPressureWarningThreshold") - .HasColumnType("real"); - - b.Property("Type") - .IsRequired() - .HasColumnType("nvarchar(56)"); - - b.Property("UpperPressureWarningThreshold") - .HasColumnType("real"); - - b.HasKey("Id"); - - b.HasIndex("Type") - .IsUnique(); - - b.ToTable("RobotModels"); - }); - - modelBuilder.Entity("Api.Database.Models.SafePosition", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b.HasKey("Id"); - - b.HasIndex("AreaId"); - - b.ToTable("SafePositions"); - }); - - modelBuilder.Entity("Api.Database.Models.Source", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b.Property("SourceId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Type") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.ToTable("Sources"); - }); - - modelBuilder.Entity("Api.Database.Models.Area", b => - { - b.HasOne("Api.Database.Models.Installation", "Installation") - .WithMany() - .HasForeignKey("InstallationId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Api.Database.Models.Plant", "Plant") - .WithMany() - .HasForeignKey("PlantId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.OwnsOne("Api.Database.Models.Pose", "DefaultLocalizationPose", b1 => - { - b1.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b1.HasKey("AreaId"); - - b1.ToTable("Areas"); - - b1.WithOwner() - .HasForeignKey("AreaId"); - - b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => - { - b2.Property("PoseAreaId") - .HasColumnType("nvarchar(450)"); - - b2.Property("W") - .HasColumnType("real"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("PoseAreaId"); - - b2.ToTable("Areas"); - - b2.WithOwner() - .HasForeignKey("PoseAreaId"); - }); - - b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => - { - b2.Property("PoseAreaId") - .HasColumnType("nvarchar(450)"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("PoseAreaId"); - - b2.ToTable("Areas"); - - b2.WithOwner() - .HasForeignKey("PoseAreaId"); - }); - - b1.Navigation("Orientation") - .IsRequired(); - - b1.Navigation("Position") - .IsRequired(); - }); - - b.OwnsOne("Api.Database.Models.MapMetadata", "MapMetadata", b1 => - { - b1.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b1.Property("MapName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.HasKey("AreaId"); - - b1.ToTable("Areas"); - - b1.WithOwner() - .HasForeignKey("AreaId"); - - b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => - { - b2.Property("MapMetadataAreaId") - .HasColumnType("nvarchar(450)"); - - b2.Property("X1") - .HasColumnType("float"); - - b2.Property("X2") - .HasColumnType("float"); - - b2.Property("Y1") - .HasColumnType("float"); - - b2.Property("Y2") - .HasColumnType("float"); - - b2.Property("Z1") - .HasColumnType("float"); - - b2.Property("Z2") - .HasColumnType("float"); - - b2.HasKey("MapMetadataAreaId"); - - b2.ToTable("Areas"); - - b2.WithOwner() - .HasForeignKey("MapMetadataAreaId"); - }); - - b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => - { - b2.Property("MapMetadataAreaId") - .HasColumnType("nvarchar(450)"); - - b2.Property("C1") - .HasColumnType("float"); - - b2.Property("C2") - .HasColumnType("float"); - - b2.Property("D1") - .HasColumnType("float"); - - b2.Property("D2") - .HasColumnType("float"); - - b2.HasKey("MapMetadataAreaId"); - - b2.ToTable("Areas"); - - b2.WithOwner() - .HasForeignKey("MapMetadataAreaId"); - }); - - b1.Navigation("Boundary") - .IsRequired(); - - b1.Navigation("TransformationMatrices") - .IsRequired(); - }); - - b.Navigation("DefaultLocalizationPose") - .IsRequired(); - - b.Navigation("Installation"); - - b.Navigation("MapMetadata") - .IsRequired(); - - b.Navigation("Plant"); - }); - - modelBuilder.Entity("Api.Database.Models.Deck", b => - { - b.HasOne("Api.Database.Models.Area", null) - .WithOne("Deck") - .HasForeignKey("Api.Database.Models.Deck", "AreaId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("Api.Database.Models.Area", "DefaultLocalizationArea") - .WithOne() - .HasForeignKey("Api.Database.Models.Deck", "DefaultLocalizationAreaId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("Api.Database.Models.Installation", "Installation") - .WithMany() - .HasForeignKey("InstallationId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.HasOne("Api.Database.Models.Plant", "Plant") - .WithMany() - .HasForeignKey("PlantId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("DefaultLocalizationArea"); - - b.Navigation("Installation"); - - b.Navigation("Plant"); - }); - - modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => - { - b.HasOne("Api.Database.Models.Area", "Area") - .WithMany() - .HasForeignKey("AreaId"); - - b.HasOne("Api.Database.Models.MissionRun", "LastRun") - .WithMany() - .HasForeignKey("LastRunId"); - - b.HasOne("Api.Database.Models.Source", "Source") - .WithMany() - .HasForeignKey("SourceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Area"); - - b.Navigation("LastRun"); - - b.Navigation("Source"); - }); - - modelBuilder.Entity("Api.Database.Models.MissionRun", b => - { - b.HasOne("Api.Database.Models.Area", "Area") - .WithMany() - .HasForeignKey("AreaId"); - - b.HasOne("Api.Database.Models.Robot", "Robot") - .WithMany() - .HasForeignKey("RobotId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Api.Database.Models.MapMetadata", "Map", b1 => - { - b1.Property("MissionRunId") - .HasColumnType("nvarchar(450)"); - - b1.Property("MapName") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.HasKey("MissionRunId"); - - b1.ToTable("MissionRuns"); - - b1.WithOwner() - .HasForeignKey("MissionRunId"); - - b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => - { - b2.Property("MapMetadataMissionRunId") - .HasColumnType("nvarchar(450)"); - - b2.Property("X1") - .HasColumnType("float"); - - b2.Property("X2") - .HasColumnType("float"); - - b2.Property("Y1") - .HasColumnType("float"); - - b2.Property("Y2") - .HasColumnType("float"); - - b2.Property("Z1") - .HasColumnType("float"); - - b2.Property("Z2") - .HasColumnType("float"); - - b2.HasKey("MapMetadataMissionRunId"); - - b2.ToTable("MissionRuns"); - - b2.WithOwner() - .HasForeignKey("MapMetadataMissionRunId"); - }); - - b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => - { - b2.Property("MapMetadataMissionRunId") - .HasColumnType("nvarchar(450)"); - - b2.Property("C1") - .HasColumnType("float"); - - b2.Property("C2") - .HasColumnType("float"); - - b2.Property("D1") - .HasColumnType("float"); - - b2.Property("D2") - .HasColumnType("float"); - - b2.HasKey("MapMetadataMissionRunId"); - - b2.ToTable("MissionRuns"); - - b2.WithOwner() - .HasForeignKey("MapMetadataMissionRunId"); - }); - - b1.Navigation("Boundary") - .IsRequired(); - - b1.Navigation("TransformationMatrices") - .IsRequired(); - }); - - b.OwnsMany("Api.Database.Models.MissionTask", "Tasks", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b1.Property("Description") - .HasMaxLength(500) - .HasColumnType("nvarchar(500)"); - - b1.Property("EchoPoseId") - .HasColumnType("int"); - - b1.Property("EchoTagLink") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.Property("EndTime") - .HasColumnType("datetimeoffset"); - - b1.Property("IsarTaskId") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.Property("MissionRunId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b1.Property("StartTime") - .HasColumnType("datetimeoffset"); - - b1.Property("Status") - .HasColumnType("int"); - - b1.Property("TagId") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.Property("TaskOrder") - .HasColumnType("int"); - - b1.HasKey("Id"); - - b1.HasIndex("MissionRunId"); - - b1.ToTable("MissionTask"); - - b1.WithOwner() - .HasForeignKey("MissionRunId"); - - b1.OwnsMany("Api.Database.Models.Inspection", "Inspections", b2 => - { - b2.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b2.Property("AnalysisType") - .HasColumnType("int"); - - b2.Property("EndTime") - .HasColumnType("datetimeoffset"); - - b2.Property("InspectionType") - .HasColumnType("int"); - - b2.Property("InspectionUrl") - .HasMaxLength(250) - .HasColumnType("nvarchar(250)"); - - b2.Property("IsarStepId") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b2.Property("MissionTaskId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b2.Property("StartTime") - .HasColumnType("datetimeoffset"); - - b2.Property("Status") - .HasColumnType("int"); - - b2.Property("VideoDuration") - .HasColumnType("real"); - - b2.HasKey("Id"); - - b2.HasIndex("MissionTaskId"); - - b2.ToTable("Inspection"); - - b2.WithOwner() - .HasForeignKey("MissionTaskId"); - }); - - b1.OwnsOne("Api.Database.Models.Position", "InspectionTarget", b2 => - { - b2.Property("MissionTaskId") - .HasColumnType("nvarchar(450)"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("MissionTaskId"); - - b2.ToTable("MissionTask"); - - b2.WithOwner() - .HasForeignKey("MissionTaskId"); - }); - - b1.OwnsOne("Api.Database.Models.Pose", "RobotPose", b2 => - { - b2.Property("MissionTaskId") - .HasColumnType("nvarchar(450)"); - - b2.HasKey("MissionTaskId"); - - b2.ToTable("MissionTask"); - - b2.WithOwner() - .HasForeignKey("MissionTaskId"); - - b2.OwnsOne("Api.Database.Models.Orientation", "Orientation", b3 => - { - b3.Property("PoseMissionTaskId") - .HasColumnType("nvarchar(450)"); - - b3.Property("W") - .HasColumnType("real"); - - b3.Property("X") - .HasColumnType("real"); - - b3.Property("Y") - .HasColumnType("real"); - - b3.Property("Z") - .HasColumnType("real"); - - b3.HasKey("PoseMissionTaskId"); - - b3.ToTable("MissionTask"); - - b3.WithOwner() - .HasForeignKey("PoseMissionTaskId"); - }); - - b2.OwnsOne("Api.Database.Models.Position", "Position", b3 => - { - b3.Property("PoseMissionTaskId") - .HasColumnType("nvarchar(450)"); - - b3.Property("X") - .HasColumnType("real"); - - b3.Property("Y") - .HasColumnType("real"); - - b3.Property("Z") - .HasColumnType("real"); - - b3.HasKey("PoseMissionTaskId"); - - b3.ToTable("MissionTask"); - - b3.WithOwner() - .HasForeignKey("PoseMissionTaskId"); - }); - - b2.Navigation("Orientation") - .IsRequired(); - - b2.Navigation("Position") - .IsRequired(); - }); - - b1.Navigation("InspectionTarget") - .IsRequired(); - - b1.Navigation("Inspections"); - - b1.Navigation("RobotPose") - .IsRequired(); - }); - - b.Navigation("Area"); - - b.Navigation("Map"); - - b.Navigation("Robot"); - - b.Navigation("Tasks"); - }); - - modelBuilder.Entity("Api.Database.Models.Plant", b => - { - b.HasOne("Api.Database.Models.Installation", "Installation") - .WithMany() - .HasForeignKey("InstallationId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Installation"); - }); - - modelBuilder.Entity("Api.Database.Models.Robot", b => - { - b.HasOne("Api.Database.Models.Area", "CurrentArea") - .WithMany() - .HasForeignKey("CurrentAreaId"); - - b.HasOne("Api.Database.Models.RobotModel", "Model") - .WithMany() - .HasForeignKey("ModelId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => - { - b1.Property("RobotId") - .HasColumnType("nvarchar(450)"); - - b1.HasKey("RobotId"); - - b1.ToTable("Robots"); - - b1.WithOwner() - .HasForeignKey("RobotId"); - - b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => - { - b2.Property("PoseRobotId") - .HasColumnType("nvarchar(450)"); - - b2.Property("W") - .HasColumnType("real"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("PoseRobotId"); - - b2.ToTable("Robots"); - - b2.WithOwner() - .HasForeignKey("PoseRobotId"); - }); - - b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => - { - b2.Property("PoseRobotId") - .HasColumnType("nvarchar(450)"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("PoseRobotId"); - - b2.ToTable("Robots"); - - b2.WithOwner() - .HasForeignKey("PoseRobotId"); - }); - - b1.Navigation("Orientation") - .IsRequired(); - - b1.Navigation("Position") - .IsRequired(); - }); - - b.OwnsMany("Api.Database.Models.VideoStream", "VideoStreams", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("nvarchar(450)"); - - b1.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.Property("RobotId") - .IsRequired() - .HasColumnType("nvarchar(450)"); - - b1.Property("ShouldRotate270Clockwise") - .HasColumnType("bit"); - - b1.Property("Type") - .IsRequired() - .HasMaxLength(64) - .HasColumnType("nvarchar(64)"); - - b1.Property("Url") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b1.HasKey("Id"); - - b1.HasIndex("RobotId"); - - b1.ToTable("VideoStream"); - - b1.WithOwner() - .HasForeignKey("RobotId"); - }); - - b.Navigation("CurrentArea"); - - b.Navigation("Model"); - - b.Navigation("Pose") - .IsRequired(); - - b.Navigation("VideoStreams"); - }); - - modelBuilder.Entity("Api.Database.Models.SafePosition", b => - { - b.HasOne("Api.Database.Models.Area", null) - .WithMany("SafePositions") - .HasForeignKey("AreaId"); - - b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => - { - b1.Property("SafePositionId") - .HasColumnType("nvarchar(450)"); - - b1.HasKey("SafePositionId"); - - b1.ToTable("SafePositions"); - - b1.WithOwner() - .HasForeignKey("SafePositionId"); - - b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => - { - b2.Property("PoseSafePositionId") - .HasColumnType("nvarchar(450)"); - - b2.Property("W") - .HasColumnType("real"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("PoseSafePositionId"); - - b2.ToTable("SafePositions"); - - b2.WithOwner() - .HasForeignKey("PoseSafePositionId"); - }); - - b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => - { - b2.Property("PoseSafePositionId") - .HasColumnType("nvarchar(450)"); - - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - - b2.HasKey("PoseSafePositionId"); - - b2.ToTable("SafePositions"); - - b2.WithOwner() - .HasForeignKey("PoseSafePositionId"); - }); - - b1.Navigation("Orientation") - .IsRequired(); - - b1.Navigation("Position") - .IsRequired(); - }); - - b.Navigation("Pose") - .IsRequired(); - }); - - modelBuilder.Entity("Api.Database.Models.Area", b => - { - b.Navigation("Deck"); - - b.Navigation("SafePositions"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.cs b/backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.cs deleted file mode 100644 index e3a4083c6..000000000 --- a/backend/api/Migrations/20230908083418_AddDefaultLocalizationAreaToDeck.cs +++ /dev/null @@ -1,115 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Api.Migrations -{ - /// - public partial class AddDefaultLocalizationAreaToDeck : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Areas_Decks_DeckId", - table: "Areas"); - - migrationBuilder.DropIndex( - name: "IX_Areas_DeckId", - table: "Areas"); - - migrationBuilder.DropColumn( - name: "DeckId", - table: "Areas"); - - migrationBuilder.AddColumn( - name: "AreaId", - table: "Decks", - type: "nvarchar(450)", - nullable: true); - - migrationBuilder.AddColumn( - name: "DefaultLocalizationAreaId", - table: "Decks", - type: "nvarchar(450)", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_Decks_AreaId", - table: "Decks", - column: "AreaId", - unique: true, - filter: "[AreaId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_Decks_DefaultLocalizationAreaId", - table: "Decks", - column: "DefaultLocalizationAreaId", - unique: true, - filter: "[DefaultLocalizationAreaId] IS NOT NULL"); - - migrationBuilder.AddForeignKey( - name: "FK_Decks_Areas_AreaId", - table: "Decks", - column: "AreaId", - principalTable: "Areas", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - - migrationBuilder.AddForeignKey( - name: "FK_Decks_Areas_DefaultLocalizationAreaId", - table: "Decks", - column: "DefaultLocalizationAreaId", - principalTable: "Areas", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_Decks_Areas_AreaId", - table: "Decks"); - - migrationBuilder.DropForeignKey( - name: "FK_Decks_Areas_DefaultLocalizationAreaId", - table: "Decks"); - - migrationBuilder.DropIndex( - name: "IX_Decks_AreaId", - table: "Decks"); - - migrationBuilder.DropIndex( - name: "IX_Decks_DefaultLocalizationAreaId", - table: "Decks"); - - migrationBuilder.DropColumn( - name: "AreaId", - table: "Decks"); - - migrationBuilder.DropColumn( - name: "DefaultLocalizationAreaId", - table: "Decks"); - - migrationBuilder.AddColumn( - name: "DeckId", - table: "Areas", - type: "nvarchar(450)", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_Areas_DeckId", - table: "Areas", - column: "DeckId"); - - migrationBuilder.AddForeignKey( - name: "FK_Areas_Decks_DeckId", - table: "Areas", - column: "DeckId", - principalTable: "Decks", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - } - } -} diff --git a/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs b/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs index 1d390791e..eadaffcc9 100644 --- a/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs +++ b/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs @@ -28,6 +28,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("nvarchar(450)"); + b.Property("DeckId") + .HasColumnType("nvarchar(450)"); + b.Property("InstallationId") .IsRequired() .HasColumnType("nvarchar(450)"); @@ -43,11 +46,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("DeckId"); + b.HasIndex("InstallationId"); b.HasIndex("PlantId"); - b.ToTable("Areas"); + b.ToTable("Areas", (string)null); }); modelBuilder.Entity("Api.Database.Models.Deck", b => @@ -56,12 +61,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("nvarchar(450)"); - b.Property("AreaId") - .HasColumnType("nvarchar(450)"); - - b.Property("DefaultLocalizationAreaId") - .HasColumnType("nvarchar(450)"); - b.Property("InstallationId") .IsRequired() .HasColumnType("nvarchar(450)"); @@ -77,19 +76,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("AreaId") - .IsUnique() - .HasFilter("[AreaId] IS NOT NULL"); - - b.HasIndex("DefaultLocalizationAreaId") - .IsUnique() - .HasFilter("[DefaultLocalizationAreaId] IS NOT NULL"); - b.HasIndex("InstallationId"); b.HasIndex("PlantId"); - b.ToTable("Decks"); + b.ToTable("Decks", (string)null); }); modelBuilder.Entity("Api.Database.Models.Installation", b => @@ -113,7 +104,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("InstallationCode") .IsUnique(); - b.ToTable("Installations"); + b.ToTable("Installations", (string)null); }); modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => @@ -159,7 +150,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SourceId"); - b.ToTable("MissionDefinitions"); + b.ToTable("MissionDefinitions", (string)null); }); modelBuilder.Entity("Api.Database.Models.MissionRun", b => @@ -225,7 +216,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("RobotId"); - b.ToTable("MissionRuns"); + b.ToTable("MissionRuns", (string)null); }); modelBuilder.Entity("Api.Database.Models.Plant", b => @@ -255,7 +246,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("PlantCode") .IsUnique(); - b.ToTable("Plants"); + b.ToTable("Plants", (string)null); }); modelBuilder.Entity("Api.Database.Models.Robot", b => @@ -319,7 +310,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ModelId"); - b.ToTable("Robots"); + b.ToTable("Robots", (string)null); }); modelBuilder.Entity("Api.Database.Models.RobotModel", b => @@ -349,7 +340,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Type") .IsUnique(); - b.ToTable("RobotModels"); + b.ToTable("RobotModels", (string)null); }); modelBuilder.Entity("Api.Database.Models.SafePosition", b => @@ -365,7 +356,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("AreaId"); - b.ToTable("SafePositions"); + b.ToTable("SafePositions", (string)null); }); modelBuilder.Entity("Api.Database.Models.Source", b => @@ -383,11 +374,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Sources"); + b.ToTable("Sources", (string)null); }); modelBuilder.Entity("Api.Database.Models.Area", b => { + b.HasOne("Api.Database.Models.Deck", "Deck") + .WithMany() + .HasForeignKey("DeckId") + .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Api.Database.Models.Installation", "Installation") .WithMany() .HasForeignKey("InstallationId") @@ -400,19 +396,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.OwnsOne("Api.Database.Models.Pose", "DefaultLocalizationPose", b1 => + b.OwnsOne("Api.Database.Models.Area.DefaultLocalizationPose#Api.Database.Models.Pose", "DefaultLocalizationPose", b1 => { b1.Property("AreaId") .HasColumnType("nvarchar(450)"); b1.HasKey("AreaId"); - b1.ToTable("Areas"); + b1.ToTable("Areas", (string)null); b1.WithOwner() .HasForeignKey("AreaId"); - b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + b1.OwnsOne("Api.Database.Models.Area.DefaultLocalizationPose#Api.Database.Models.Pose.Orientation#Api.Database.Models.Orientation", "Orientation", b2 => { b2.Property("PoseAreaId") .HasColumnType("nvarchar(450)"); @@ -431,13 +427,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseAreaId"); - b2.ToTable("Areas"); + b2.ToTable("Areas", (string)null); b2.WithOwner() .HasForeignKey("PoseAreaId"); }); - b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + b1.OwnsOne("Api.Database.Models.Area.DefaultLocalizationPose#Api.Database.Models.Pose.Position#Api.Database.Models.Position", "Position", b2 => { b2.Property("PoseAreaId") .HasColumnType("nvarchar(450)"); @@ -453,7 +449,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseAreaId"); - b2.ToTable("Areas"); + b2.ToTable("Areas", (string)null); b2.WithOwner() .HasForeignKey("PoseAreaId"); @@ -466,7 +462,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - b.OwnsOne("Api.Database.Models.MapMetadata", "MapMetadata", b1 => + b.OwnsOne("Api.Database.Models.Area.MapMetadata#Api.Database.Models.MapMetadata", "MapMetadata", b1 => { b1.Property("AreaId") .HasColumnType("nvarchar(450)"); @@ -478,12 +474,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("AreaId"); - b1.ToTable("Areas"); + b1.ToTable("Areas", (string)null); b1.WithOwner() .HasForeignKey("AreaId"); - b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + b1.OwnsOne("Api.Database.Models.Area.MapMetadata#Api.Database.Models.MapMetadata.Boundary#Api.Database.Models.Boundary", "Boundary", b2 => { b2.Property("MapMetadataAreaId") .HasColumnType("nvarchar(450)"); @@ -508,13 +504,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataAreaId"); - b2.ToTable("Areas"); + b2.ToTable("Areas", (string)null); b2.WithOwner() .HasForeignKey("MapMetadataAreaId"); }); - b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + b1.OwnsOne("Api.Database.Models.Area.MapMetadata#Api.Database.Models.MapMetadata.TransformationMatrices#Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => { b2.Property("MapMetadataAreaId") .HasColumnType("nvarchar(450)"); @@ -533,7 +529,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataAreaId"); - b2.ToTable("Areas"); + b2.ToTable("Areas", (string)null); b2.WithOwner() .HasForeignKey("MapMetadataAreaId"); @@ -546,6 +542,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); + b.Navigation("Deck"); + b.Navigation("DefaultLocalizationPose") .IsRequired(); @@ -559,16 +557,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Api.Database.Models.Deck", b => { - b.HasOne("Api.Database.Models.Area", null) - .WithOne("Deck") - .HasForeignKey("Api.Database.Models.Deck", "AreaId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("Api.Database.Models.Area", "DefaultLocalizationArea") - .WithOne() - .HasForeignKey("Api.Database.Models.Deck", "DefaultLocalizationAreaId") - .OnDelete(DeleteBehavior.Restrict); - b.HasOne("Api.Database.Models.Installation", "Installation") .WithMany() .HasForeignKey("InstallationId") @@ -581,8 +569,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.Navigation("DefaultLocalizationArea"); - b.Navigation("Installation"); b.Navigation("Plant"); @@ -623,7 +609,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.OwnsOne("Api.Database.Models.MapMetadata", "Map", b1 => + b.OwnsOne("Api.Database.Models.MissionRun.Map#Api.Database.Models.MapMetadata", "Map", b1 => { b1.Property("MissionRunId") .HasColumnType("nvarchar(450)"); @@ -635,12 +621,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey("MissionRunId"); - b1.ToTable("MissionRuns"); + b1.ToTable("MissionRuns", (string)null); b1.WithOwner() .HasForeignKey("MissionRunId"); - b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + b1.OwnsOne("Api.Database.Models.MissionRun.Map#Api.Database.Models.MapMetadata.Boundary#Api.Database.Models.Boundary", "Boundary", b2 => { b2.Property("MapMetadataMissionRunId") .HasColumnType("nvarchar(450)"); @@ -665,13 +651,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataMissionRunId"); - b2.ToTable("MissionRuns"); + b2.ToTable("MissionRuns", (string)null); b2.WithOwner() .HasForeignKey("MapMetadataMissionRunId"); }); - b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + b1.OwnsOne("Api.Database.Models.MissionRun.Map#Api.Database.Models.MapMetadata.TransformationMatrices#Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => { b2.Property("MapMetadataMissionRunId") .HasColumnType("nvarchar(450)"); @@ -690,7 +676,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("MapMetadataMissionRunId"); - b2.ToTable("MissionRuns"); + b2.ToTable("MissionRuns", (string)null); b2.WithOwner() .HasForeignKey("MapMetadataMissionRunId"); @@ -703,7 +689,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - b.OwnsMany("Api.Database.Models.MissionTask", "Tasks", b1 => + b.OwnsMany("Api.Database.Models.MissionRun.Tasks#Api.Database.Models.MissionTask", "Tasks", b1 => { b1.Property("Id") .ValueGeneratedOnAdd() @@ -748,12 +734,34 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasIndex("MissionRunId"); - b1.ToTable("MissionTask"); + b1.ToTable("MissionTask", (string)null); b1.WithOwner() .HasForeignKey("MissionRunId"); - b1.OwnsMany("Api.Database.Models.Inspection", "Inspections", b2 => + b1.OwnsOne("Api.Database.Models.MissionRun.Tasks#Api.Database.Models.MissionTask.InspectionTarget#Api.Database.Models.Position", "InspectionTarget", b2 => + { + b2.Property("MissionTaskId") + .HasColumnType("nvarchar(450)"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("MissionTaskId"); + + b2.ToTable("MissionTask", (string)null); + + b2.WithOwner() + .HasForeignKey("MissionTaskId"); + }); + + b1.OwnsMany("Api.Database.Models.MissionRun.Tasks#Api.Database.Models.MissionTask.Inspections#Api.Database.Models.Inspection", "Inspections", b2 => { b2.Property("Id") .ValueGeneratedOnAdd() @@ -793,47 +801,25 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasIndex("MissionTaskId"); - b2.ToTable("Inspection"); + b2.ToTable("Inspection", (string)null); b2.WithOwner() .HasForeignKey("MissionTaskId"); }); - b1.OwnsOne("Api.Database.Models.Position", "InspectionTarget", b2 => + b1.OwnsOne("Api.Database.Models.MissionRun.Tasks#Api.Database.Models.MissionTask.RobotPose#Api.Database.Models.Pose", "RobotPose", b2 => { b2.Property("MissionTaskId") .HasColumnType("nvarchar(450)"); - b2.Property("X") - .HasColumnType("real"); - - b2.Property("Y") - .HasColumnType("real"); - - b2.Property("Z") - .HasColumnType("real"); - b2.HasKey("MissionTaskId"); - b2.ToTable("MissionTask"); + b2.ToTable("MissionTask", (string)null); b2.WithOwner() .HasForeignKey("MissionTaskId"); - }); - - b1.OwnsOne("Api.Database.Models.Pose", "RobotPose", b2 => - { - b2.Property("MissionTaskId") - .HasColumnType("nvarchar(450)"); - b2.HasKey("MissionTaskId"); - - b2.ToTable("MissionTask"); - - b2.WithOwner() - .HasForeignKey("MissionTaskId"); - - b2.OwnsOne("Api.Database.Models.Orientation", "Orientation", b3 => + b2.OwnsOne("Api.Database.Models.MissionRun.Tasks#Api.Database.Models.MissionTask.RobotPose#Api.Database.Models.Pose.Orientation#Api.Database.Models.Orientation", "Orientation", b3 => { b3.Property("PoseMissionTaskId") .HasColumnType("nvarchar(450)"); @@ -852,13 +838,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b3.HasKey("PoseMissionTaskId"); - b3.ToTable("MissionTask"); + b3.ToTable("MissionTask", (string)null); b3.WithOwner() .HasForeignKey("PoseMissionTaskId"); }); - b2.OwnsOne("Api.Database.Models.Position", "Position", b3 => + b2.OwnsOne("Api.Database.Models.MissionRun.Tasks#Api.Database.Models.MissionTask.RobotPose#Api.Database.Models.Pose.Position#Api.Database.Models.Position", "Position", b3 => { b3.Property("PoseMissionTaskId") .HasColumnType("nvarchar(450)"); @@ -874,7 +860,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b3.HasKey("PoseMissionTaskId"); - b3.ToTable("MissionTask"); + b3.ToTable("MissionTask", (string)null); b3.WithOwner() .HasForeignKey("PoseMissionTaskId"); @@ -928,19 +914,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + b.OwnsOne("Api.Database.Models.Robot.Pose#Api.Database.Models.Pose", "Pose", b1 => { b1.Property("RobotId") .HasColumnType("nvarchar(450)"); b1.HasKey("RobotId"); - b1.ToTable("Robots"); + b1.ToTable("Robots", (string)null); b1.WithOwner() .HasForeignKey("RobotId"); - b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + b1.OwnsOne("Api.Database.Models.Robot.Pose#Api.Database.Models.Pose.Orientation#Api.Database.Models.Orientation", "Orientation", b2 => { b2.Property("PoseRobotId") .HasColumnType("nvarchar(450)"); @@ -959,13 +945,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseRobotId"); - b2.ToTable("Robots"); + b2.ToTable("Robots", (string)null); b2.WithOwner() .HasForeignKey("PoseRobotId"); }); - b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + b1.OwnsOne("Api.Database.Models.Robot.Pose#Api.Database.Models.Pose.Position#Api.Database.Models.Position", "Position", b2 => { b2.Property("PoseRobotId") .HasColumnType("nvarchar(450)"); @@ -981,7 +967,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseRobotId"); - b2.ToTable("Robots"); + b2.ToTable("Robots", (string)null); b2.WithOwner() .HasForeignKey("PoseRobotId"); @@ -994,7 +980,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - b.OwnsMany("Api.Database.Models.VideoStream", "VideoStreams", b1 => + b.OwnsMany("Api.Database.Models.Robot.VideoStreams#Api.Database.Models.VideoStream", "VideoStreams", b1 => { b1.Property("Id") .ValueGeneratedOnAdd() @@ -1026,7 +1012,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasIndex("RobotId"); - b1.ToTable("VideoStream"); + b1.ToTable("VideoStream", (string)null); b1.WithOwner() .HasForeignKey("RobotId"); @@ -1048,19 +1034,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) .WithMany("SafePositions") .HasForeignKey("AreaId"); - b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + b.OwnsOne("Api.Database.Models.SafePosition.Pose#Api.Database.Models.Pose", "Pose", b1 => { b1.Property("SafePositionId") .HasColumnType("nvarchar(450)"); b1.HasKey("SafePositionId"); - b1.ToTable("SafePositions"); + b1.ToTable("SafePositions", (string)null); b1.WithOwner() .HasForeignKey("SafePositionId"); - b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + b1.OwnsOne("Api.Database.Models.SafePosition.Pose#Api.Database.Models.Pose.Orientation#Api.Database.Models.Orientation", "Orientation", b2 => { b2.Property("PoseSafePositionId") .HasColumnType("nvarchar(450)"); @@ -1079,13 +1065,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseSafePositionId"); - b2.ToTable("SafePositions"); + b2.ToTable("SafePositions", (string)null); b2.WithOwner() .HasForeignKey("PoseSafePositionId"); }); - b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + b1.OwnsOne("Api.Database.Models.SafePosition.Pose#Api.Database.Models.Pose.Position#Api.Database.Models.Position", "Position", b2 => { b2.Property("PoseSafePositionId") .HasColumnType("nvarchar(450)"); @@ -1101,7 +1087,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b2.HasKey("PoseSafePositionId"); - b2.ToTable("SafePositions"); + b2.ToTable("SafePositions", (string)null); b2.WithOwner() .HasForeignKey("PoseSafePositionId"); @@ -1120,8 +1106,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Api.Database.Models.Area", b => { - b.Navigation("Deck"); - b.Navigation("SafePositions"); }); #pragma warning restore 612, 618 diff --git a/backend/api/Services/DeckService.cs b/backend/api/Services/DeckService.cs index beca409e8..55e1eaaf1 100644 --- a/backend/api/Services/DeckService.cs +++ b/backend/api/Services/DeckService.cs @@ -56,7 +56,7 @@ public async Task> ReadAll() private IQueryable GetDecks() { - return _context.Decks.Include(p => p.Plant).Include(i => i.Installation).Include(d => d.DefaultLocalizationArea); + return _context.Decks.Include(p => p.Plant).Include(i => i.Installation); } public async Task ReadById(string id)