diff --git a/backend/README.md b/backend/README.md index c443f4d1e..c59ce9627 100644 --- a/backend/README.md +++ b/backend/README.md @@ -315,7 +315,7 @@ The access matrix looks like this: | | **Read Only** | **User** | **Admin** | | -------------------------- | ------------- | -------- | --------- | | Area | Read | Read | CRUD | -| Deck | Read | Read | CRUD | +| InspectionArea | Read | Read | CRUD | | Plant | Read | Read | CRUD | | Installation | Read | Read | CRUD | | MissionLoader | Read | Read | CRUD | diff --git a/backend/api.test/Client/AreaTests.cs b/backend/api.test/Client/AreaTests.cs index 190a86a9b..277ab3e6a 100644 --- a/backend/api.test/Client/AreaTests.cs +++ b/backend/api.test/Client/AreaTests.cs @@ -82,12 +82,12 @@ public async Task AreaTest() Name = testPlant }; - string testDeck = "testDeckAreaTest"; - var deckQuery = new CreateDeckQuery + string testInspectionArea = "testInspectionAreaAreaTest"; + var inspectionAreaQuery = new CreateInspectionAreaQuery { InstallationCode = testInstallation, PlantCode = testPlant, - Name = testDeck + Name = testInspectionArea }; string testArea = "testAreaAreaTest"; @@ -95,7 +95,7 @@ public async Task AreaTest() { InstallationCode = testInstallation, PlantCode = testPlant, - DeckName = testDeck, + InspectionAreaName = testInspectionArea, AreaName = testArea, DefaultLocalizationPose = testPose }; @@ -112,8 +112,8 @@ public async Task AreaTest() "application/json" ); - var deckContent = new StringContent( - JsonSerializer.Serialize(deckQuery), + var inspectionAreaContent = new StringContent( + JsonSerializer.Serialize(inspectionAreaQuery), null, "application/json" ); @@ -129,15 +129,15 @@ public async Task AreaTest() var installationResponse = await _client.PostAsync(installationUrl, installationContent); string plantUrl = "/plants"; var plantResponse = await _client.PostAsync(plantUrl, plantContent); - string deckUrl = "/decks"; - var deckResponse = await _client.PostAsync(deckUrl, deckContent); + string inspectionAreaUrl = "/inspectionAreas"; + var inspectionAreaResponse = await _client.PostAsync(inspectionAreaUrl, inspectionAreaContent); string areaUrl = "/areas"; var areaResponse = await _client.PostAsync(areaUrl, areaContent); // Assert Assert.True(installationResponse.IsSuccessStatusCode); Assert.True(plantResponse.IsSuccessStatusCode); - Assert.True(deckResponse.IsSuccessStatusCode); + Assert.True(inspectionAreaResponse.IsSuccessStatusCode); Assert.True(areaResponse.IsSuccessStatusCode); var area = await areaResponse.Content.ReadFromJsonAsync(_serializerOptions); Assert.NotNull(area); @@ -149,7 +149,7 @@ public async Task MissionIsCreatedInInspectionArea() // Arrange - Initialise area var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); // Arrange - Robot var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation); @@ -178,7 +178,7 @@ public async Task MissionIsCreatedInInspectionArea() RobotId = robotId, DesiredStartTime = DateTime.UtcNow, InstallationCode = installation.InstallationCode, - InspectionAreaName = deck.Name, + InspectionAreaName = inspectionArea.Name, Name = testMissionName, Tasks = tasks }; @@ -197,8 +197,8 @@ public async Task MissionIsCreatedInInspectionArea() var mission = await missionResponse.Content.ReadFromJsonAsync(_serializerOptions); Assert.NotNull(mission); Assert.NotNull(mission.MissionId); - string inspectionAreaUrl = "/decks"; - var inspectionareaMissionsResponse = await _client.GetAsync(inspectionAreaUrl + $"/{deck.Id}/mission-definitions"); + string inspectionAreaUrl = "/inspectionAreas"; + var inspectionareaMissionsResponse = await _client.GetAsync(inspectionAreaUrl + $"/{inspectionArea.Id}/mission-definitions"); // Assert Assert.True(inspectionareaMissionsResponse.IsSuccessStatusCode); @@ -228,16 +228,16 @@ public async Task EmergencyDockTest() } [Fact] - public async Task UpdateDefaultLocalizationPoseOnDeck() + public async Task UpdateDefaultLocalizationPoseOnInspectionArea() { // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); - string deckId = deck.Id; + string inspectionAreaId = inspectionArea.Id; - string url = $"/decks/{deckId}/update-default-localization-pose"; + string url = $"/inspectionAreas/{inspectionAreaId}/update-default-localization-pose"; var query = new CreateDefaultLocalizationPose { Pose = new Pose @@ -266,13 +266,13 @@ public async Task UpdateDefaultLocalizationPoseOnDeck() // Act var putResponse = await _client.PutAsync(url, content); Assert.True(putResponse.IsSuccessStatusCode); - var putDeck = await putResponse.Content.ReadFromJsonAsync(_serializerOptions); + var putInspectionArea = await putResponse.Content.ReadFromJsonAsync(_serializerOptions); // Assert - Assert.NotNull(putDeck); - Assert.NotNull(putDeck.DefaultLocalizationPose); - Assert.True(putDeck.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z)); - Assert.True(putDeck.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W)); + Assert.NotNull(putInspectionArea); + Assert.NotNull(putInspectionArea.DefaultLocalizationPose); + Assert.True(putInspectionArea.DefaultLocalizationPose.Position.Z.Equals(query.Pose.Position.Z)); + Assert.True(putInspectionArea.DefaultLocalizationPose.Orientation.W.Equals(query.Pose.Orientation.W)); } } } diff --git a/backend/api.test/Client/MissionTests.cs b/backend/api.test/Client/MissionTests.cs index 7c669d1e0..0269d9902 100644 --- a/backend/api.test/Client/MissionTests.cs +++ b/backend/api.test/Client/MissionTests.cs @@ -159,8 +159,8 @@ public async Task AddNonDuplicateAreasToDb() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var _ = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, deck.Name); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var _ = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, inspectionArea.Name); var testPose = new Pose { @@ -182,7 +182,7 @@ public async Task AddNonDuplicateAreasToDb() { InstallationCode = installation.InstallationCode, PlantCode = plant.PlantCode, - DeckName = deck.Name, + InspectionAreaName = inspectionArea.Name, AreaName = "AddNonDuplicateAreasToDb_Area", DefaultLocalizationPose = testPose }; @@ -206,8 +206,8 @@ public async Task AddDuplicateAreasToDb_Fails() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, deck.Name); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, inspectionArea.Name); var testPose = new Pose { @@ -229,7 +229,7 @@ public async Task AddDuplicateAreasToDb_Fails() { InstallationCode = installation.InstallationCode, PlantCode = plant.PlantCode, - DeckName = deck.Name, + InspectionAreaName = inspectionArea.Name, AreaName = area.Name, DefaultLocalizationPose = testPose }; @@ -267,7 +267,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); string testMissionName = "testMissionScheduleDuplicateCustomMissionDefinitions"; @@ -280,7 +280,7 @@ public async Task ScheduleDuplicateCustomMissionDefinitions() { RobotId = robotId, InstallationCode = installation.InstallationCode, - InspectionAreaName = deck.Name, + InspectionAreaName = inspectionArea.Name, DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc), InspectionFrequency = new TimeSpan(14, 0, 0, 0), Name = testMissionName, @@ -342,7 +342,7 @@ public async Task GetNextRun() // Arrange - Initialise area var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); // Arrange - Robot var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation); @@ -354,7 +354,7 @@ public async Task GetNextRun() { RobotId = robotId, InstallationCode = installation.InstallationCode, - InspectionAreaName = deck.Name, + InspectionAreaName = inspectionArea.Name, DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc), InspectionFrequency = new TimeSpan(14, 0, 0, 0), Name = testMissionName, @@ -448,8 +448,8 @@ public async Task ScheduleDuplicatMissionDefinitions() // Arrange - Initialise area var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, deck.Name); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var area = await _databaseUtilities.ReadOrNewArea(installation.InstallationCode, plant.PlantCode, inspectionArea.Name); // Arrange - Robot var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation); @@ -499,7 +499,7 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission() // Arrange - Initialise area var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); string testMissionName = "testMissionDoesNotStartIfRobotIsNotInSameInstallationAsMission"; @@ -516,7 +516,7 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission() { RobotId = robotId, InstallationCode = installation.InstallationCode, - InspectionAreaName = deck.Name, + InspectionAreaName = inspectionArea.Name, DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc), InspectionFrequency = new TimeSpan(14, 0, 0, 0), Name = testMissionName, @@ -556,22 +556,22 @@ public async Task MissionDoesNotStartIfRobotIsNotInSameInstallationAsMission() } [Fact] - public async Task MissionFailsIfRobotIsNotInSameDeckAsMission() + public async Task MissionFailsIfRobotIsNotInSameInspectionAreaAsMission() { // Arrange - Initialise area var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - string deckName1 = "deckMissionFailsIfRobotIsNotInSameDeckAsMission1"; - var deck1 = await _databaseUtilities.NewDeck(installation.InstallationCode, plant.PlantCode, deckName1); + string inspectionAreaName1 = "inspectionAreaMissionFailsIfRobotIsNotInSameInspectionAreaAsMission1"; + var inspectionArea1 = await _databaseUtilities.NewInspectionArea(installation.InstallationCode, plant.PlantCode, inspectionAreaName1); - string deckName2 = "deckMissionFailsIfRobotIsNotInSameDeckAsMission2"; - var deck2 = await _databaseUtilities.NewDeck(installation.InstallationCode, plant.PlantCode, deckName2); + string inspectionAreaName2 = "inspectionAreaMissionFailsIfRobotIsNotInSameInspectionAreaAsMission2"; + var inspectionArea2 = await _databaseUtilities.NewInspectionArea(installation.InstallationCode, plant.PlantCode, inspectionAreaName2); - string testMissionName = "testMissionFailsIfRobotIsNotInSameDeckAsMission"; + string testMissionName = "testMissionFailsIfRobotIsNotInSameInspectionAreaAsMission"; // Arrange - Robot - var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck1); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea1); string robotId = robot.Id; // Arrange - Mission Run Query @@ -579,7 +579,7 @@ public async Task MissionFailsIfRobotIsNotInSameDeckAsMission() { RobotId = robotId, InstallationCode = installation.InstallationCode, - InspectionAreaName = deck2.Name, + InspectionAreaName = inspectionArea2.Name, DesiredStartTime = DateTime.SpecifyKind(new DateTime(3050, 1, 1), DateTimeKind.Utc), InspectionFrequency = new TimeSpan(14, 0, 0, 0), Name = testMissionName, diff --git a/backend/api.test/Client/RobotTests.cs b/backend/api.test/Client/RobotTests.cs index 89ea9ba01..db62c1279 100644 --- a/backend/api.test/Client/RobotTests.cs +++ b/backend/api.test/Client/RobotTests.cs @@ -95,7 +95,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation() var wrongInstallation = await _databaseUtilities.NewInstallation("wrongInstallation"); var wrongPlant = await _databaseUtilities.ReadOrNewPlant(wrongInstallation.InstallationCode); - var wrongDeck = await _databaseUtilities.ReadOrNewDeck(wrongInstallation.InstallationCode, wrongPlant.PlantCode); + var wrongInspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(wrongInstallation.InstallationCode, wrongPlant.PlantCode); // Arrange - Create robot var robotQuery = new CreateRobotQuery @@ -108,7 +108,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation() Host = "localhost", Port = 3000, CurrentInstallationCode = installation.InstallationCode, - CurrentInspectionAreaName = wrongDeck.Name, + CurrentInspectionAreaName = wrongInspectionArea.Name, }; string robotUrl = "/robots"; @@ -124,7 +124,7 @@ public async Task RobotIsNotCreatedWithAreaNotInInstallation() } catch (DbUpdateException ex) { - Assert.True(ex.Message == $"Could not create new robot in database as inspection area '{wrongDeck.Name}' does not exist in installation {installation.InstallationCode}"); + Assert.True(ex.Message == $"Could not create new robot in database as inspection area '{wrongInspectionArea.Name}' does not exist in installation {installation.InstallationCode}"); } } } diff --git a/backend/api.test/Client/RoleAccessTests.cs b/backend/api.test/Client/RoleAccessTests.cs index b0d575a27..b16851cec 100644 --- a/backend/api.test/Client/RoleAccessTests.cs +++ b/backend/api.test/Client/RoleAccessTests.cs @@ -116,13 +116,13 @@ public async Task AuthorisedGetPlantTest_NotFound() } [Fact] - public async Task ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTest() + public async Task ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTest() { // Arrange var accessRoleQuery = new CreateAccessRoleQuery { - InstallationCode = "ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestInstallation", - RoleName = "User.ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestInstallation", + InstallationCode = "ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInstallation", + RoleName = "User.ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInstallation", AccessLevel = RoleAccessLevel.USER }; var accessRoleContent = new StringContent( @@ -148,14 +148,14 @@ public async Task ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTest() } }; - string testInstallation = "ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestInstallation"; + string testInstallation = "ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInstallation"; var installationQuery = new CreateInstallationQuery { InstallationCode = testInstallation, Name = testInstallation }; - string testPlant = "ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestPlant"; + string testPlant = "ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestPlant"; var plantQuery = new CreatePlantQuery { InstallationCode = testInstallation, @@ -163,20 +163,20 @@ public async Task ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTest() Name = testPlant }; - string testDeck = "ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestDeck"; - var deckQuery = new CreateDeckQuery + string testInspectionArea = "ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInspectionArea"; + var inspectionAreaQuery = new CreateInspectionAreaQuery { InstallationCode = testInstallation, PlantCode = testPlant, - Name = testDeck + Name = testInspectionArea }; - string testArea = "ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestArea"; + string testArea = "ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestArea"; var areaQuery = new CreateAreaQuery { InstallationCode = testInstallation, PlantCode = testPlant, - DeckName = testDeck, + InspectionAreaName = testInspectionArea, AreaName = testArea, DefaultLocalizationPose = testPose }; @@ -193,8 +193,8 @@ public async Task ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTest() "application/json" ); - var deckContent = new StringContent( - JsonSerializer.Serialize(deckQuery), + var inspectionAreaContent = new StringContent( + JsonSerializer.Serialize(inspectionAreaQuery), null, "application/json" ); @@ -212,19 +212,19 @@ public async Task ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTest() var accessRoleResponse = await _client.PostAsync(accessRoleUrl, accessRoleContent); string plantUrl = "/plants"; var plantResponse = await _client.PostAsync(plantUrl, plantContent); - string deckUrl = "/decks"; - var deckResponse = await _client.PostAsync(deckUrl, deckContent); + string inspectionAreaUrl = "/inspectionAreas"; + var inspectionAreaResponse = await _client.PostAsync(inspectionAreaUrl, inspectionAreaContent); string areaUrl = "/areas"; var areaResponse = await _client.PostAsync(areaUrl, areaContent); // Only restrict ourselves to non-admin role after doing POSTs - _httpContextAccessor.SetHttpContextRoles(["User.ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTestInstallation"]); + _httpContextAccessor.SetHttpContextRoles(["User.ExplicitlyAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInstallation"]); // Assert Assert.True(accessRoleResponse.IsSuccessStatusCode); Assert.True(installationResponse.IsSuccessStatusCode); Assert.True(plantResponse.IsSuccessStatusCode); - Assert.True(deckResponse.IsSuccessStatusCode); + Assert.True(inspectionAreaResponse.IsSuccessStatusCode); Assert.True(areaResponse.IsSuccessStatusCode); var area = await areaResponse.Content.ReadFromJsonAsync(_serializerOptions); Assert.NotNull(area); @@ -241,7 +241,7 @@ public async Task ExplicitlyAuthorisedPostInstallationPlantDeckAndAreaTest() } [Fact] - public async Task AdminAuthorisedPostInstallationPlantDeckAndAreaTest() + public async Task AdminAuthorisedPostInstallationPlantInspectionAreaAndAreaTest() { // Arrange var testPose = new Pose @@ -261,14 +261,14 @@ public async Task AdminAuthorisedPostInstallationPlantDeckAndAreaTest() } }; - string testInstallation = "AdminAuthorisedPostInstallationPlantDeckAndAreaTestInstallation"; + string testInstallation = "AdminAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInstallation"; var installationQuery = new CreateInstallationQuery { InstallationCode = testInstallation, Name = testInstallation }; - string testPlant = "AdminAuthorisedPostInstallationPlantDeckAndAreaTestPlant"; + string testPlant = "AdminAuthorisedPostInstallationPlantInspectionAreaAndAreaTestPlant"; var plantQuery = new CreatePlantQuery { InstallationCode = testInstallation, @@ -276,20 +276,20 @@ public async Task AdminAuthorisedPostInstallationPlantDeckAndAreaTest() Name = testPlant }; - string testDeck = "AdminAuthorisedPostInstallationPlantDeckAndAreaTestDeck"; - var deckQuery = new CreateDeckQuery + string testInspectionArea = "AdminAuthorisedPostInstallationPlantInspectionAreaAndAreaTestInspectionArea"; + var inspectionAreaQuery = new CreateInspectionAreaQuery { InstallationCode = testInstallation, PlantCode = testPlant, - Name = testDeck + Name = testInspectionArea }; - string testArea = "AdminAuthorisedPostInstallationPlantDeckAndAreaTestArea"; + string testArea = "AdminAuthorisedPostInstallationPlantInspectionAreaAndAreaTestArea"; var areaQuery = new CreateAreaQuery { InstallationCode = testInstallation, PlantCode = testPlant, - DeckName = testDeck, + InspectionAreaName = testInspectionArea, AreaName = testArea, DefaultLocalizationPose = testPose }; @@ -306,8 +306,8 @@ public async Task AdminAuthorisedPostInstallationPlantDeckAndAreaTest() "application/json" ); - var deckContent = new StringContent( - JsonSerializer.Serialize(deckQuery), + var inspectionAreaContent = new StringContent( + JsonSerializer.Serialize(inspectionAreaQuery), null, "application/json" ); @@ -323,15 +323,15 @@ public async Task AdminAuthorisedPostInstallationPlantDeckAndAreaTest() var installationResponse = await _client.PostAsync(installationUrl, installationContent); string plantUrl = "/plants"; var plantResponse = await _client.PostAsync(plantUrl, plantContent); - string deckUrl = "/decks"; - var deckResponse = await _client.PostAsync(deckUrl, deckContent); + string inspectionAreaUrl = "/inspectionAreas"; + var inspectionAreaResponse = await _client.PostAsync(inspectionAreaUrl, inspectionAreaContent); string areaUrl = "/areas"; var areaResponse = await _client.PostAsync(areaUrl, areaContent); // Assert Assert.True(installationResponse.IsSuccessStatusCode); Assert.True(plantResponse.IsSuccessStatusCode); - Assert.True(deckResponse.IsSuccessStatusCode); + Assert.True(inspectionAreaResponse.IsSuccessStatusCode); Assert.True(areaResponse.IsSuccessStatusCode); var area = await areaResponse.Content.ReadFromJsonAsync(_serializerOptions); Assert.NotNull(area); diff --git a/backend/api.test/Database/DatabaseUtilities.cs b/backend/api.test/Database/DatabaseUtilities.cs index 0eba682b1..b972b363b 100644 --- a/backend/api.test/Database/DatabaseUtilities.cs +++ b/backend/api.test/Database/DatabaseUtilities.cs @@ -14,7 +14,7 @@ public class DatabaseUtilities private readonly AccessRoleService _accessRoleService; private readonly MissionTaskService _missionTaskService; private readonly AreaService _areaService; - private readonly DeckService _deckService; + private readonly InspectionAreaService _inspectionAreaService; private readonly InstallationService _installationService; private readonly MissionRunService _missionRunService; private readonly PlantService _plantService; @@ -25,7 +25,7 @@ public class DatabaseUtilities private readonly string _testInstallationCode = "testInstallationCode"; private readonly string _testInstallationName = "testInstallation"; private readonly string _testPlantCode = "testPlantCode"; - private readonly string _testDeckName = "testDeck"; + private readonly string _testInspectionAreaName = "testInspectionArea"; private readonly string _testAreaName = "testArea"; @@ -37,19 +37,19 @@ public DatabaseUtilities(FlotillaDbContext context) _installationService = new InstallationService(context, _accessRoleService); _missionTaskService = new MissionTaskService(context, new Mock>().Object); _plantService = new PlantService(context, _installationService, _accessRoleService); - _deckService = new DeckService(context, defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, new MockSignalRService()); - _areaService = new AreaService(context, _installationService, _plantService, _deckService, defaultLocalizationPoseService, _accessRoleService); + _inspectionAreaService = new InspectionAreaService(context, defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, new MockSignalRService()); + _areaService = new AreaService(context, _installationService, _plantService, _inspectionAreaService, defaultLocalizationPoseService, _accessRoleService); _userInfoService = new UserInfoService(context, new HttpContextAccessor(), new Mock>().Object); _robotModelService = new RobotModelService(context); - _robotService = new RobotService(context, new Mock>().Object, _robotModelService, new MockSignalRService(), _accessRoleService, _installationService, _deckService); - _missionRunService = new MissionRunService(context, new MockSignalRService(), new Mock>().Object, _accessRoleService, _missionTaskService, _deckService, _robotService, _userInfoService); + _robotService = new RobotService(context, new Mock>().Object, _robotModelService, new MockSignalRService(), _accessRoleService, _installationService, _inspectionAreaService); + _missionRunService = new MissionRunService(context, new MockSignalRService(), new Mock>().Object, _accessRoleService, _missionTaskService, _inspectionAreaService, _robotService, _userInfoService); _sourceService = new SourceService(context, new Mock>().Object); } public async Task NewMissionRun( string installationCode, Robot robot, - Deck inspectionArea, + InspectionArea inspectionArea, bool writeToDatabase = false, MissionRunType missionRunType = MissionRunType.Normal, MissionStatus missionStatus = MissionStatus.Pending, @@ -128,43 +128,43 @@ public async Task NewPlant(string installationCode) return await _plantService.Create(createPlantQuery); } - public async Task ReadOrNewDeck(string installationCode, string plantCode) + public async Task ReadOrNewInspectionArea(string installationCode, string plantCode) { - if (await _deckService.ReadByInstallationAndName(installationCode, _testDeckName) is Deck deck) return deck; - return await NewDeck(installationCode, plantCode); + if (await _inspectionAreaService.ReadByInstallationAndName(installationCode, _testInspectionAreaName) is InspectionArea inspectionArea) return inspectionArea; + return await NewInspectionArea(installationCode, plantCode); } - public async Task NewDeck(string installationCode, string plantCode, string deckName = "") + public async Task NewInspectionArea(string installationCode, string plantCode, string inspectionAreaName = "") { - if (string.IsNullOrEmpty(deckName)) deckName = _testDeckName; - var createDeckQuery = new CreateDeckQuery + if (string.IsNullOrEmpty(inspectionAreaName)) inspectionAreaName = _testInspectionAreaName; + var createInspectionAreaQuery = new CreateInspectionAreaQuery { InstallationCode = installationCode, PlantCode = plantCode, - Name = deckName, + Name = inspectionAreaName, DefaultLocalizationPose = new CreateDefaultLocalizationPose() { Pose = new Pose() } }; - return await _deckService.Create(createDeckQuery); + return await _inspectionAreaService.Create(createInspectionAreaQuery); } - public async Task ReadOrNewArea(string installationCode, string plantCode, string deckName) + public async Task ReadOrNewArea(string installationCode, string plantCode, string inspectionAreaName) { if (await _areaService.ReadByInstallationAndName(_testInstallationCode, _testAreaName) is Area area) return area; - return await NewArea(installationCode, plantCode, deckName); + return await NewArea(installationCode, plantCode, inspectionAreaName); } - public async Task NewArea(string installationCode, string plantCode, string deckName, string areaName = "") + public async Task NewArea(string installationCode, string plantCode, string inspectionAreaName, string areaName = "") { if (string.IsNullOrEmpty(areaName)) areaName = _testAreaName; var createAreaQuery = new CreateAreaQuery { InstallationCode = installationCode, PlantCode = plantCode, - DeckName = deckName, + InspectionAreaName = inspectionAreaName, AreaName = areaName, DefaultLocalizationPose = new Pose() }; @@ -172,7 +172,7 @@ public async Task NewArea(string installationCode, string plantCode, strin return await _areaService.Create(createAreaQuery); } - public async Task NewRobot(RobotStatus status, Installation installation, Deck? inspectionArea = null) + public async Task NewRobot(RobotStatus status, Installation installation, InspectionArea? inspectionArea = null) { var createRobotQuery = new CreateRobotQuery { diff --git a/backend/api.test/EventHandlers/TestMissionEventHandler.cs b/backend/api.test/EventHandlers/TestMissionEventHandler.cs index 335ad3a89..dc2751832 100644 --- a/backend/api.test/EventHandlers/TestMissionEventHandler.cs +++ b/backend/api.test/EventHandlers/TestMissionEventHandler.cs @@ -77,13 +77,13 @@ public TestMissionEventHandler(DatabaseFixture fixture) var installationService = new InstallationService(context, accessRoleService); var defaultLocalizationPoseService = new DefaultLocalizationPoseService(context); var plantService = new PlantService(context, installationService, accessRoleService); - var deckService = new DeckService(context, defaultLocalizationPoseService, installationService, plantService, accessRoleService, signalRService); - var areaService = new AreaService(context, installationService, plantService, deckService, defaultLocalizationPoseService, accessRoleService); + var inspectionAreaService = new InspectionAreaService(context, defaultLocalizationPoseService, installationService, plantService, accessRoleService, signalRService); + var areaService = new AreaService(context, installationService, plantService, inspectionAreaService, defaultLocalizationPoseService, accessRoleService); var mapServiceMock = new MockMapService(); - _robotService = new RobotService(context, robotServiceLogger, robotModelService, signalRService, accessRoleService, installationService, deckService); - _missionRunService = new MissionRunService(context, signalRService, missionLogger, accessRoleService, missionTaskService, deckService, _robotService, userInfoService); + _robotService = new RobotService(context, robotServiceLogger, robotModelService, signalRService, accessRoleService, installationService, inspectionAreaService); + _missionRunService = new MissionRunService(context, signalRService, missionLogger, accessRoleService, missionTaskService, inspectionAreaService, _robotService, userInfoService); var missionDefinitionService = new MissionDefinitionService(context, missionLoader, signalRService, accessRoleService, missionDefinitionServiceLogger, _missionRunService, sourceService); - _localizationService = new LocalizationService(localizationServiceLogger, _robotService, installationService, deckService); + _localizationService = new LocalizationService(localizationServiceLogger, _robotService, installationService, inspectionAreaService); var errorHandlingService = new ErrorHandlingService(errorHandlingServiceLogger, _robotService, _missionRunService); var returnToHomeService = new ReturnToHomeService(returnToHomeServiceLogger, _robotService, _missionRunService); _missionSchedulingService = new MissionSchedulingService(missionSchedulingServiceLogger, _missionRunService, _robotService, @@ -157,9 +157,9 @@ public async Task ScheduledMissionStartedWhenSystemIsAvailable() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck); - var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea); + var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea); // Act await _missionRunService.Create(missionRun); @@ -176,10 +176,10 @@ public async Task SecondScheduledMissionQueuedIfRobotIsBusy() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck); - var missionRunOne = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck); - var missionRunTwo = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea); + var missionRunOne = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea); + var missionRunTwo = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea); // Act await _missionRunService.Create(missionRunOne); @@ -199,9 +199,9 @@ public async Task NewMissionIsStartedWhenRobotBecomesAvailable() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, deck); - var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, inspectionArea); + var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea); await _missionRunService.Create(missionRun); Thread.Sleep(100); @@ -230,8 +230,8 @@ public async Task ReturnToHomeMissionIsStartedIfQueueIsEmptyWhenRobotBecomesAvai // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, deck); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, inspectionArea); var mqttEventArgs = new MqttReceivedArgs( new IsarStatusMessage @@ -265,8 +265,8 @@ public async Task ReturnToHomeMissionIsNotStartedIfReturnToHomeIsNotSupported() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, deck); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, inspectionArea); robot.RobotCapabilities!.Remove(RobotCapabilitiesEnum.return_to_home); await _robotService.Update(robot); @@ -302,11 +302,11 @@ public async Task MissionRunIsStartedForOtherAvailableRobotIfOneRobotHasAnOngoin // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robotOne = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck); - var robotTwo = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck); - var missionRunOne = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robotOne, deck); - var missionRunTwo = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robotTwo, deck); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robotOne = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea); + var robotTwo = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea); + var missionRunOne = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robotOne, inspectionArea); + var missionRunTwo = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robotTwo, inspectionArea); // Act (Ensure first mission is started) await _missionRunService.Create(missionRunOne); @@ -333,11 +333,11 @@ public async Task QueuedMissionsAreNotAbortedWhenRobotAvailableHappensAtTheSameT // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, null); - var missionRun1 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck, true); + var missionRun1 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea, true); Thread.Sleep(100); - var missionRun2 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck, true); + var missionRun2 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea, true); Thread.Sleep(100); var missionRunCreatedEventArgs = new MissionRunCreatedEventArgs(missionRun1.Id); @@ -379,10 +379,10 @@ public async Task QueuedContinuesWhenOnIsarStatusHappensAtTheSameTimeAsOnIsarMis // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, deck); - var missionRun1 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck, true, MissionRunType.Normal, MissionStatus.Ongoing, Guid.NewGuid().ToString()); - var missionRun2 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck, true); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation, inspectionArea); + var missionRun1 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea, true, MissionRunType.Normal, MissionStatus.Ongoing, Guid.NewGuid().ToString()); + var missionRun2 = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea, true); Thread.Sleep(100); var missionRunCreatedEventArgs = new MissionRunCreatedEventArgs(missionRun1.Id); @@ -426,10 +426,10 @@ public async Task ReturnHomeMissionAbortedIfNewMissionScheduled() // Arrange var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); - var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, deck); - var returnToHomeMission = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck, true, MissionRunType.ReturnHome, MissionStatus.Ongoing, Guid.NewGuid().ToString()); - var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck, true, MissionRunType.Normal, MissionStatus.Pending, Guid.NewGuid().ToString()); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); + var robot = await _databaseUtilities.NewRobot(RobotStatus.Busy, installation, inspectionArea); + var returnToHomeMission = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea, true, MissionRunType.ReturnHome, MissionStatus.Ongoing, Guid.NewGuid().ToString()); + var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea, true, MissionRunType.Normal, MissionStatus.Pending, Guid.NewGuid().ToString()); Thread.Sleep(100); diff --git a/backend/api.test/Mocks/MissionLoaderMock.cs b/backend/api.test/Mocks/MissionLoaderMock.cs index 9acaf350b..1e5fd7e91 100644 --- a/backend/api.test/Mocks/MissionLoaderMock.cs +++ b/backend/api.test/Mocks/MissionLoaderMock.cs @@ -54,7 +54,7 @@ public class MockMissionLoader() : IMissionLoader private readonly MissionDefinition _mockMissionDefinition = new() { - InspectionArea = new Deck(), + InspectionArea = new InspectionArea(), Comment = "", Id = "", InstallationCode = "TTT", diff --git a/backend/api.test/Mocks/StidServiceMock.cs b/backend/api.test/Mocks/StidServiceMock.cs index 802f8b2d3..f63ef20aa 100644 --- a/backend/api.test/Mocks/StidServiceMock.cs +++ b/backend/api.test/Mocks/StidServiceMock.cs @@ -17,8 +17,8 @@ public class MockStidService(FlotillaDbContext context) : IStidService string testAreaName = "StidServiceMockArea"; var area = context.Areas - .Include(a => a.Deck).ThenInclude(d => d.Installation) - .Include(a => a.Deck).ThenInclude(d => d.Plant).ThenInclude(p => p.Installation) + .Include(a => a.InspectionArea).ThenInclude(d => d.Installation) + .Include(a => a.InspectionArea).ThenInclude(d => d.Plant).ThenInclude(p => p.Installation) .Include(d => d.Plant) .Include(i => i.Installation).Include(d => d.DefaultLocalizationPose) .Where(area => area.Name.Contains(testAreaName)).ToList().FirstOrDefault(); @@ -39,21 +39,21 @@ public class MockStidService(FlotillaDbContext context) : IStidService PlantCode = "TTT" }; - var testDeck = new Deck + var testInspectionArea = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = testPlant, Installation = testPlant.Installation, DefaultLocalizationPose = new DefaultLocalizationPose(), - Name = "StidServiceMockDeck" + Name = "StidServiceMockInspectionArea" }; var testArea = new Area { Id = Guid.NewGuid().ToString(), - Deck = testDeck, - Plant = testDeck.Plant, - Installation = testDeck.Plant.Installation, + InspectionArea = testInspectionArea, + Plant = testInspectionArea.Plant, + Installation = testInspectionArea.Plant.Installation, Name = testAreaName, MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -61,7 +61,7 @@ public class MockStidService(FlotillaDbContext context) : IStidService context.Add(testInstallation); context.Add(testPlant); - context.Add(testDeck); + context.Add(testInspectionArea); context.Add(testArea); await context.SaveChangesAsync(); diff --git a/backend/api.test/Services/MissionService.cs b/backend/api.test/Services/MissionService.cs index 9bc307239..72ce43a26 100644 --- a/backend/api.test/Services/MissionService.cs +++ b/backend/api.test/Services/MissionService.cs @@ -22,7 +22,7 @@ public class MissionServiceTest : IDisposable private readonly IAccessRoleService _accessRoleService; private readonly UserInfoService _userInfoService; private readonly IMissionTaskService _missionTaskService; - private readonly IDeckService _deckService; + private readonly IInspectionAreaService _inspectionAreaService; private readonly IInstallationService _installationService; private readonly IPlantService _plantService; private readonly IRobotModelService _robotModelService; @@ -39,10 +39,10 @@ public MissionServiceTest(DatabaseFixture fixture) _missionTaskService = new MissionTaskService(_context, new Mock>().Object); _installationService = new InstallationService(_context, _accessRoleService); _plantService = new PlantService(_context, _installationService, _accessRoleService); - _deckService = new DeckService(_context, defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, new MockSignalRService()); + _inspectionAreaService = new InspectionAreaService(_context, defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, new MockSignalRService()); _robotModelService = new RobotModelService(_context); - _robotService = new RobotService(_context, new Mock>().Object, _robotModelService, new MockSignalRService(), _accessRoleService, _installationService, _deckService); - _missionRunService = new MissionRunService(_context, _signalRService, _logger, _accessRoleService, _missionTaskService, _deckService, _robotService, _userInfoService); + _robotService = new RobotService(_context, new Mock>().Object, _robotModelService, new MockSignalRService(), _accessRoleService, _installationService, _inspectionAreaService); + _missionRunService = new MissionRunService(_context, _signalRService, _logger, _accessRoleService, _missionTaskService, _inspectionAreaService, _robotService, _userInfoService); _databaseUtilities = new DatabaseUtilities(_context); } @@ -70,9 +70,9 @@ public async Task Create() var installation = await _databaseUtilities.ReadOrNewInstallation(); var plant = await _databaseUtilities.ReadOrNewPlant(installation.InstallationCode); - var deck = await _databaseUtilities.ReadOrNewDeck(installation.InstallationCode, plant.PlantCode); + var inspectionArea = await _databaseUtilities.ReadOrNewInspectionArea(installation.InstallationCode, plant.PlantCode); var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation); - var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, deck); + var missionRun = await _databaseUtilities.NewMissionRun(installation.InstallationCode, robot, inspectionArea); await _missionRunService.Create(missionRun); diff --git a/backend/api.test/Services/RobotService.cs b/backend/api.test/Services/RobotService.cs index 41fd5f61a..c38ded146 100644 --- a/backend/api.test/Services/RobotService.cs +++ b/backend/api.test/Services/RobotService.cs @@ -23,7 +23,7 @@ public class RobotServiceTest : IDisposable private readonly IInstallationService _installationService; private readonly IPlantService _plantService; private readonly IDefaultLocalizationPoseService _defaultLocalizationPoseService; - private readonly IDeckService _deckService; + private readonly IInspectionAreaService _inspectionAreaService; private readonly IAreaService _areaService; private readonly DatabaseUtilities _databaseUtilities; @@ -38,8 +38,8 @@ public RobotServiceTest(DatabaseFixture fixture) _installationService = new InstallationService(_context, _accessRoleService); _plantService = new PlantService(_context, _installationService, _accessRoleService); _defaultLocalizationPoseService = new DefaultLocalizationPoseService(_context); - _deckService = new DeckService(_context, _defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, _signalRService); - _areaService = new AreaService(_context, _installationService, _plantService, _deckService, _defaultLocalizationPoseService, _accessRoleService); + _inspectionAreaService = new InspectionAreaService(_context, _defaultLocalizationPoseService, _installationService, _plantService, _accessRoleService, _signalRService); + _areaService = new AreaService(_context, _installationService, _plantService, _inspectionAreaService, _defaultLocalizationPoseService, _accessRoleService); } public void Dispose() @@ -53,7 +53,7 @@ public async Task ReadAll() { var installation = await _databaseUtilities.ReadOrNewInstallation(); var _ = await _databaseUtilities.NewRobot(RobotStatus.Available, installation); - var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _deckService); + var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _inspectionAreaService); var robots = await robotService.ReadAll(); Assert.True(robots.Any()); @@ -62,7 +62,7 @@ public async Task ReadAll() [Fact] public async Task Read() { - var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _deckService); + var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _inspectionAreaService); var installation = await _databaseUtilities.ReadOrNewInstallation(); var robot = await _databaseUtilities.NewRobot(RobotStatus.Available, installation); var robotById = await robotService.ReadById(robot.Id, readOnly: false); @@ -73,7 +73,7 @@ public async Task Read() [Fact] public async Task ReadIdDoesNotExist() { - var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _deckService); + var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _inspectionAreaService); var robot = await robotService.ReadById("some_id_that_does_not_exist", readOnly: true); Assert.Null(robot); } @@ -81,7 +81,7 @@ public async Task ReadIdDoesNotExist() [Fact] public async Task Create() { - var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _deckService); + var robotService = new RobotService(_context, _logger, _robotModelService, _signalRService, _accessRoleService, _installationService, _inspectionAreaService); var installationService = new InstallationService(_context, _accessRoleService); var installation = await installationService.Create(new CreateInstallationQuery diff --git a/backend/api/Controllers/AreaController.cs b/backend/api/Controllers/AreaController.cs index 554a05db5..6da666bb6 100644 --- a/backend/api/Controllers/AreaController.cs +++ b/backend/api/Controllers/AreaController.cs @@ -66,7 +66,7 @@ public async Task> Create([FromBody] CreateAreaQuery /// Updates default localization pose /// /// - /// This query updates the default localization pose for a deck + /// This query updates the default localization pose for an inspection area /// [HttpPut] [Authorize(Roles = Role.Admin)] @@ -127,9 +127,9 @@ public async Task> DeleteArea([FromRoute] string id) if (area is null) return NotFound($"Area with id {id} not found"); - if (area.Deck == null || area.Plant == null || area.Installation == null) + if (area.InspectionArea == null || area.Plant == null || area.Installation == null) { - string errorMessage = "Deck, plant or installation missing from area"; + string errorMessage = "Inspection area, plant or installation missing from area"; logger.LogWarning(errorMessage); return StatusCode(StatusCodes.Status500InternalServerError, errorMessage); } @@ -186,9 +186,9 @@ public async Task> GetAreaById([FromRoute] string id) if (area == null) return NotFound($"Could not find area with id {id}"); - if (area.Deck == null || area.Plant == null || area.Installation == null) + if (area.InspectionArea == null || area.Plant == null || area.Installation == null) { - string errorMessage = "Deck, plant or installation missing from area"; + string errorMessage = "Inspection area, plant or installation missing from area"; logger.LogWarning(errorMessage); return StatusCode(StatusCodes.Status500InternalServerError, errorMessage); } @@ -204,23 +204,23 @@ public async Task> GetAreaById([FromRoute] string id) } /// - /// Lookup area by specified deck id. + /// Lookup area by specified inspection area id. /// [HttpGet] [Authorize(Roles = Role.Any)] - [Route("deck/{deckId}")] + [Route("inspection-area/{inspectionAreaId}")] [ProducesResponseType(typeof(AreaResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task>> GetAreaByDeckId([FromRoute] string deckId) + public async Task>> GetAreaByInspectionAreaId([FromRoute] string inspectionAreaId) { try { - var areas = await areaService.ReadByDeckId(deckId, readOnly: true); + var areas = await areaService.ReadByInspectionAreaId(inspectionAreaId, readOnly: true); if (!areas.Any()) - return NotFound($"Could not find area for deck with id {deckId}"); + return NotFound($"Could not find area for inspection area with id {inspectionAreaId}"); var response = areas.Select(area => new AreaResponse(area!)); return Ok(response); @@ -251,7 +251,7 @@ public async Task>> GetMissionDefi if (area == null) return NotFound($"Could not find area with id {id}"); - var missionDefinitions = await missionDefinitionService.ReadByInspectionAreaId(area.Deck.Id, readOnly: true); + var missionDefinitions = await missionDefinitionService.ReadByInspectionAreaId(area.InspectionArea.Id, readOnly: true); var missionDefinitionResponses = missionDefinitions.FindAll(m => !m.IsDeprecated).Select(m => new MissionDefinitionResponse(m)); return Ok(missionDefinitionResponses); } diff --git a/backend/api/Controllers/DeckController.cs b/backend/api/Controllers/DeckController.cs index dad162584..10330a3b9 100644 --- a/backend/api/Controllers/DeckController.cs +++ b/backend/api/Controllers/DeckController.cs @@ -8,11 +8,11 @@ namespace Api.Controllers { [ApiController] - [Route("decks")] - public class DeckController( - ILogger logger, + [Route("inspectionAreas")] + public class InspectionAreaController( + ILogger logger, IMapService mapService, - IDeckService deckService, + IInspectionAreaService inspectionAreaService, IDefaultLocalizationPoseService defaultLocalizationPoseService, IInstallationService installationService, IPlantService plantService, @@ -20,167 +20,167 @@ IMissionDefinitionService missionDefinitionService ) : ControllerBase { /// - /// List all decks in the Flotilla database + /// List all inspection areas in the Flotilla database /// /// - /// This query gets all decks + /// This query gets all inspection areas /// [HttpGet] [Authorize(Roles = Role.Any)] - [ProducesResponseType(typeof(IList), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IList), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task>> GetDecks() + public async Task>> GetInspectionAreas() { try { - var decks = await deckService.ReadAll(readOnly: true); - var deckResponses = decks.Select(d => new DeckResponse(d)).ToList(); - return Ok(deckResponses); + var inspectionAreas = await inspectionAreaService.ReadAll(readOnly: true); + var inspectionAreaResponses = inspectionAreas.Select(d => new InspectionAreaResponse(d)).ToList(); + return Ok(inspectionAreaResponses); } catch (Exception e) { - logger.LogError(e, "Error during GET of decks from database"); + logger.LogError(e, "Error during GET of inspection areas from database"); throw; } } /// - /// List all decks in the specified installation + /// List all inspection areas in the specified installation /// /// - /// This query gets all decks in specified installation + /// This query gets all inspection areas in specified installation /// [HttpGet("installation/{installationCode}")] [Authorize(Roles = Role.Any)] - [ProducesResponseType(typeof(IList), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(IList), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task>> GetDecksByInstallationCode([FromRoute] string installationCode) + public async Task>> GetInspectionAreasByInstallationCode([FromRoute] string installationCode) { try { - var decks = await deckService.ReadByInstallation(installationCode, readOnly: true); - var deckResponses = decks.Select(d => new DeckResponse(d)).ToList(); - return Ok(deckResponses); + var inspectionAreas = await inspectionAreaService.ReadByInstallation(installationCode, readOnly: true); + var inspectionAreaResponses = inspectionAreas.Select(d => new InspectionAreaResponse(d)).ToList(); + return Ok(inspectionAreaResponses); } catch (Exception e) { - logger.LogError(e, "Error during GET of decks from database"); + logger.LogError(e, "Error during GET of inspection areas from database"); throw; } } /// - /// Lookup deck by specified id. + /// Lookup inspection area by specified id. /// [HttpGet] [Authorize(Roles = Role.Any)] [Route("{id}")] - [ProducesResponseType(typeof(DeckResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(InspectionAreaResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> GetDeckById([FromRoute] string id) + public async Task> GetInspectionAreaById([FromRoute] string id) { try { - var deck = await deckService.ReadById(id, readOnly: true); - if (deck == null) - return NotFound($"Could not find deck with id {id}"); - return Ok(new DeckResponse(deck)); + var inspectionArea = await inspectionAreaService.ReadById(id, readOnly: true); + if (inspectionArea == null) + return NotFound($"Could not find inspection area with id {id}"); + return Ok(new InspectionAreaResponse(inspectionArea)); } catch (Exception e) { - logger.LogError(e, "Error during GET of deck from database"); + logger.LogError(e, "Error during GET of inspection area from database"); throw; } } /// - /// Lookup all the mission definitions related to a deck + /// Lookup all the mission definitions related to a inspection area /// [HttpGet] [Authorize(Roles = Role.Any)] - [Route("{deckId}/mission-definitions")] + [Route("{inspectionAreaId}/mission-definitions")] [ProducesResponseType(typeof(MissionDefinitionResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task>> GetMissionDefinitionsInDeck([FromRoute] string deckId) + public async Task>> GetMissionDefinitionsInInspectionArea([FromRoute] string inspectionAreaId) { try { - var deck = await deckService.ReadById(deckId, readOnly: true); - if (deck == null) - return NotFound($"Could not find deck with id {deckId}"); + var inspectionArea = await inspectionAreaService.ReadById(inspectionAreaId, readOnly: true); + if (inspectionArea == null) + return NotFound($"Could not find inspection area with id {inspectionAreaId}"); - var missionDefinitions = await missionDefinitionService.ReadByInspectionAreaId(deck.Id, readOnly: true); + var missionDefinitions = await missionDefinitionService.ReadByInspectionAreaId(inspectionArea.Id, readOnly: true); var missionDefinitionResponses = missionDefinitions.FindAll(m => !m.IsDeprecated).Select(m => new MissionDefinitionResponse(m)); return Ok(missionDefinitionResponses); } catch (Exception e) { - logger.LogError(e, "Error during GET of deck missions from database"); + logger.LogError(e, "Error during GET of inspection area missions from database"); throw; } } /// - /// Add a new deck + /// Add a new inspection area /// /// - /// This query adds a new deck to the database + /// This query adds a new inspection area to the database /// [HttpPost] [Authorize(Roles = Role.Admin)] - [ProducesResponseType(typeof(DeckResponse), StatusCodes.Status201Created)] + [ProducesResponseType(typeof(InspectionAreaResponse), StatusCodes.Status201Created)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> Create([FromBody] CreateDeckQuery deck) + public async Task> Create([FromBody] CreateInspectionAreaQuery inspectionArea) { - logger.LogInformation("Creating new deck"); + logger.LogInformation("Creating new inspection area"); try { - var existingInstallation = await installationService.ReadByInstallationCode(deck.InstallationCode, readOnly: true); + var existingInstallation = await installationService.ReadByInstallationCode(inspectionArea.InstallationCode, readOnly: true); if (existingInstallation == null) { - return NotFound($"Could not find installation with name {deck.InstallationCode}"); + return NotFound($"Could not find installation with name {inspectionArea.InstallationCode}"); } - var existingPlant = await plantService.ReadByInstallationAndPlantCode(existingInstallation, deck.PlantCode, readOnly: true); + var existingPlant = await plantService.ReadByInstallationAndPlantCode(existingInstallation, inspectionArea.PlantCode, readOnly: true); if (existingPlant == null) { - return NotFound($"Could not find plant with name {deck.PlantCode}"); + return NotFound($"Could not find plant with name {inspectionArea.PlantCode}"); } - var existingDeck = await deckService.ReadByInstallationAndPlantAndName(existingInstallation, existingPlant, deck.Name, readOnly: true); - if (existingDeck != null) + var existingInspectionArea = await inspectionAreaService.ReadByInstallationAndPlantAndName(existingInstallation, existingPlant, inspectionArea.Name, readOnly: true); + if (existingInspectionArea != null) { - logger.LogInformation("An deck for given name and deck already exists"); - return BadRequest($"Deck already exists"); + logger.LogInformation("An inspection area for given name and inspection area already exists"); + return BadRequest($"InspectionArea already exists"); } - var newDeck = await deckService.Create(deck); + var newInspectionArea = await inspectionAreaService.Create(inspectionArea); logger.LogInformation( - "Succesfully created new deck with id '{deckId}'", - newDeck.Id + "Succesfully created new inspection area with id '{inspectionAreaId}'", + newInspectionArea.Id ); return CreatedAtAction( - nameof(GetDeckById), - new { id = newDeck.Id }, - new DeckResponse(newDeck) + nameof(GetInspectionAreaById), + new { id = newInspectionArea.Id }, + new InspectionAreaResponse(newInspectionArea) ); } catch (Exception e) { - logger.LogError(e, "Error while creating new deck"); + logger.LogError(e, "Error while creating new inspection area"); throw; } } @@ -189,41 +189,41 @@ public async Task> Create([FromBody] CreateDeckQuery /// Updates default localization pose /// /// - /// This query updates the default localization pose for a deck + /// This query updates the default localization pose for a inspection area /// [HttpPut] [Authorize(Roles = Role.Admin)] - [Route("{deckId}/update-default-localization-pose")] - [ProducesResponseType(typeof(DeckResponse), StatusCodes.Status201Created)] + [Route("{inspectionAreaId}/update-default-localization-pose")] + [ProducesResponseType(typeof(InspectionAreaResponse), StatusCodes.Status201Created)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> UpdateDefaultLocalizationPose([FromRoute] string deckId, [FromBody] CreateDefaultLocalizationPose newDefaultLocalizationPose) + public async Task> UpdateDefaultLocalizationPose([FromRoute] string inspectionAreaId, [FromBody] CreateDefaultLocalizationPose newDefaultLocalizationPose) { - logger.LogInformation("Updating default localization pose on deck '{deckId}'", deckId); + logger.LogInformation("Updating default localization pose on inspection area '{inspectionAreaId}'", inspectionAreaId); try { - var deck = await deckService.ReadById(deckId, readOnly: false); - if (deck is null) + var inspectionArea = await inspectionAreaService.ReadById(inspectionAreaId, readOnly: false); + if (inspectionArea is null) { - logger.LogInformation("A deck with id '{deckId}' does not exist", deckId); - return NotFound("Deck does not exists"); + logger.LogInformation("A inspection area with id '{inspectionAreaId}' does not exist", inspectionAreaId); + return NotFound("InspectionArea does not exists"); } - if (deck.DefaultLocalizationPose != null) + if (inspectionArea.DefaultLocalizationPose != null) { - deck.DefaultLocalizationPose.Pose = newDefaultLocalizationPose.Pose; - deck.DefaultLocalizationPose.DockingEnabled = newDefaultLocalizationPose.IsDockingStation; - _ = await defaultLocalizationPoseService.Update(deck.DefaultLocalizationPose); + inspectionArea.DefaultLocalizationPose.Pose = newDefaultLocalizationPose.Pose; + inspectionArea.DefaultLocalizationPose.DockingEnabled = newDefaultLocalizationPose.IsDockingStation; + _ = await defaultLocalizationPoseService.Update(inspectionArea.DefaultLocalizationPose); } else { - deck.DefaultLocalizationPose = new DefaultLocalizationPose(newDefaultLocalizationPose.Pose, newDefaultLocalizationPose.IsDockingStation); - deck = await deckService.Update(deck); + inspectionArea.DefaultLocalizationPose = new DefaultLocalizationPose(newDefaultLocalizationPose.Pose, newDefaultLocalizationPose.IsDockingStation); + inspectionArea = await inspectionAreaService.Update(inspectionArea); } - return Ok(new DeckResponse(deck)); + return Ok(new InspectionAreaResponse(inspectionArea)); } catch (Exception e) { @@ -233,26 +233,26 @@ public async Task> UpdateDefaultLocalizationPose([Fro } /// - /// Deletes the deck with the specified id from the database. + /// Deletes the inspection area with the specified id from the database. /// [HttpDelete] [Authorize(Roles = Role.Admin)] [Route("{id}")] - [ProducesResponseType(typeof(DeckResponse), StatusCodes.Status200OK)] + [ProducesResponseType(typeof(InspectionAreaResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status403Forbidden)] [ProducesResponseType(StatusCodes.Status404NotFound)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task> DeleteDeck([FromRoute] string id) + public async Task> DeleteInspectionArea([FromRoute] string id) { - var deck = await deckService.Delete(id); - if (deck is null) - return NotFound($"Deck with id {id} not found"); - return Ok(new DeckResponse(deck)); + var inspectionArea = await inspectionAreaService.Delete(id); + if (inspectionArea is null) + return NotFound($"InspectionArea with id {id} not found"); + return Ok(new InspectionAreaResponse(inspectionArea)); } /// - /// Gets map metadata for localization poses belonging to deck with specified id + /// Gets map metadata for localization poses belonging to inspection area with specified id /// [HttpGet] [Authorize(Roles = Role.Any)] @@ -264,23 +264,23 @@ public async Task> DeleteDeck([FromRoute] string id) [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task> GetMapMetadata([FromRoute] string id) { - var deck = await deckService.ReadById(id, readOnly: true); - if (deck is null) + var inspectionArea = await inspectionAreaService.ReadById(id, readOnly: true); + if (inspectionArea is null) { - string errorMessage = $"Deck not found for deck with ID {id}"; + string errorMessage = $"InspectionArea not found for inspectionArea with ID {id}"; logger.LogError("{ErrorMessage}", errorMessage); return NotFound(errorMessage); } - if (deck.Installation == null) + if (inspectionArea.Installation == null) { - string errorMessage = "Installation missing from deck"; + string errorMessage = "Installation missing from inspection area"; logger.LogWarning(errorMessage); return StatusCode(StatusCodes.Status500InternalServerError, errorMessage); } - if (deck.DefaultLocalizationPose is null) + if (inspectionArea.DefaultLocalizationPose is null) { - string errorMessage = $"Deck with id '{deck.Id}' does not have a default localization pose"; + string errorMessage = $"InspectionArea with id '{inspectionArea.Id}' does not have a default localization pose"; logger.LogInformation("{ErrorMessage}", errorMessage); return NotFound(errorMessage); } @@ -288,21 +288,21 @@ public async Task> GetMapMetadata([FromRoute] string i MapMetadata? mapMetadata; var positions = new List { - deck.DefaultLocalizationPose.Pose.Position + inspectionArea.DefaultLocalizationPose.Pose.Position }; try { - mapMetadata = await mapService.ChooseMapFromPositions(positions, deck.Installation.InstallationCode); + mapMetadata = await mapService.ChooseMapFromPositions(positions, inspectionArea.Installation.InstallationCode); } catch (RequestFailedException e) { - string errorMessage = $"An error occurred while retrieving the map for deck {deck.Id}"; + string errorMessage = $"An error occurred while retrieving the map for inspection area {inspectionArea.Id}"; logger.LogError(e, "{ErrorMessage}", errorMessage); return StatusCode(StatusCodes.Status502BadGateway, errorMessage); } catch (ArgumentOutOfRangeException e) { - string errorMessage = $"Could not find a suitable map for deck {deck.Id}"; + string errorMessage = $"Could not find a suitable map for inspection area {inspectionArea.Id}"; logger.LogError(e, "{ErrorMessage}", errorMessage); return NotFound(errorMessage); } diff --git a/backend/api/Controllers/MissionSchedulingController.cs b/backend/api/Controllers/MissionSchedulingController.cs index 0db1b9fe9..63c9bb76b 100644 --- a/backend/api/Controllers/MissionSchedulingController.cs +++ b/backend/api/Controllers/MissionSchedulingController.cs @@ -24,7 +24,7 @@ public class MissionSchedulingController( ILocalizationService localizationService, IRobotService robotService, ISourceService sourceService, - IDeckService deckService + IInspectionAreaService inspectionAreaService ) : ControllerBase { @@ -245,11 +245,11 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery .Select(t => stidService.GetTagArea(t.TagId!, scheduledMissionQuery.InstallationCode).Result) .ToList(); - var missionDeckNames = missionAreas.Where(a => a != null).Select(a => a!.Deck.Name).Distinct().ToList(); - if (missionDeckNames.Count > 1) + var missionInspectionAreaNames = missionAreas.Where(a => a != null).Select(a => a!.InspectionArea.Name).Distinct().ToList(); + if (missionInspectionAreaNames.Count > 1) { - string joinedMissionDeckNames = string.Join(", ", [.. missionDeckNames]); - logger.LogWarning($"Mission {missionDefinition.Name} has tags on more than one deck. The decks are: {joinedMissionDeckNames}."); + string joinedMissionInspectionAreaNames = string.Join(", ", [.. missionInspectionAreaNames]); + logger.LogWarning($"Mission {missionDefinition.Name} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}."); } var sortedAreas = missionAreas.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key); @@ -286,7 +286,7 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery existingMissionDefinition = missionDefinitions.First(); if (existingMissionDefinition.InspectionArea == null) { - existingMissionDefinition.InspectionArea = area.Deck; + existingMissionDefinition.InspectionArea = area.InspectionArea; await missionDefinitionService.Update(existingMissionDefinition); } } @@ -299,7 +299,7 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery Name = missionDefinition.Name, InspectionFrequency = scheduledMissionQuery.InspectionFrequency, InstallationCode = scheduledMissionQuery.InstallationCode, - InspectionArea = area.Deck, + InspectionArea = area.InspectionArea, Map = new MapMetadata() }; @@ -333,7 +333,7 @@ [FromBody] ScheduledMissionQuery scheduledMissionQuery await missionDefinitionService.Create(scheduledMissionDefinition); } - if (missionRun.Robot.CurrentInspectionArea != null && !await localizationService.RobotIsOnSameDeckAsMission(missionRun.Robot.Id, missionRun.InspectionArea!.Id)) + if (missionRun.Robot.CurrentInspectionArea != null && !await localizationService.RobotIsOnSameInspectionAreaAsMission(missionRun.Robot.Id, missionRun.InspectionArea!.Id)) { return Conflict($"The robot {missionRun.Robot.Name} is assumed to be in a different inspection area so the mission was not scheduled."); } @@ -385,10 +385,10 @@ [FromBody] CustomMissionQuery customMissionQuery var missionTasks = customMissionQuery.Tasks.Select(task => new MissionTask(task)).ToList(); MissionDefinition? customMissionDefinition; - Deck? inspectionArea = null; + InspectionArea? inspectionArea = null; try { - if (customMissionQuery.InspectionAreaName != null) { inspectionArea = await deckService.ReadByInstallationAndName(customMissionQuery.InstallationCode, customMissionQuery.InspectionAreaName, readOnly: true); } + if (customMissionQuery.InspectionAreaName != null) { inspectionArea = await inspectionAreaService.ReadByInstallationAndName(customMissionQuery.InstallationCode, customMissionQuery.InspectionAreaName, readOnly: true); } if (inspectionArea == null) { throw new AreaNotFoundException($"No inspection area with name {customMissionQuery.InspectionAreaName} in installation {customMissionQuery.InstallationCode} was found"); @@ -451,7 +451,7 @@ [FromBody] CustomMissionQuery customMissionQuery if (scheduledMission.Tasks.Any()) { scheduledMission.CalculateEstimatedDuration(); } - if (scheduledMission.Robot.CurrentInspectionArea != null && !await localizationService.RobotIsOnSameDeckAsMission(scheduledMission.Robot.Id, scheduledMission.InspectionArea.Id)) + if (scheduledMission.Robot.CurrentInspectionArea != null && !await localizationService.RobotIsOnSameInspectionAreaAsMission(scheduledMission.Robot.Id, scheduledMission.InspectionArea.Id)) { return Conflict($"The robot {scheduledMission.Robot.Name} is assumed to be in a different inspection area so the mission was not scheduled."); } diff --git a/backend/api/Controllers/Models/AreaQueryStringParameters.cs b/backend/api/Controllers/Models/AreaQueryStringParameters.cs index 568e31dfb..c50a9f45c 100644 --- a/backend/api/Controllers/Models/AreaQueryStringParameters.cs +++ b/backend/api/Controllers/Models/AreaQueryStringParameters.cs @@ -14,8 +14,8 @@ public AreaQueryStringParameters() public string? InstallationCode { get; set; } /// - /// Filter for the deck of the mission + /// Filter for the inspection area of the mission /// - public string? Deck { get; set; } + public string? InspectionArea { get; set; } } } diff --git a/backend/api/Controllers/Models/AreaResponse.cs b/backend/api/Controllers/Models/AreaResponse.cs index b078f9f44..f03ed027c 100644 --- a/backend/api/Controllers/Models/AreaResponse.cs +++ b/backend/api/Controllers/Models/AreaResponse.cs @@ -6,7 +6,7 @@ public class AreaResponse { public string Id { get; set; } = string.Empty; - public string DeckName { get; set; } + public string InspectionAreaName { get; set; } public string PlantCode { get; set; } @@ -28,7 +28,7 @@ public AreaResponse() { } public AreaResponse(Area area) { Id = area.Id; - DeckName = area.Deck!.Name; + InspectionAreaName = area.InspectionArea!.Name; PlantCode = area.Plant.PlantCode; PlantName = area.Plant.Name; InstallationCode = area.Installation.InstallationCode; diff --git a/backend/api/Controllers/Models/CreateAreaQuery.cs b/backend/api/Controllers/Models/CreateAreaQuery.cs index 9596753e1..a4d171568 100644 --- a/backend/api/Controllers/Models/CreateAreaQuery.cs +++ b/backend/api/Controllers/Models/CreateAreaQuery.cs @@ -6,7 +6,7 @@ public struct CreateAreaQuery { public string InstallationCode { get; set; } public string PlantCode { get; set; } - public string DeckName { get; set; } + public string InspectionAreaName { get; set; } public string AreaName { get; set; } public Pose? DefaultLocalizationPose { get; set; } diff --git a/backend/api/Controllers/Models/CreateDeckQuery.cs b/backend/api/Controllers/Models/CreateDeckQuery.cs index 1b3d67dff..3ecb171e3 100644 --- a/backend/api/Controllers/Models/CreateDeckQuery.cs +++ b/backend/api/Controllers/Models/CreateDeckQuery.cs @@ -1,6 +1,6 @@ namespace Api.Controllers.Models { - public struct CreateDeckQuery + public struct CreateInspectionAreaQuery { public string InstallationCode { get; set; } public string PlantCode { get; set; } diff --git a/backend/api/Controllers/Models/DeckResponse.cs b/backend/api/Controllers/Models/DeckResponse.cs index 364c26d39..6a769ae59 100644 --- a/backend/api/Controllers/Models/DeckResponse.cs +++ b/backend/api/Controllers/Models/DeckResponse.cs @@ -3,11 +3,11 @@ namespace Api.Controllers.Models { - public class DeckResponse + public class InspectionAreaResponse { public string Id { get; set; } - public string DeckName { get; set; } + public string InspectionAreaName { get; set; } public string PlantCode { get; set; } @@ -17,16 +17,16 @@ public class DeckResponse [JsonConstructor] #nullable disable - public DeckResponse() { } + public InspectionAreaResponse() { } #nullable enable - public DeckResponse(Deck deck) + public InspectionAreaResponse(InspectionArea inspectionArea) { - Id = deck.Id; - DeckName = deck.Name; - PlantCode = deck.Plant.PlantCode; - InstallationCode = deck.Installation.InstallationCode; - DefaultLocalizationPose = deck.DefaultLocalizationPose?.Pose; + Id = inspectionArea.Id; + InspectionAreaName = inspectionArea.Name; + PlantCode = inspectionArea.Plant.PlantCode; + InstallationCode = inspectionArea.Installation.InstallationCode; + DefaultLocalizationPose = inspectionArea.DefaultLocalizationPose?.Pose; } } } diff --git a/backend/api/Controllers/Models/MissionDefinitionResponse.cs b/backend/api/Controllers/Models/MissionDefinitionResponse.cs index 5b732443d..a22950119 100644 --- a/backend/api/Controllers/Models/MissionDefinitionResponse.cs +++ b/backend/api/Controllers/Models/MissionDefinitionResponse.cs @@ -26,7 +26,7 @@ public class MissionDefinitionResponse public virtual MissionRun? LastSuccessfulRun { get; set; } [JsonPropertyName("inspectionArea")] - public DeckResponse? InspectionArea { get; set; } + public InspectionAreaResponse? InspectionArea { get; set; } [JsonPropertyName("isDeprecated")] public bool IsDeprecated { get; set; } @@ -47,7 +47,7 @@ public MissionDefinitionResponse(MissionDefinition missionDefinition) InstallationCode = missionDefinition.InstallationCode; Comment = missionDefinition.Comment; InspectionFrequency = missionDefinition.InspectionFrequency; - InspectionArea = missionDefinition.InspectionArea != null ? new DeckResponse(missionDefinition.InspectionArea) : null; + InspectionArea = missionDefinition.InspectionArea != null ? new InspectionAreaResponse(missionDefinition.InspectionArea) : null; LastSuccessfulRun = missionDefinition.LastSuccessfulRun; IsDeprecated = missionDefinition.IsDeprecated; SourceId = missionDefinition.Source.SourceId; @@ -79,7 +79,7 @@ public class MissionDefinitionWithTasksResponse(IMissionDefinitionService servic public virtual MissionRun? LastSuccessfulRun { get; } = missionDefinition.LastSuccessfulRun; [JsonPropertyName("inspectionArea")] - public Deck? InspectionArea { get; } = missionDefinition.InspectionArea; + public InspectionArea? InspectionArea { get; } = missionDefinition.InspectionArea; [JsonPropertyName("isDeprecated")] public bool IsDeprecated { get; } = missionDefinition.IsDeprecated; diff --git a/backend/api/Controllers/Models/MissionRunResponse.cs b/backend/api/Controllers/Models/MissionRunResponse.cs index 107ee7371..953023cb1 100644 --- a/backend/api/Controllers/Models/MissionRunResponse.cs +++ b/backend/api/Controllers/Models/MissionRunResponse.cs @@ -20,7 +20,7 @@ public class MissionRunResponse public string InstallationCode { get; set; } - public DeckResponse? InspectionArea { get; set; } + public InspectionAreaResponse? InspectionArea { get; set; } public virtual RobotResponse Robot { get; set; } @@ -55,7 +55,7 @@ public MissionRunResponse(MissionRun mission) StatusReason = mission.StatusReason; Comment = mission.Comment; InstallationCode = mission.InstallationCode; - InspectionArea = mission.InspectionArea != null ? new DeckResponse(mission.InspectionArea) : null; + InspectionArea = mission.InspectionArea != null ? new InspectionAreaResponse(mission.InspectionArea) : null; Robot = new RobotResponse(mission.Robot); Status = mission.Status; IsCompleted = mission.IsCompleted; diff --git a/backend/api/Controllers/Models/RobotResponse.cs b/backend/api/Controllers/Models/RobotResponse.cs index b34358775..c7b74b9ba 100644 --- a/backend/api/Controllers/Models/RobotResponse.cs +++ b/backend/api/Controllers/Models/RobotResponse.cs @@ -16,7 +16,7 @@ public class RobotResponse public Installation CurrentInstallation { get; } - public DeckResponse? CurrentInspectionArea { get; set; } + public InspectionAreaResponse? CurrentInspectionArea { get; set; } public float BatteryLevel { get; set; } @@ -59,7 +59,7 @@ public RobotResponse(Robot robot) Model = robot.Model; SerialNumber = robot.SerialNumber; CurrentInstallation = robot.CurrentInstallation; - CurrentInspectionArea = robot.CurrentInspectionArea != null ? new DeckResponse(robot.CurrentInspectionArea) : null; + CurrentInspectionArea = robot.CurrentInspectionArea != null ? new InspectionAreaResponse(robot.CurrentInspectionArea) : null; BatteryLevel = robot.BatteryLevel; BatteryState = robot.BatteryState; PressureLevel = robot.PressureLevel; diff --git a/backend/api/Controllers/RobotController.cs b/backend/api/Controllers/RobotController.cs index c537862ea..7aba68288 100644 --- a/backend/api/Controllers/RobotController.cs +++ b/backend/api/Controllers/RobotController.cs @@ -16,7 +16,7 @@ public class RobotController( IIsarService isarService, IMissionSchedulingService missionSchedulingService, IRobotModelService robotModelService, - IDeckService deckService, + IInspectionAreaService inspectionAreaService, IErrorHandlingService errorHandlingService ) : ControllerBase { @@ -225,7 +225,7 @@ [FromBody] UpdateRobotQuery query } else { - var inspectionArea = await deckService.ReadById(query.InspectionAreaId, readOnly: true); + var inspectionArea = await inspectionAreaService.ReadById(query.InspectionAreaId, readOnly: true); if (inspectionArea == null) return NotFound($"No inspection area with ID {query.InspectionAreaId} was found"); await robotService.UpdateCurrentInspectionArea(id, inspectionArea.Id); robot.CurrentInspectionArea = inspectionArea; diff --git a/backend/api/Database/Context/FlotillaDbContext.cs b/backend/api/Database/Context/FlotillaDbContext.cs index 9aef1595f..7f077b206 100644 --- a/backend/api/Database/Context/FlotillaDbContext.cs +++ b/backend/api/Database/Context/FlotillaDbContext.cs @@ -21,7 +21,7 @@ public FlotillaDbContext(DbContextOptions options) : base(options) public DbSet MissionDefinitions => Set(); public DbSet Plants => Set(); public DbSet Installations => Set(); - public DbSet Decks => Set(); + public DbSet InspectionAreas => Set(); public DbSet Areas => Set(); public DbSet Sources => Set(); public DbSet DefaultLocalizationPoses => Set(); @@ -90,11 +90,11 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) a.PlantCode }).IsUnique(); - modelBuilder.Entity().HasOne(a => a.Deck).WithMany().OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity().HasOne(a => a.InspectionArea).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.Plant).WithMany().OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity().HasOne(d => d.Installation).WithMany().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(p => p.Installation).WithMany().OnDelete(DeleteBehavior.Restrict); } diff --git a/backend/api/Database/Context/InitDb.cs b/backend/api/Database/Context/InitDb.cs index c3d529ff0..994203e23 100644 --- a/backend/api/Database/Context/InitDb.cs +++ b/backend/api/Database/Context/InitDb.cs @@ -9,7 +9,7 @@ public static class InitDb private static readonly List installations = GetInstallations(); private static readonly List robots = GetRobots(); private static readonly List plants = GetPlants(); - private static readonly List decks = GetDecks(); + private static readonly List inspectionAreas = GetInspectionAreas(); private static readonly List areas = GetAreas(); private static readonly List sources = GetSources(); private static readonly List tasks = GetMissionTasks(); @@ -99,54 +99,54 @@ private static List GetPlants() ]); } - private static List GetDecks() + private static List GetInspectionAreas() { - var deck1 = new Deck + var inspectionArea1 = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = plants[0], Installation = plants[0].Installation, DefaultLocalizationPose = new DefaultLocalizationPose(), - Name = "TestDeck" + Name = "TestInspectionArea" }; - var deck2 = new Deck + var inspectionArea2 = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = plants[0], Installation = plants[0].Installation, DefaultLocalizationPose = new DefaultLocalizationPose(), - Name = "TestDeck2" + Name = "TestInspectionArea2" }; - var deck3 = new Deck + var inspectionArea3 = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = plants[0], Installation = plants[0].Installation, DefaultLocalizationPose = new DefaultLocalizationPose(), - Name = "TestDeck3" + Name = "TestInspectionArea3" }; - var deck4 = new Deck + var inspectionArea4 = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = plants[0], Installation = plants[0].Installation, DefaultLocalizationPose = new DefaultLocalizationPose(), - Name = "TestDeck4" + Name = "TestInspectionArea4" }; - var deckHuldraMezzanine = new Deck + var inspectionAreaHuldraMezzanine = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = plants[0], Installation = plants[0].Installation, DefaultLocalizationPose = new DefaultLocalizationPose(), - Name = "Huldra Mezzanine Deck" + Name = "Huldra Mezzanine InspectionArea" }; - var deckKLab = new Deck + var inspectionAreaKLab = new InspectionArea { Id = Guid.NewGuid().ToString(), Plant = plants[1], @@ -155,14 +155,14 @@ private static List GetDecks() Name = "K-Lab" }; - return new List( + return new List( [ - deck1, - deck2, - deck3, - deck4, - deckHuldraMezzanine, - deckKLab + inspectionArea1, + inspectionArea2, + inspectionArea3, + inspectionArea4, + inspectionAreaHuldraMezzanine, + inspectionAreaKLab ]); } @@ -171,9 +171,9 @@ private static List GetAreas() var area1 = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[0], - Plant = decks[0].Plant, - Installation = decks[0].Installation, + InspectionArea = inspectionAreas[0], + Plant = inspectionAreas[0].Plant, + Installation = inspectionAreas[0].Installation, Name = "testArea", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -182,9 +182,9 @@ private static List GetAreas() var area2 = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[0], - Plant = decks[0].Plant, - Installation = decks[0].Installation, + InspectionArea = inspectionAreas[0], + Plant = inspectionAreas[0].Plant, + Installation = inspectionAreas[0].Installation, Name = "testArea2", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -193,9 +193,9 @@ private static List GetAreas() var area3 = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[0], - Plant = decks[0].Plant, - Installation = decks[0].Installation, + InspectionArea = inspectionAreas[0], + Plant = inspectionAreas[0].Plant, + Installation = inspectionAreas[0].Installation, Name = "testArea3", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -204,9 +204,9 @@ private static List GetAreas() var area4 = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[1], - Plant = decks[1].Plant, - Installation = decks[1].Installation, + InspectionArea = inspectionAreas[1], + Plant = inspectionAreas[1].Plant, + Installation = inspectionAreas[1].Installation, Name = "testArea4", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -215,9 +215,9 @@ private static List GetAreas() var area5 = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[2], - Plant = decks[2].Plant, - Installation = decks[2].Installation, + InspectionArea = inspectionAreas[2], + Plant = inspectionAreas[2].Plant, + Installation = inspectionAreas[2].Installation, Name = "testArea5", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -226,9 +226,9 @@ private static List GetAreas() var area6 = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[3], - Plant = decks[3].Plant, - Installation = decks[3].Installation, + InspectionArea = inspectionAreas[3], + Plant = inspectionAreas[3].Plant, + Installation = inspectionAreas[3].Installation, Name = "testArea6", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -237,9 +237,9 @@ private static List GetAreas() var areaHuldraHB = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[4], - Plant = decks[4].Plant, - Installation = decks[4].Installation, + InspectionArea = inspectionAreas[4], + Plant = inspectionAreas[4].Plant, + Installation = inspectionAreas[4].Installation, Name = "HB", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -248,9 +248,9 @@ private static List GetAreas() var areaKLab = new Area { Id = Guid.NewGuid().ToString(), - Deck = decks[5], - Plant = decks[5].Plant, - Installation = decks[5].Installation, + InspectionArea = inspectionAreas[5], + Plant = inspectionAreas[5].Plant, + Installation = inspectionAreas[5].Installation, Name = "K-lab", MapMetadata = new MapMetadata(), DefaultLocalizationPose = new DefaultLocalizationPose(), @@ -349,8 +349,8 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 1", - InstallationCode = decks[0].Installation!.InstallationCode, - InspectionArea = decks[0], + InstallationCode = inspectionAreas[0].Installation!.InstallationCode, + InspectionArea = inspectionAreas[0], Source = sources[0], Comment = "Interesting comment", InspectionFrequency = new DateTime().AddDays(12) - new DateTime(), @@ -361,8 +361,8 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 2", - InstallationCode = decks[1].Installation!.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation!.InstallationCode, + InspectionArea = inspectionAreas[1], Source = sources[1], InspectionFrequency = new DateTime().AddDays(7) - new DateTime(), LastSuccessfulRun = null @@ -372,8 +372,8 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 3", - InstallationCode = decks[1].Installation!.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation!.InstallationCode, + InspectionArea = inspectionAreas[1], Source = sources[2], LastSuccessfulRun = null }; @@ -382,9 +382,9 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 4", - InstallationCode = decks[2].Installation.InstallationCode, + InstallationCode = inspectionAreas[2].Installation.InstallationCode, InspectionFrequency = new DateTime().AddDays(90) - new DateTime(), - InspectionArea = decks[2], + InspectionArea = inspectionAreas[2], Source = sources[2], LastSuccessfulRun = null }; @@ -393,9 +393,9 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 5", - InstallationCode = decks[2].Installation.InstallationCode, + InstallationCode = inspectionAreas[2].Installation.InstallationCode, InspectionFrequency = new DateTime().AddDays(35) - new DateTime(), - InspectionArea = decks[2], + InspectionArea = inspectionAreas[2], Source = sources[2], LastSuccessfulRun = null }; @@ -404,9 +404,9 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 6", - InstallationCode = decks[3].Installation.InstallationCode, + InstallationCode = inspectionAreas[3].Installation.InstallationCode, InspectionFrequency = new DateTime().AddDays(4) - new DateTime(), - InspectionArea = decks[3], + InspectionArea = inspectionAreas[3], Source = sources[2], LastSuccessfulRun = null }; @@ -414,8 +414,8 @@ private static List GetMissionDefinitions() { Id = Guid.NewGuid().ToString(), Name = "Placeholder Mission 7", - InstallationCode = decks[3].Installation.InstallationCode, - InspectionArea = decks[4], + InstallationCode = inspectionAreas[3].Installation.InstallationCode, + InspectionArea = inspectionAreas[4], Source = sources[2], LastSuccessfulRun = null }; @@ -530,8 +530,8 @@ private static List GetMissionRuns() { Name = "Placeholder Mission 1", Robot = robots[0], - InstallationCode = decks[0].Installation!.InstallationCode, - InspectionArea = decks[0], + InstallationCode = inspectionAreas[0].Installation!.InstallationCode, + InspectionArea = inspectionAreas[0], MissionId = missionDefinitions[0].Id, Status = MissionStatus.Successful, DesiredStartTime = DateTime.UtcNow, @@ -542,8 +542,8 @@ private static List GetMissionRuns() { Name = "Placeholder Mission 2", Robot = robots[1], - InstallationCode = decks[1].Installation!.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation!.InstallationCode, + InspectionArea = inspectionAreas[1], MissionId = missionDefinitions[0].Id, Status = MissionStatus.Successful, DesiredStartTime = DateTime.UtcNow, @@ -555,8 +555,8 @@ private static List GetMissionRuns() { Name = "Placeholder Mission 3", Robot = robots[2], - InstallationCode = decks[1].Installation!.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation!.InstallationCode, + InspectionArea = inspectionAreas[1], MissionId = missionDefinitions[1].Id, Status = MissionStatus.Successful, DesiredStartTime = DateTime.UtcNow, @@ -567,8 +567,8 @@ private static List GetMissionRuns() { Name = "Placeholder Mission 4", Robot = robots[2], - InstallationCode = decks[1].Installation.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation.InstallationCode, + InspectionArea = inspectionAreas[1], MissionId = missionDefinitions[1].Id, Status = MissionStatus.Failed, DesiredStartTime = DateTime.UtcNow, @@ -583,8 +583,8 @@ private static List GetMissionRuns() { Name = "Placeholder Mission 5", Robot = robots[2], - InstallationCode = decks[1].Installation.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation.InstallationCode, + InspectionArea = inspectionAreas[1], MissionId = missionDefinitions[1].Id, Status = MissionStatus.PartiallySuccessful, DesiredStartTime = DateTime.UtcNow, @@ -599,8 +599,8 @@ private static List GetMissionRuns() { Name = "Placeholder Mission 6", Robot = robots[2], - InstallationCode = decks[1].Installation.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation.InstallationCode, + InspectionArea = inspectionAreas[1], MissionId = missionDefinitions[1].Id, Status = MissionStatus.Cancelled, DesiredStartTime = DateTime.UtcNow, @@ -615,8 +615,8 @@ private static List GetMissionRuns() { Name = "Some failed tasks", Robot = robots[2], - InstallationCode = decks[1].Installation.InstallationCode, - InspectionArea = decks[1], + InstallationCode = inspectionAreas[1].Installation.InstallationCode, + InspectionArea = inspectionAreas[1], MissionId = missionDefinitions[1].Id, Status = MissionStatus.Failed, DesiredStartTime = DateTime.UtcNow, @@ -682,7 +682,7 @@ public static void PopulateDb(FlotillaDbContext context) context.AddRange(robots); context.AddRange(plants); - context.AddRange(decks); + context.AddRange(inspectionAreas); context.AddRange(areas); context.AddRange(sources); diff --git a/backend/api/Database/Models/Area.cs b/backend/api/Database/Models/Area.cs index d2db416dd..360f1124e 100644 --- a/backend/api/Database/Models/Area.cs +++ b/backend/api/Database/Models/Area.cs @@ -11,7 +11,7 @@ public class Area public string Id { get; set; } [Required] - public virtual Deck Deck { get; set; } + public virtual InspectionArea InspectionArea { get; set; } [Required] public virtual Plant Plant { get; set; } diff --git a/backend/api/Database/Models/Deck.cs b/backend/api/Database/Models/Deck.cs index 48414a9e6..da137c16f 100644 --- a/backend/api/Database/Models/Deck.cs +++ b/backend/api/Database/Models/Deck.cs @@ -4,7 +4,7 @@ #pragma warning disable CS8618 namespace Api.Database.Models { - public class Deck + public class InspectionArea { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] diff --git a/backend/api/Database/Models/MissionDefinition.cs b/backend/api/Database/Models/MissionDefinition.cs index 42cef67ed..602124ae9 100644 --- a/backend/api/Database/Models/MissionDefinition.cs +++ b/backend/api/Database/Models/MissionDefinition.cs @@ -28,7 +28,7 @@ public class MissionDefinition : SortableRecord public virtual MissionRun? LastSuccessfulRun { get; set; } - public Deck? InspectionArea { get; set; } + public InspectionArea? InspectionArea { get; set; } public MapMetadata? Map { get; set; } diff --git a/backend/api/Database/Models/MissionRun.cs b/backend/api/Database/Models/MissionRun.cs index c2596830c..cfe232d1b 100644 --- a/backend/api/Database/Models/MissionRun.cs +++ b/backend/api/Database/Models/MissionRun.cs @@ -69,7 +69,7 @@ public IList Tasks [MaxLength(1000)] public string? Comment { get; set; } - public Deck? InspectionArea { get; set; } + public InspectionArea? InspectionArea { get; set; } public bool IsCompleted => _status diff --git a/backend/api/Database/Models/Robot.cs b/backend/api/Database/Models/Robot.cs index 0fce2d7a6..0620ac9b1 100644 --- a/backend/api/Database/Models/Robot.cs +++ b/backend/api/Database/Models/Robot.cs @@ -20,7 +20,7 @@ public Robot() Pose = new Pose(); } - public Robot(CreateRobotQuery createQuery, Installation installation, RobotModel model, Deck? inspectionArea = null) + public Robot(CreateRobotQuery createQuery, Installation installation, RobotModel model, InspectionArea? inspectionArea = null) { var documentation = new List(); foreach (var documentQuery in createQuery.Documentation) @@ -70,7 +70,7 @@ public Robot(CreateRobotQuery createQuery, Installation installation, RobotModel [Required] public Installation CurrentInstallation { get; set; } - public Deck? CurrentInspectionArea { get; set; } + public InspectionArea? CurrentInspectionArea { get; set; } public float BatteryLevel { get; set; } diff --git a/backend/api/Migrations/20241218142253_RenameDeckToInspectionArea.Designer.cs b/backend/api/Migrations/20241218142253_RenameDeckToInspectionArea.Designer.cs new file mode 100644 index 000000000..bd4dc09f5 --- /dev/null +++ b/backend/api/Migrations/20241218142253_RenameDeckToInspectionArea.Designer.cs @@ -0,0 +1,1336 @@ +// +using System; +using Api.Database.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Api.Migrations +{ + [DbContext(typeof(FlotillaDbContext))] + [Migration("20241218142253_RenameDeckToInspectionArea")] + partial class RenameDeckToInspectionArea + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Api.Database.Models.AccessRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("AccessLevel") + .IsRequired() + .HasColumnType("text"); + + b.Property("InstallationId") + .HasColumnType("text"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InstallationId"); + + b.ToTable("AccessRoles"); + }); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b.Property("InspectionAreaId") + .IsRequired() + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DefaultLocalizationPoseId"); + + b.HasIndex("InspectionAreaId"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("Areas"); + }); + + modelBuilder.Entity("Api.Database.Models.DefaultLocalizationPose", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DockingEnabled") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("DefaultLocalizationPoses"); + }); + + modelBuilder.Entity("Api.Database.Models.Inspection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("AnalysisType") + .HasColumnType("text"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionTargetName") + .HasColumnType("text"); + + b.Property("InspectionType") + .IsRequired() + .HasColumnType("text"); + + b.Property("InspectionUrl") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("IsarInspectionId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsarTaskId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("VideoDuration") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("Inspections"); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DefaultLocalizationPoseId"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("Decks"); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionFinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Finding") + .IsRequired() + .HasColumnType("text"); + + b.Property("InspectionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionId") + .HasColumnType("text"); + + b.Property("IsarTaskId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionId"); + + b.ToTable("InspectionFindings"); + }); + + modelBuilder.Entity("Api.Database.Models.Installation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("InstallationCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("InstallationCode") + .IsUnique(); + + b.ToTable("Installations"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("InspectionAreaId") + .HasColumnType("text"); + + b.Property("InspectionFrequency") + .HasColumnType("bigint"); + + b.Property("InstallationCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsDeprecated") + .HasColumnType("boolean"); + + b.Property("LastSuccessfulRunId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SourceId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionAreaId"); + + b.HasIndex("LastSuccessfulRunId"); + + b.HasIndex("SourceId"); + + b.ToTable("MissionDefinitions"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("DesiredStartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("EstimatedDuration") + .HasColumnType("bigint"); + + b.Property("InspectionAreaId") + .HasColumnType("text"); + + b.Property("InstallationCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsDeprecated") + .HasColumnType("boolean"); + + b.Property("IsarMissionId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("MissionRunType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("StatusReason") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.HasKey("Id"); + + b.HasIndex("InspectionAreaId"); + + b.HasIndex("RobotId"); + + b.ToTable("MissionRuns"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionId") + .HasColumnType("text"); + + b.Property("IsarTaskId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("MissionRunId") + .HasColumnType("text"); + + b.Property("PoseId") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("TagId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TagLink") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TaskOrder") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionId"); + + b.HasIndex("MissionRunId"); + + b.ToTable("MissionTasks"); + }); + + modelBuilder.Entity("Api.Database.Models.Plant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(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("text"); + + b.Property("BatteryLevel") + .HasColumnType("real"); + + b.Property("BatteryState") + .HasColumnType("text"); + + b.Property("CurrentInspectionAreaId") + .HasColumnType("text"); + + b.Property("CurrentInstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CurrentMissionId") + .HasColumnType("text"); + + b.Property("Deprecated") + .HasColumnType("boolean"); + + b.Property("FlotillaStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("Host") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsarConnected") + .HasColumnType("boolean"); + + b.Property("IsarId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("MissionQueueFrozen") + .HasColumnType("boolean"); + + b.Property("ModelId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Port") + .HasColumnType("integer"); + + b.Property("PressureLevel") + .HasColumnType("real"); + + b.Property("RobotCapabilities") + .HasColumnType("text"); + + b.Property("SerialNumber") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrentInspectionAreaId"); + + b.HasIndex("CurrentInstallationId"); + + b.HasIndex("ModelId"); + + b.ToTable("Robots"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotBatteryTimeseries", b => + { + b.Property("BatteryLevel") + .HasColumnType("real"); + + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.ToTable("RobotBatteryTimeseries"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("AverageDurationPerTag") + .HasColumnType("real"); + + b.Property("BatteryMissionStartThreshold") + .HasColumnType("real"); + + b.Property("BatteryWarningThreshold") + .HasColumnType("real"); + + b.Property("LowerPressureWarningThreshold") + .HasColumnType("real"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpperPressureWarningThreshold") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("Type") + .IsUnique(); + + b.ToTable("RobotModels"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotPoseTimeseries", b => + { + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("OrientationW") + .HasColumnType("real"); + + b.Property("OrientationX") + .HasColumnType("real"); + + b.Property("OrientationY") + .HasColumnType("real"); + + b.Property("OrientationZ") + .HasColumnType("real"); + + b.Property("PositionX") + .HasColumnType("real"); + + b.Property("PositionY") + .HasColumnType("real"); + + b.Property("PositionZ") + .HasColumnType("real"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.ToTable("RobotPoseTimeseries"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotPressureTimeseries", b => + { + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("Pressure") + .HasColumnType("real"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.ToTable("RobotPressureTimeseries"); + }); + + modelBuilder.Entity("Api.Database.Models.Source", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("CustomMissionTasks") + .HasColumnType("text"); + + b.Property("SourceId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Sources"); + }); + + modelBuilder.Entity("Api.Database.Models.UserInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Oid") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("UserInfos"); + }); + + modelBuilder.Entity("Api.Services.MissionLoaders.TagInspectionMetadata", b => + { + b.Property("TagId") + .HasColumnType("text"); + + b.HasKey("TagId"); + + b.ToTable("TagInspectionMetadata"); + }); + + modelBuilder.Entity("Api.Database.Models.AccessRole", b => + { + b.HasOne("Api.Database.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId"); + + b.Navigation("Installation"); + }); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") + .WithMany() + .HasForeignKey("DefaultLocalizationPoseId"); + + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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.MapMetadata", "MapMetadata", b1 => + { + b1.Property("AreaId") + .HasColumnType("text"); + + b1.Property("MapName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.HasKey("AreaId"); + + b1.ToTable("Areas"); + + b1.WithOwner() + .HasForeignKey("AreaId"); + + b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + { + b2.Property("MapMetadataAreaId") + .HasColumnType("text"); + + b2.Property("X1") + .HasColumnType("double precision"); + + b2.Property("X2") + .HasColumnType("double precision"); + + b2.Property("Y1") + .HasColumnType("double precision"); + + b2.Property("Y2") + .HasColumnType("double precision"); + + b2.Property("Z1") + .HasColumnType("double precision"); + + b2.Property("Z2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("MapMetadataAreaId"); + }); + + b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + { + b2.Property("MapMetadataAreaId") + .HasColumnType("text"); + + b2.Property("C1") + .HasColumnType("double precision"); + + b2.Property("C2") + .HasColumnType("double precision"); + + b2.Property("D1") + .HasColumnType("double precision"); + + b2.Property("D2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("MapMetadataAreaId"); + }); + + b1.Navigation("Boundary") + .IsRequired(); + + b1.Navigation("TransformationMatrices") + .IsRequired(); + }); + + b.Navigation("DefaultLocalizationPose"); + + b.Navigation("InspectionArea"); + + b.Navigation("Installation"); + + b.Navigation("MapMetadata") + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("Api.Database.Models.DefaultLocalizationPose", b => + { + b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + { + b1.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b1.HasKey("DefaultLocalizationPoseId"); + + b1.ToTable("DefaultLocalizationPoses"); + + b1.WithOwner() + .HasForeignKey("DefaultLocalizationPoseId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseDefaultLocalizationPoseId") + .HasColumnType("text"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseDefaultLocalizationPoseId"); + + b2.ToTable("DefaultLocalizationPoses"); + + b2.WithOwner() + .HasForeignKey("PoseDefaultLocalizationPoseId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseDefaultLocalizationPoseId") + .HasColumnType("text"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseDefaultLocalizationPoseId"); + + b2.ToTable("DefaultLocalizationPoses"); + + b2.WithOwner() + .HasForeignKey("PoseDefaultLocalizationPoseId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.Navigation("Pose") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Database.Models.Inspection", b => + { + b.OwnsOne("Api.Database.Models.Position", "InspectionTarget", b1 => + { + b1.Property("InspectionId") + .HasColumnType("text"); + + b1.Property("X") + .HasColumnType("real"); + + b1.Property("Y") + .HasColumnType("real"); + + b1.Property("Z") + .HasColumnType("real"); + + b1.HasKey("InspectionId"); + + b1.ToTable("Inspections"); + + b1.WithOwner() + .HasForeignKey("InspectionId"); + }); + + b.Navigation("InspectionTarget") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionArea", b => + { + b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") + .WithMany() + .HasForeignKey("DefaultLocalizationPoseId"); + + 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("DefaultLocalizationPose"); + + b.Navigation("Installation"); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionFinding", b => + { + b.HasOne("Api.Database.Models.Inspection", null) + .WithMany("InspectionFindings") + .HasForeignKey("InspectionId"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => + { + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Api.Database.Models.MissionRun", "LastSuccessfulRun") + .WithMany() + .HasForeignKey("LastSuccessfulRunId"); + + b.HasOne("Api.Database.Models.Source", "Source") + .WithMany() + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Api.Database.Models.MapMetadata", "Map", b1 => + { + b1.Property("MissionDefinitionId") + .HasColumnType("text"); + + b1.Property("MapName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.HasKey("MissionDefinitionId"); + + b1.ToTable("MissionDefinitions"); + + b1.WithOwner() + .HasForeignKey("MissionDefinitionId"); + + b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + { + b2.Property("MapMetadataMissionDefinitionId") + .HasColumnType("text"); + + b2.Property("X1") + .HasColumnType("double precision"); + + b2.Property("X2") + .HasColumnType("double precision"); + + b2.Property("Y1") + .HasColumnType("double precision"); + + b2.Property("Y2") + .HasColumnType("double precision"); + + b2.Property("Z1") + .HasColumnType("double precision"); + + b2.Property("Z2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataMissionDefinitionId"); + + b2.ToTable("MissionDefinitions"); + + b2.WithOwner() + .HasForeignKey("MapMetadataMissionDefinitionId"); + }); + + b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + { + b2.Property("MapMetadataMissionDefinitionId") + .HasColumnType("text"); + + b2.Property("C1") + .HasColumnType("double precision"); + + b2.Property("C2") + .HasColumnType("double precision"); + + b2.Property("D1") + .HasColumnType("double precision"); + + b2.Property("D2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataMissionDefinitionId"); + + b2.ToTable("MissionDefinitions"); + + b2.WithOwner() + .HasForeignKey("MapMetadataMissionDefinitionId"); + }); + + b1.Navigation("Boundary") + .IsRequired(); + + b1.Navigation("TransformationMatrices") + .IsRequired(); + }); + + b.Navigation("InspectionArea"); + + b.Navigation("LastSuccessfulRun"); + + b.Navigation("Map"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Api.Database.Models.Robot", "Robot") + .WithMany() + .HasForeignKey("RobotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionArea"); + + b.Navigation("Robot"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionTask", b => + { + b.HasOne("Api.Database.Models.Inspection", "Inspection") + .WithMany() + .HasForeignKey("InspectionId"); + + b.HasOne("Api.Database.Models.MissionRun", null) + .WithMany("Tasks") + .HasForeignKey("MissionRunId"); + + b.OwnsOne("Api.Services.Models.IsarZoomDescription", "IsarZoomDescription", b1 => + { + b1.Property("MissionTaskId") + .HasColumnType("text"); + + b1.Property("ObjectHeight") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectHeight"); + + b1.Property("ObjectWidth") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectWidth"); + + b1.HasKey("MissionTaskId"); + + b1.ToTable("MissionTasks"); + + b1.WithOwner() + .HasForeignKey("MissionTaskId"); + }); + + b.OwnsOne("Api.Database.Models.Pose", "RobotPose", b1 => + { + b1.Property("MissionTaskId") + .HasColumnType("text"); + + b1.HasKey("MissionTaskId"); + + b1.ToTable("MissionTasks"); + + b1.WithOwner() + .HasForeignKey("MissionTaskId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseMissionTaskId") + .HasColumnType("text"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseMissionTaskId"); + + b2.ToTable("MissionTasks"); + + b2.WithOwner() + .HasForeignKey("PoseMissionTaskId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseMissionTaskId") + .HasColumnType("text"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseMissionTaskId"); + + b2.ToTable("MissionTasks"); + + b2.WithOwner() + .HasForeignKey("PoseMissionTaskId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.Navigation("Inspection"); + + b.Navigation("IsarZoomDescription"); + + b.Navigation("RobotPose") + .IsRequired(); + }); + + 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.InspectionArea", "CurrentInspectionArea") + .WithMany() + .HasForeignKey("CurrentInspectionAreaId"); + + b.HasOne("Api.Database.Models.Installation", "CurrentInstallation") + .WithMany() + .HasForeignKey("CurrentInstallationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Api.Database.Models.RobotModel", "Model") + .WithMany() + .HasForeignKey("ModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Api.Database.Models.DocumentInfo", "Documentation", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b1.Property("Url") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.HasKey("Id"); + + b1.HasIndex("RobotId"); + + b1.ToTable("DocumentInfo"); + + b1.WithOwner() + .HasForeignKey("RobotId"); + }); + + b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + { + b1.Property("RobotId") + .HasColumnType("text"); + + b1.HasKey("RobotId"); + + b1.ToTable("Robots"); + + b1.WithOwner() + .HasForeignKey("RobotId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseRobotId") + .HasColumnType("text"); + + 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("text"); + + 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.Navigation("CurrentInspectionArea"); + + b.Navigation("CurrentInstallation"); + + b.Navigation("Documentation"); + + b.Navigation("Model"); + + b.Navigation("Pose") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Services.MissionLoaders.TagInspectionMetadata", b => + { + b.OwnsOne("Api.Services.Models.IsarZoomDescription", "ZoomDescription", b1 => + { + b1.Property("TagInspectionMetadataTagId") + .HasColumnType("text"); + + b1.Property("ObjectHeight") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectHeight"); + + b1.Property("ObjectWidth") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectWidth"); + + b1.HasKey("TagInspectionMetadataTagId"); + + b1.ToTable("TagInspectionMetadata"); + + b1.WithOwner() + .HasForeignKey("TagInspectionMetadataTagId"); + }); + + b.Navigation("ZoomDescription"); + }); + + modelBuilder.Entity("Api.Database.Models.Inspection", b => + { + b.Navigation("InspectionFindings"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.Navigation("Tasks"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/api/Migrations/20241218142253_RenameDeckToInspectionArea.cs b/backend/api/Migrations/20241218142253_RenameDeckToInspectionArea.cs new file mode 100644 index 000000000..8abbafd22 --- /dev/null +++ b/backend/api/Migrations/20241218142253_RenameDeckToInspectionArea.cs @@ -0,0 +1,62 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Api.Migrations +{ + /// + public partial class RenameDeckToInspectionArea : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Areas_Decks_DeckId", + table: "Areas"); + + migrationBuilder.RenameColumn( + name: "DeckId", + table: "Areas", + newName: "InspectionAreaId"); + + migrationBuilder.RenameIndex( + name: "IX_Areas_DeckId", + table: "Areas", + newName: "IX_Areas_InspectionAreaId"); + + migrationBuilder.AddForeignKey( + name: "FK_Areas_Decks_InspectionAreaId", + table: "Areas", + column: "InspectionAreaId", + principalTable: "Decks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Areas_Decks_InspectionAreaId", + table: "Areas"); + + migrationBuilder.RenameColumn( + name: "InspectionAreaId", + table: "Areas", + newName: "DeckId"); + + migrationBuilder.RenameIndex( + name: "IX_Areas_InspectionAreaId", + table: "Areas", + newName: "IX_Areas_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/20241218142700_RenameDeckTableToInspectionArea.Designer.cs b/backend/api/Migrations/20241218142700_RenameDeckTableToInspectionArea.Designer.cs new file mode 100644 index 000000000..abe7472bd --- /dev/null +++ b/backend/api/Migrations/20241218142700_RenameDeckTableToInspectionArea.Designer.cs @@ -0,0 +1,1336 @@ +// +using System; +using Api.Database.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Api.Migrations +{ + [DbContext(typeof(FlotillaDbContext))] + [Migration("20241218142700_RenameDeckTableToInspectionArea")] + partial class RenameDeckTableToInspectionArea + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.11") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Api.Database.Models.AccessRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("AccessLevel") + .IsRequired() + .HasColumnType("text"); + + b.Property("InstallationId") + .HasColumnType("text"); + + b.Property("RoleName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InstallationId"); + + b.ToTable("AccessRoles"); + }); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b.Property("InspectionAreaId") + .IsRequired() + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DefaultLocalizationPoseId"); + + b.HasIndex("InspectionAreaId"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("Areas"); + }); + + modelBuilder.Entity("Api.Database.Models.DefaultLocalizationPose", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DockingEnabled") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.ToTable("DefaultLocalizationPoses"); + }); + + modelBuilder.Entity("Api.Database.Models.Inspection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("AnalysisType") + .HasColumnType("text"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionTargetName") + .HasColumnType("text"); + + b.Property("InspectionType") + .IsRequired() + .HasColumnType("text"); + + b.Property("InspectionUrl") + .HasMaxLength(250) + .HasColumnType("character varying(250)"); + + b.Property("IsarInspectionId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsarTaskId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("VideoDuration") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.ToTable("Inspections"); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DefaultLocalizationPoseId"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("InspectionAreas"); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionFinding", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Finding") + .IsRequired() + .HasColumnType("text"); + + b.Property("InspectionDate") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionId") + .HasColumnType("text"); + + b.Property("IsarTaskId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionId"); + + b.ToTable("InspectionFindings"); + }); + + modelBuilder.Entity("Api.Database.Models.Installation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("InstallationCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.HasKey("Id"); + + b.HasIndex("InstallationCode") + .IsUnique(); + + b.ToTable("Installations"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("InspectionAreaId") + .HasColumnType("text"); + + b.Property("InspectionFrequency") + .HasColumnType("bigint"); + + b.Property("InstallationCode") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsDeprecated") + .HasColumnType("boolean"); + + b.Property("LastSuccessfulRunId") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("SourceId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionAreaId"); + + b.HasIndex("LastSuccessfulRunId"); + + b.HasIndex("SourceId"); + + b.ToTable("MissionDefinitions"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Comment") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Description") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.Property("DesiredStartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("EstimatedDuration") + .HasColumnType("bigint"); + + b.Property("InspectionAreaId") + .HasColumnType("text"); + + b.Property("InstallationCode") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsDeprecated") + .HasColumnType("boolean"); + + b.Property("IsarMissionId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("MissionRunType") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("StatusReason") + .HasMaxLength(450) + .HasColumnType("character varying(450)"); + + b.HasKey("Id"); + + b.HasIndex("InspectionAreaId"); + + b.HasIndex("RobotId"); + + b.ToTable("MissionRuns"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionTask", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Description") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("EndTime") + .HasColumnType("timestamp with time zone"); + + b.Property("InspectionId") + .HasColumnType("text"); + + b.Property("IsarTaskId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("MissionRunId") + .HasColumnType("text"); + + b.Property("PoseId") + .HasColumnType("integer"); + + b.Property("StartTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.Property("TagId") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TagLink") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("TaskOrder") + .HasColumnType("integer"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("InspectionId"); + + b.HasIndex("MissionRunId"); + + b.ToTable("MissionTasks"); + }); + + modelBuilder.Entity("Api.Database.Models.Plant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantCode") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(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("text"); + + b.Property("BatteryLevel") + .HasColumnType("real"); + + b.Property("BatteryState") + .HasColumnType("text"); + + b.Property("CurrentInspectionAreaId") + .HasColumnType("text"); + + b.Property("CurrentInstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("CurrentMissionId") + .HasColumnType("text"); + + b.Property("Deprecated") + .HasColumnType("boolean"); + + b.Property("FlotillaStatus") + .IsRequired() + .HasColumnType("text"); + + b.Property("Host") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("IsarConnected") + .HasColumnType("boolean"); + + b.Property("IsarId") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("MissionQueueFrozen") + .HasColumnType("boolean"); + + b.Property("ModelId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Port") + .HasColumnType("integer"); + + b.Property("PressureLevel") + .HasColumnType("real"); + + b.Property("RobotCapabilities") + .HasColumnType("text"); + + b.Property("SerialNumber") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CurrentInspectionAreaId"); + + b.HasIndex("CurrentInstallationId"); + + b.HasIndex("ModelId"); + + b.ToTable("Robots"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotBatteryTimeseries", b => + { + b.Property("BatteryLevel") + .HasColumnType("real"); + + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.ToTable("RobotBatteryTimeseries"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("AverageDurationPerTag") + .HasColumnType("real"); + + b.Property("BatteryMissionStartThreshold") + .HasColumnType("real"); + + b.Property("BatteryWarningThreshold") + .HasColumnType("real"); + + b.Property("LowerPressureWarningThreshold") + .HasColumnType("real"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("UpperPressureWarningThreshold") + .HasColumnType("real"); + + b.HasKey("Id"); + + b.HasIndex("Type") + .IsUnique(); + + b.ToTable("RobotModels"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotPoseTimeseries", b => + { + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("OrientationW") + .HasColumnType("real"); + + b.Property("OrientationX") + .HasColumnType("real"); + + b.Property("OrientationY") + .HasColumnType("real"); + + b.Property("OrientationZ") + .HasColumnType("real"); + + b.Property("PositionX") + .HasColumnType("real"); + + b.Property("PositionY") + .HasColumnType("real"); + + b.Property("PositionZ") + .HasColumnType("real"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.ToTable("RobotPoseTimeseries"); + }); + + modelBuilder.Entity("Api.Database.Models.RobotPressureTimeseries", b => + { + b.Property("MissionId") + .HasColumnType("text"); + + b.Property("Pressure") + .HasColumnType("real"); + + b.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Time") + .HasColumnType("timestamp with time zone"); + + b.ToTable("RobotPressureTimeseries"); + }); + + modelBuilder.Entity("Api.Database.Models.Source", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("CustomMissionTasks") + .HasColumnType("text"); + + b.Property("SourceId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Sources"); + }); + + modelBuilder.Entity("Api.Database.Models.UserInfo", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("Oid") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("UserInfos"); + }); + + modelBuilder.Entity("Api.Services.MissionLoaders.TagInspectionMetadata", b => + { + b.Property("TagId") + .HasColumnType("text"); + + b.HasKey("TagId"); + + b.ToTable("TagInspectionMetadata"); + }); + + modelBuilder.Entity("Api.Database.Models.AccessRole", b => + { + b.HasOne("Api.Database.Models.Installation", "Installation") + .WithMany() + .HasForeignKey("InstallationId"); + + b.Navigation("Installation"); + }); + + modelBuilder.Entity("Api.Database.Models.Area", b => + { + b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") + .WithMany() + .HasForeignKey("DefaultLocalizationPoseId"); + + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + 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.MapMetadata", "MapMetadata", b1 => + { + b1.Property("AreaId") + .HasColumnType("text"); + + b1.Property("MapName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.HasKey("AreaId"); + + b1.ToTable("Areas"); + + b1.WithOwner() + .HasForeignKey("AreaId"); + + b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + { + b2.Property("MapMetadataAreaId") + .HasColumnType("text"); + + b2.Property("X1") + .HasColumnType("double precision"); + + b2.Property("X2") + .HasColumnType("double precision"); + + b2.Property("Y1") + .HasColumnType("double precision"); + + b2.Property("Y2") + .HasColumnType("double precision"); + + b2.Property("Z1") + .HasColumnType("double precision"); + + b2.Property("Z2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("MapMetadataAreaId"); + }); + + b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + { + b2.Property("MapMetadataAreaId") + .HasColumnType("text"); + + b2.Property("C1") + .HasColumnType("double precision"); + + b2.Property("C2") + .HasColumnType("double precision"); + + b2.Property("D1") + .HasColumnType("double precision"); + + b2.Property("D2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataAreaId"); + + b2.ToTable("Areas"); + + b2.WithOwner() + .HasForeignKey("MapMetadataAreaId"); + }); + + b1.Navigation("Boundary") + .IsRequired(); + + b1.Navigation("TransformationMatrices") + .IsRequired(); + }); + + b.Navigation("DefaultLocalizationPose"); + + b.Navigation("InspectionArea"); + + b.Navigation("Installation"); + + b.Navigation("MapMetadata") + .IsRequired(); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("Api.Database.Models.DefaultLocalizationPose", b => + { + b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + { + b1.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b1.HasKey("DefaultLocalizationPoseId"); + + b1.ToTable("DefaultLocalizationPoses"); + + b1.WithOwner() + .HasForeignKey("DefaultLocalizationPoseId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseDefaultLocalizationPoseId") + .HasColumnType("text"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseDefaultLocalizationPoseId"); + + b2.ToTable("DefaultLocalizationPoses"); + + b2.WithOwner() + .HasForeignKey("PoseDefaultLocalizationPoseId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseDefaultLocalizationPoseId") + .HasColumnType("text"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseDefaultLocalizationPoseId"); + + b2.ToTable("DefaultLocalizationPoses"); + + b2.WithOwner() + .HasForeignKey("PoseDefaultLocalizationPoseId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.Navigation("Pose") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Database.Models.Inspection", b => + { + b.OwnsOne("Api.Database.Models.Position", "InspectionTarget", b1 => + { + b1.Property("InspectionId") + .HasColumnType("text"); + + b1.Property("X") + .HasColumnType("real"); + + b1.Property("Y") + .HasColumnType("real"); + + b1.Property("Z") + .HasColumnType("real"); + + b1.HasKey("InspectionId"); + + b1.ToTable("Inspections"); + + b1.WithOwner() + .HasForeignKey("InspectionId"); + }); + + b.Navigation("InspectionTarget") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionArea", b => + { + b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") + .WithMany() + .HasForeignKey("DefaultLocalizationPoseId"); + + 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("DefaultLocalizationPose"); + + b.Navigation("Installation"); + + b.Navigation("Plant"); + }); + + modelBuilder.Entity("Api.Database.Models.InspectionFinding", b => + { + b.HasOne("Api.Database.Models.Inspection", null) + .WithMany("InspectionFindings") + .HasForeignKey("InspectionId"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => + { + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Api.Database.Models.MissionRun", "LastSuccessfulRun") + .WithMany() + .HasForeignKey("LastSuccessfulRunId"); + + b.HasOne("Api.Database.Models.Source", "Source") + .WithMany() + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsOne("Api.Database.Models.MapMetadata", "Map", b1 => + { + b1.Property("MissionDefinitionId") + .HasColumnType("text"); + + b1.Property("MapName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.HasKey("MissionDefinitionId"); + + b1.ToTable("MissionDefinitions"); + + b1.WithOwner() + .HasForeignKey("MissionDefinitionId"); + + b1.OwnsOne("Api.Database.Models.Boundary", "Boundary", b2 => + { + b2.Property("MapMetadataMissionDefinitionId") + .HasColumnType("text"); + + b2.Property("X1") + .HasColumnType("double precision"); + + b2.Property("X2") + .HasColumnType("double precision"); + + b2.Property("Y1") + .HasColumnType("double precision"); + + b2.Property("Y2") + .HasColumnType("double precision"); + + b2.Property("Z1") + .HasColumnType("double precision"); + + b2.Property("Z2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataMissionDefinitionId"); + + b2.ToTable("MissionDefinitions"); + + b2.WithOwner() + .HasForeignKey("MapMetadataMissionDefinitionId"); + }); + + b1.OwnsOne("Api.Database.Models.TransformationMatrices", "TransformationMatrices", b2 => + { + b2.Property("MapMetadataMissionDefinitionId") + .HasColumnType("text"); + + b2.Property("C1") + .HasColumnType("double precision"); + + b2.Property("C2") + .HasColumnType("double precision"); + + b2.Property("D1") + .HasColumnType("double precision"); + + b2.Property("D2") + .HasColumnType("double precision"); + + b2.HasKey("MapMetadataMissionDefinitionId"); + + b2.ToTable("MissionDefinitions"); + + b2.WithOwner() + .HasForeignKey("MapMetadataMissionDefinitionId"); + }); + + b1.Navigation("Boundary") + .IsRequired(); + + b1.Navigation("TransformationMatrices") + .IsRequired(); + }); + + b.Navigation("InspectionArea"); + + b.Navigation("LastSuccessfulRun"); + + b.Navigation("Map"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Api.Database.Models.Robot", "Robot") + .WithMany() + .HasForeignKey("RobotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("InspectionArea"); + + b.Navigation("Robot"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionTask", b => + { + b.HasOne("Api.Database.Models.Inspection", "Inspection") + .WithMany() + .HasForeignKey("InspectionId"); + + b.HasOne("Api.Database.Models.MissionRun", null) + .WithMany("Tasks") + .HasForeignKey("MissionRunId"); + + b.OwnsOne("Api.Services.Models.IsarZoomDescription", "IsarZoomDescription", b1 => + { + b1.Property("MissionTaskId") + .HasColumnType("text"); + + b1.Property("ObjectHeight") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectHeight"); + + b1.Property("ObjectWidth") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectWidth"); + + b1.HasKey("MissionTaskId"); + + b1.ToTable("MissionTasks"); + + b1.WithOwner() + .HasForeignKey("MissionTaskId"); + }); + + b.OwnsOne("Api.Database.Models.Pose", "RobotPose", b1 => + { + b1.Property("MissionTaskId") + .HasColumnType("text"); + + b1.HasKey("MissionTaskId"); + + b1.ToTable("MissionTasks"); + + b1.WithOwner() + .HasForeignKey("MissionTaskId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseMissionTaskId") + .HasColumnType("text"); + + b2.Property("W") + .HasColumnType("real"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseMissionTaskId"); + + b2.ToTable("MissionTasks"); + + b2.WithOwner() + .HasForeignKey("PoseMissionTaskId"); + }); + + b1.OwnsOne("Api.Database.Models.Position", "Position", b2 => + { + b2.Property("PoseMissionTaskId") + .HasColumnType("text"); + + b2.Property("X") + .HasColumnType("real"); + + b2.Property("Y") + .HasColumnType("real"); + + b2.Property("Z") + .HasColumnType("real"); + + b2.HasKey("PoseMissionTaskId"); + + b2.ToTable("MissionTasks"); + + b2.WithOwner() + .HasForeignKey("PoseMissionTaskId"); + }); + + b1.Navigation("Orientation") + .IsRequired(); + + b1.Navigation("Position") + .IsRequired(); + }); + + b.Navigation("Inspection"); + + b.Navigation("IsarZoomDescription"); + + b.Navigation("RobotPose") + .IsRequired(); + }); + + 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.InspectionArea", "CurrentInspectionArea") + .WithMany() + .HasForeignKey("CurrentInspectionAreaId"); + + b.HasOne("Api.Database.Models.Installation", "CurrentInstallation") + .WithMany() + .HasForeignKey("CurrentInstallationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Api.Database.Models.RobotModel", "Model") + .WithMany() + .HasForeignKey("ModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Api.Database.Models.DocumentInfo", "Documentation", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b1.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.Property("RobotId") + .IsRequired() + .HasColumnType("text"); + + b1.Property("Url") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b1.HasKey("Id"); + + b1.HasIndex("RobotId"); + + b1.ToTable("DocumentInfo"); + + b1.WithOwner() + .HasForeignKey("RobotId"); + }); + + b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => + { + b1.Property("RobotId") + .HasColumnType("text"); + + b1.HasKey("RobotId"); + + b1.ToTable("Robots"); + + b1.WithOwner() + .HasForeignKey("RobotId"); + + b1.OwnsOne("Api.Database.Models.Orientation", "Orientation", b2 => + { + b2.Property("PoseRobotId") + .HasColumnType("text"); + + 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("text"); + + 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.Navigation("CurrentInspectionArea"); + + b.Navigation("CurrentInstallation"); + + b.Navigation("Documentation"); + + b.Navigation("Model"); + + b.Navigation("Pose") + .IsRequired(); + }); + + modelBuilder.Entity("Api.Services.MissionLoaders.TagInspectionMetadata", b => + { + b.OwnsOne("Api.Services.Models.IsarZoomDescription", "ZoomDescription", b1 => + { + b1.Property("TagInspectionMetadataTagId") + .HasColumnType("text"); + + b1.Property("ObjectHeight") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectHeight"); + + b1.Property("ObjectWidth") + .HasColumnType("double precision") + .HasAnnotation("Relational:JsonPropertyName", "objectWidth"); + + b1.HasKey("TagInspectionMetadataTagId"); + + b1.ToTable("TagInspectionMetadata"); + + b1.WithOwner() + .HasForeignKey("TagInspectionMetadataTagId"); + }); + + b.Navigation("ZoomDescription"); + }); + + modelBuilder.Entity("Api.Database.Models.Inspection", b => + { + b.Navigation("InspectionFindings"); + }); + + modelBuilder.Entity("Api.Database.Models.MissionRun", b => + { + b.Navigation("Tasks"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/backend/api/Migrations/20241218142700_RenameDeckTableToInspectionArea.cs b/backend/api/Migrations/20241218142700_RenameDeckTableToInspectionArea.cs new file mode 100644 index 000000000..764884be0 --- /dev/null +++ b/backend/api/Migrations/20241218142700_RenameDeckTableToInspectionArea.cs @@ -0,0 +1,238 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Api.Migrations +{ + /// + public partial class RenameDeckTableToInspectionArea : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Areas_Decks_InspectionAreaId", + table: "Areas"); + + migrationBuilder.DropForeignKey( + name: "FK_Decks_DefaultLocalizationPoses_DefaultLocalizationPoseId", + table: "Decks"); + + migrationBuilder.DropForeignKey( + name: "FK_Decks_Installations_InstallationId", + table: "Decks"); + + migrationBuilder.DropForeignKey( + name: "FK_Decks_Plants_PlantId", + table: "Decks"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinitions_Decks_InspectionAreaId", + table: "MissionDefinitions"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionRuns_Decks_InspectionAreaId", + table: "MissionRuns"); + + migrationBuilder.DropForeignKey( + name: "FK_Robots_Decks_CurrentInspectionAreaId", + table: "Robots"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Decks", + table: "Decks"); + + migrationBuilder.RenameTable( + name: "Decks", + newName: "InspectionAreas"); + + migrationBuilder.RenameIndex( + name: "IX_Decks_PlantId", + table: "InspectionAreas", + newName: "IX_InspectionAreas_PlantId"); + + migrationBuilder.RenameIndex( + name: "IX_Decks_InstallationId", + table: "InspectionAreas", + newName: "IX_InspectionAreas_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_Decks_DefaultLocalizationPoseId", + table: "InspectionAreas", + newName: "IX_InspectionAreas_DefaultLocalizationPoseId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_InspectionAreas", + table: "InspectionAreas", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Areas_InspectionAreas_InspectionAreaId", + table: "Areas", + column: "InspectionAreaId", + principalTable: "InspectionAreas", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_InspectionAreas_DefaultLocalizationPoses_DefaultLocalizatio~", + table: "InspectionAreas", + column: "DefaultLocalizationPoseId", + principalTable: "DefaultLocalizationPoses", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_InspectionAreas_Installations_InstallationId", + table: "InspectionAreas", + column: "InstallationId", + principalTable: "Installations", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_InspectionAreas_Plants_PlantId", + table: "InspectionAreas", + column: "PlantId", + principalTable: "Plants", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinitions_InspectionAreas_InspectionAreaId", + table: "MissionDefinitions", + column: "InspectionAreaId", + principalTable: "InspectionAreas", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionRuns_InspectionAreas_InspectionAreaId", + table: "MissionRuns", + column: "InspectionAreaId", + principalTable: "InspectionAreas", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Robots_InspectionAreas_CurrentInspectionAreaId", + table: "Robots", + column: "CurrentInspectionAreaId", + principalTable: "InspectionAreas", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Areas_InspectionAreas_InspectionAreaId", + table: "Areas"); + + migrationBuilder.DropForeignKey( + name: "FK_InspectionAreas_DefaultLocalizationPoses_DefaultLocalizatio~", + table: "InspectionAreas"); + + migrationBuilder.DropForeignKey( + name: "FK_InspectionAreas_Installations_InstallationId", + table: "InspectionAreas"); + + migrationBuilder.DropForeignKey( + name: "FK_InspectionAreas_Plants_PlantId", + table: "InspectionAreas"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionDefinitions_InspectionAreas_InspectionAreaId", + table: "MissionDefinitions"); + + migrationBuilder.DropForeignKey( + name: "FK_MissionRuns_InspectionAreas_InspectionAreaId", + table: "MissionRuns"); + + migrationBuilder.DropForeignKey( + name: "FK_Robots_InspectionAreas_CurrentInspectionAreaId", + table: "Robots"); + + migrationBuilder.DropPrimaryKey( + name: "PK_InspectionAreas", + table: "InspectionAreas"); + + migrationBuilder.RenameTable( + name: "InspectionAreas", + newName: "Decks"); + + migrationBuilder.RenameIndex( + name: "IX_InspectionAreas_PlantId", + table: "Decks", + newName: "IX_Decks_PlantId"); + + migrationBuilder.RenameIndex( + name: "IX_InspectionAreas_InstallationId", + table: "Decks", + newName: "IX_Decks_InstallationId"); + + migrationBuilder.RenameIndex( + name: "IX_InspectionAreas_DefaultLocalizationPoseId", + table: "Decks", + newName: "IX_Decks_DefaultLocalizationPoseId"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Decks", + table: "Decks", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Areas_Decks_InspectionAreaId", + table: "Areas", + column: "InspectionAreaId", + principalTable: "Decks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Decks_DefaultLocalizationPoses_DefaultLocalizationPoseId", + table: "Decks", + column: "DefaultLocalizationPoseId", + principalTable: "DefaultLocalizationPoses", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Decks_Installations_InstallationId", + table: "Decks", + column: "InstallationId", + principalTable: "Installations", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Decks_Plants_PlantId", + table: "Decks", + column: "PlantId", + principalTable: "Plants", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionDefinitions_Decks_InspectionAreaId", + table: "MissionDefinitions", + column: "InspectionAreaId", + principalTable: "Decks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MissionRuns_Decks_InspectionAreaId", + table: "MissionRuns", + column: "InspectionAreaId", + principalTable: "Decks", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Robots_Decks_CurrentInspectionAreaId", + table: "Robots", + column: "CurrentInspectionAreaId", + principalTable: "Decks", + principalColumn: "Id"); + } + } +} diff --git a/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs b/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs index eb0803969..65ef9475a 100644 --- a/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs +++ b/backend/api/Migrations/FlotillaDbContextModelSnapshot.cs @@ -52,48 +52,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) .ValueGeneratedOnAdd() .HasColumnType("text"); - b.Property("DeckId") - .IsRequired() - .HasColumnType("text"); - b.Property("DefaultLocalizationPoseId") .HasColumnType("text"); - b.Property("InstallationId") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("character varying(200)"); - - b.Property("PlantId") + b.Property("InspectionAreaId") .IsRequired() .HasColumnType("text"); - b.HasKey("Id"); - - b.HasIndex("DeckId"); - - b.HasIndex("DefaultLocalizationPoseId"); - - b.HasIndex("InstallationId"); - - b.HasIndex("PlantId"); - - b.ToTable("Areas"); - }); - - modelBuilder.Entity("Api.Database.Models.Deck", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("text"); - - b.Property("DefaultLocalizationPoseId") - .HasColumnType("text"); - b.Property("InstallationId") .IsRequired() .HasColumnType("text"); @@ -111,11 +76,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("DefaultLocalizationPoseId"); + b.HasIndex("InspectionAreaId"); + b.HasIndex("InstallationId"); b.HasIndex("PlantId"); - b.ToTable("Decks"); + b.ToTable("Areas"); }); modelBuilder.Entity("Api.Database.Models.DefaultLocalizationPose", b => @@ -180,6 +147,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Inspections"); }); + modelBuilder.Entity("Api.Database.Models.InspectionArea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("text"); + + b.Property("DefaultLocalizationPoseId") + .HasColumnType("text"); + + b.Property("InstallationId") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("PlantId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DefaultLocalizationPoseId"); + + b.HasIndex("InstallationId"); + + b.HasIndex("PlantId"); + + b.ToTable("InspectionAreas"); + }); + modelBuilder.Entity("Api.Database.Models.InspectionFinding", b => { b.Property("Id") @@ -680,16 +680,16 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Api.Database.Models.Area", b => { - b.HasOne("Api.Database.Models.Deck", "Deck") - .WithMany() - .HasForeignKey("DeckId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") .WithMany() .HasForeignKey("DefaultLocalizationPoseId"); + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") + .WithMany() + .HasForeignKey("InspectionAreaId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + b.HasOne("Api.Database.Models.Installation", "Installation") .WithMany() .HasForeignKey("InstallationId") @@ -782,10 +782,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); - b.Navigation("Deck"); - b.Navigation("DefaultLocalizationPose"); + b.Navigation("InspectionArea"); + b.Navigation("Installation"); b.Navigation("MapMetadata") @@ -794,31 +794,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Plant"); }); - modelBuilder.Entity("Api.Database.Models.Deck", b => - { - b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") - .WithMany() - .HasForeignKey("DefaultLocalizationPoseId"); - - 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("DefaultLocalizationPose"); - - b.Navigation("Installation"); - - b.Navigation("Plant"); - }); - modelBuilder.Entity("Api.Database.Models.DefaultLocalizationPose", b => { b.OwnsOne("Api.Database.Models.Pose", "Pose", b1 => @@ -919,6 +894,31 @@ protected override void BuildModel(ModelBuilder modelBuilder) .IsRequired(); }); + modelBuilder.Entity("Api.Database.Models.InspectionArea", b => + { + b.HasOne("Api.Database.Models.DefaultLocalizationPose", "DefaultLocalizationPose") + .WithMany() + .HasForeignKey("DefaultLocalizationPoseId"); + + 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("DefaultLocalizationPose"); + + b.Navigation("Installation"); + + b.Navigation("Plant"); + }); + modelBuilder.Entity("Api.Database.Models.InspectionFinding", b => { b.HasOne("Api.Database.Models.Inspection", null) @@ -928,7 +928,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Api.Database.Models.MissionDefinition", b => { - b.HasOne("Api.Database.Models.Deck", "InspectionArea") + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") .WithMany() .HasForeignKey("InspectionAreaId") .OnDelete(DeleteBehavior.Restrict); @@ -1034,7 +1034,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Api.Database.Models.MissionRun", b => { - b.HasOne("Api.Database.Models.Deck", "InspectionArea") + b.HasOne("Api.Database.Models.InspectionArea", "InspectionArea") .WithMany() .HasForeignKey("InspectionAreaId") .OnDelete(DeleteBehavior.Restrict); @@ -1168,7 +1168,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Api.Database.Models.Robot", b => { - b.HasOne("Api.Database.Models.Deck", "CurrentInspectionArea") + b.HasOne("Api.Database.Models.InspectionArea", "CurrentInspectionArea") .WithMany() .HasForeignKey("CurrentInspectionAreaId"); diff --git a/backend/api/Program.cs b/backend/api/Program.cs index c150ca116..a98d6b347 100644 --- a/backend/api/Program.cs +++ b/backend/api/Program.cs @@ -81,7 +81,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/backend/api/Services/AreaService.cs b/backend/api/Services/AreaService.cs index 20b2b5a14..b6b3ca94f 100644 --- a/backend/api/Services/AreaService.cs +++ b/backend/api/Services/AreaService.cs @@ -14,7 +14,7 @@ public interface IAreaService public Task ReadById(string id, bool readOnly = true); - public Task> ReadByDeckId(string deckId, bool readOnly = true); + public Task> ReadByInspectionAreaId(string inspectionAreaId, bool readOnly = true); public Task ReadByInstallationAndName(string installationCode, string areaName, bool readOnly = true); @@ -38,7 +38,7 @@ public interface IAreaService Justification = "Entity framework does not support translating culture info to SQL calls" )] public class AreaService( - FlotillaDbContext context, IInstallationService installationService, IPlantService plantService, IDeckService deckService, + FlotillaDbContext context, IInstallationService installationService, IPlantService plantService, IInspectionAreaService inspectionAreaService, IDefaultLocalizationPoseService defaultLocalizationPoseService, IAccessRoleService accessRoleService) : IAreaService { public async Task> ReadAll(AreaQueryStringParameters parameters, bool readOnly = true) @@ -61,10 +61,10 @@ public async Task> ReadAll(AreaQueryStringParameters parameters, .FirstOrDefaultAsync(a => a.Id.Equals(id)); } - public async Task> ReadByDeckId(string deckId, bool readOnly = true) + public async Task> ReadByInspectionAreaId(string inspectionAreaId, bool readOnly = true) { - if (deckId == null) { return []; } - return await GetAreas(readOnly: readOnly).Where(a => a.Deck != null && a.Deck.Id.Equals(deckId)).ToListAsync(); + if (inspectionAreaId == null) { return []; } + return await GetAreas(readOnly: readOnly).Where(a => a.InspectionArea != null && a.InspectionArea.Id.Equals(inspectionAreaId)).ToListAsync(); } public async Task ReadByInstallationAndName(string installationCode, string areaName, bool readOnly = true) @@ -91,11 +91,11 @@ public async Task Create(CreateAreaQuery newAreaQuery) var plant = await plantService.ReadByInstallationAndPlantCode(installation, newAreaQuery.PlantCode, readOnly: true) ?? throw new PlantNotFoundException($"No plant with name {newAreaQuery.PlantCode} could be found"); - var deck = await deckService.ReadByInstallationAndPlantAndName(installation, plant, newAreaQuery.DeckName, readOnly: true) ?? - throw new DeckNotFoundException($"No deck with name {newAreaQuery.DeckName} could be found"); + var inspectionArea = await inspectionAreaService.ReadByInstallationAndPlantAndName(installation, plant, newAreaQuery.InspectionAreaName, readOnly: true) ?? + throw new InspectionAreaNotFoundException($"No inspection area with name {newAreaQuery.InspectionAreaName} could be found"); - var existingArea = await ReadByInstallationAndPlantAndDeckAndName( - installation, plant, deck, newAreaQuery.AreaName, readOnly: true); + var existingArea = await ReadByInstallationAndPlantAndInspectionAreaAndName( + installation, plant, inspectionArea, newAreaQuery.AreaName, readOnly: true); if (existingArea != null) { throw new AreaExistsException($"Area with name {newAreaQuery.AreaName} already exists"); @@ -112,14 +112,14 @@ public async Task Create(CreateAreaQuery newAreaQuery) Name = newAreaQuery.AreaName, DefaultLocalizationPose = defaultLocalizationPose, MapMetadata = new MapMetadata(), - Deck = deck!, + InspectionArea = inspectionArea!, Plant = plant!, Installation = installation! }; context.Entry(newArea.Installation).State = EntityState.Unchanged; context.Entry(newArea.Plant).State = EntityState.Unchanged; - context.Entry(newArea.Deck).State = EntityState.Unchanged; + context.Entry(newArea.InspectionArea).State = EntityState.Unchanged; if (newArea.DefaultLocalizationPose is not null) { context.Entry(newArea.DefaultLocalizationPose).State = EntityState.Modified; } @@ -166,13 +166,13 @@ private IQueryable GetAreas(bool readOnly = true) var accessibleInstallationCodes = accessRoleService.GetAllowedInstallationCodes(); var query = context.Areas .Include(area => area.DefaultLocalizationPose) - .Include(area => area.Deck) - .ThenInclude(deck => deck != null ? deck.DefaultLocalizationPose : null) - .Include(area => area.Deck) - .ThenInclude(deck => deck.Plant) + .Include(area => area.InspectionArea) + .ThenInclude(inspectionArea => inspectionArea != null ? inspectionArea.DefaultLocalizationPose : null) + .Include(area => area.InspectionArea) + .ThenInclude(inspectionArea => inspectionArea.Plant) .ThenInclude(plant => plant.Installation) - .Include(area => area.Deck) - .ThenInclude(deck => deck.Installation) + .Include(area => area.InspectionArea) + .ThenInclude(inspectionArea => inspectionArea.Installation) .Include(area => area.Plant) .ThenInclude(plant => plant.Installation) .Include(area => area.Installation) @@ -186,8 +186,8 @@ private IQueryable GetAreasWithSubModels(bool readOnly = true) // Include related entities using the Include method var query = context.Areas - .Include(a => a.Deck) - .ThenInclude(deck => deck != null ? deck.Plant : null) + .Include(a => a.InspectionArea) + .ThenInclude(inspectionArea => inspectionArea != null ? inspectionArea.Plant : null) .ThenInclude(plant => plant != null ? plant.Installation : null) .Include(a => a.Plant) .ThenInclude(plant => plant != null ? plant.Installation : null) @@ -197,10 +197,10 @@ private IQueryable GetAreasWithSubModels(bool readOnly = true) return readOnly ? query.AsNoTracking() : query.AsTracking(); } - public async Task ReadByInstallationAndPlantAndDeckAndName(Installation installation, Plant plant, Deck deck, string areaName, bool readOnly = true) + public async Task ReadByInstallationAndPlantAndInspectionAreaAndName(Installation installation, Plant plant, InspectionArea inspectionArea, string areaName, bool readOnly = true) { return await GetAreas(readOnly: readOnly).Where(a => - a.Deck != null && a.Deck.Id.Equals(deck.Id) && + a.InspectionArea != null && a.InspectionArea.Id.Equals(inspectionArea.Id) && a.Plant.Id.Equals(plant.Id) && a.Installation.Id.Equals(installation.Id) && a.Name.ToLower().Equals(areaName.ToLower()) @@ -213,21 +213,21 @@ AreaQueryStringParameters parameters { Expression> installationFilter = string.IsNullOrEmpty(parameters.InstallationCode) ? area => true - : area => area.Deck != null && - area.Deck.Plant != null && - area.Deck.Plant.Installation != null && - area.Deck.Plant.Installation.InstallationCode.ToLower().Equals(parameters.InstallationCode.ToLower().Trim()); + : area => area.InspectionArea != null && + area.InspectionArea.Plant != null && + area.InspectionArea.Plant.Installation != null && + area.InspectionArea.Plant.Installation.InstallationCode.ToLower().Equals(parameters.InstallationCode.ToLower().Trim()); - Expression> deckFilter = area => string.IsNullOrEmpty(parameters.Deck) || - (area.Deck != null && - area.Deck.Name != null && - area.Deck.Name.ToLower().Equals(parameters.Deck.ToLower().Trim())); + Expression> inspectionAreaFilter = area => string.IsNullOrEmpty(parameters.InspectionArea) || + (area.InspectionArea != null && + area.InspectionArea.Name != null && + area.InspectionArea.Name.ToLower().Equals(parameters.InspectionArea.ToLower().Trim())); var area = Expression.Parameter(typeof(Area)); Expression body = Expression.AndAlso( Expression.Invoke(installationFilter, area), - Expression.Invoke(deckFilter, area) + Expression.Invoke(inspectionAreaFilter, area) ); return Expression.Lambda>(body, area); @@ -237,7 +237,7 @@ public void DetachTracking(Area area) { if (area.Installation != null) installationService.DetachTracking(area.Installation); if (area.Plant != null) plantService.DetachTracking(area.Plant); - if (area.Deck != null) deckService.DetachTracking(area.Deck); + if (area.InspectionArea != null) inspectionAreaService.DetachTracking(area.InspectionArea); if (area.DefaultLocalizationPose != null) defaultLocalizationPoseService.DetachTracking(area.DefaultLocalizationPose); context.Entry(area).State = EntityState.Detached; } diff --git a/backend/api/Services/DeckService.cs b/backend/api/Services/DeckService.cs index b9c8e6e18..31d4ddb62 100644 --- a/backend/api/Services/DeckService.cs +++ b/backend/api/Services/DeckService.cs @@ -7,25 +7,25 @@ using Microsoft.EntityFrameworkCore; namespace Api.Services { - public interface IDeckService + public interface IInspectionAreaService { - public Task> ReadAll(bool readOnly = true); + public Task> ReadAll(bool readOnly = true); - public Task ReadById(string id, bool readOnly = true); + public Task ReadById(string id, bool readOnly = true); - public Task> ReadByInstallation(string installationCode, bool readOnly = true); + public Task> ReadByInstallation(string installationCode, bool readOnly = true); - public Task ReadByInstallationAndName(string installationCode, string deckName, bool readOnly = true); + public Task ReadByInstallationAndName(string installationCode, string inspectionAreaName, bool readOnly = true); - public Task ReadByInstallationAndPlantAndName(Installation installation, Plant plant, string deckName, bool readOnly = true); + public Task ReadByInstallationAndPlantAndName(Installation installation, Plant plant, string inspectionAreaName, bool readOnly = true); - public Task Create(CreateDeckQuery newDeck); + public Task Create(CreateInspectionAreaQuery newInspectionArea); - public Task Update(Deck deck); + public Task Update(InspectionArea inspectionArea); - public Task Delete(string id); + public Task Delete(string id); - public void DetachTracking(Deck deck); + public void DetachTracking(InspectionArea inspectionArea); } [SuppressMessage( @@ -38,116 +38,116 @@ public interface IDeckService "CA1304:Specify CultureInfo", Justification = "Entity framework does not support translating culture info to SQL calls" )] - public class DeckService( + public class InspectionAreaService( FlotillaDbContext context, IDefaultLocalizationPoseService defaultLocalizationPoseService, IInstallationService installationService, IPlantService plantService, IAccessRoleService accessRoleService, - ISignalRService signalRService) : IDeckService + ISignalRService signalRService) : IInspectionAreaService { - public async Task> ReadAll(bool readOnly = true) + public async Task> ReadAll(bool readOnly = true) { - return await GetDecks(readOnly: readOnly).ToListAsync(); + return await GetInspectionAreas(readOnly: readOnly).ToListAsync(); } - public async Task ReadById(string id, bool readOnly = true) + public async Task ReadById(string id, bool readOnly = true) { - return await GetDecks(readOnly: readOnly) + return await GetInspectionAreas(readOnly: readOnly) .FirstOrDefaultAsync(a => a.Id.Equals(id)); } - public async Task> ReadByInstallation(string installationCode, bool readOnly = true) + public async Task> ReadByInstallation(string installationCode, bool readOnly = true) { var installation = await installationService.ReadByInstallationCode(installationCode, readOnly: true); if (installation == null) { return []; } - return await GetDecks(readOnly: readOnly).Where(a => + return await GetInspectionAreas(readOnly: readOnly).Where(a => a.Installation != null && a.Installation.Id.Equals(installation.Id)).ToListAsync(); } - public async Task ReadByInstallationAndName(string installationCode, string deckName, bool readOnly = true) + public async Task ReadByInstallationAndName(string installationCode, string inspectionAreaName, bool readOnly = true) { - if (deckName == null) { return null; } - return await GetDecks(readOnly: readOnly).Where(a => - a.Installation != null && a.Installation.InstallationCode.ToLower().Equals(installationCode.ToLower()) && a.Name.ToLower().Equals(deckName.ToLower()) + if (inspectionAreaName == null) { return null; } + return await GetInspectionAreas(readOnly: readOnly).Where(a => + a.Installation != null && a.Installation.InstallationCode.ToLower().Equals(installationCode.ToLower()) && a.Name.ToLower().Equals(inspectionAreaName.ToLower()) ).FirstOrDefaultAsync(); } - public async Task ReadByInstallationAndPlantAndName(Installation installation, Plant plant, string name, bool readOnly = true) + public async Task ReadByInstallationAndPlantAndName(Installation installation, Plant plant, string name, bool readOnly = true) { - return await GetDecks(readOnly: readOnly).Where(a => + return await GetInspectionAreas(readOnly: readOnly).Where(a => a.Plant != null && a.Plant.Id.Equals(plant.Id) && a.Installation != null && a.Installation.Id.Equals(installation.Id) && a.Name.ToLower().Equals(name.ToLower()) ).Include(d => d.Plant).Include(i => i.Installation).FirstOrDefaultAsync(); } - public async Task Create(CreateDeckQuery newDeckQuery) + public async Task Create(CreateInspectionAreaQuery newInspectionAreaQuery) { - var installation = await installationService.ReadByInstallationCode(newDeckQuery.InstallationCode, readOnly: true) ?? - throw new InstallationNotFoundException($"No installation with name {newDeckQuery.InstallationCode} could be found"); - var plant = await plantService.ReadByInstallationAndPlantCode(installation, newDeckQuery.PlantCode, readOnly: true) ?? - throw new PlantNotFoundException($"No plant with name {newDeckQuery.PlantCode} could be found"); - var existingDeck = await ReadByInstallationAndPlantAndName(installation, plant, newDeckQuery.Name, readOnly: true); + var installation = await installationService.ReadByInstallationCode(newInspectionAreaQuery.InstallationCode, readOnly: true) ?? + throw new InstallationNotFoundException($"No installation with name {newInspectionAreaQuery.InstallationCode} could be found"); + var plant = await plantService.ReadByInstallationAndPlantCode(installation, newInspectionAreaQuery.PlantCode, readOnly: true) ?? + throw new PlantNotFoundException($"No plant with name {newInspectionAreaQuery.PlantCode} could be found"); + var existingInspectionArea = await ReadByInstallationAndPlantAndName(installation, plant, newInspectionAreaQuery.Name, readOnly: true); - if (existingDeck != null) + if (existingInspectionArea != null) { - throw new DeckExistsException($"Deck with name {newDeckQuery.Name} already exists"); + throw new InspectionAreaExistsException($"Inspection are with name {newInspectionAreaQuery.Name} already exists"); } DefaultLocalizationPose? defaultLocalizationPose = null; - if (newDeckQuery.DefaultLocalizationPose != null) + if (newInspectionAreaQuery.DefaultLocalizationPose != null) { - defaultLocalizationPose = await defaultLocalizationPoseService.Create(new DefaultLocalizationPose(newDeckQuery.DefaultLocalizationPose.Value.Pose, newDeckQuery.DefaultLocalizationPose.Value.IsDockingStation)); + defaultLocalizationPose = await defaultLocalizationPoseService.Create(new DefaultLocalizationPose(newInspectionAreaQuery.DefaultLocalizationPose.Value.Pose, newInspectionAreaQuery.DefaultLocalizationPose.Value.IsDockingStation)); } - var deck = new Deck + var inspectionArea = new InspectionArea { - Name = newDeckQuery.Name, + Name = newInspectionAreaQuery.Name, Installation = installation, Plant = plant, DefaultLocalizationPose = defaultLocalizationPose }; - context.Entry(deck.Installation).State = EntityState.Unchanged; - context.Entry(deck.Plant).State = EntityState.Unchanged; - if (deck.DefaultLocalizationPose is not null) { context.Entry(deck.DefaultLocalizationPose).State = EntityState.Modified; } + context.Entry(inspectionArea.Installation).State = EntityState.Unchanged; + context.Entry(inspectionArea.Plant).State = EntityState.Unchanged; + if (inspectionArea.DefaultLocalizationPose is not null) { context.Entry(inspectionArea.DefaultLocalizationPose).State = EntityState.Modified; } - await context.Decks.AddAsync(deck); - await ApplyDatabaseUpdate(deck.Installation); - _ = signalRService.SendMessageAsync("Deck created", deck.Installation, new DeckResponse(deck)); - DetachTracking(deck); - return deck!; + await context.InspectionAreas.AddAsync(inspectionArea); + await ApplyDatabaseUpdate(inspectionArea.Installation); + _ = signalRService.SendMessageAsync("InspectionArea created", inspectionArea.Installation, new InspectionAreaResponse(inspectionArea)); + DetachTracking(inspectionArea); + return inspectionArea!; } - public async Task Update(Deck deck) + public async Task Update(InspectionArea inspectionArea) { - var entry = context.Update(deck); - await ApplyDatabaseUpdate(deck.Installation); - _ = signalRService.SendMessageAsync("Deck updated", deck.Installation, new DeckResponse(deck)); + var entry = context.Update(inspectionArea); + await ApplyDatabaseUpdate(inspectionArea.Installation); + _ = signalRService.SendMessageAsync("InspectionArea updated", inspectionArea.Installation, new InspectionAreaResponse(inspectionArea)); return entry.Entity; } - public async Task Delete(string id) + public async Task Delete(string id) { - var deck = await GetDecks() + var inspectionArea = await GetInspectionAreas() .FirstOrDefaultAsync(ev => ev.Id.Equals(id)); - if (deck is null) + if (inspectionArea is null) { return null; } - context.Decks.Remove(deck); - await ApplyDatabaseUpdate(deck.Installation); - _ = signalRService.SendMessageAsync("Deck deleted", deck.Installation, new DeckResponse(deck)); + context.InspectionAreas.Remove(inspectionArea); + await ApplyDatabaseUpdate(inspectionArea.Installation); + _ = signalRService.SendMessageAsync("InspectionArea deleted", inspectionArea.Installation, new InspectionAreaResponse(inspectionArea)); - return deck; + return inspectionArea; } - private IQueryable GetDecks(bool readOnly = true) + private IQueryable GetInspectionAreas(bool readOnly = true) { var accessibleInstallationCodes = accessRoleService.GetAllowedInstallationCodes(); - var query = context.Decks.Include(p => p.Plant).ThenInclude(p => p.Installation).Include(i => i.Installation).Include(d => d.DefaultLocalizationPose) + var query = context.InspectionAreas.Include(p => p.Plant).ThenInclude(p => p.Installation).Include(i => i.Installation).Include(d => d.DefaultLocalizationPose) .Where((d) => accessibleInstallationCodes.Result.Contains(d.Installation.InstallationCode.ToUpper())); return readOnly ? query.AsNoTracking() : query.AsTracking(); } @@ -158,15 +158,15 @@ private async Task ApplyDatabaseUpdate(Installation? installation) if (installation == null || accessibleInstallationCodes.Contains(installation.InstallationCode.ToUpper(CultureInfo.CurrentCulture))) await context.SaveChangesAsync(); else - throw new UnauthorizedAccessException($"User does not have permission to update deck in installation {installation.Name}"); + throw new UnauthorizedAccessException($"User does not have permission to update inspection area in installation {installation.Name}"); } - public void DetachTracking(Deck deck) + public void DetachTracking(InspectionArea inspectionArea) { - if (deck.Installation != null) installationService.DetachTracking(deck.Installation); - if (deck.Plant != null) plantService.DetachTracking(deck.Plant); - if (deck.DefaultLocalizationPose != null) defaultLocalizationPoseService.DetachTracking(deck.DefaultLocalizationPose); - context.Entry(deck).State = EntityState.Detached; + if (inspectionArea.Installation != null) installationService.DetachTracking(inspectionArea.Installation); + if (inspectionArea.Plant != null) plantService.DetachTracking(inspectionArea.Plant); + if (inspectionArea.DefaultLocalizationPose != null) defaultLocalizationPoseService.DetachTracking(inspectionArea.DefaultLocalizationPose); + context.Entry(inspectionArea).State = EntityState.Detached; } } } diff --git a/backend/api/Services/EchoService.cs b/backend/api/Services/EchoService.cs index fedeb0f72..69a29beec 100644 --- a/backend/api/Services/EchoService.cs +++ b/backend/api/Services/EchoService.cs @@ -116,11 +116,11 @@ public async Task> GetTasksForMission(string missionSourceId) .Select(t => stidService.GetTagArea(t.TagId, echoMission.InstallationCode).Result) .ToList(); - var missionDeckNames = missionAreas.Where(a => a != null).Select(a => a!.Deck.Name).Distinct().ToList(); - if (missionDeckNames.Count > 1) + var missionInspectionAreaNames = missionAreas.Where(a => a != null).Select(a => a!.InspectionArea.Name).Distinct().ToList(); + if (missionInspectionAreaNames.Count > 1) { - string joinedMissionDeckNames = string.Join(", ", [.. missionDeckNames]); - logger.LogWarning($"Mission {echoMission.Name} has tags on more than one deck. The decks are: {joinedMissionDeckNames}."); + string joinedMissionInspectionAreaNames = string.Join(", ", [.. missionInspectionAreaNames]); + logger.LogWarning($"Mission {echoMission.Name} has tags on more than one inspection area. The inspection areas are: {joinedMissionInspectionAreaNames}."); } var sortedAreas = missionAreas.GroupBy(i => i).OrderByDescending(grp => grp.Count()).Select(grp => grp.Key); @@ -144,7 +144,7 @@ public async Task> GetTasksForMission(string missionSourceId) Source = source, Name = echoMission.Name, InstallationCode = echoMission.InstallationCode, - InspectionArea = area.Deck + InspectionArea = area.InspectionArea }; return missionDefinition; } diff --git a/backend/api/Services/LocalizationService.cs b/backend/api/Services/LocalizationService.cs index 4b9032abf..aebc0b6c7 100644 --- a/backend/api/Services/LocalizationService.cs +++ b/backend/api/Services/LocalizationService.cs @@ -5,10 +5,10 @@ namespace Api.Services public interface ILocalizationService { public Task EnsureRobotIsOnSameInstallationAsMission(Robot robot, MissionDefinition missionDefinition); - public Task RobotIsOnSameDeckAsMission(string robotId, string inspectionAreaId); + public Task RobotIsOnSameInspectionAreaAsMission(string robotId, string inspectionAreaId); } - public class LocalizationService(ILogger logger, IRobotService robotService, IInstallationService installationService, IDeckService deckService) : ILocalizationService + public class LocalizationService(ILogger logger, IRobotService robotService, IInstallationService installationService, IInspectionAreaService inspectionAreaService) : ILocalizationService { public async Task EnsureRobotIsOnSameInstallationAsMission(Robot robot, MissionDefinition missionDefinition) @@ -30,7 +30,7 @@ public async Task EnsureRobotIsOnSameInstallationAsMission(Robot robot, MissionD } } - public async Task RobotIsOnSameDeckAsMission(string robotId, string inspectionAreaId) + public async Task RobotIsOnSameInspectionAreaAsMission(string robotId, string inspectionAreaId) { var robot = await robotService.ReadById(robotId, readOnly: true); if (robot is null) @@ -49,19 +49,19 @@ public async Task RobotIsOnSameDeckAsMission(string robotId, string inspec throw new RobotCurrentAreaMissingException(ErrorMessage); } - var missionInspectionArea = await deckService.ReadById(inspectionAreaId, readOnly: true); + var missionInspectionArea = await inspectionAreaService.ReadById(inspectionAreaId, readOnly: true); if (missionInspectionArea is null) { const string ErrorMessage = "The mission does not have an associated inspection area"; logger.LogError("{Message}", ErrorMessage); - throw new DeckNotFoundException(ErrorMessage); + throw new InspectionAreaNotFoundException(ErrorMessage); } if (robot.CurrentInspectionArea is null) { - const string ErrorMessage = "The robot area is not associated with any deck"; + const string ErrorMessage = "The robot area is not associated with any inspection area"; logger.LogError("{Message}", ErrorMessage); - throw new DeckNotFoundException(ErrorMessage); + throw new InspectionAreaNotFoundException(ErrorMessage); } return robot.CurrentInspectionArea.Id == missionInspectionArea.Id; diff --git a/backend/api/Services/MissionDefinitionService.cs b/backend/api/Services/MissionDefinitionService.cs index 1a4a2e113..aacb3ad6b 100644 --- a/backend/api/Services/MissionDefinitionService.cs +++ b/backend/api/Services/MissionDefinitionService.cs @@ -166,7 +166,7 @@ private IQueryable GetMissionDefinitionsWithSubModels(bool re var accessibleInstallationCodes = accessRoleService.GetAllowedInstallationCodes(); var query = context.MissionDefinitions .Include(missionDefinition => missionDefinition.InspectionArea) - .ThenInclude(deck => deck!.Plant) + .ThenInclude(inspectionArea => inspectionArea!.Plant) .ThenInclude(plant => plant.Installation) .Include(missionDefinition => missionDefinition.InspectionArea) .ThenInclude(area => area!.Installation) @@ -176,7 +176,7 @@ private IQueryable GetMissionDefinitionsWithSubModels(bool re .ThenInclude(missionTask => missionTask.Inspection) .ThenInclude(inspection => inspection != null ? inspection.InspectionFindings : null) .Include(missionDefinition => missionDefinition.InspectionArea) - .ThenInclude(deck => deck!.DefaultLocalizationPose) + .ThenInclude(inspectionArea => inspectionArea!.DefaultLocalizationPose) .ThenInclude(defaultLocalizationPose => defaultLocalizationPose != null ? defaultLocalizationPose.Pose : null) .Where((m) => m.InspectionArea == null || accessibleInstallationCodes.Result.Contains(m.InspectionArea.Installation.InstallationCode.ToUpper())); return readOnly ? query.AsNoTracking() : query.AsTracking(); diff --git a/backend/api/Services/MissionRunService.cs b/backend/api/Services/MissionRunService.cs index 127f075cd..7ddeb28a4 100644 --- a/backend/api/Services/MissionRunService.cs +++ b/backend/api/Services/MissionRunService.cs @@ -73,7 +73,7 @@ public class MissionRunService( ILogger logger, IAccessRoleService accessRoleService, IMissionTaskService missionTaskService, - IDeckService deckService, + IInspectionAreaService inspectionAreaService, IRobotService robotService, IUserInfoService userInfoService) : IMissionRunService { @@ -240,7 +240,7 @@ private IQueryable GetMissionRunsWithSubModels(bool readOnly = true) var accessibleInstallationCodes = accessRoleService.GetAllowedInstallationCodes(); var query = context.MissionRuns .Include(missionRun => missionRun.InspectionArea) - .ThenInclude(deck => deck != null ? deck.Plant : null) + .ThenInclude(inspectionArea => inspectionArea != null ? inspectionArea.Plant : null) .ThenInclude(plant => plant != null ? plant.Installation : null) .Include(missionRun => missionRun.InspectionArea) .ThenInclude(area => area != null ? area.Plant : null) @@ -248,7 +248,7 @@ private IQueryable GetMissionRunsWithSubModels(bool readOnly = true) .Include(missionRun => missionRun.InspectionArea) .ThenInclude(area => area != null ? area.Installation : null) .Include(missionRun => missionRun.InspectionArea) - .ThenInclude(deck => deck != null ? deck.DefaultLocalizationPose : null) + .ThenInclude(inspectionArea => inspectionArea != null ? inspectionArea.DefaultLocalizationPose : null) .ThenInclude(defaultLocalizationPose => defaultLocalizationPose != null ? defaultLocalizationPose.Pose : null) .Include(missionRun => missionRun.Robot) .Include(missionRun => missionRun.Robot) @@ -566,7 +566,7 @@ public void DetachTracking(MissionRun missionRun) { missionTaskService.DetachTracking(task); } - if (missionRun.InspectionArea != null) deckService.DetachTracking(missionRun.InspectionArea); + if (missionRun.InspectionArea != null) inspectionAreaService.DetachTracking(missionRun.InspectionArea); if (missionRun.Robot != null) robotService.DetachTracking(missionRun.Robot); context.Entry(missionRun).State = EntityState.Detached; } diff --git a/backend/api/Services/MissionSchedulingService.cs b/backend/api/Services/MissionSchedulingService.cs index 574870412..06a9963b0 100644 --- a/backend/api/Services/MissionSchedulingService.cs +++ b/backend/api/Services/MissionSchedulingService.cs @@ -84,10 +84,10 @@ public async Task StartNextMissionRunIfSystemIsAvailable(Robot robot) { await robotService.UpdateCurrentInspectionArea(robot.Id, missionRun.InspectionArea.Id); } - else if (!await localizationService.RobotIsOnSameDeckAsMission(robot.Id, missionRun.InspectionArea!.Id)) + else if (!await localizationService.RobotIsOnSameInspectionAreaAsMission(robot.Id, missionRun.InspectionArea!.Id)) { - logger.LogError("Robot {RobotId} is not on the same deck as the mission run {MissionRunId}. Aborting all mission runs", robot.Id, missionRun.Id); - try { await AbortAllScheduledMissions(robot.Id, "Aborted: Robot was at different deck"); } + logger.LogError("Robot {RobotId} is not on the same inspection area as the mission run {MissionRunId}. Aborting all mission runs", robot.Id, missionRun.Id); + try { await AbortAllScheduledMissions(robot.Id, "Aborted: Robot was at different inspection area"); } catch (RobotNotFoundException) { logger.LogError("Failed to abort scheduled missions for robot {RobotId}", robot.Id); } try { await returnToHomeService.ScheduleReturnToHomeMissionRunIfNotAlreadyScheduledOrRobotIsHome(robot.Id); } @@ -271,7 +271,7 @@ public async Task ScheduleMissionToDriveToDockPosition(string robotId) { string errorMessage = $"Robot with ID {robotId} could return home as it did not have an inspection area"; logger.LogError("{Message}", errorMessage); - throw new DeckNotFoundException(errorMessage); + throw new InspectionAreaNotFoundException(errorMessage); } // Cloning to avoid tracking same object diff --git a/backend/api/Services/ReturnToHomeService.cs b/backend/api/Services/ReturnToHomeService.cs index 84ff68258..5bb7ae0be 100644 --- a/backend/api/Services/ReturnToHomeService.cs +++ b/backend/api/Services/ReturnToHomeService.cs @@ -23,7 +23,7 @@ public class ReturnToHomeService(ILogger logger, IRobotServ MissionRun missionRun; try { missionRun = await ScheduleReturnToHomeMissionRun(robotId); } - catch (Exception ex) when (ex is RobotNotFoundException or AreaNotFoundException or DeckNotFoundException or PoseNotFoundException or UnsupportedRobotCapabilityException or MissionRunNotFoundException) + catch (Exception ex) when (ex is RobotNotFoundException or AreaNotFoundException or InspectionAreaNotFoundException or PoseNotFoundException or UnsupportedRobotCapabilityException or MissionRunNotFoundException) { // TODO: if we make ISAR aware of return to home missions, we can avoid scheduling them when the robot does not need them throw new ReturnToHomeMissionFailedToScheduleException(ex.Message); @@ -47,7 +47,7 @@ private async Task ScheduleReturnToHomeMissionRun(string robotId) throw new RobotNotFoundException(errorMessage); } Pose? return_to_home_pose; - Deck? currentInspectionArea; + InspectionArea? currentInspectionArea; if (robot.RobotCapabilities is not null && robot.RobotCapabilities.Contains(RobotCapabilitiesEnum.auto_return_to_home)) { var previousMissionRun = await missionRunService.ReadLastExecutedMissionRunByRobot(robot.Id, readOnly: true); @@ -64,7 +64,7 @@ private async Task ScheduleReturnToHomeMissionRun(string robotId) { string errorMessage = $"Robot with ID {robotId} could return home as it did not have an inspection area"; logger.LogError("{Message}", errorMessage); - throw new DeckNotFoundException(errorMessage); + throw new InspectionAreaNotFoundException(errorMessage); } var returnToHomeMissionRun = new MissionRun @@ -84,7 +84,7 @@ private async Task ScheduleReturnToHomeMissionRun(string robotId) var missionRun = await missionRunService.Create(returnToHomeMissionRun, false); logger.LogInformation( - "Scheduled a mission for the robot {RobotName} to return to home location on deck {DeckName}", + "Scheduled a mission for the robot {RobotName} to return to home location on inspection area {InspectionAreaName}", robot.Name, currentInspectionArea?.Name); return missionRun; } diff --git a/backend/api/Services/RobotService.cs b/backend/api/Services/RobotService.cs index c86077e99..2a0cd3e46 100644 --- a/backend/api/Services/RobotService.cs +++ b/backend/api/Services/RobotService.cs @@ -46,7 +46,7 @@ public class RobotService( ISignalRService signalRService, IAccessRoleService accessRoleService, IInstallationService installationService, - IDeckService deckService) : IRobotService + IInspectionAreaService inspectionAreaService) : IRobotService { public async Task Create(Robot newRobot) @@ -73,13 +73,13 @@ public async Task CreateFromQuery(CreateRobotQuery robotQuery) throw new DbUpdateException($"Could not create new robot in database as installation {robotQuery.CurrentInstallationCode} doesn't exist"); } - Deck? inspectionArea = null; + InspectionArea? inspectionArea = null; if (robotQuery.CurrentInspectionAreaName is not null) { - inspectionArea = await deckService.ReadByInstallationAndName(robotQuery.CurrentInstallationCode, robotQuery.CurrentInspectionAreaName, readOnly: true); + inspectionArea = await inspectionAreaService.ReadByInstallationAndName(robotQuery.CurrentInstallationCode, robotQuery.CurrentInspectionAreaName, readOnly: true); if (inspectionArea is null) { - logger.LogError("Inspection area '{CurrentDeckName}' does not exist in installation {CurrentInstallation}", robotQuery.CurrentInspectionAreaName, robotQuery.CurrentInstallationCode); + logger.LogError("Inspection area '{CurrentInspectionAreaName}' does not exist in installation {CurrentInstallation}", robotQuery.CurrentInspectionAreaName, robotQuery.CurrentInstallationCode); throw new DbUpdateException($"Could not create new robot in database as inspection area '{robotQuery.CurrentInspectionAreaName}' does not exist in installation {robotQuery.CurrentInstallationCode}"); } } @@ -222,7 +222,7 @@ public async Task UpdateCurrentInspectionArea(string robotId, string? inspection return; } - var area = await deckService.ReadById(inspectionAreaId, readOnly: true); + var area = await inspectionAreaService.ReadById(inspectionAreaId, readOnly: true); if (area is null) { logger.LogError("Could not find inspection area '{InspectionAreaId}' setting robot '{IsarId}' inspection area to null", inspectionAreaId, robotId); @@ -300,7 +300,7 @@ private IQueryable GetRobotsWithSubModels(bool readOnly = true) .Include(r => r.Model) .Include(r => r.CurrentInstallation) .Include(r => r.CurrentInspectionArea) - .ThenInclude(deck => deck != null ? deck.DefaultLocalizationPose : null) + .ThenInclude(inspectionArea => inspectionArea != null ? inspectionArea.DefaultLocalizationPose : null) .ThenInclude(defaultLocalizationPose => defaultLocalizationPose != null ? defaultLocalizationPose.Pose : null) .Include(r => r.CurrentInspectionArea) .ThenInclude(area => area != null ? area.Plant : null) @@ -364,7 +364,7 @@ private void NotifySignalROfUpdatedRobot(Robot robot, Installation installation) public void DetachTracking(Robot robot) { if (robot.CurrentInstallation != null) installationService.DetachTracking(robot.CurrentInstallation); - if (robot.CurrentInspectionArea != null) deckService.DetachTracking(robot.CurrentInspectionArea); + if (robot.CurrentInspectionArea != null) inspectionAreaService.DetachTracking(robot.CurrentInspectionArea); if (robot.Model != null) robotModelService.DetachTracking(robot.Model); context.Entry(robot).State = EntityState.Detached; } diff --git a/backend/api/Utilities/Exceptions.cs b/backend/api/Utilities/Exceptions.cs index 1d929616f..5256be6ef 100644 --- a/backend/api/Utilities/Exceptions.cs +++ b/backend/api/Utilities/Exceptions.cs @@ -31,7 +31,7 @@ public class PlantNotFoundException(string message) : Exception(message) { } - public class DeckNotFoundException(string message) : Exception(message) + public class InspectionAreaNotFoundException(string message) : Exception(message) { } @@ -79,7 +79,7 @@ public class AreaExistsException(string message) : Exception(message) { } - public class DeckExistsException(string message) : Exception(message) + public class InspectionAreaExistsException(string message) : Exception(message) { } diff --git a/frontend/src/api/ApiCaller.tsx b/frontend/src/api/ApiCaller.tsx index 2d11bfafe..0b7219cfc 100644 --- a/frontend/src/api/ApiCaller.tsx +++ b/frontend/src/api/ApiCaller.tsx @@ -11,7 +11,7 @@ import { tokenReverificationInterval } from 'components/Contexts/AuthProvider' import { MapMetadata } from 'models/MapMetadata' import { MissionDefinition, PlantInfo } from 'models/MissionDefinition' import { MissionDefinitionUpdateForm } from 'models/MissionDefinitionUpdateForm' -import { Deck } from 'models/Deck' +import { InspectionArea } from 'models/InspectionArea' import { ApiError, isApiError } from './ApiError' import { MediaStreamConfig } from 'models/VideoStream' @@ -234,8 +234,8 @@ export class BackendAPICaller { return result.content } - static async getMissionDefinitionsInDeck(deck: Deck): Promise { - let path: string = 'decks/' + deck.id + '/mission-definitions' + static async getMissionDefinitionsInInspectionArea(inspectionArea: InspectionArea): Promise { + let path: string = 'inspectionAreas/' + inspectionArea.id + '/mission-definitions' const result = await BackendAPICaller.GET(path).catch( BackendAPICaller.handleError('GET', path) @@ -355,29 +355,29 @@ export class BackendAPICaller { return result.content } - static async getAreasByDeckId(deckId: string): Promise { - const path: string = 'areas/deck/' + deckId + static async getAreasByInspectionAreaId(inspectionAreaId: string): Promise { + const path: string = 'areas/inspectionArea/' + inspectionAreaId const result = await this.GET(path).catch(BackendAPICaller.handleError('GET', path)) return result.content } - static async getDecks(): Promise { - const path: string = 'decks' - const result = await this.GET(path).catch(BackendAPICaller.handleError('GET', path)) + static async getInspectionAreas(): Promise { + const path: string = 'inspectionAreas' + const result = await this.GET(path).catch(BackendAPICaller.handleError('GET', path)) return result.content } - static async getDecksByInstallationCode(installationCode: string): Promise { - const path: string = 'decks/installation/' + installationCode - const result = await this.GET(path).catch((e) => { + static async getInspectionAreasByInstallationCode(installationCode: string): Promise { + const path: string = 'inspectionAreas/installation/' + installationCode + const result = await this.GET(path).catch((e) => { console.error(`Failed to GET /${path}: ` + e) throw e }) return result.content } - static async getDeckMapMetadata(id: string): Promise { - const path: string = 'decks/' + id + '/map-metadata' + static async getInspectionAreaMapMetadata(id: string): Promise { + const path: string = 'inspectionAreas/' + id + '/map-metadata' const result = await this.GET(path).catch((e) => { console.error(`Failed to GET /${path}: ` + e) throw e diff --git a/frontend/src/components/Contexts/InstallationContext.tsx b/frontend/src/components/Contexts/InstallationContext.tsx index a5bc077ca..ffb873a50 100644 --- a/frontend/src/components/Contexts/InstallationContext.tsx +++ b/frontend/src/components/Contexts/InstallationContext.tsx @@ -1,7 +1,7 @@ import { createContext, FC, useContext, useState, useEffect } from 'react' import { BackendAPICaller } from 'api/ApiCaller' import { PlantInfo } from 'models/MissionDefinition' -import { Deck } from 'models/Deck' +import { InspectionArea } from 'models/Deck' import { SignalREventLabels, useSignalRContext } from './SignalRContext' import { Area } from 'models/Area' import { useLanguageContext } from './LanguageContext' @@ -12,7 +12,7 @@ import { AlertCategory } from 'components/Alerts/AlertsBanner' interface IInstallationContext { installationCode: string installationName: string - installationDecks: Deck[] + installationInspectionAreas: InspectionArea[] installationAreas: Area[] switchInstallation: (selectedName: string) => void } @@ -32,7 +32,7 @@ interface Props { const defaultInstallation = { installationCode: '', installationName: '', - installationDecks: [], + installationInspectionAreas: [], installationAreas: [], switchInstallation: (selectedInstallation: string) => {}, } @@ -47,7 +47,7 @@ export const InstallationProvider: FC = ({ children }) => { const [installationName, setInstallationName] = useState( window.localStorage.getItem('installationName') || '' ) - const [installationDecks, setInstallationDecks] = useState([]) + const [installationInspectionAreas, setInstallationInspectionAreas] = useState([]) const [installationAreas, setInstallationAreas] = useState([]) const installationCode = (allPlantsMap.get(installationName) || '').toUpperCase() @@ -77,11 +77,11 @@ export const InstallationProvider: FC = ({ children }) => { useEffect(() => { if (installationCode) - BackendAPICaller.getDecksByInstallationCode(installationCode) - .then((decks: Deck[]) => { - setInstallationDecks(decks) - decks.forEach((deck) => - BackendAPICaller.getAreasByDeckId(deck.id) + BackendAPICaller.getInspectionAreasByInstallationCode(installationCode) + .then((inspectionAreas: InspectionArea[]) => { + setInstallationInspectionAreas(inspectionAreas) + inspectionAreas.forEach((inspectionArea) => + BackendAPICaller.getAreasByInspectionAreaId(inspectionArea.id) .then((areas) => setInstallationAreas((oldAreas) => { let areasCopy = [...oldAreas] @@ -98,8 +98,8 @@ export const InstallationProvider: FC = ({ children }) => { setAlert( AlertType.RequestFail, , AlertCategory.ERROR @@ -107,8 +107,8 @@ export const InstallationProvider: FC = ({ children }) => { setListAlert( AlertType.RequestFail, , AlertCategory.ERROR @@ -120,7 +120,7 @@ export const InstallationProvider: FC = ({ children }) => { setAlert( AlertType.RequestFail, , @@ -129,7 +129,7 @@ export const InstallationProvider: FC = ({ children }) => { setListAlert( AlertType.RequestFail, , @@ -141,38 +141,38 @@ export const InstallationProvider: FC = ({ children }) => { useEffect(() => { if (connectionReady) { - registerEvent(SignalREventLabels.deckCreated, (username: string, message: string) => { - const newDeck: Deck = JSON.parse(message) - if (newDeck.installationCode !== installationCode) return - setInstallationDecks((oldDecks) => { - return [...oldDecks, newDeck] + registerEvent(SignalREventLabels.inspectionAreaCreated, (username: string, message: string) => { + const newInspectionArea: InspectionArea = JSON.parse(message) + if (newInspectionArea.installationCode !== installationCode) return + setInstallationInspectionAreas((oldInspectionAreas) => { + return [...oldInspectionAreas, newInspectionArea] }) }) - registerEvent(SignalREventLabels.deckUpdated, (username: string, message: string) => { - const updatedDeck: Deck = JSON.parse(message) - if (updatedDeck.installationCode !== installationCode) return + registerEvent(SignalREventLabels.inspectionAreaUpdated, (username: string, message: string) => { + const updatedInspectionArea: InspectionArea = JSON.parse(message) + if (updatedInspectionArea.installationCode !== installationCode) return - setInstallationDecks((oldDecks) => { - const deckIndex = oldDecks.findIndex((d) => d.id === updatedDeck.id) - if (deckIndex === -1) return [...oldDecks, updatedDeck] + setInstallationInspectionAreas((oldInspectionAreas) => { + const inspectionAreaIndex = oldInspectionAreas.findIndex((d) => d.id === updatedInspectionArea.id) + if (inspectionAreaIndex === -1) return [...oldInspectionAreas, updatedInspectionArea] else { - let oldDecksCopy = [...oldDecks] - oldDecksCopy[deckIndex] = updatedDeck - return oldDecksCopy + let oldInspectionAreasCopy = [...oldInspectionAreas] + oldInspectionAreasCopy[inspectionAreaIndex] = updatedInspectionArea + return oldInspectionAreasCopy } }) }) - registerEvent(SignalREventLabels.deckDeleted, (username: string, message: string) => { - const deletedDeck: Deck = JSON.parse(message) - if (deletedDeck.installationCode !== installationCode) return - setInstallationDecks((oldDecks) => { - const deckIndex = oldDecks.findIndex((d) => d.id === deletedDeck.id) - if (deckIndex !== -1) { - let oldDecksCopy = [...oldDecks] - oldDecksCopy.splice(deckIndex, 1) - return oldDecksCopy + registerEvent(SignalREventLabels.inspectionAreaDeleted, (username: string, message: string) => { + const deletedInspectionArea: InspectionArea = JSON.parse(message) + if (deletedInspectionArea.installationCode !== installationCode) return + setInstallationInspectionAreas((oldInspectionAreas) => { + const inspectionAreaIndex = oldInspectionAreas.findIndex((d) => d.id === deletedInspectionArea.id) + if (inspectionAreaIndex !== -1) { + let oldInspectionAreasCopy = [...oldInspectionAreas] + oldInspectionAreasCopy.splice(inspectionAreaIndex, 1) + return oldInspectionAreasCopy } - return oldDecks + return oldInspectionAreas }) }) } @@ -186,20 +186,20 @@ export const InstallationProvider: FC = ({ children }) => { window.localStorage.setItem('installationCode', derivedCode) } - const [filteredInstallationDecks, setFilteredInstallationDecks] = useState([]) + const [filteredInstallationInspectionAreas, setFilteredInstallationInspectionAreas] = useState([]) const [filteredInstallationAreas, setFilteredInstallationAreas] = useState([]) useEffect(() => { - setFilteredInstallationDecks(installationDecks.filter((d) => d.installationCode === installationCode)) + setFilteredInstallationInspectionAreas(installationInspectionAreas.filter((d) => d.installationCode === installationCode)) setFilteredInstallationAreas(installationAreas.filter((a) => a.installationCode === installationCode)) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [installationCode, installationDecks, installationAreas]) + }, [installationCode, installationInspectionAreas, installationAreas]) return ( void closeDialog: () => void robotId: string - missionDeckNames: string[] + missionInspectionAreaNames: string[] } export const ScheduleMissionWithConfirmDialogs = ({ robotId, - missionDeckNames, + missionInspectionAreaNames, scheduleMissions, closeDialog, }: ConfirmScheduleDialogProps) => { @@ -76,7 +76,7 @@ export const ScheduleMissionWithConfirmDialogs = ({ scheduleMissions={scheduleMissions} closeDialog={closeDialog} robotId={robot!.id} - missionDeckNames={missionDeckNames} + missionInspectionAreaNames={missionInspectionAreaNames} /> ) } diff --git a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConfirmLocalizationDialog.tsx b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConfirmLocalizationDialog.tsx index 8b03e6eea..d53563a93 100644 --- a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConfirmLocalizationDialog.tsx +++ b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConfirmLocalizationDialog.tsx @@ -1,5 +1,5 @@ import { Button, Checkbox, Dialog, Typography } from '@equinor/eds-core-react' -import { DeckMapView } from 'utils/DeckMapView' +import { InspectionAreaMapView } from 'utils/InspectionAreaMapView' import { HorizontalContent, StyledDialog, VerticalContent } from './ScheduleMissionStyles' import { useLanguageContext } from 'components/Contexts/LanguageContext' import { Robot } from 'models/Robot' @@ -10,20 +10,20 @@ interface ConfirmLocalizationDialogProps { closeDialog: () => void scheduleMissions: () => void robot: Robot - newDeckName: string + newInspectionAreaName: string } export const ConfirmLocalizationDialog = ({ closeDialog, scheduleMissions, robot, - newDeckName, + newInspectionAreaName, }: ConfirmLocalizationDialogProps) => { const { TranslateText } = useLanguageContext() - const { installationDecks } = useInstallationContext() + const { installationInspectionAreas } = useInstallationContext() const [isCheckboxClicked, setIsCheckboxClicked] = useState(false) - const newDeck = installationDecks.find((deck) => deck.deckName === newDeckName) + const newInspectionArea = installationInspectionAreas.find((inspectionArea) => inspectionArea.inspectionAreaName === newInspectionAreaName) return ( @@ -35,12 +35,12 @@ export const ConfirmLocalizationDialog = ({ {`${robot.name} (${robot.model.type}) ${TranslateText( 'needs to be placed on marked position on' - )} ${newDeckName} `} + )} ${newInspectionAreaName} `} {TranslateText('before')} {` ${TranslateText('clicking confirm')}.`} - {newDeck && newDeck.defaultLocalizationPose && ( - + {newInspectionArea && newInspectionArea.defaultLocalizationPose && ( + )} {newDeckName} + {newInspectionAreaName} diff --git a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConflictingLocalizationDialog.tsx b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConflictingLocalizationDialog.tsx index d22fddf73..e5223b7cc 100644 --- a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConflictingLocalizationDialog.tsx +++ b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ConflictingLocalizationDialog.tsx @@ -2,34 +2,34 @@ import { Button, Dialog, List, Typography } from '@equinor/eds-core-react' import { StyledDialog, VerticalContent } from './ScheduleMissionStyles' import { useLanguageContext } from 'components/Contexts/LanguageContext' -interface ConflictingRobotDeckDialogProps { +interface ConflictingRobotInspectionAreaDialogProps { closeDialog: () => void - robotDeckName: string - desiredDeckName: string + robotInspectionAreaName: string + desiredInspectionAreaName: string } -interface ConflictingMissionDecksDialogProps { +interface ConflictingMissionInspectionAreasDialogProps { closeDialog: () => void - missionDeckNames: string[] + missionInspectionAreaNames: string[] } -export const ConflictingRobotDeckDialog = ({ +export const ConflictingRobotInspectionAreaDialog = ({ closeDialog, - robotDeckName, - desiredDeckName, -}: ConflictingRobotDeckDialogProps) => { + robotInspectionAreaName, + desiredInspectionAreaName, +}: ConflictingRobotInspectionAreaDialogProps) => { const { TranslateText } = useLanguageContext() return ( - {TranslateText('Conflicting decks')} + {TranslateText('Conflicting inspection areas')} - {TranslateText('The missions you are trying to add are on')} {desiredDeckName}{' '} - {TranslateText('but the robot is currently running missions on')} {{robotDeckName}}. + {TranslateText('The missions you are trying to add are on')} {desiredInspectionAreaName}{' '} + {TranslateText('but the robot is currently running missions on')} {{robotInspectionAreaName}}. {TranslateText('Will not be added dialog text')} @@ -43,17 +43,17 @@ export const ConflictingRobotDeckDialog = ({ ) } -export const ConflictingMissionDecksDialog = ({ +export const ConflictingMissionInspectionAreasDialog = ({ closeDialog, - missionDeckNames, -}: ConflictingMissionDecksDialogProps) => { + missionInspectionAreaNames, +}: ConflictingMissionInspectionAreasDialogProps) => { const { TranslateText } = useLanguageContext() - const MissionDeckNamesList = ( + const MissionInspectionAreaNamesList = ( - {missionDeckNames.map((deckName) => ( + {missionInspectionAreaNames.map((inspectionAreaName) => ( - {deckName} + {inspectionAreaName} ))} @@ -62,15 +62,15 @@ export const ConflictingMissionDecksDialog = ({ return ( - {TranslateText('Conflicting decks')} + {TranslateText('Conflicting inspection areas')} - {TranslateText('The missions you are trying to add are on these decks:')} - {MissionDeckNamesList} + {TranslateText('The missions you are trying to add are on these inspection areas:')} + {MissionInspectionAreaNamesList} - {TranslateText('You can only add missions from one deck.')} + {TranslateText('You can only add missions from one inspection area.')} diff --git a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ScheduleMissionWithLocalizationVerification.tsx b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ScheduleMissionWithLocalizationVerification.tsx index c0be74265..87a807dee 100644 --- a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ScheduleMissionWithLocalizationVerification.tsx +++ b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/ScheduleMissionWithLocalizationVerification.tsx @@ -1,8 +1,8 @@ import { Robot } from 'models/Robot' import { useEffect, useState } from 'react' import { ConfirmLocalizationDialog } from './ConfirmLocalizationDialog' -import { ConflictingMissionDecksDialog, ConflictingRobotDeckDialog } from './ConflictingLocalizationDialog' -import { UnknownDeckDialog } from './UnknownDeckDialog' +import { ConflictingMissionInspectionAreasDialog, ConflictingRobotInspectionAreaDialog } from './ConflictingLocalizationDialog' +import { UnknownInspectionAreaDialog } from './UnknownInspectionAreaDialog' import { useRobotContext } from 'components/Contexts/RobotContext' import { useMissionsContext } from 'components/Contexts/MissionRunsContext' @@ -10,20 +10,20 @@ interface IProps { scheduleMissions: () => void closeDialog: () => void robotId: string - missionDeckNames: string[] + missionInspectionAreaNames: string[] } enum DialogTypes { - verifyDeck, - unknownNewDeck, - conflictingMissionDecks, - conflictingRobotDeck, + verifyInspectionArea, + unknownNewInspectionArea, + conflictingMissionInspectionAreas, + conflictingRobotInspectionArea, unknown, } export const ScheduleMissionWithLocalizationVerificationDialog = ({ robotId, - missionDeckNames, + missionInspectionAreaNames, scheduleMissions, closeDialog, }: IProps): JSX.Element => { @@ -32,14 +32,14 @@ export const ScheduleMissionWithLocalizationVerificationDialog = ({ const [selectedRobot, setSelectedRobot] = useState() const { ongoingMissions } = useMissionsContext() - const unikMissionDeckNames = missionDeckNames.filter( - (deckName, index) => deckName !== '' && missionDeckNames.indexOf(deckName) === index + const unikMissionInspectionAreaNames = missionInspectionAreaNames.filter( + (inspectionAreaName, index) => inspectionAreaName !== '' && missionInspectionAreaNames.indexOf(inspectionAreaName) === index ) - const ongoingLocalizationMissionOnSameDeckExists = + const ongoingLocalizationMissionOnSameInspectionAreaExists = ongoingMissions.filter( (mission) => - mission.robot?.id === selectedRobot?.id && mission.inspectionArea?.deckName === unikMissionDeckNames[0] + mission.robot?.id === selectedRobot?.id && mission.inspectionArea?.inspectionAreaName === unikMissionInspectionAreaNames[0] ).length > 0 useEffect(() => { @@ -50,59 +50,59 @@ export const ScheduleMissionWithLocalizationVerificationDialog = ({ if (!selectedRobot) return if ( - (unikMissionDeckNames.length === 1 && - selectedRobot.currentInspectionArea?.deckName && - unikMissionDeckNames[0] === selectedRobot?.currentInspectionArea?.deckName) || - ongoingLocalizationMissionOnSameDeckExists + (unikMissionInspectionAreaNames.length === 1 && + selectedRobot.currentInspectionArea?.inspectionAreaName && + unikMissionInspectionAreaNames[0] === selectedRobot?.currentInspectionArea?.inspectionAreaName) || + ongoingLocalizationMissionOnSameInspectionAreaExists ) { scheduleMissions() return } - if (unikMissionDeckNames.length > 1) { - setDialogToOpen(DialogTypes.conflictingMissionDecks) + if (unikMissionInspectionAreaNames.length > 1) { + setDialogToOpen(DialogTypes.conflictingMissionInspectionAreas) return } - if (unikMissionDeckNames.length === 0) { - setDialogToOpen(DialogTypes.unknownNewDeck) + if (unikMissionInspectionAreaNames.length === 0) { + setDialogToOpen(DialogTypes.unknownNewInspectionArea) return } - if (!selectedRobot.currentInspectionArea?.deckName && !ongoingLocalizationMissionOnSameDeckExists) { - setDialogToOpen(DialogTypes.verifyDeck) + if (!selectedRobot.currentInspectionArea?.inspectionAreaName && !ongoingLocalizationMissionOnSameInspectionAreaExists) { + setDialogToOpen(DialogTypes.verifyInspectionArea) return } - if (unikMissionDeckNames[0] !== selectedRobot.currentInspectionArea?.deckName) { - setDialogToOpen(DialogTypes.conflictingRobotDeck) + if (unikMissionInspectionAreaNames[0] !== selectedRobot.currentInspectionArea?.inspectionAreaName) { + setDialogToOpen(DialogTypes.conflictingRobotInspectionArea) return } // To ignore scheduleMissions dependency // eslint-disable-next-line react-hooks/exhaustive-deps - }, [unikMissionDeckNames, selectedRobot?.currentInspectionArea?.deckName]) + }, [unikMissionInspectionAreaNames, selectedRobot?.currentInspectionArea?.inspectionAreaName]) return ( <> - {dialogToOpen === DialogTypes.verifyDeck && ( + {dialogToOpen === DialogTypes.verifyInspectionArea && ( )} - {dialogToOpen === DialogTypes.conflictingMissionDecks && ( - + {dialogToOpen === DialogTypes.conflictingMissionInspectionAreas && ( + )} - {dialogToOpen === DialogTypes.conflictingRobotDeck && ( - )} - {dialogToOpen === DialogTypes.unknownNewDeck && } + {dialogToOpen === DialogTypes.unknownNewInspectionArea && } ) } diff --git a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/UnknownDeckDialog.tsx b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/UnknownDeckDialog.tsx index 94deb081f..18a4ddd63 100644 --- a/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/UnknownDeckDialog.tsx +++ b/frontend/src/components/Displays/ConfirmScheduleDialogs/LocalizationVerification/UnknownDeckDialog.tsx @@ -2,21 +2,21 @@ import { Button, Dialog, Typography } from '@equinor/eds-core-react' import { StyledDialog, VerticalContent } from './ScheduleMissionStyles' import { useLanguageContext } from 'components/Contexts/LanguageContext' -interface UnknownDeckDialogProps { +interface UnknownInspectionAreaDialogProps { closeDialog: () => void } -export const UnknownDeckDialog = ({ closeDialog }: UnknownDeckDialogProps) => { +export const UnknownInspectionAreaDialog = ({ closeDialog }: UnknownInspectionAreaDialogProps) => { const { TranslateText } = useLanguageContext() return ( - {TranslateText('Unknown deck')} + {TranslateText('Unknown inspection area')} - {TranslateText('Cannot start selected mission as it has unknown deck.')} + {TranslateText('Cannot start selected mission as it has unknown inspection area.')} diff --git a/frontend/src/components/Displays/MissionButtons/MissionRestartButton.tsx b/frontend/src/components/Displays/MissionButtons/MissionRestartButton.tsx index 92cb7e648..3d0f88245 100644 --- a/frontend/src/components/Displays/MissionButtons/MissionRestartButton.tsx +++ b/frontend/src/components/Displays/MissionButtons/MissionRestartButton.tsx @@ -115,7 +115,7 @@ export const MissionRestartButton = ({ mission, hasFailedTasks, smallButton }: M scheduleMissions={() => startReRun(selectedRerunOption!)} closeDialog={() => setIsLocationVerificationOpen(false)} robotId={mission.robot.id} - missionDeckNames={[mission.inspectionArea?.deckName ?? '']} + missionInspectionAreaNames={[mission.inspectionArea?.inspectionAreaName ?? '']} /> )} diff --git a/frontend/src/components/Pages/InspectionPage/DeckCards.tsx b/frontend/src/components/Pages/InspectionPage/DeckCards.tsx index e6aa94359..1148e2681 100644 --- a/frontend/src/components/Pages/InspectionPage/DeckCards.tsx +++ b/frontend/src/components/Pages/InspectionPage/DeckCards.tsx @@ -1,9 +1,9 @@ -import { Deck } from 'models/Deck' -import { DeckInspectionTuple, Inspection } from './InspectionSection' +import { InspectionArea } from 'models/InspectionArea' +import { InspectionAreaInspectionTuple, Inspection } from './InspectionSection' import { useLanguageContext } from 'components/Contexts/LanguageContext' import { CardMissionInformation, - DeckCardColors, + InspectionAreaCardColors, StyledDict, compareInspections, getDeadlineInspection, @@ -14,62 +14,62 @@ import { tokens } from '@equinor/eds-tokens' import { useMissionsContext } from 'components/Contexts/MissionRunsContext' import { useRobotContext } from 'components/Contexts/RobotContext' -interface IDeckCardProps { - deckMissions: DeckInspectionTuple[] - onClickDeck: (deck: Deck) => void - selectedDeck: Deck | undefined +interface IInspectionAreaCardProps { + inspectionAreaMissions: InspectionAreaInspectionTuple[] + onClickInspectionArea: (inspectionArea: InspectionArea) => void + selectedInspectionArea: InspectionArea | undefined handleScheduleAll: (inspections: Inspection[]) => void } -interface DeckCardProps { - deckData: DeckInspectionTuple - onClickDeck: (deck: Deck) => void - selectedDeck: Deck | undefined +interface InspectionAreaCardProps { + inspectionAreaData: InspectionAreaInspectionTuple + onClickInspectionArea: (inspectionArea: InspectionArea) => void + selectedInspectionArea: InspectionArea | undefined handleScheduleAll: (inspections: Inspection[]) => void } -const DeckCard = ({ deckData, onClickDeck, selectedDeck, handleScheduleAll }: DeckCardProps) => { +const InspectionAreaCard = ({ inspectionAreaData, onClickInspectionArea, selectedInspectionArea, handleScheduleAll }: InspectionAreaCardProps) => { const { TranslateText } = useLanguageContext() const { ongoingMissions } = useMissionsContext() const { enabledRobots } = useRobotContext() - const isScheduleMissionsDisabled = enabledRobots.length === 0 || deckData.inspections.length === 0 + const isScheduleMissionsDisabled = enabledRobots.length === 0 || inspectionAreaData.inspections.length === 0 - const getCardColorFromInspections = (inspections: Inspection[]): DeckCardColors => { - if (inspections.length === 0) return DeckCardColors.Gray + const getCardColorFromInspections = (inspections: Inspection[]): InspectionAreaCardColors => { + if (inspections.length === 0) return InspectionAreaCardColors.Gray const sortedInspections = inspections.sort(compareInspections) - if (sortedInspections.length === 0) return DeckCardColors.Green + if (sortedInspections.length === 0) return InspectionAreaCardColors.Green const nextInspection = sortedInspections[0] if (!nextInspection.deadline) { - if (!nextInspection.missionDefinition.inspectionFrequency) return DeckCardColors.Green - else return DeckCardColors.Red + if (!nextInspection.missionDefinition.inspectionFrequency) return InspectionAreaCardColors.Green + else return InspectionAreaCardColors.Red } return getDeadlineInspection(nextInspection.deadline) } let queueMissionsTooltip = '' - if (deckData.inspections.length === 0) queueMissionsTooltip = TranslateText('No planned inspection') + if (inspectionAreaData.inspections.length === 0) queueMissionsTooltip = TranslateText('No planned inspection') else if (isScheduleMissionsDisabled) queueMissionsTooltip = TranslateText('No robot available') return ( - - + + 0 ? () => onClickDeck(deckData.deck) : undefined} + key={inspectionAreaData.inspectionArea.inspectionAreaName} + onClick={inspectionAreaData.inspections.length > 0 ? () => onClickInspectionArea(inspectionAreaData.inspectionArea) : undefined} style={ - selectedDeck === deckData.deck - ? { border: `solid ${getCardColorFromInspections(deckData.inspections)} 2px` } + selectedInspectionArea === inspectionAreaData.inspectionArea + ? { border: `solid ${getCardColorFromInspections(inspectionAreaData.inspections)} 2px` } : {} } > - - - {deckData.deck.deckName.toString()} - {deckData.inspections + + + {inspectionAreaData.inspectionArea.inspectionAreaName.toString()} + {inspectionAreaData.inspections .filter((i) => ongoingMissions.find((m) => m.missionId === i.missionDefinition.id)) .map((inspection) => ( @@ -77,20 +77,20 @@ const DeckCard = ({ deckData, onClickDeck, selectedDeck, handleScheduleAll }: De {TranslateText('InProgress')} ))} - - {deckData.inspections && ( - + + {inspectionAreaData.inspections && ( + )} - +