From 7423ef620346f710f8203d4c1da83de839a9bae4 Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Thu, 3 Aug 2023 15:19:30 +0200 Subject: [PATCH 1/3] feat(daps): remove daps remove the daps service including all calls to daps remove daps from business logic Refs: CPLP-3105 --- src/Portal.Backend.sln | 30 - .../Administration.Service.csproj | 1 - .../BusinessLogic/ConnectorsBusinessLogic.cs | 188 +- .../BusinessLogic/IConnectorsBusinessLogic.cs | 38 +- .../Controllers/ConnectorsController.cs | 50 +- .../Models/ConnectorInputModel.cs | 3 - .../Administration.Service/Program.cs | 4 +- .../Administration.Service/appsettings.json | 11 - .../Daps.Library/Daps.Library.csproj | 45 - .../Daps.Library/DapsService.cs | 128 - .../DapsServiceCollectionExtension.cs | 46 - .../Daps.Library/DapsSettings.cs | 41 - .../Daps.Library/IDapsService.cs | 60 - .../Daps.Library/Models/DapsResponse.cs | 23 - .../Daps.Library/Models/DapsUpdateData.cs | 28 - .../BusinessLogic/SdFactoryBusinessLogic.cs | 1 + .../Models/ConnectorUpdateInformation.cs | 3 +- .../Repositories/ConnectorsRepository.cs | 21 +- .../Repositories/IConnectorsRepository.cs | 17 +- ...803131109_CPLP-3105-RemoveDaps.Designer.cs | 7248 +++++++++++++++++ .../20230803131109_CPLP-3105-RemoveDaps.cs | 128 + .../PortalDbContextModelSnapshot.cs | 127 +- .../Seeder/Data/connectors.consortia.json | 20 +- .../AuditEntities/AuditConnector20230803.cs | 61 + .../Entities/Connector.cs | 5 +- .../Entities/ConnectorClientDetail.cs | 22 - .../PortalDbContext.cs | 14 +- .../ConnectorsBusinessLogicTests.cs | 423 +- .../Controllers/ConnectorsControllerTests.cs | 55 +- .../appsettings.IntegrationTests.json | 3 - .../Daps.Library.Tests.csproj | 49 - .../Daps.Library.Tests/DapsServiceTests.cs | 365 - .../Daps.Library.Tests/Usings.cs | 25 - .../OfferProviderServiceTests.cs | 3 +- .../ConnectorRepositoryTests.cs | 116 +- .../Seeder/Data/connectors.test.json | 25 +- 36 files changed, 7887 insertions(+), 1540 deletions(-) delete mode 100644 src/externalsystems/Daps.Library/Daps.Library.csproj delete mode 100644 src/externalsystems/Daps.Library/DapsService.cs delete mode 100644 src/externalsystems/Daps.Library/DapsServiceCollectionExtension.cs delete mode 100644 src/externalsystems/Daps.Library/DapsSettings.cs delete mode 100644 src/externalsystems/Daps.Library/IDapsService.cs delete mode 100644 src/externalsystems/Daps.Library/Models/DapsResponse.cs delete mode 100644 src/externalsystems/Daps.Library/Models/DapsUpdateData.cs create mode 100644 src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs create mode 100644 src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs create mode 100644 src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs delete mode 100644 src/portalbackend/PortalBackend.PortalEntities/Entities/ConnectorClientDetail.cs delete mode 100644 tests/externalsystems/Daps.Library.Tests/Daps.Library.Tests.csproj delete mode 100644 tests/externalsystems/Daps.Library.Tests/DapsServiceTests.cs delete mode 100644 tests/externalsystems/Daps.Library.Tests/Usings.cs diff --git a/src/Portal.Backend.sln b/src/Portal.Backend.sln index b808785626..3e625d207a 100644 --- a/src/Portal.Backend.sln +++ b/src/Portal.Backend.sln @@ -164,10 +164,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationChecklist.Config EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Framework.HttpClient", "framework\Framework.HttpClient\Framework.HttpClient.csproj", "{4B13E087-E789-4A8D-BE06-5461FA4900A5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Daps.Library", "externalsystems\Daps.Library\Daps.Library.csproj", "{1C159649-85BE-4D5B-9DDE-58C310CCA30B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Daps.Library.Tests", "..\tests\externalsystems\Daps.Library.Tests\Daps.Library.Tests.csproj", "{3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker.Library", "processes\Processes.Worker.Library\Processes.Worker.Library.csproj", "{527A4A82-D63A-4DD5-B37D-0AC8A79F1B0E}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApplicationChecklist.Executor", "processes\ApplicationChecklist.Executor\ApplicationChecklist.Executor.csproj", "{0221E83B-B26B-442F-ACAD-B1043DF9993A}" @@ -1036,30 +1032,6 @@ Global {4B13E087-E789-4A8D-BE06-5461FA4900A5}.Release|x64.Build.0 = Release|Any CPU {4B13E087-E789-4A8D-BE06-5461FA4900A5}.Release|x86.ActiveCfg = Release|Any CPU {4B13E087-E789-4A8D-BE06-5461FA4900A5}.Release|x86.Build.0 = Release|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Debug|x64.ActiveCfg = Debug|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Debug|x64.Build.0 = Debug|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Debug|x86.ActiveCfg = Debug|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Debug|x86.Build.0 = Debug|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Release|Any CPU.Build.0 = Release|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Release|x64.ActiveCfg = Release|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Release|x64.Build.0 = Release|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Release|x86.ActiveCfg = Release|Any CPU - {1C159649-85BE-4D5B-9DDE-58C310CCA30B}.Release|x86.Build.0 = Release|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Debug|x64.ActiveCfg = Debug|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Debug|x64.Build.0 = Debug|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Debug|x86.ActiveCfg = Debug|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Debug|x86.Build.0 = Debug|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Release|Any CPU.Build.0 = Release|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Release|x64.ActiveCfg = Release|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Release|x64.Build.0 = Release|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Release|x86.ActiveCfg = Release|Any CPU - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF}.Release|x86.Build.0 = Release|Any CPU {527A4A82-D63A-4DD5-B37D-0AC8A79F1B0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {527A4A82-D63A-4DD5-B37D-0AC8A79F1B0E}.Debug|Any CPU.Build.0 = Debug|Any CPU {527A4A82-D63A-4DD5-B37D-0AC8A79F1B0E}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -1394,8 +1366,6 @@ Global {AB9FC684-E08A-4EEC-9F3A-C256CB2E4D73} = {23500169-FC01-4D2B-A997-E7FAE2169FC0} {C3E5E7C8-69D3-4ECB-A4FA-53A9A780EFF0} = {282CEF03-292F-4A49-83C6-997567D0FF5F} {4B13E087-E789-4A8D-BE06-5461FA4900A5} = {23500169-FC01-4D2B-A997-E7FAE2169FC0} - {1C159649-85BE-4D5B-9DDE-58C310CCA30B} = {C8957230-4203-452C-A085-34091C5E370B} - {3C07D5B5-5F9B-40ED-9B2F-1CA9F27124AF} = {323C198D-A8C6-4EB0-8B79-72624275E35F} {527A4A82-D63A-4DD5-B37D-0AC8A79F1B0E} = {282CEF03-292F-4A49-83C6-997567D0FF5F} {0221E83B-B26B-442F-ACAD-B1043DF9993A} = {282CEF03-292F-4A49-83C6-997567D0FF5F} {4C7E9EAC-222B-4C13-B8B1-5987406817A0} = {282CEF03-292F-4A49-83C6-997567D0FF5F} diff --git a/src/administration/Administration.Service/Administration.Service.csproj b/src/administration/Administration.Service/Administration.Service.csproj index 4775eaee53..ec09183555 100644 --- a/src/administration/Administration.Service/Administration.Service.csproj +++ b/src/administration/Administration.Service/Administration.Service.csproj @@ -45,7 +45,6 @@ - diff --git a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs index 5cd9ee8183..a975bedaaf 100644 --- a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs @@ -21,8 +21,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.Async; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.IO; @@ -31,6 +29,7 @@ using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Identities; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; using System.Text.RegularExpressions; @@ -44,7 +43,7 @@ public class ConnectorsBusinessLogic : IConnectorsBusinessLogic { private readonly IPortalRepositories _portalRepositories; private readonly ISdFactoryBusinessLogic _sdFactoryBusinessLogic; - private readonly IDapsService _dapsService; + private readonly IIdentityService _identityService; private readonly ConnectorsSettings _settings; private static readonly Regex bpnRegex = new(@"(\w|\d){16}", RegexOptions.None, TimeSpan.FromSeconds(1)); @@ -54,19 +53,19 @@ public class ConnectorsBusinessLogic : IConnectorsBusinessLogic /// Access to the needed repositories /// The options /// Access to the connectorsSdFactory - /// Access to the daps service - public ConnectorsBusinessLogic(IPortalRepositories portalRepositories, IOptions options, ISdFactoryBusinessLogic sdFactoryBusinessLogic, IDapsService dapsService) + /// Access to the current logged in user + public ConnectorsBusinessLogic(IPortalRepositories portalRepositories, IOptions options, ISdFactoryBusinessLogic sdFactoryBusinessLogic, IIdentityService identityService) { _portalRepositories = portalRepositories; _settings = options.Value; _sdFactoryBusinessLogic = sdFactoryBusinessLogic; - _dapsService = dapsService; + _identityService = identityService; } /// - public Task> GetAllCompanyConnectorDatas(Guid companyId, int page, int size) + public Task> GetAllCompanyConnectorDatas(int page, int size) { - var connectors = _portalRepositories.GetInstance().GetAllCompanyConnectorsForIamUser(companyId); + var connectors = _portalRepositories.GetInstance().GetAllCompanyConnectorsForCompanyId(_identityService.IdentityData.CompanyId); return Pagination.CreateResponseAsync(page, size, _settings.MaxPageSize, (skip, take) => new Pagination.AsyncSource @@ -92,15 +91,16 @@ public ConnectorsBusinessLogic(IPortalRepositories portalRepositories, IOptions< } /// - public Task> GetManagedConnectorForCompany(Guid companyId, int page, int size) => + public Task> GetManagedConnectorForCompany(int page, int size) => Pagination.CreateResponseAsync( page, size, _settings.MaxPageSize, - _portalRepositories.GetInstance().GetManagedConnectorsForCompany(companyId)); + _portalRepositories.GetInstance().GetManagedConnectorsForCompany(_identityService.IdentityData.CompanyId)); - public async Task GetCompanyConnectorData(Guid connectorId, Guid companyId) + public async Task GetCompanyConnectorData(Guid connectorId) { + var companyId = _identityService.IdentityData.CompanyId; var result = await _portalRepositories.GetInstance().GetConnectorByIdForCompany(connectorId, companyId).ConfigureAwait(false); if (result == default) { @@ -114,30 +114,16 @@ public async Task GetCompanyConnectorData(Guid connectorId, Guid } /// - public Task CreateConnectorAsync(ConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken) - { - ValidateCertificationType(connectorInputModel.Certificate); - return CreateConnectorInternalAsync(connectorInputModel, companyId, cancellationToken); - } + public Task CreateConnectorAsync(ConnectorInputModel connectorInputModel, CancellationToken cancellationToken) => + CreateConnectorInternalAsync(connectorInputModel, cancellationToken); - public Task CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken) - { - ValidateCertificationType(connectorInputModel.Certificate); - return CreateManagedConnectorInternalAsync(connectorInputModel, companyId, cancellationToken); - } - - private void ValidateCertificationType(IFormFile? certificate) - { - if (certificate != null && !_settings.ValidCertificationContentTypes.Contains(certificate.ContentType)) - { - throw new UnsupportedMediaTypeException( - $"Only {string.Join(",", _settings.ValidCertificationContentTypes)} files are allowed."); - } - } + public Task CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, CancellationToken cancellationToken) => + CreateManagedConnectorInternalAsync(connectorInputModel, cancellationToken); - private async Task CreateConnectorInternalAsync(ConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken) + private async Task CreateConnectorInternalAsync(ConnectorInputModel connectorInputModel, CancellationToken cancellationToken) { - var (name, connectorUrl, location, certificate, technicalUserId) = connectorInputModel; + var companyId = _identityService.IdentityData.CompanyId; + var (name, connectorUrl, location, technicalUserId) = connectorInputModel; await CheckLocationExists(location); var result = await _portalRepositories @@ -161,14 +147,14 @@ private async Task CreateConnectorInternalAsync(ConnectorInputModel connec connectorRequestModel, result.Bpn, result.SelfDescriptionDocumentId.Value, - certificate, null, cancellationToken).ConfigureAwait(false); } - private async Task CreateManagedConnectorInternalAsync(ManagedConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken) + private async Task CreateManagedConnectorInternalAsync(ManagedConnectorInputModel connectorInputModel, CancellationToken cancellationToken) { - var (name, connectorUrl, location, subscriptionId, certificate, technicalUserId) = connectorInputModel; + var companyId = _identityService.IdentityData.CompanyId; + var (name, connectorUrl, location, subscriptionId, technicalUserId) = connectorInputModel; await CheckLocationExists(location).ConfigureAwait(false); var result = await _portalRepositories.GetInstance() @@ -213,7 +199,6 @@ private async Task CreateManagedConnectorInternalAsync(ManagedConnectorInp connectorRequestModel, result.ProviderBpn, result.SelfDescriptionDocumentId!.Value, - certificate, subscriptionId, cancellationToken).ConfigureAwait(false); } @@ -245,7 +230,6 @@ private async Task CreateAndRegisterConnectorAsync( ConnectorRequestModel connectorInputModel, string businessPartnerNumber, Guid selfDescriptionDocumentId, - IFormFile? file, Guid? subscriptionId, CancellationToken cancellationToken) { @@ -262,6 +246,7 @@ private async Task CreateAndRegisterConnectorAsync( connector.HostId = host; connector.TypeId = type; connector.DateLastChanged = DateTimeOffset.UtcNow; + connector.StatusId = ConnectorStatusId.PENDING; if (technicalUserId != null) { connector.CompanyServiceAccountId = technicalUserId; @@ -273,33 +258,6 @@ private async Task CreateAndRegisterConnectorAsync( connectorsRepository.CreateConnectorAssignedSubscriptions(createdConnector.Id, subscriptionId.Value); } - DapsResponse? response = null; - if (file is not null) - { - try - { - response = await _dapsService - .EnableDapsAuthAsync(name, connectorUrl, businessPartnerNumber, file, cancellationToken) - .ConfigureAwait(false); - } - catch (ServiceException) - { - // No error should be visible for the user - } - } - - if (!string.IsNullOrWhiteSpace(response?.ClientId)) - { - connectorsRepository.CreateConnectorClientDetails(createdConnector.Id, response.ClientId); - createdConnector.DapsRegistrationSuccessful = true; - createdConnector.StatusId = ConnectorStatusId.ACTIVE; - } - else - { - createdConnector.DapsRegistrationSuccessful = false; - createdConnector.StatusId = ConnectorStatusId.PENDING; - } - var selfDescriptionDocumentUrl = $"{_settings.SelfDescriptionDocumentUrl}/{selfDescriptionDocumentId}"; await _sdFactoryBusinessLogic .RegisterConnectorAsync(createdConnector.Id, selfDescriptionDocumentUrl, businessPartnerNumber, cancellationToken) @@ -310,11 +268,11 @@ await _sdFactoryBusinessLogic } /// - public async Task DeleteConnectorAsync(Guid connectorId, Guid companyId, CancellationToken cancellationToken) + public async Task DeleteConnectorAsync(Guid connectorId) { + var companyId = _identityService.IdentityData.CompanyId; var connectorsRepository = _portalRepositories.GetInstance(); - var (isValidConnectorId, isProvidingOrHostCompany, dapsClientId, selfDescriptionDocumentId, - documentStatus, connectorStatus, dapsRegistrationSuccess) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false); + var (isValidConnectorId, isProvidingOrHostCompany, selfDescriptionDocumentId, documentStatusId, connectorStatus) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false); if (!isValidConnectorId) { @@ -326,51 +284,39 @@ public async Task DeleteConnectorAsync(Guid connectorId, Guid companyId, Cancell throw new ForbiddenException($"company {companyId} is neither provider nor host-company of connector {connectorId}"); } - switch ((dapsRegistrationSuccess ?? false, connectorStatus)) + switch (connectorStatus) { - case (true, ConnectorStatusId.ACTIVE) when selfDescriptionDocumentId == null: - await DeleteUpdateConnectorDetail(connectorId, dapsClientId, connectorsRepository, cancellationToken); - break; - case (true, ConnectorStatusId.ACTIVE) when selfDescriptionDocumentId != null && documentStatus != null: - await DeleteConnector(connectorId, dapsClientId, selfDescriptionDocumentId.Value, documentStatus.Value, connectorsRepository, cancellationToken); - break; - case (false, ConnectorStatusId.PENDING) when selfDescriptionDocumentId == null: + case ConnectorStatusId.PENDING when selfDescriptionDocumentId == null: await DeleteConnectorWithoutDocuments(connectorId, connectorsRepository); break; - case (false, ConnectorStatusId.PENDING) when selfDescriptionDocumentId != null: + case ConnectorStatusId.PENDING: await DeleteConnectorWithDocuments(connectorId, selfDescriptionDocumentId.Value, connectorsRepository); break; - case (true, ConnectorStatusId.ACTIVE) when selfDescriptionDocumentId != null && documentStatus == null: - throw new UnexpectedConditionException("documentStatus should never be null here"); + case ConnectorStatusId.ACTIVE when selfDescriptionDocumentId != null && documentStatusId != null: + await DeleteConnector(connectorId, selfDescriptionDocumentId.Value, documentStatusId.Value, connectorsRepository); + break; default: - throw new ConflictException($"Connector status does not match a deletion scenario. Deletion declined"); + throw new ConflictException("Connector status does not match a deletion scenario. Deletion declined"); } } - private async Task DeleteConnector(Guid connectorId, string? dapsClientId, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository, CancellationToken cancellationToken) + private async Task DeleteConnector(Guid connectorId, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository) { _portalRepositories.GetInstance().AttachAndModifyDocument( selfDescriptionDocumentId, a => { a.DocumentStatusId = documentStatus; }, a => { a.DocumentStatusId = DocumentStatusId.INACTIVE; }); - await DeleteUpdateConnectorDetail(connectorId, dapsClientId, connectorsRepository, cancellationToken); + await DeleteUpdateConnectorDetail(connectorId, connectorsRepository); } - private async Task DeleteUpdateConnectorDetail(Guid connectorId, string? dapsClientId, IConnectorsRepository connectorsRepository, CancellationToken cancellationToken) + private async Task DeleteUpdateConnectorDetail(Guid connectorId, IConnectorsRepository connectorsRepository) { - if (string.IsNullOrWhiteSpace(dapsClientId)) - { - throw new ConflictException("DapsClientId must be set"); - } - - connectorsRepository.DeleteConnectorClientDetails(connectorId); connectorsRepository.AttachAndModifyConnector(connectorId, null, con => { con.StatusId = ConnectorStatusId.INACTIVE; con.DateLastChanged = DateTimeOffset.UtcNow; }); - await _dapsService.DeleteDapsClient(dapsClientId, cancellationToken).ConfigureAwait(false); await _portalRepositories.SaveAsync(); } @@ -405,48 +351,7 @@ public IAsyncEnumerable GetCompanyConnectorEndPointAsync( } /// - public async Task TriggerDapsAsync(Guid connectorId, IFormFile certificate, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken) - { - var connectorsRepository = _portalRepositories - .GetInstance(); - var connector = await connectorsRepository - .GetConnectorInformationByIdForIamUser(connectorId, identity.CompanyId) - .ConfigureAwait(false); - - if (connector == default) - { - throw new NotFoundException($"Connector {connectorId} does not exists"); - } - - if (!connector.IsProviderUser) - { - throw new ForbiddenException("User is not provider of the connector"); - } - - var connectorData = connector.ConnectorInformationData; - var response = await _dapsService - .EnableDapsAuthAsync(connectorData.Name, connectorData.Url, connectorData.Bpn, certificate, cancellationToken) - .ConfigureAwait(false); - if (string.IsNullOrWhiteSpace(response?.ClientId)) - { - throw new ConflictException("Client Id should be set here"); - } - - connectorsRepository.AttachAndModifyConnector(connectorId, null, con => - { - con.DapsRegistrationSuccessful = true; - con.StatusId = ConnectorStatusId.ACTIVE; - con.DateLastChanged = DateTimeOffset.UtcNow; - }); - - connectorsRepository.CreateConnectorClientDetails(connectorId, response.ClientId); - - await _portalRepositories.SaveAsync().ConfigureAwait(false); - return true; - } - - /// - public async Task ProcessClearinghouseSelfDescription(SelfDescriptionResponseData data, Guid userId, CancellationToken cancellationToken) + public async Task ProcessClearinghouseSelfDescription(SelfDescriptionResponseData data, CancellationToken cancellationToken) { var result = await _portalRepositories.GetInstance() .GetConnectorDataById(data.ExternalId) @@ -462,19 +367,20 @@ public async Task ProcessClearinghouseSelfDescription(SelfDescriptionResponseDat throw new ConflictException($"Connector {data.ExternalId} already has a document assigned"); } - await _sdFactoryBusinessLogic.ProcessFinishSelfDescriptionLpForConnector(data, userId, cancellationToken).ConfigureAwait(false); + await _sdFactoryBusinessLogic.ProcessFinishSelfDescriptionLpForConnector(data, _identityService.IdentityData.UserId, cancellationToken).ConfigureAwait(false); await _portalRepositories.SaveAsync().ConfigureAwait(false); } /// - public Task UpdateConnectorUrl(Guid connectorId, ConnectorUpdateRequest data, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken) + public Task UpdateConnectorUrl(Guid connectorId, ConnectorUpdateRequest data) { data.ConnectorUrl.EnsureValidHttpUrl(() => nameof(data.ConnectorUrl)); - return UpdateConnectorUrlInternal(connectorId, data, identity, cancellationToken); + return UpdateConnectorUrlInternal(connectorId, data); } - private async Task UpdateConnectorUrlInternal(Guid connectorId, ConnectorUpdateRequest data, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken) + private async Task UpdateConnectorUrlInternal(Guid connectorId, ConnectorUpdateRequest data) { + var identity = _identityService.IdentityData; var connectorsRepository = _portalRepositories .GetInstance(); var connector = await connectorsRepository @@ -501,11 +407,6 @@ private async Task UpdateConnectorUrlInternal(Guid connectorId, ConnectorUpdateR throw new ConflictException($"Connector {connectorId} is in state {ConnectorStatusId.INACTIVE}"); } - if (string.IsNullOrWhiteSpace(connector.DapsClientId)) - { - throw new ConflictException($"Connector {connectorId} has no client id"); - } - var bpn = connector.Type == ConnectorTypeId.CONNECTOR_AS_A_SERVICE ? connector.Bpn : await _portalRepositories.GetInstance() @@ -516,9 +417,6 @@ private async Task UpdateConnectorUrlInternal(Guid connectorId, ConnectorUpdateR throw new ConflictException("The business partner number must be set here"); } - await _dapsService - .UpdateDapsConnectorUrl(connector.DapsClientId, data.ConnectorUrl, bpn, cancellationToken) - .ConfigureAwait(false); connectorsRepository.AttachAndModifyConnector(connectorId, null, con => { con.ConnectorUrl = data.ConnectorUrl; @@ -528,7 +426,7 @@ await _dapsService } /// - public IAsyncEnumerable GetConnectorOfferSubscriptionData(bool? connectorIdSet, Guid companyId) => + public IAsyncEnumerable GetConnectorOfferSubscriptionData(bool? connectorIdSet) => _portalRepositories.GetInstance() - .GetConnectorOfferSubscriptionData(connectorIdSet, companyId); + .GetConnectorOfferSubscriptionData(connectorIdSet, _identityService.IdentityData.CompanyId); } diff --git a/src/administration/Administration.Service/BusinessLogic/IConnectorsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/IConnectorsBusinessLogic.cs index 20a3b87e04..e53e19c060 100644 --- a/src/administration/Administration.Service/BusinessLogic/IConnectorsBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/IConnectorsBusinessLogic.cs @@ -33,48 +33,42 @@ public interface IConnectorsBusinessLogic /// /// Get all of a user's company's connectors by iam user ID. /// - /// company to retrieve connectors for. /// /// /// AsyncEnumerable of the result connectors. - Task> GetAllCompanyConnectorDatas(Guid companyId, int page, int size); + Task> GetAllCompanyConnectorDatas(int page, int size); /// /// Get all of a user's company's connectors by iam user ID. /// - /// /// /// /// AsyncEnumerable of the result connectors. - Task> GetManagedConnectorForCompany(Guid companyId, int page, int size); + Task> GetManagedConnectorForCompany(int page, int size); - Task GetCompanyConnectorData(Guid connectorId, Guid companyId); + Task GetCompanyConnectorData(Guid connectorId); /// /// Add a connector to persistence layer and calls the sd factory service with connector parameters. /// /// Connector parameters for creation. - /// companyId of the user /// /// View model of created connector. - Task CreateConnectorAsync(ConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken); + Task CreateConnectorAsync(ConnectorInputModel connectorInputModel, CancellationToken cancellationToken); /// /// Add a managed connector to persistence layer and calls the sd factory service with connector parameters. /// /// Connector parameters for creation. - /// companyId of the user /// /// View model of created connector. - Task CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, Guid companyId, CancellationToken cancellationToken); + Task CreateManagedConnectorAsync(ManagedConnectorInputModel connectorInputModel, CancellationToken cancellationToken); /// /// Remove a connector from persistence layer by id. /// /// ID of the connector to be deleted. - /// companyId of the user - /// Cancellation Token - Task DeleteConnectorAsync(Guid connectorId, Guid companyId, CancellationToken cancellationToken); + Task DeleteConnectorAsync(Guid connectorId); /// /// Retrieve connector end point along with bpns @@ -83,32 +77,19 @@ public interface IConnectorsBusinessLogic /// IAsyncEnumerable GetCompanyConnectorEndPointAsync(IEnumerable bpns); - /// - /// Triggers the daps endpoint for the given trigger - /// - /// Id of the connector the endpoint should get triggered for. - /// The certificate - /// identity (userId and companyId) of the user - /// - /// true if the call to daps was successful, otherwise false. - Task TriggerDapsAsync(Guid connectorId, IFormFile certificate, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken); - /// /// Processes the clearinghouse self description /// /// The response data - /// Id of the user /// CancellationToken - Task ProcessClearinghouseSelfDescription(SelfDescriptionResponseData data, Guid userId, CancellationToken cancellationToken); + Task ProcessClearinghouseSelfDescription(SelfDescriptionResponseData data, CancellationToken cancellationToken); /// /// Update the connector url /// /// Id of the connector /// Update data for the connector - /// identity (userId and companyId) of the user - /// CancellationToken - Task UpdateConnectorUrl(Guid connectorId, ConnectorUpdateRequest data, (Guid UserId, Guid CompanyId) identity, CancellationToken cancellationToken); + Task UpdateConnectorUrl(Guid connectorId, ConnectorUpdateRequest data); /// /// Gets the offer subscription data @@ -117,7 +98,6 @@ public interface IConnectorsBusinessLogic /// Optional: if true only respond with subscriptions where a link to a connector is given, /// if false it will only return subscriptions where no link to an connector exists. /// - /// Id of the company to get the subscriptions for /// Returns an IAsyncEnumerable of - IAsyncEnumerable GetConnectorOfferSubscriptionData(bool? connectorIdSet, Guid companyId); + IAsyncEnumerable GetConnectorOfferSubscriptionData(bool? connectorIdSet); } diff --git a/src/administration/Administration.Service/Controllers/ConnectorsController.cs b/src/administration/Administration.Service/Controllers/ConnectorsController.cs index fb72b9a05e..d7cb8d9ad8 100644 --- a/src/administration/Administration.Service/Controllers/ConnectorsController.cs +++ b/src/administration/Administration.Service/Controllers/ConnectorsController.cs @@ -66,7 +66,7 @@ public ConnectorsController(IConnectorsBusinessLogic connectorsBusinessLogic) [Authorize(Policy = PolicyTypes.ValidCompany)] [ProducesResponseType(typeof(Pagination.Response), StatusCodes.Status200OK)] public Task> GetCompanyConnectorsForCurrentUserAsync([FromQuery] int page = 0, [FromQuery] int size = 15) => - this.WithCompanyId(companyId => _businessLogic.GetAllCompanyConnectorDatas(companyId, page, size)); + _businessLogic.GetAllCompanyConnectorDatas(page, size); /// /// Retrieves all company connectors for currently logged in user. @@ -85,7 +85,7 @@ public ConnectorsController(IConnectorsBusinessLogic connectorsBusinessLogic) [Authorize(Policy = PolicyTypes.ValidCompany)] [ProducesResponseType(typeof(Pagination.Response), StatusCodes.Status200OK)] public Task> GetManagedConnectorsForCurrentUserAsync([FromQuery] int page = 0, [FromQuery] int size = 15) => - this.WithCompanyId(companyId => _businessLogic.GetManagedConnectorForCompany(companyId, page, size)); + _businessLogic.GetManagedConnectorForCompany(page, size); /// /// Retrieves company connector details for the given connetor id. @@ -103,7 +103,7 @@ public ConnectorsController(IConnectorsBusinessLogic connectorsBusinessLogic) [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] public Task GetCompanyConnectorByIdForCurrentUserAsync([FromRoute] Guid connectorId) => - this.WithCompanyId(companyId => _businessLogic.GetCompanyConnectorData(connectorId, companyId)); + _businessLogic.GetCompanyConnectorData(connectorId); /// /// Creates a new connector with provided parameters from body, also registers connector at sd factory service. @@ -124,7 +124,7 @@ public Task GetCompanyConnectorByIdForCurrentUserAsync([FromRoute [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status503ServiceUnavailable)] public async Task CreateConnectorAsync([FromForm] ConnectorInputModel connectorInputModel, CancellationToken cancellationToken) { - var connectorId = await this.WithCompanyId(companyId => _businessLogic.CreateConnectorAsync(connectorInputModel, companyId, cancellationToken)).ConfigureAwait(false); + var connectorId = await _businessLogic.CreateConnectorAsync(connectorInputModel, cancellationToken).ConfigureAwait(false); return CreatedAtRoute(nameof(GetCompanyConnectorByIdForCurrentUserAsync), new { connectorId }, connectorId); } @@ -147,41 +147,14 @@ public async Task CreateConnectorAsync([FromForm] Connecto [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status503ServiceUnavailable)] public async Task CreateManagedConnectorAsync([FromForm] ManagedConnectorInputModel connectorInputModel, CancellationToken cancellationToken) { - var connectorId = await this.WithCompanyId(companyId => _businessLogic.CreateManagedConnectorAsync(connectorInputModel, companyId, cancellationToken)).ConfigureAwait(false); + var connectorId = await _businessLogic.CreateManagedConnectorAsync(connectorInputModel, cancellationToken).ConfigureAwait(false); return CreatedAtRoute(nameof(GetCompanyConnectorByIdForCurrentUserAsync), new { connectorId }, connectorId); } - /// - /// Triggers the daps endpoint for the given connector. - /// - /// Id of the connector to trigger the daps call. - /// - /// Cancellation Token - /// View model of the created connector. - /// Example: POST: /api/administration/connectors/trigger-daps/5636F9B9-C3DE-4BA5-8027-00D17A2FECFB - /// Returns true if the daps call was successful, otherwise false. - /// Input parameter are invalid. - /// Connector was not found. - /// Access to SD factory failed with the given status code. - /// user does not belong to company of companyUserId. - [Obsolete("this endpoint will be removed in the near future")] - [HttpPost] - [Route("trigger-daps/{connectorId:guid}")] - [Authorize(Roles = "notexistingrole")] - [Authorize(Policy = PolicyTypes.ValidCompany)] - [ProducesResponseType(typeof(bool), StatusCodes.Status200OK)] - [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status400BadRequest)] - [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] - [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status503ServiceUnavailable)] - [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)] - public async Task TriggerDapsAuth([FromRoute] Guid connectorId, [FromForm] IFormFile certificate, CancellationToken cancellationToken) => - await this.WithUserIdAndCompanyId(identity => _businessLogic.TriggerDapsAsync(connectorId, certificate, identity, cancellationToken)).ConfigureAwait(false); - /// /// Removes a connector from persistence layer by id. /// /// ID of the connector to be deleted. - /// cancellation token /// Example: DELETE: /api/administration/connectors/5636F9B9-C3DE-4BA5-8027-00D17A2FECFB /// Empty response on success. /// Record not found. @@ -193,9 +166,9 @@ public async Task TriggerDapsAuth([FromRoute] Guid connectorId, [FromForm] [ProducesResponseType(typeof(IActionResult), StatusCodes.Status204NoContent)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status409Conflict)] - public async Task DeleteConnectorAsync([FromRoute] Guid connectorId, CancellationToken cancellationToken) + public async Task DeleteConnectorAsync([FromRoute] Guid connectorId) { - await this.WithCompanyId(companyId => _businessLogic.DeleteConnectorAsync(connectorId, companyId, cancellationToken)); + await _businessLogic.DeleteConnectorAsync(connectorId); return NoContent(); } @@ -230,7 +203,7 @@ public IAsyncEnumerable GetCompanyConnectorEndPointAsync( [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] public async Task ProcessClearinghouseSelfDescription([FromBody] SelfDescriptionResponseData data, CancellationToken cancellationToken) { - await this.WithUserId(userId => _businessLogic.ProcessClearinghouseSelfDescription(data, userId, cancellationToken).ConfigureAwait(false)); + await _businessLogic.ProcessClearinghouseSelfDescription(data, cancellationToken).ConfigureAwait(false); return NoContent(); } @@ -239,7 +212,6 @@ public async Task ProcessClearinghouseSelfDescription([FromBody /// /// Id of the connector to trigger the daps call. /// The update data - /// Cancellation Token /// NoContent Result. /// Example: PUT: /api/administration/connectors/{connectorId}/connectorUrl /// Url was successfully updated. @@ -256,9 +228,9 @@ public async Task ProcessClearinghouseSelfDescription([FromBody [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status403Forbidden)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status404NotFound)] [ProducesResponseType(typeof(ErrorResponse), StatusCodes.Status503ServiceUnavailable)] - public async Task UpdateConnectorUrl([FromRoute] Guid connectorId, [FromBody] ConnectorUpdateRequest data, CancellationToken cancellationToken) + public async Task UpdateConnectorUrl([FromRoute] Guid connectorId, [FromBody] ConnectorUpdateRequest data) { - await this.WithUserIdAndCompanyId(identity => _businessLogic.UpdateConnectorUrl(connectorId, data, identity, cancellationToken)) + await _businessLogic.UpdateConnectorUrl(connectorId, data) .ConfigureAwait(false); return NoContent(); } @@ -277,5 +249,5 @@ await this.WithUserIdAndCompanyId(identity => _businessLogic.UpdateConnectorUrl( [Authorize(Roles = "view_connectors")] [ProducesResponseType(typeof(IAsyncEnumerable), StatusCodes.Status200OK)] public IAsyncEnumerable GetConnectorOfferSubscriptionData([FromQuery] bool? connectorIdSet) => - this.WithCompanyId(companyId => _businessLogic.GetConnectorOfferSubscriptionData(connectorIdSet, companyId)); + _businessLogic.GetConnectorOfferSubscriptionData(connectorIdSet); } diff --git a/src/administration/Administration.Service/Models/ConnectorInputModel.cs b/src/administration/Administration.Service/Models/ConnectorInputModel.cs index a512107bcb..6052915870 100644 --- a/src/administration/Administration.Service/Models/ConnectorInputModel.cs +++ b/src/administration/Administration.Service/Models/ConnectorInputModel.cs @@ -35,7 +35,6 @@ public record ConnectorInputModel( [MaxLength(255)] string Name, [MaxLength(255)] string ConnectorUrl, [StringLength(2, MinimumLength = 2)] string Location, - IFormFile? Certificate, Guid? TechnicalUserId ); @@ -46,14 +45,12 @@ public record ConnectorInputModel( /// URL of the connector.. /// Connector's location country code. /// Id of the offer subscription. -/// The certificate for the daps call. /// Id of the technical user. public record ManagedConnectorInputModel( [MaxLength(255)] string Name, [MaxLength(255)] string ConnectorUrl, [StringLength(2, MinimumLength = 2)] string Location, Guid SubscriptionId, - IFormFile? Certificate, Guid? TechnicalUserId ); diff --git a/src/administration/Administration.Service/Program.cs b/src/administration/Administration.Service/Program.cs index c606f32860..f2bdeca371 100644 --- a/src/administration/Administration.Service/Program.cs +++ b/src/administration/Administration.Service/Program.cs @@ -20,7 +20,6 @@ using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.DependencyInjection; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library; using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.Mailing.SendMail; using Org.Eclipse.TractusX.Portal.Backend.Notifications.Library; @@ -67,8 +66,7 @@ builder.Services.AddTransient() .ConfigureIdentityProviderSettings(builder.Configuration.GetSection("IdentityProviderAdmin")); - builder.Services.AddDapsService(builder.Configuration) - .AddApplicationChecklist(builder.Configuration.GetSection("ApplicationChecklist")) + builder.Services.AddApplicationChecklist(builder.Configuration.GetSection("ApplicationChecklist")) .AddOfferSubscriptionProcess(); builder.Services.AddTransient() diff --git a/src/administration/Administration.Service/appsettings.json b/src/administration/Administration.Service/appsettings.json index a245a498ad..303206eff5 100644 --- a/src/administration/Administration.Service/appsettings.json +++ b/src/administration/Administration.Service/appsettings.json @@ -256,17 +256,6 @@ "ApplicationsMaxPageSize": 20, "DocumentTypeIds": [] }, - "Daps":{ - "IsActive": true, - "DapsUrl": "", - "Username": "", - "Password": "", - "ClientId": "", - "GrantType": "", - "ClientSecret": "", - "Scope": "", - "KeycloakTokenAddress": "" - }, "Invitation": { "RegistrationAppAddress": "https://portal.example.org/registration", "InvitedUserInitialRoles": [], diff --git a/src/externalsystems/Daps.Library/Daps.Library.csproj b/src/externalsystems/Daps.Library/Daps.Library.csproj deleted file mode 100644 index ebdd26117e..0000000000 --- a/src/externalsystems/Daps.Library/Daps.Library.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - net6.0 - enable - enable - Org.Eclipse.TractusX.Portal.Backend.Daps.Library - Org.Eclipse.TractusX.Portal.Backend.Daps.Library - - - - - - - - - - - - - - - - - diff --git a/src/externalsystems/Daps.Library/DapsService.cs b/src/externalsystems/Daps.Library/DapsService.cs deleted file mode 100644 index b8c7ec8dcd..0000000000 --- a/src/externalsystems/Daps.Library/DapsService.cs +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.HttpClientExtensions; -using Org.Eclipse.TractusX.Portal.Backend.Framework.IO; -using Org.Eclipse.TractusX.Portal.Backend.Framework.Token; -using System.Net.Http.Json; -using System.Text.Json; - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library; - -public class DapsService : IDapsService -{ - private const string BaseSecurityProfile = "BASE_SECURITY_PROFILE"; - private static readonly JsonSerializerOptions Options = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; - private readonly ITokenService _tokenService; - private readonly ILogger _logger; - private readonly DapsSettings _settings; - - /// - /// Creates a new instance of - /// - /// - /// - /// - public DapsService(ITokenService tokenService, ILogger logger, IOptions options) - { - _tokenService = tokenService; - _logger = logger; - _settings = options.Value; - } - - /// - public Task EnableDapsAuthAsync(string clientName, string connectorUrl, string businessPartnerNumber, IFormFile formFile, CancellationToken cancellationToken) - { - if (!CheckDapsIsActive("daps-post")) - { - return Task.FromResult(null); - } - - connectorUrl.EnsureValidHttpUrl(() => nameof(connectorUrl)); - return HandleRequest(clientName, connectorUrl, businessPartnerNumber, formFile, cancellationToken); - } - - private async Task HandleRequest(string clientName, string connectorUrl, string businessPartnerNumber, - IFormFile formFile, CancellationToken cancellationToken) - { - var httpClient = await _tokenService.GetAuthorizedClient(_settings, cancellationToken).ConfigureAwait(false); - - using var stream = formFile.OpenReadStream(); - - var multiPartStream = new MultipartFormDataContent(); - multiPartStream.Add(new StreamContent(stream), "file", formFile.FileName); - multiPartStream.Add(new StringContent(clientName), "clientName"); - multiPartStream.Add(new StringContent(BaseSecurityProfile), "securityProfile"); - multiPartStream.Add(new StringContent(connectorUrl.AppendToPathEncoded(businessPartnerNumber)), "referringConnector"); - - var result = await httpClient.PostAsync(string.Empty, multiPartStream, cancellationToken) - .CatchingIntoServiceExceptionFor("daps-post", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false); - return await result.Content.ReadFromJsonAsync(Options, cancellationToken) - .ConfigureAwait(false); - } - - /// - public async Task DeleteDapsClient(string dapsClientId, CancellationToken cancellationToken) - { - if (!CheckDapsIsActive("daps-delete")) - { - return true; - } - - var httpClient = await _tokenService.GetAuthorizedClient(_settings, cancellationToken).ConfigureAwait(false); - await httpClient.DeleteAsync(dapsClientId, cancellationToken) - .CatchingIntoServiceExceptionFor("daps-delete", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false); - - return true; - } - - /// - public async Task UpdateDapsConnectorUrl(string dapsClientId, string connectorUrl, string businessPartnerNumber, - CancellationToken cancellationToken) - { - if (!CheckDapsIsActive("daps-update")) - { - return true; - } - - var dapsUpdate = new DapsUpdateData(connectorUrl.AppendToPathEncoded(businessPartnerNumber)); - var httpClient = await _tokenService.GetAuthorizedClient(_settings, cancellationToken).ConfigureAwait(false); - await httpClient.PutAsJsonAsync(dapsClientId, dapsUpdate, cancellationToken) - .CatchingIntoServiceExceptionFor("daps-update", HttpAsyncResponseMessageExtension.RecoverOptions.INFRASTRUCTURE).ConfigureAwait(false); - - return true; - } - - private bool CheckDapsIsActive(string callType) - { - if (_settings.IsActive) - { - return true; - } - - _logger.LogInformation($"{callType} call skipped due to daps is disabled"); - return false; - - } -} diff --git a/src/externalsystems/Daps.Library/DapsServiceCollectionExtension.cs b/src/externalsystems/Daps.Library/DapsServiceCollectionExtension.cs deleted file mode 100644 index cc5052c466..0000000000 --- a/src/externalsystems/Daps.Library/DapsServiceCollectionExtension.cs +++ /dev/null @@ -1,46 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Framework.HttpClientExtensions; -using Org.Eclipse.TractusX.Portal.Backend.Framework.Logging; - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library; - -public static class DapsServiceCollectionExtension -{ - public static IServiceCollection AddDapsService(this IServiceCollection services, IConfiguration configuration) - { - services.AddOptions() - .Bind(configuration.GetSection("Daps")) - .ValidateOnStart(); - services.AddTransient>(); - - var sp = services.BuildServiceProvider(); - var settings = sp.GetRequiredService>(); - services - .AddCustomHttpClientWithAuthentication(settings.Value.DapsUrl, settings.Value.KeycloakTokenAddress) - .AddTransient(); - - return services; - } -} diff --git a/src/externalsystems/Daps.Library/DapsSettings.cs b/src/externalsystems/Daps.Library/DapsSettings.cs deleted file mode 100644 index 6d8b4b21bf..0000000000 --- a/src/externalsystems/Daps.Library/DapsSettings.cs +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; -using System.ComponentModel.DataAnnotations; - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library; - -/// -/// Settings used in business logic concerning daps. -/// -public class DapsSettings : KeyVaultAuthSettings -{ - /// - /// If true the daps call will executed like before, if false no daps call will be made - /// - public bool IsActive { get; set; } - - /// - /// Daps endpoint. - /// - [Required] - public string DapsUrl { get; set; } = null!; -} diff --git a/src/externalsystems/Daps.Library/IDapsService.cs b/src/externalsystems/Daps.Library/IDapsService.cs deleted file mode 100644 index 8f1866b977..0000000000 --- a/src/externalsystems/Daps.Library/IDapsService.cs +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -using Microsoft.AspNetCore.Http; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library; - -/// -/// Service to handle communication with the connectors sd factory -/// -public interface IDapsService -{ - /// - /// Registers the Connector at the connectorsSdFactory - /// - /// name of the client - /// the connectors url with the bpn of the company append to it - /// the business partner number - /// The file - /// cancellation token - /// throws an exception if the service call wasn't successfully - Task EnableDapsAuthAsync(string clientName, string connectorUrl, string businessPartnerNumber, IFormFile formFile, CancellationToken cancellationToken); - - /// - /// Deletes the daps client - /// - /// name of the client - /// cancellation token - /// throws an exception if the service call wasn't successfully - Task DeleteDapsClient(string dapsClientId, CancellationToken cancellationToken); - - /// - /// Updates the url of the connector - /// - /// name of the client - /// the connectors url with bpn of the company append to it - /// the business partner number - /// cancellation token - /// throws an exception if the service call wasn't successfully - Task UpdateDapsConnectorUrl(string dapsClientId, string connectorUrl, string businessPartnerNumber, CancellationToken cancellationToken); -} diff --git a/src/externalsystems/Daps.Library/Models/DapsResponse.cs b/src/externalsystems/Daps.Library/Models/DapsResponse.cs deleted file mode 100644 index eb0cd8a597..0000000000 --- a/src/externalsystems/Daps.Library/Models/DapsResponse.cs +++ /dev/null @@ -1,23 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; - -public record DapsResponse(string ClientId); diff --git a/src/externalsystems/Daps.Library/Models/DapsUpdateData.cs b/src/externalsystems/Daps.Library/Models/DapsUpdateData.cs deleted file mode 100644 index da2589f6ac..0000000000 --- a/src/externalsystems/Daps.Library/Models/DapsUpdateData.cs +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -using System.Text.Json.Serialization; - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; - -public record DapsUpdateData( - [property: JsonPropertyName("referringConnector")] - string ReferringConnector -); diff --git a/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs b/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs index bb79494fd2..2e5df85397 100644 --- a/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs +++ b/src/externalsystems/SdFactory.Library/BusinessLogic/SdFactoryBusinessLogic.cs @@ -139,6 +139,7 @@ public async Task ProcessFinishSelfDescriptionLpForConnector(SelfDescriptionResp if (documentId != null) { con.SelfDescriptionDocumentId = documentId; + con.StatusId = ConnectorStatusId.ACTIVE; } if (!confirm) diff --git a/src/portalbackend/PortalBackend.DBAccess/Models/ConnectorUpdateInformation.cs b/src/portalbackend/PortalBackend.DBAccess/Models/ConnectorUpdateInformation.cs index c212924dbb..3a77068c82 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Models/ConnectorUpdateInformation.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Models/ConnectorUpdateInformation.cs @@ -30,5 +30,4 @@ public record ConnectorUpdateInformation( ConnectorTypeId Type, bool IsHostCompany, string ConnectorUrl, - string? Bpn, - string? DapsClientId); + string? Bpn); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs index 141eaf798b..97e0b8b161 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs @@ -42,7 +42,7 @@ public ConnectorsRepository(PortalDbContext portalDbContext) } /// - public IQueryable GetAllCompanyConnectorsForIamUser(Guid companyId) => + public IQueryable GetAllCompanyConnectorsForCompanyId(Guid companyId) => _context.Connectors .AsNoTracking() .Where(x => x.ProviderId == companyId && x.StatusId != ConnectorStatusId.INACTIVE); @@ -137,27 +137,17 @@ public Connector AttachAndModifyConnector(Guid connectorId, Action? i .SingleOrDefaultAsync(); /// - public Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, string? DapsClientId, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, bool? DapsRegistrationSuccessful)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId) => + public Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId) => _context.Connectors .Where(x => x.Id == connectorId) - .Select(connector => new ValueTuple( + .Select(connector => new ValueTuple( true, connector.ProviderId == companyId || connector.HostId == companyId, - connector.ClientDetails == null ? null : connector.ClientDetails!.ClientId, connector.SelfDescriptionDocumentId, connector.SelfDescriptionDocument!.DocumentStatusId, - connector.StatusId, - connector.DapsRegistrationSuccessful + connector.StatusId )).SingleOrDefaultAsync(); - /// - public void CreateConnectorClientDetails(Guid connectorId, string dapsClientId) => - _context.ConnectorClientDetails.Add(new ConnectorClientDetail(connectorId, dapsClientId)); - - /// - public void DeleteConnectorClientDetails(Guid connectorId) => - _context.ConnectorClientDetails.Remove(new ConnectorClientDetail(connectorId, null!)); - /// public Task GetConnectorUpdateInformation(Guid connectorId, Guid companyId) => _context.Connectors @@ -167,8 +157,7 @@ public void DeleteConnectorClientDetails(Guid connectorId) => c.TypeId, c.HostId == companyId, c.ConnectorUrl, - c.Provider!.BusinessPartnerNumber, - c.ClientDetails!.ClientId + c.Provider!.BusinessPartnerNumber )) .SingleOrDefaultAsync(); diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs index 43c38e20b1..7a0a94d29b 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs @@ -35,7 +35,7 @@ public interface IConnectorsRepository /// /// The id of the provider company. /// Queryable of connectors that allows transformation. - IQueryable GetAllCompanyConnectorsForIamUser(Guid companyId); + IQueryable GetAllCompanyConnectorsForCompanyId(Guid companyId); /// /// Get all managed connectors of a user's company by iam user ID. @@ -87,20 +87,7 @@ public interface IConnectorsRepository /// Id of the connector /// Id of the company /// returns SelfDescriptionDocument Data/c> - Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, string? DapsClientId, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, bool? DapsRegistrationSuccessful)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId); - - /// - /// Creates the connector details - /// - /// Id of the connector - /// client id of daps - void CreateConnectorClientDetails(Guid connectorId, string dapsClientId); - - /// - /// Deletes the connector client details - /// - /// Id of the connector - void DeleteConnectorClientDetails(Guid connectorId); + Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId); /// /// Gets the data required for the connector update diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs new file mode 100644 index 0000000000..1351d02498 --- /dev/null +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs @@ -0,0 +1,7248 @@ +/******************************************************************************** + * Copyright (c) 2021, 2023 BMW Group AG + * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; + +#nullable disable + +namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.Migrations.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20230803131109_CPLP-3105-RemoveDaps")] + partial class CPLP3105RemoveDaps + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasDefaultSchema("portal") + .UseCollation("en_US.utf8") + .HasAnnotation("ProductVersion", "6.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditAppSubscriptionDetail20221118", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AppInstanceId") + .HasColumnType("uuid") + .HasColumnName("app_instance_id"); + + b.Property("AppSubscriptionUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("app_subscription_url"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferSubscriptionId") + .HasColumnType("uuid") + .HasColumnName("offer_subscription_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_app_subscription_detail20221118"); + + b.ToTable("audit_app_subscription_detail20221118", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditCompanyApplication20221005", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("ApplicationStatusId") + .HasColumnType("integer") + .HasColumnName("application_status_id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_application20221005"); + + b.ToTable("audit_company_application20221005", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditCompanyApplication20230214", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("ApplicationStatusId") + .HasColumnType("integer") + .HasColumnName("application_status_id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("ChecklistProcessId") + .HasColumnType("uuid") + .HasColumnName("checklist_process_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_application20230214"); + + b.ToTable("audit_company_application20230214", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditCompanyAssignedRole2023316", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanyRoleId") + .HasColumnType("integer") + .HasColumnName("company_role_id"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_assigned_role2023316"); + + b.ToTable("audit_company_assigned_role2023316", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditCompanyUser20221005", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanyUserStatusId") + .HasColumnType("integer") + .HasColumnName("company_user_status_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Email") + .HasColumnType("text") + .HasColumnName("email"); + + b.Property("Firstname") + .HasColumnType("text") + .HasColumnName("firstname"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("Lastlogin") + .HasColumnType("bytea") + .HasColumnName("lastlogin"); + + b.Property("Lastname") + .HasColumnType("text") + .HasColumnName("lastname"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_user20221005"); + + b.ToTable("audit_company_user20221005", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditCompanyUser20230522", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Email") + .HasColumnType("text") + .HasColumnName("email"); + + b.Property("Firstname") + .HasColumnType("text") + .HasColumnName("firstname"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("Lastlogin") + .HasColumnType("bytea") + .HasColumnName("lastlogin"); + + b.Property("Lastname") + .HasColumnType("text") + .HasColumnName("lastname"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_user20230523"); + + b.ToTable("audit_company_user20230523", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditCompanyUserAssignedRole20221018", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("UserRoleId") + .HasColumnType("uuid") + .HasColumnName("user_role_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_user_assigned_role20221018"); + + b.ToTable("audit_company_user_assigned_role20221018", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditConnector20230405", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("ConnectorUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("connector_url"); + + b.Property("DapsRegistrationSuccessful") + .HasColumnType("boolean") + .HasColumnName("daps_registration_successful"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("HostId") + .HasColumnType("uuid") + .HasColumnName("host_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LocationId") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)") + .HasColumnName("location_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("ProviderId") + .HasColumnType("uuid") + .HasColumnName("provider_id"); + + b.Property("SelfDescriptionDocumentId") + .HasColumnType("uuid") + .HasColumnName("self_description_document_id"); + + b.Property("SelfDescriptionMessage") + .HasColumnType("text") + .HasColumnName("self_description_message"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_connector20230405"); + + b.ToTable("audit_connector20230405", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditConnector20230503", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyServiceAccountId") + .HasColumnType("uuid") + .HasColumnName("company_service_account_id"); + + b.Property("ConnectorUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("connector_url"); + + b.Property("DapsRegistrationSuccessful") + .HasColumnType("boolean") + .HasColumnName("daps_registration_successful"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("HostId") + .HasColumnType("uuid") + .HasColumnName("host_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LocationId") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)") + .HasColumnName("location_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("ProviderId") + .HasColumnType("uuid") + .HasColumnName("provider_id"); + + b.Property("SelfDescriptionDocumentId") + .HasColumnType("uuid") + .HasColumnName("self_description_document_id"); + + b.Property("SelfDescriptionMessage") + .HasColumnType("text") + .HasColumnName("self_description_message"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_connector20230503"); + + b.ToTable("audit_connector20230503", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditConnector20230803", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyServiceAccountId") + .HasColumnType("uuid") + .HasColumnName("company_service_account_id"); + + b.Property("ConnectorUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("connector_url"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("HostId") + .HasColumnType("uuid") + .HasColumnName("host_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LocationId") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)") + .HasColumnName("location_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("ProviderId") + .HasColumnType("uuid") + .HasColumnName("provider_id"); + + b.Property("SelfDescriptionDocumentId") + .HasColumnType("uuid") + .HasColumnName("self_description_document_id"); + + b.Property("SelfDescriptionMessage") + .HasColumnType("text") + .HasColumnName("self_description_message"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_connector20230803"); + + b.ToTable("audit_connector20230803", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditConsent20230412", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AgreementId") + .HasColumnType("uuid") + .HasColumnName("agreement_id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("Comment") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("comment"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("ConsentStatusId") + .HasColumnType("integer") + .HasColumnName("consent_status_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("Target") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("target"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_consent20230412"); + + b.ToTable("audit_consent20230412", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditIdentityAssignedRole20230522", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("IdentityId") + .HasColumnType("uuid") + .HasColumnName("identity_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("UserRoleId") + .HasColumnType("uuid") + .HasColumnName("user_role_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_identity_assigned_role20230522"); + + b.ToTable("audit_identity_assigned_role20230522", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditOffer20230119", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("ContactEmail") + .HasColumnType("text") + .HasColumnName("contact_email"); + + b.Property("ContactNumber") + .HasColumnType("text") + .HasColumnName("contact_number"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DateReleased") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_released"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("MarketingUrl") + .HasColumnType("text") + .HasColumnName("marketing_url"); + + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("OfferStatusId") + .HasColumnType("integer") + .HasColumnName("offer_status_id"); + + b.Property("OfferTypeId") + .HasColumnType("integer") + .HasColumnName("offer_type_id"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .HasColumnName("provider"); + + b.Property("ProviderCompanyId") + .HasColumnType("uuid") + .HasColumnName("provider_company_id"); + + b.Property("SalesManagerId") + .HasColumnType("uuid") + .HasColumnName("sales_manager_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_offer20230119"); + + b.ToTable("audit_offer20230119", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditOffer20230406", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("ContactEmail") + .HasColumnType("text") + .HasColumnName("contact_email"); + + b.Property("ContactNumber") + .HasColumnType("text") + .HasColumnName("contact_number"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DateReleased") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_released"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LicenseTypeId") + .HasColumnType("integer") + .HasColumnName("license_type_id"); + + b.Property("MarketingUrl") + .HasColumnType("text") + .HasColumnName("marketing_url"); + + b.Property("Name") + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("OfferStatusId") + .HasColumnType("integer") + .HasColumnName("offer_status_id"); + + b.Property("OfferTypeId") + .HasColumnType("integer") + .HasColumnName("offer_type_id"); + + b.Property("Provider") + .IsRequired() + .HasColumnType("text") + .HasColumnName("provider"); + + b.Property("ProviderCompanyId") + .HasColumnType("uuid") + .HasColumnName("provider_company_id"); + + b.Property("SalesManagerId") + .HasColumnType("uuid") + .HasColumnName("sales_manager_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_offer20230406"); + + b.ToTable("audit_offer20230406", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditOfferSubscription20221005", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("DisplayName") + .HasColumnType("text") + .HasColumnName("display_name"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("OfferSubscriptionStatusId") + .HasColumnType("integer") + .HasColumnName("offer_subscription_status_id"); + + b.Property("RequesterId") + .HasColumnType("uuid") + .HasColumnName("requester_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_offer_subscription20221005"); + + b.ToTable("audit_offer_subscription20221005", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditOfferSubscription20230317", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("Description") + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("DisplayName") + .HasColumnType("text") + .HasColumnName("display_name"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("OfferSubscriptionStatusId") + .HasColumnType("integer") + .HasColumnName("offer_subscription_status_id"); + + b.Property("ProcessId") + .HasColumnType("uuid") + .HasColumnName("process_id"); + + b.Property("RequesterId") + .HasColumnType("uuid") + .HasColumnName("requester_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_offer_subscription20230317"); + + b.ToTable("audit_offer_subscription20230317", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditProviderCompanyDetail20230614", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("AutoSetupCallbackUrl") + .HasColumnType("text") + .HasColumnName("auto_setup_callback_url"); + + b.Property("AutoSetupUrl") + .IsRequired() + .HasColumnType("text") + .HasColumnName("auto_setup_url"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_provider_company_detail20230614"); + + b.ToTable("audit_provider_company_detail20230614", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditUserRole20221017", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("UserRoleText") + .IsRequired() + .HasColumnType("text") + .HasColumnName("user_role"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_user_role20221017"); + + b.ToTable("audit_user_role20221017", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Address", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("City") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("city"); + + b.Property("CountryAlpha2Code") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("country_alpha2code"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Region") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("region"); + + b.Property("Streetadditional") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("streetadditional"); + + b.Property("Streetname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("streetname"); + + b.Property("Streetnumber") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("streetnumber"); + + b.Property("Zipcode") + .HasMaxLength(12) + .HasColumnType("character varying(12)") + .HasColumnName("zipcode"); + + b.HasKey("Id") + .HasName("pk_addresses"); + + b.HasIndex("CountryAlpha2Code") + .HasDatabaseName("ix_addresses_country_alpha2code"); + + b.ToTable("addresses", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AgreementCategoryId") + .HasColumnType("integer") + .HasColumnName("agreement_category_id"); + + b.Property("AgreementType") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("agreement_type"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.Property("IssuerCompanyId") + .HasColumnType("uuid") + .HasColumnName("issuer_company_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("UseCaseId") + .HasColumnType("uuid") + .HasColumnName("use_case_id"); + + b.HasKey("Id") + .HasName("pk_agreements"); + + b.HasIndex("AgreementCategoryId") + .HasDatabaseName("ix_agreements_agreement_category_id"); + + b.HasIndex("DocumentId") + .HasDatabaseName("ix_agreements_document_id"); + + b.HasIndex("IssuerCompanyId") + .HasDatabaseName("ix_agreements_issuer_company_id"); + + b.HasIndex("UseCaseId") + .HasDatabaseName("ix_agreements_use_case_id"); + + b.ToTable("agreements", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementAssignedCompanyRole", b => + { + b.Property("AgreementId") + .HasColumnType("uuid") + .HasColumnName("agreement_id"); + + b.Property("CompanyRoleId") + .HasColumnType("integer") + .HasColumnName("company_role_id"); + + b.HasKey("AgreementId", "CompanyRoleId") + .HasName("pk_agreement_assigned_company_roles"); + + b.HasIndex("CompanyRoleId") + .HasDatabaseName("ix_agreement_assigned_company_roles_company_role_id"); + + b.ToTable("agreement_assigned_company_roles", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementAssignedOffer", b => + { + b.Property("AgreementId") + .HasColumnType("uuid") + .HasColumnName("agreement_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.HasKey("AgreementId", "OfferId") + .HasName("pk_agreement_assigned_offers"); + + b.HasIndex("OfferId") + .HasDatabaseName("ix_agreement_assigned_offers_offer_id"); + + b.ToTable("agreement_assigned_offers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementAssignedOfferType", b => + { + b.Property("AgreementId") + .HasColumnType("uuid") + .HasColumnName("agreement_id"); + + b.Property("OfferTypeId") + .HasColumnType("integer") + .HasColumnName("offer_type_id"); + + b.HasKey("AgreementId", "OfferTypeId") + .HasName("pk_agreement_assigned_offer_types"); + + b.HasIndex("OfferTypeId") + .HasDatabaseName("ix_agreement_assigned_offer_types_offer_type_id"); + + b.ToTable("agreement_assigned_offer_types", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementCategory", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_agreement_categories"); + + b.ToTable("agreement_categories", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "CX_FRAME_CONTRACT" + }, + new + { + Id = 2, + Label = "APP_CONTRACT" + }, + new + { + Id = 3, + Label = "DATA_CONTRACT" + }, + new + { + Id = 4, + Label = "SERVICE_CONTRACT" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppAssignedUseCase", b => + { + b.Property("AppId") + .HasColumnType("uuid") + .HasColumnName("app_id"); + + b.Property("UseCaseId") + .HasColumnType("uuid") + .HasColumnName("use_case_id"); + + b.HasKey("AppId", "UseCaseId") + .HasName("pk_app_assigned_use_cases"); + + b.HasIndex("UseCaseId") + .HasDatabaseName("ix_app_assigned_use_cases_use_case_id"); + + b.ToTable("app_assigned_use_cases", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AppId") + .HasColumnType("uuid") + .HasColumnName("app_id"); + + b.Property("IamClientId") + .HasColumnType("uuid") + .HasColumnName("iam_client_id"); + + b.HasKey("Id") + .HasName("pk_app_instances"); + + b.HasIndex("AppId") + .HasDatabaseName("ix_app_instances_app_id"); + + b.HasIndex("IamClientId") + .HasDatabaseName("ix_app_instances_iam_client_id"); + + b.ToTable("app_instances", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstanceAssignedCompanyServiceAccount", b => + { + b.Property("AppInstanceId") + .HasColumnType("uuid") + .HasColumnName("app_instance_id"); + + b.Property("CompanyServiceAccountId") + .HasColumnType("uuid") + .HasColumnName("company_service_account_id"); + + b.HasKey("AppInstanceId", "CompanyServiceAccountId") + .HasName("pk_app_instance_assigned_service_accounts"); + + b.HasIndex("CompanyServiceAccountId") + .HasDatabaseName("ix_app_instance_assigned_service_accounts_company_service_acco"); + + b.ToTable("app_instance_assigned_service_accounts", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstanceSetup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AppId") + .HasColumnType("uuid") + .HasColumnName("app_id"); + + b.Property("InstanceUrl") + .HasColumnType("text") + .HasColumnName("instance_url"); + + b.Property("IsSingleInstance") + .HasColumnType("boolean") + .HasColumnName("is_single_instance"); + + b.HasKey("Id") + .HasName("pk_app_instance_setups"); + + b.HasIndex("AppId") + .IsUnique() + .HasDatabaseName("ix_app_instance_setups_app_id"); + + b.ToTable("app_instance_setups", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppLanguage", b => + { + b.Property("AppId") + .HasColumnType("uuid") + .HasColumnName("app_id"); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name"); + + b.HasKey("AppId", "LanguageShortName") + .HasName("pk_app_languages"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_app_languages_language_short_name"); + + b.ToTable("app_languages", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntry", b => + { + b.Property("ApplicationId") + .HasColumnType("uuid") + .HasColumnName("application_id"); + + b.Property("ApplicationChecklistEntryTypeId") + .HasColumnType("integer") + .HasColumnName("application_checklist_entry_type_id"); + + b.Property("ApplicationChecklistEntryStatusId") + .HasColumnType("integer") + .HasColumnName("application_checklist_entry_status_id"); + + b.Property("Comment") + .HasColumnType("text") + .HasColumnName("comment"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.HasKey("ApplicationId", "ApplicationChecklistEntryTypeId") + .HasName("pk_application_checklist"); + + b.HasIndex("ApplicationChecklistEntryStatusId") + .HasDatabaseName("ix_application_checklist_application_checklist_entry_status_id"); + + b.HasIndex("ApplicationChecklistEntryTypeId") + .HasDatabaseName("ix_application_checklist_application_checklist_entry_type_id"); + + b.ToTable("application_checklist", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntryStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_application_checklist_statuses"); + + b.ToTable("application_checklist_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "TO_DO" + }, + new + { + Id = 2, + Label = "IN_PROGRESS" + }, + new + { + Id = 3, + Label = "DONE" + }, + new + { + Id = 4, + Label = "FAILED" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntryType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_application_checklist_types"); + + b.ToTable("application_checklist_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "REGISTRATION_VERIFICATION" + }, + new + { + Id = 2, + Label = "BUSINESS_PARTNER_NUMBER" + }, + new + { + Id = 3, + Label = "IDENTITY_WALLET" + }, + new + { + Id = 4, + Label = "CLEARING_HOUSE" + }, + new + { + Id = 5, + Label = "SELF_DESCRIPTION_LP" + }, + new + { + Id = 6, + Label = "APPLICATION_ACTIVATION" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppSubscriptionDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AppInstanceId") + .HasColumnType("uuid") + .HasColumnName("app_instance_id"); + + b.Property("AppSubscriptionUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("app_subscription_url"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferSubscriptionId") + .HasColumnType("uuid") + .HasColumnName("offer_subscription_id"); + + b.HasKey("Id") + .HasName("pk_app_subscription_details"); + + b.HasIndex("AppInstanceId") + .HasDatabaseName("ix_app_subscription_details_app_instance_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_app_subscription_details_last_editor_id"); + + b.HasIndex("OfferSubscriptionId") + .IsUnique() + .HasDatabaseName("ix_app_subscription_details_offer_subscription_id"); + + b.ToTable("app_subscription_details", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_APPSUBSCRIPTIONDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_APPSUBSCRIPTIONDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_APPSUBSCRIPTIONDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_app_subscription_detail20221118 (\"id\", \"offer_subscription_id\", \"app_instance_id\", \"app_subscription_url\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.offer_subscription_id, \r\n OLD.app_instance_id, \r\n OLD.app_subscription_url, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_APPSUBSCRIPTIONDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_APPSUBSCRIPTIONDETAIL AFTER DELETE\r\nON portal.app_subscription_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_APPSUBSCRIPTIONDETAIL();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_APPSUBSCRIPTIONDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_APPSUBSCRIPTIONDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_APPSUBSCRIPTIONDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_app_subscription_detail20221118 (\"id\", \"offer_subscription_id\", \"app_instance_id\", \"app_subscription_url\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.offer_subscription_id, \r\n NEW.app_instance_id, \r\n NEW.app_subscription_url, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_APPSUBSCRIPTIONDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_APPSUBSCRIPTIONDETAIL AFTER INSERT\r\nON portal.app_subscription_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_APPSUBSCRIPTIONDETAIL();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_APPSUBSCRIPTIONDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_APPSUBSCRIPTIONDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_APPSUBSCRIPTIONDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_app_subscription_detail20221118 (\"id\", \"offer_subscription_id\", \"app_instance_id\", \"app_subscription_url\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.offer_subscription_id, \r\n NEW.app_instance_id, \r\n NEW.app_subscription_url, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_APPSUBSCRIPTIONDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_APPSUBSCRIPTIONDETAIL AFTER UPDATE\r\nON portal.app_subscription_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_APPSUBSCRIPTIONDETAIL();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AuditCompanySsiDetail20230621", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanySsiDetailStatusId") + .HasColumnType("integer") + .HasColumnName("company_ssi_detail_status_id"); + + b.Property("CreatorUserId") + .HasColumnType("uuid") + .HasColumnName("creator_user_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.Property("ExpiryDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("expiry_date"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("VerifiedCredentialExternalTypeUseCaseDetailId") + .HasColumnType("uuid") + .HasColumnName("verified_credential_external_type_use_case_detail_id"); + + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_company_ssi_detail20230621"); + + b.ToTable("audit_company_ssi_detail20230621", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AuditIdentity20230526", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("IdentityTypeId") + .HasColumnType("integer") + .HasColumnName("identity_type_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("UserEntityId") + .HasMaxLength(36) + .HasColumnType("character varying(36)") + .HasColumnName("user_entity_id"); + + b.Property("UserStatusId") + .HasColumnType("integer") + .HasColumnName("user_status_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_identity20230526"); + + b.ToTable("audit_identity20230526", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AuditOperation", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_audit_operation"); + + b.ToTable("audit_operation", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "INSERT" + }, + new + { + Id = 2, + Label = "UPDATE" + }, + new + { + Id = 3, + Label = "DELETE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.BpdmIdentifier", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_bpdm_identifiers"); + + b.ToTable("bpdm_identifiers", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "EU_VAT_ID_DE" + }, + new + { + Id = 2, + Label = "CH_UID" + }, + new + { + Id = 3, + Label = "EU_VAT_ID_FR" + }, + new + { + Id = 4, + Label = "FR_SIREN" + }, + new + { + Id = 5, + Label = "EU_VAT_ID_AT" + }, + new + { + Id = 6, + Label = "DE_BNUM" + }, + new + { + Id = 7, + Label = "CZ_ICO" + }, + new + { + Id = 8, + Label = "EU_VAT_ID_CZ" + }, + new + { + Id = 9, + Label = "EU_VAT_ID_PL" + }, + new + { + Id = 10, + Label = "EU_VAT_ID_BE" + }, + new + { + Id = 11, + Label = "EU_VAT_ID_CH" + }, + new + { + Id = 12, + Label = "EU_VAT_ID_DK" + }, + new + { + Id = 13, + Label = "EU_VAT_ID_ES" + }, + new + { + Id = 14, + Label = "EU_VAT_ID_GB" + }, + new + { + Id = 15, + Label = "EU_VAT_ID_NO" + }, + new + { + Id = 16, + Label = "BE_ENT_NO" + }, + new + { + Id = 17, + Label = "CVR_DK" + }, + new + { + Id = 18, + Label = "ID_CRN" + }, + new + { + Id = 19, + Label = "NO_ORGID" + }, + new + { + Id = 20, + Label = "LEI_ID" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AddressId") + .HasColumnType("uuid") + .HasColumnName("address_id"); + + b.Property("BusinessPartnerNumber") + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("business_partner_number"); + + b.Property("CompanyStatusId") + .HasColumnType("integer") + .HasColumnName("company_status_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("SelfDescriptionDocumentId") + .HasColumnType("uuid") + .HasColumnName("self_description_document_id"); + + b.Property("Shortname") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("shortname"); + + b.HasKey("Id") + .HasName("pk_companies"); + + b.HasIndex("AddressId") + .HasDatabaseName("ix_companies_address_id"); + + b.HasIndex("CompanyStatusId") + .HasDatabaseName("ix_companies_company_status_id"); + + b.HasIndex("SelfDescriptionDocumentId") + .HasDatabaseName("ix_companies_self_description_document_id"); + + b.ToTable("companies", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplication", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("ApplicationStatusId") + .HasColumnType("integer") + .HasColumnName("application_status_id"); + + b.Property("ChecklistProcessId") + .HasColumnType("uuid") + .HasColumnName("checklist_process_id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("Id") + .HasName("pk_company_applications"); + + b.HasIndex("ApplicationStatusId") + .HasDatabaseName("ix_company_applications_application_status_id"); + + b.HasIndex("ChecklistProcessId") + .IsUnique() + .HasDatabaseName("ix_company_applications_checklist_process_id"); + + b.HasIndex("CompanyId") + .HasDatabaseName("ix_company_applications_company_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_company_applications_last_editor_id"); + + b.ToTable("company_applications", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_COMPANYAPPLICATION", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_COMPANYAPPLICATION() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_COMPANYAPPLICATION$\r\nBEGIN\r\n INSERT INTO portal.audit_company_application20230214 (\"id\", \"date_created\", \"date_last_changed\", \"application_status_id\", \"company_id\", \"checklist_process_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.date_created, \r\n OLD.date_last_changed, \r\n OLD.application_status_id, \r\n OLD.company_id, \r\n OLD.checklist_process_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_COMPANYAPPLICATION$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_COMPANYAPPLICATION AFTER DELETE\r\nON portal.company_applications\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_COMPANYAPPLICATION();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYAPPLICATION", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_COMPANYAPPLICATION() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYAPPLICATION$\r\nBEGIN\r\n INSERT INTO portal.audit_company_application20230214 (\"id\", \"date_created\", \"date_last_changed\", \"application_status_id\", \"company_id\", \"checklist_process_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.date_last_changed, \r\n NEW.application_status_id, \r\n NEW.company_id, \r\n NEW.checklist_process_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYAPPLICATION$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYAPPLICATION AFTER INSERT\r\nON portal.company_applications\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_COMPANYAPPLICATION();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYAPPLICATION", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_COMPANYAPPLICATION() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYAPPLICATION$\r\nBEGIN\r\n INSERT INTO portal.audit_company_application20230214 (\"id\", \"date_created\", \"date_last_changed\", \"application_status_id\", \"company_id\", \"checklist_process_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.date_last_changed, \r\n NEW.application_status_id, \r\n NEW.company_id, \r\n NEW.checklist_process_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYAPPLICATION$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYAPPLICATION AFTER UPDATE\r\nON portal.company_applications\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_COMPANYAPPLICATION();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplicationStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_company_application_statuses"); + + b.ToTable("company_application_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "CREATED" + }, + new + { + Id = 2, + Label = "ADD_COMPANY_DATA" + }, + new + { + Id = 3, + Label = "INVITE_USER" + }, + new + { + Id = 4, + Label = "SELECT_COMPANY_ROLE" + }, + new + { + Id = 5, + Label = "UPLOAD_DOCUMENTS" + }, + new + { + Id = 6, + Label = "VERIFY" + }, + new + { + Id = 7, + Label = "SUBMITTED" + }, + new + { + Id = 8, + Label = "CONFIRMED" + }, + new + { + Id = 9, + Label = "DECLINED" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyAssignedRole", b => + { + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanyRoleId") + .HasColumnType("integer") + .HasColumnName("company_role_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("CompanyId", "CompanyRoleId") + .HasName("pk_company_assigned_roles"); + + b.HasIndex("CompanyRoleId") + .HasDatabaseName("ix_company_assigned_roles_company_role_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_company_assigned_roles_last_editor_id"); + + b.ToTable("company_assigned_roles", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_COMPANYASSIGNEDROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_COMPANYASSIGNEDROLE() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_COMPANYASSIGNEDROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_company_assigned_role2023316 (\"company_id\", \"company_role_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.company_id, \r\n OLD.company_role_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_COMPANYASSIGNEDROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_COMPANYASSIGNEDROLE AFTER DELETE\r\nON portal.company_assigned_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_COMPANYASSIGNEDROLE();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYASSIGNEDROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_COMPANYASSIGNEDROLE() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYASSIGNEDROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_company_assigned_role2023316 (\"company_id\", \"company_role_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.company_id, \r\n NEW.company_role_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYASSIGNEDROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYASSIGNEDROLE AFTER INSERT\r\nON portal.company_assigned_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_COMPANYASSIGNEDROLE();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYASSIGNEDROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_COMPANYASSIGNEDROLE() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYASSIGNEDROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_company_assigned_role2023316 (\"company_id\", \"company_role_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.company_id, \r\n NEW.company_role_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYASSIGNEDROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYASSIGNEDROLE AFTER UPDATE\r\nON portal.company_assigned_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_COMPANYASSIGNEDROLE();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyAssignedUseCase", b => + { + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("UseCaseId") + .HasColumnType("uuid") + .HasColumnName("use_case_id"); + + b.HasKey("CompanyId", "UseCaseId") + .HasName("pk_company_assigned_use_cases"); + + b.HasIndex("UseCaseId") + .HasDatabaseName("ix_company_assigned_use_cases_use_case_id"); + + b.ToTable("company_assigned_use_cases", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyIdentifier", b => + { + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("UniqueIdentifierId") + .HasColumnType("integer") + .HasColumnName("unique_identifier_id"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text") + .HasColumnName("value"); + + b.HasKey("CompanyId", "UniqueIdentifierId") + .HasName("pk_company_identifiers"); + + b.HasIndex("UniqueIdentifierId") + .HasDatabaseName("ix_company_identifiers_unique_identifier_id"); + + b.ToTable("company_identifiers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyIdentityProvider", b => + { + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("IdentityProviderId") + .HasColumnType("uuid") + .HasColumnName("identity_provider_id"); + + b.HasKey("CompanyId", "IdentityProviderId") + .HasName("pk_company_identity_providers"); + + b.HasIndex("IdentityProviderId") + .HasDatabaseName("ix_company_identity_providers_identity_provider_id"); + + b.ToTable("company_identity_providers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_company_roles"); + + b.ToTable("company_roles", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "ACTIVE_PARTICIPANT" + }, + new + { + Id = 2, + Label = "APP_PROVIDER" + }, + new + { + Id = 3, + Label = "SERVICE_PROVIDER" + }, + new + { + Id = 4, + Label = "OPERATOR" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleAssignedRoleCollection", b => + { + b.Property("CompanyRoleId") + .HasColumnType("integer") + .HasColumnName("company_role_id"); + + b.Property("UserRoleCollectionId") + .HasColumnType("uuid") + .HasColumnName("user_role_collection_id"); + + b.HasKey("CompanyRoleId") + .HasName("pk_company_role_assigned_role_collections"); + + b.HasIndex("UserRoleCollectionId") + .IsUnique() + .HasDatabaseName("ix_company_role_assigned_role_collections_user_role_collection"); + + b.ToTable("company_role_assigned_role_collections", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleDescription", b => + { + b.Property("CompanyRoleId") + .HasColumnType("integer") + .HasColumnName("company_role_id"); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description"); + + b.HasKey("CompanyRoleId", "LanguageShortName") + .HasName("pk_company_role_descriptions"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_company_role_descriptions_language_short_name"); + + b.ToTable("company_role_descriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleRegistrationData", b => + { + b.Property("CompanyRoleId") + .HasColumnType("integer") + .HasColumnName("company_role_id"); + + b.Property("IsRegistrationRole") + .HasColumnType("boolean") + .HasColumnName("is_registration_role"); + + b.HasKey("CompanyRoleId") + .HasName("pk_company_role_registration_data"); + + b.ToTable("company_role_registration_data", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("ClientClientId") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("client_client_id"); + + b.Property("ClientId") + .HasMaxLength(36) + .HasColumnType("character varying(36)") + .HasColumnName("client_id"); + + b.Property("CompanyServiceAccountTypeId") + .HasColumnType("integer") + .HasColumnName("company_service_account_type_id"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("OfferSubscriptionId") + .HasColumnType("uuid") + .HasColumnName("offer_subscription_id"); + + b.HasKey("Id") + .HasName("pk_company_service_accounts"); + + b.HasIndex("ClientClientId") + .IsUnique() + .HasDatabaseName("ix_company_service_accounts_client_client_id"); + + b.HasIndex("CompanyServiceAccountTypeId") + .HasDatabaseName("ix_company_service_accounts_company_service_account_type_id"); + + b.HasIndex("OfferSubscriptionId") + .HasDatabaseName("ix_company_service_accounts_offer_subscription_id"); + + b.ToTable("company_service_accounts", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccountType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_company_service_account_types"); + + b.ToTable("company_service_account_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "MANAGED" + }, + new + { + Id = 2, + Label = "OWN" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanySsiDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanySsiDetailStatusId") + .HasColumnType("integer") + .HasColumnName("company_ssi_detail_status_id"); + + b.Property("CreatorUserId") + .HasColumnType("uuid") + .HasColumnName("creator_user_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.Property("ExpiryDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("expiry_date"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("VerifiedCredentialExternalTypeUseCaseDetailId") + .HasColumnType("uuid") + .HasColumnName("verified_credential_external_type_use_case_detail_id"); + + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.HasKey("Id") + .HasName("pk_company_ssi_details"); + + b.HasIndex("CompanyId") + .HasDatabaseName("ix_company_ssi_details_company_id"); + + b.HasIndex("CompanySsiDetailStatusId") + .HasDatabaseName("ix_company_ssi_details_company_ssi_detail_status_id"); + + b.HasIndex("CreatorUserId") + .HasDatabaseName("ix_company_ssi_details_creator_user_id"); + + b.HasIndex("DocumentId") + .IsUnique() + .HasDatabaseName("ix_company_ssi_details_document_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_company_ssi_details_last_editor_id"); + + b.HasIndex("VerifiedCredentialExternalTypeUseCaseDetailId") + .HasDatabaseName("ix_company_ssi_details_verified_credential_external_type_use_c"); + + b.HasIndex("VerifiedCredentialTypeId") + .HasDatabaseName("ix_company_ssi_details_verified_credential_type_id"); + + b.ToTable("company_ssi_details", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_COMPANYSSIDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_COMPANYSSIDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_company_ssi_detail20230621 (\"id\", \"company_id\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"document_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_use_case_detail_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.company_id, \r\n OLD.verified_credential_type_id, \r\n OLD.company_ssi_detail_status_id, \r\n OLD.document_id, \r\n OLD.date_created, \r\n OLD.creator_user_id, \r\n OLD.expiry_date, \r\n OLD.verified_credential_external_type_use_case_detail_id, \r\n OLD.date_last_changed, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_COMPANYSSIDETAIL AFTER DELETE\r\nON portal.company_ssi_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_COMPANYSSIDETAIL();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_company_ssi_detail20230621 (\"id\", \"company_id\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"document_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_use_case_detail_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.company_id, \r\n NEW.verified_credential_type_id, \r\n NEW.company_ssi_detail_status_id, \r\n NEW.document_id, \r\n NEW.date_created, \r\n NEW.creator_user_id, \r\n NEW.expiry_date, \r\n NEW.verified_credential_external_type_use_case_detail_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL AFTER INSERT\r\nON portal.company_ssi_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_COMPANYSSIDETAIL();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_company_ssi_detail20230621 (\"id\", \"company_id\", \"verified_credential_type_id\", \"company_ssi_detail_status_id\", \"document_id\", \"date_created\", \"creator_user_id\", \"expiry_date\", \"verified_credential_external_type_use_case_detail_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.company_id, \r\n NEW.verified_credential_type_id, \r\n NEW.company_ssi_detail_status_id, \r\n NEW.document_id, \r\n NEW.date_created, \r\n NEW.creator_user_id, \r\n NEW.expiry_date, \r\n NEW.verified_credential_external_type_use_case_detail_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL AFTER UPDATE\r\nON portal.company_ssi_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_COMPANYSSIDETAIL();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanySsiDetailStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_company_ssi_detail_statuses"); + + b.ToTable("company_ssi_detail_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "PENDING" + }, + new + { + Id = 2, + Label = "ACTIVE" + }, + new + { + Id = 3, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_company_statuses"); + + b.ToTable("company_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "PENDING" + }, + new + { + Id = 2, + Label = "ACTIVE" + }, + new + { + Id = 3, + Label = "REJECTED" + }, + new + { + Id = 4, + Label = "INACTIVE" + }, + new + { + Id = 5, + Label = "DELETED" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", b => + { + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Email") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("email"); + + b.Property("Firstname") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("firstname"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("Lastlogin") + .HasColumnType("bytea") + .HasColumnName("lastlogin"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("lastname"); + + b.HasKey("Id") + .HasName("pk_company_users"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_company_users_last_editor_id"); + + b.ToTable("company_users", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_COMPANYUSER", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_COMPANYUSER() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_COMPANYUSER$\r\nBEGIN\r\n INSERT INTO portal.audit_company_user20230523 (\"id\", \"email\", \"firstname\", \"lastlogin\", \"lastname\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.email, \r\n OLD.firstname, \r\n OLD.lastlogin, \r\n OLD.lastname, \r\n OLD.date_last_changed, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_COMPANYUSER$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_COMPANYUSER AFTER DELETE\r\nON portal.company_users\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_COMPANYUSER();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_COMPANYUSER", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_COMPANYUSER() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_COMPANYUSER$\r\nBEGIN\r\n INSERT INTO portal.audit_company_user20230523 (\"id\", \"email\", \"firstname\", \"lastlogin\", \"lastname\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.email, \r\n NEW.firstname, \r\n NEW.lastlogin, \r\n NEW.lastname, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_COMPANYUSER$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_COMPANYUSER AFTER INSERT\r\nON portal.company_users\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_COMPANYUSER();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_COMPANYUSER", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_COMPANYUSER() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_COMPANYUSER$\r\nBEGIN\r\n INSERT INTO portal.audit_company_user20230523 (\"id\", \"email\", \"firstname\", \"lastlogin\", \"lastname\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.email, \r\n NEW.firstname, \r\n NEW.lastlogin, \r\n NEW.lastname, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_COMPANYUSER$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_COMPANYUSER AFTER UPDATE\r\nON portal.company_users\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_COMPANYUSER();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUserAssignedAppFavourite", b => + { + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("AppId") + .HasColumnType("uuid") + .HasColumnName("app_id"); + + b.HasKey("CompanyUserId", "AppId") + .HasName("pk_company_user_assigned_app_favourites"); + + b.HasIndex("AppId") + .HasDatabaseName("ix_company_user_assigned_app_favourites_app_id"); + + b.ToTable("company_user_assigned_app_favourites", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUserAssignedBusinessPartner", b => + { + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("BusinessPartnerNumber") + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("business_partner_number"); + + b.HasKey("CompanyUserId", "BusinessPartnerNumber") + .HasName("pk_company_user_assigned_business_partners"); + + b.ToTable("company_user_assigned_business_partners", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("CompanyServiceAccountId") + .HasColumnType("uuid") + .HasColumnName("company_service_account_id"); + + b.Property("ConnectorUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("connector_url"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("HostId") + .HasColumnType("uuid") + .HasColumnName("host_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LocationId") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("location_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("ProviderId") + .HasColumnType("uuid") + .HasColumnName("provider_id"); + + b.Property("SelfDescriptionDocumentId") + .HasColumnType("uuid") + .HasColumnName("self_description_document_id"); + + b.Property("SelfDescriptionMessage") + .HasColumnType("text") + .HasColumnName("self_description_message"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("Id") + .HasName("pk_connectors"); + + b.HasIndex("CompanyServiceAccountId") + .IsUnique() + .HasDatabaseName("ix_connectors_company_service_account_id"); + + b.HasIndex("HostId") + .HasDatabaseName("ix_connectors_host_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_connectors_last_editor_id"); + + b.HasIndex("LocationId") + .HasDatabaseName("ix_connectors_location_id"); + + b.HasIndex("ProviderId") + .HasDatabaseName("ix_connectors_provider_id"); + + b.HasIndex("SelfDescriptionDocumentId") + .IsUnique() + .HasDatabaseName("ix_connectors_self_description_document_id"); + + b.HasIndex("StatusId") + .HasDatabaseName("ix_connectors_status_id"); + + b.HasIndex("TypeId") + .HasDatabaseName("ix_connectors_type_id"); + + b.ToTable("connectors", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.name, \r\n OLD.connector_url, \r\n OLD.type_id, \r\n OLD.status_id, \r\n OLD.provider_id, \r\n OLD.host_id, \r\n OLD.self_description_document_id, \r\n OLD.location_id, \r\n OLD.self_description_message, \r\n OLD.date_last_changed, \r\n OLD.company_service_account_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_CONNECTOR AFTER DELETE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_CONNECTOR AFTER INSERT\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_CONNECTOR AFTER UPDATE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorAssignedOfferSubscription", b => + { + b.Property("ConnectorId") + .HasColumnType("uuid") + .HasColumnName("connector_id"); + + b.Property("OfferSubscriptionId") + .HasColumnType("uuid") + .HasColumnName("offer_subscription_id"); + + b.HasKey("ConnectorId", "OfferSubscriptionId") + .HasName("pk_connector_assigned_offer_subscriptions"); + + b.HasIndex("OfferSubscriptionId") + .HasDatabaseName("ix_connector_assigned_offer_subscriptions_offer_subscription_id"); + + b.ToTable("connector_assigned_offer_subscriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_connector_statuses"); + + b.ToTable("connector_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "PENDING" + }, + new + { + Id = 2, + Label = "ACTIVE" + }, + new + { + Id = 3, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_connector_types"); + + b.ToTable("connector_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "COMPANY_CONNECTOR" + }, + new + { + Id = 2, + Label = "CONNECTOR_AS_A_SERVICE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Consent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AgreementId") + .HasColumnType("uuid") + .HasColumnName("agreement_id"); + + b.Property("Comment") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("comment"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("ConsentStatusId") + .HasColumnType("integer") + .HasColumnName("consent_status_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("Target") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("target"); + + b.HasKey("Id") + .HasName("pk_consents"); + + b.HasIndex("AgreementId") + .HasDatabaseName("ix_consents_agreement_id"); + + b.HasIndex("CompanyId") + .HasDatabaseName("ix_consents_company_id"); + + b.HasIndex("CompanyUserId") + .HasDatabaseName("ix_consents_company_user_id"); + + b.HasIndex("ConsentStatusId") + .HasDatabaseName("ix_consents_consent_status_id"); + + b.HasIndex("DocumentId") + .HasDatabaseName("ix_consents_document_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_consents_last_editor_id"); + + b.ToTable("consents", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_CONSENT", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONSENT() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_CONSENT$\r\nBEGIN\r\n INSERT INTO portal.audit_consent20230412 (\"id\", \"date_created\", \"comment\", \"consent_status_id\", \"target\", \"agreement_id\", \"company_id\", \"document_id\", \"company_user_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.date_created, \r\n OLD.comment, \r\n OLD.consent_status_id, \r\n OLD.target, \r\n OLD.agreement_id, \r\n OLD.company_id, \r\n OLD.document_id, \r\n OLD.company_user_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_CONSENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_CONSENT AFTER DELETE\r\nON portal.consents\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_CONSENT();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_CONSENT", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONSENT() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_CONSENT$\r\nBEGIN\r\n INSERT INTO portal.audit_consent20230412 (\"id\", \"date_created\", \"comment\", \"consent_status_id\", \"target\", \"agreement_id\", \"company_id\", \"document_id\", \"company_user_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.comment, \r\n NEW.consent_status_id, \r\n NEW.target, \r\n NEW.agreement_id, \r\n NEW.company_id, \r\n NEW.document_id, \r\n NEW.company_user_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_CONSENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_CONSENT AFTER INSERT\r\nON portal.consents\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_CONSENT();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_CONSENT", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONSENT() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_CONSENT$\r\nBEGIN\r\n INSERT INTO portal.audit_consent20230412 (\"id\", \"date_created\", \"comment\", \"consent_status_id\", \"target\", \"agreement_id\", \"company_id\", \"document_id\", \"company_user_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.comment, \r\n NEW.consent_status_id, \r\n NEW.target, \r\n NEW.agreement_id, \r\n NEW.company_id, \r\n NEW.document_id, \r\n NEW.company_user_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_CONSENT$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_CONSENT AFTER UPDATE\r\nON portal.consents\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_CONSENT();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentAssignedOffer", b => + { + b.Property("ConsentId") + .HasColumnType("uuid") + .HasColumnName("consent_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.HasKey("ConsentId", "OfferId") + .HasName("pk_consent_assigned_offers"); + + b.HasIndex("OfferId") + .HasDatabaseName("ix_consent_assigned_offers_offer_id"); + + b.ToTable("consent_assigned_offers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentAssignedOfferSubscription", b => + { + b.Property("ConsentId") + .HasColumnType("uuid") + .HasColumnName("consent_id"); + + b.Property("OfferSubscriptionId") + .HasColumnType("uuid") + .HasColumnName("offer_subscription_id"); + + b.HasKey("ConsentId", "OfferSubscriptionId") + .HasName("pk_consent_assigned_offer_subscriptions"); + + b.HasIndex("OfferSubscriptionId") + .HasDatabaseName("ix_consent_assigned_offer_subscriptions_offer_subscription_id"); + + b.ToTable("consent_assigned_offer_subscriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_consent_statuses"); + + b.ToTable("consent_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "ACTIVE" + }, + new + { + Id = 2, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Country", b => + { + b.Property("Alpha2Code") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("alpha2code") + .IsFixedLength(); + + b.Property("Alpha3Code") + .HasMaxLength(3) + .HasColumnType("character(3)") + .HasColumnName("alpha3code") + .IsFixedLength(); + + b.Property("CountryNameDe") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("country_name_de"); + + b.Property("CountryNameEn") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("country_name_en"); + + b.HasKey("Alpha2Code") + .HasName("pk_countries"); + + b.ToTable("countries", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CountryAssignedIdentifier", b => + { + b.Property("CountryAlpha2Code") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("country_alpha2code"); + + b.Property("UniqueIdentifierId") + .HasColumnType("integer") + .HasColumnName("unique_identifier_id"); + + b.Property("BpdmIdentifierId") + .HasColumnType("integer") + .HasColumnName("bpdm_identifier_id"); + + b.HasKey("CountryAlpha2Code", "UniqueIdentifierId") + .HasName("pk_country_assigned_identifiers"); + + b.HasIndex("BpdmIdentifierId") + .HasDatabaseName("ix_country_assigned_identifiers_bpdm_identifier_id"); + + b.HasIndex("UniqueIdentifierId") + .HasDatabaseName("ix_country_assigned_identifiers_unique_identifier_id"); + + b.ToTable("country_assigned_identifiers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DocumentContent") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("document_content"); + + b.Property("DocumentHash") + .IsRequired() + .HasColumnType("bytea") + .HasColumnName("document_hash"); + + b.Property("DocumentName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("document_name"); + + b.Property("DocumentStatusId") + .HasColumnType("integer") + .HasColumnName("document_status_id"); + + b.Property("DocumentTypeId") + .HasColumnType("integer") + .HasColumnName("document_type_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.HasKey("Id") + .HasName("pk_documents"); + + b.HasIndex("CompanyUserId") + .HasDatabaseName("ix_documents_company_user_id"); + + b.HasIndex("DocumentStatusId") + .HasDatabaseName("ix_documents_document_status_id"); + + b.HasIndex("DocumentTypeId") + .HasDatabaseName("ix_documents_document_type_id"); + + b.HasIndex("MediaTypeId") + .HasDatabaseName("ix_documents_media_type_id"); + + b.ToTable("documents", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.DocumentStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_document_status"); + + b.ToTable("document_status", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "PENDING" + }, + new + { + Id = 2, + Label = "LOCKED" + }, + new + { + Id = 3, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.DocumentType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_document_types"); + + b.ToTable("document_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "CX_FRAME_CONTRACT" + }, + new + { + Id = 2, + Label = "COMMERCIAL_REGISTER_EXTRACT" + }, + new + { + Id = 3, + Label = "APP_CONTRACT" + }, + new + { + Id = 4, + Label = "CONFORMITY_APPROVAL_REGISTRATION" + }, + new + { + Id = 5, + Label = "ADDITIONAL_DETAILS" + }, + new + { + Id = 6, + Label = "APP_LEADIMAGE" + }, + new + { + Id = 7, + Label = "APP_IMAGE" + }, + new + { + Id = 8, + Label = "SELF_DESCRIPTION" + }, + new + { + Id = 9, + Label = "APP_TECHNICAL_INFORMATION" + }, + new + { + Id = 10, + Label = "CONFORMITY_APPROVAL_CONNECTOR" + }, + new + { + Id = 11, + Label = "CONFORMITY_APPROVAL_BUSINESS_APPS" + }, + new + { + Id = 12, + Label = "CONFORMITY_APPROVAL_SERVICES" + }, + new + { + Id = 13, + Label = "SERVICE_LEADIMAGE" + }, + new + { + Id = 14, + Label = "PRESENTATION" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IamClient", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("ClientClientId") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("client_client_id"); + + b.HasKey("Id") + .HasName("pk_iam_clients"); + + b.HasIndex("ClientClientId") + .IsUnique() + .HasDatabaseName("ix_iam_clients_client_client_id"); + + b.ToTable("iam_clients", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IamIdentityProvider", b => + { + b.Property("IamIdpAlias") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("iam_idp_alias"); + + b.Property("IdentityProviderId") + .HasColumnType("uuid") + .HasColumnName("identity_provider_id"); + + b.HasKey("IamIdpAlias") + .HasName("pk_iam_identity_providers"); + + b.HasIndex("IdentityProviderId") + .IsUnique() + .HasDatabaseName("ix_iam_identity_providers_identity_provider_id"); + + b.ToTable("iam_identity_providers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("IdentityTypeId") + .HasColumnType("integer") + .HasColumnName("identity_type_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("UserEntityId") + .HasMaxLength(36) + .HasColumnType("character varying(36)") + .HasColumnName("user_entity_id"); + + b.Property("UserStatusId") + .HasColumnType("integer") + .HasColumnName("user_status_id"); + + b.HasKey("Id") + .HasName("pk_identities"); + + b.HasIndex("CompanyId") + .HasDatabaseName("ix_identities_company_id"); + + b.HasIndex("IdentityTypeId") + .HasDatabaseName("ix_identities_identity_type_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_identities_last_editor_id"); + + b.HasIndex("UserEntityId") + .IsUnique() + .HasDatabaseName("ix_identities_user_entity_id"); + + b.HasIndex("UserStatusId") + .HasDatabaseName("ix_identities_user_status_id"); + + b.ToTable("identities", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_IDENTITY", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_IDENTITY() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_IDENTITY$\r\nBEGIN\r\n INSERT INTO portal.audit_identity20230526 (\"id\", \"date_created\", \"company_id\", \"user_status_id\", \"user_entity_id\", \"identity_type_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.date_created, \r\n OLD.company_id, \r\n OLD.user_status_id, \r\n OLD.user_entity_id, \r\n OLD.identity_type_id, \r\n OLD.date_last_changed, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_IDENTITY$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_IDENTITY AFTER DELETE\r\nON portal.identities\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_IDENTITY();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_IDENTITY", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_IDENTITY() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_IDENTITY$\r\nBEGIN\r\n INSERT INTO portal.audit_identity20230526 (\"id\", \"date_created\", \"company_id\", \"user_status_id\", \"user_entity_id\", \"identity_type_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.company_id, \r\n NEW.user_status_id, \r\n NEW.user_entity_id, \r\n NEW.identity_type_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_IDENTITY$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_IDENTITY AFTER INSERT\r\nON portal.identities\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_IDENTITY();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_IDENTITY", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_IDENTITY() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_IDENTITY$\r\nBEGIN\r\n INSERT INTO portal.audit_identity20230526 (\"id\", \"date_created\", \"company_id\", \"user_status_id\", \"user_entity_id\", \"identity_type_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.company_id, \r\n NEW.user_status_id, \r\n NEW.user_entity_id, \r\n NEW.identity_type_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_IDENTITY$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_IDENTITY AFTER UPDATE\r\nON portal.identities\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_IDENTITY();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityAssignedRole", b => + { + b.Property("IdentityId") + .HasColumnType("uuid") + .HasColumnName("identity_id"); + + b.Property("UserRoleId") + .HasColumnType("uuid") + .HasColumnName("user_role_id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("IdentityId", "UserRoleId") + .HasName("pk_identity_assigned_roles"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_identity_assigned_roles_last_editor_id"); + + b.HasIndex("UserRoleId") + .HasDatabaseName("ix_identity_assigned_roles_user_role_id"); + + b.ToTable("identity_assigned_roles", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_IDENTITYASSIGNEDROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_IDENTITYASSIGNEDROLE() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_IDENTITYASSIGNEDROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_identity_assigned_role20230522 (\"identity_id\", \"user_role_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.identity_id, \r\n OLD.user_role_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_IDENTITYASSIGNEDROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_IDENTITYASSIGNEDROLE AFTER DELETE\r\nON portal.identity_assigned_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_IDENTITYASSIGNEDROLE();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_IDENTITYASSIGNEDROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_IDENTITYASSIGNEDROLE() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_IDENTITYASSIGNEDROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_identity_assigned_role20230522 (\"identity_id\", \"user_role_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.identity_id, \r\n NEW.user_role_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_IDENTITYASSIGNEDROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_IDENTITYASSIGNEDROLE AFTER INSERT\r\nON portal.identity_assigned_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_IDENTITYASSIGNEDROLE();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_IDENTITYASSIGNEDROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_IDENTITYASSIGNEDROLE() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_IDENTITYASSIGNEDROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_identity_assigned_role20230522 (\"identity_id\", \"user_role_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.identity_id, \r\n NEW.user_role_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_IDENTITYASSIGNEDROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_IDENTITYASSIGNEDROLE AFTER UPDATE\r\nON portal.identity_assigned_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_IDENTITYASSIGNEDROLE();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProvider", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("IdentityProviderCategoryId") + .HasColumnType("integer") + .HasColumnName("identity_provider_category_id"); + + b.HasKey("Id") + .HasName("pk_identity_providers"); + + b.HasIndex("IdentityProviderCategoryId") + .HasDatabaseName("ix_identity_providers_identity_provider_category_id"); + + b.ToTable("identity_providers", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProviderCategory", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_identity_provider_categories"); + + b.ToTable("identity_provider_categories", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "KEYCLOAK_SHARED" + }, + new + { + Id = 2, + Label = "KEYCLOAK_OIDC" + }, + new + { + Id = 3, + Label = "KEYCLOAK_SAML" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_identity_type"); + + b.ToTable("identity_type", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "COMPANY_USER" + }, + new + { + Id = 2, + Label = "COMPANY_SERVICE_ACCOUNT" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityUserStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_identity_user_statuses"); + + b.ToTable("identity_user_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "ACTIVE" + }, + new + { + Id = 2, + Label = "INACTIVE" + }, + new + { + Id = 3, + Label = "DELETED" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Invitation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("CompanyApplicationId") + .HasColumnType("uuid") + .HasColumnName("company_application_id"); + + b.Property("CompanyUserId") + .HasColumnType("uuid") + .HasColumnName("company_user_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("InvitationStatusId") + .HasColumnType("integer") + .HasColumnName("invitation_status_id"); + + b.HasKey("Id") + .HasName("pk_invitations"); + + b.HasIndex("CompanyApplicationId") + .HasDatabaseName("ix_invitations_company_application_id"); + + b.HasIndex("CompanyUserId") + .HasDatabaseName("ix_invitations_company_user_id"); + + b.HasIndex("InvitationStatusId") + .HasDatabaseName("ix_invitations_invitation_status_id"); + + b.ToTable("invitations", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.InvitationStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_invitation_statuses"); + + b.ToTable("invitation_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "CREATED" + }, + new + { + Id = 2, + Label = "PENDING" + }, + new + { + Id = 3, + Label = "ACCEPTED" + }, + new + { + Id = 4, + Label = "DECLINED" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", b => + { + b.Property("ShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("short_name") + .IsFixedLength(); + + b.HasKey("ShortName") + .HasName("pk_languages"); + + b.ToTable("languages", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.LanguageLongName", b => + { + b.Property("ShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("short_name") + .IsFixedLength(); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name") + .IsFixedLength(); + + b.Property("LongName") + .IsRequired() + .HasColumnType("text") + .HasColumnName("long_name"); + + b.HasKey("ShortName", "LanguageShortName") + .HasName("pk_language_long_names"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_language_long_names_language_short_name"); + + b.ToTable("language_long_names", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.LicenseType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_license_types"); + + b.ToTable("license_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "COTS" + }, + new + { + Id = 2, + Label = "FOSS" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.MediaType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_media_types"); + + b.ToTable("media_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "JPEG" + }, + new + { + Id = 2, + Label = "GIF" + }, + new + { + Id = 3, + Label = "PNG" + }, + new + { + Id = 4, + Label = "SVG" + }, + new + { + Id = 5, + Label = "TIFF" + }, + new + { + Id = 6, + Label = "PDF" + }, + new + { + Id = 7, + Label = "JSON" + }, + new + { + Id = 8, + Label = "PEM" + }, + new + { + Id = 9, + Label = "CA_CERT" + }, + new + { + Id = 10, + Label = "PKX_CER" + }, + new + { + Id = 11, + Label = "OCTET" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Content") + .HasColumnType("text") + .HasColumnName("content"); + + b.Property("CreatorUserId") + .HasColumnType("uuid") + .HasColumnName("creator_user_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("Done") + .HasColumnType("boolean") + .HasColumnName("done"); + + b.Property("DueDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("due_date"); + + b.Property("IsRead") + .HasColumnType("boolean") + .HasColumnName("is_read"); + + b.Property("NotificationTypeId") + .HasColumnType("integer") + .HasColumnName("notification_type_id"); + + b.Property("ReceiverUserId") + .HasColumnType("uuid") + .HasColumnName("receiver_user_id"); + + b.HasKey("Id") + .HasName("pk_notifications"); + + b.HasIndex("CreatorUserId") + .HasDatabaseName("ix_notifications_creator_user_id"); + + b.HasIndex("NotificationTypeId") + .HasDatabaseName("ix_notifications_notification_type_id"); + + b.HasIndex("ReceiverUserId") + .HasDatabaseName("ix_notifications_receiver_user_id"); + + b.ToTable("notifications", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationTopic", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_notification_topic"); + + b.ToTable("notification_topic", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "INFO" + }, + new + { + Id = 2, + Label = "ACTION" + }, + new + { + Id = 3, + Label = "OFFER" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_notification_type"); + + b.ToTable("notification_type", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "INFO" + }, + new + { + Id = 2, + Label = "ACTION" + }, + new + { + Id = 3, + Label = "WELCOME" + }, + new + { + Id = 4, + Label = "WELCOME_USE_CASES" + }, + new + { + Id = 5, + Label = "WELCOME_SERVICE_PROVIDER" + }, + new + { + Id = 6, + Label = "WELCOME_CONNECTOR_REGISTRATION" + }, + new + { + Id = 7, + Label = "WELCOME_APP_MARKETPLACE" + }, + new + { + Id = 8, + Label = "APP_SUBSCRIPTION_REQUEST" + }, + new + { + Id = 9, + Label = "APP_SUBSCRIPTION_ACTIVATION" + }, + new + { + Id = 10, + Label = "CONNECTOR_REGISTERED" + }, + new + { + Id = 11, + Label = "APP_RELEASE_REQUEST" + }, + new + { + Id = 12, + Label = "TECHNICAL_USER_CREATION" + }, + new + { + Id = 13, + Label = "SERVICE_REQUEST" + }, + new + { + Id = 14, + Label = "SERVICE_ACTIVATION" + }, + new + { + Id = 15, + Label = "APP_ROLE_ADDED" + }, + new + { + Id = 16, + Label = "APP_RELEASE_APPROVAL" + }, + new + { + Id = 17, + Label = "SERVICE_RELEASE_REQUEST" + }, + new + { + Id = 18, + Label = "SERVICE_RELEASE_APPROVAL" + }, + new + { + Id = 19, + Label = "APP_RELEASE_REJECTION" + }, + new + { + Id = 20, + Label = "SERVICE_RELEASE_REJECTION" + }, + new + { + Id = 21, + Label = "ROLE_UPDATE_CORE_OFFER" + }, + new + { + Id = 22, + Label = "ROLE_UPDATE_APP_OFFER" + }, + new + { + Id = 23, + Label = "SUBSCRIPTION_URL_UPDATE" + }, + new + { + Id = 24, + Label = "CREDENTIAL_APPROVAL" + }, + new + { + Id = 25, + Label = "CREDENTIAL_REJECTED" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationTypeAssignedTopic", b => + { + b.Property("NotificationTypeId") + .HasColumnType("integer") + .HasColumnName("notification_type_id"); + + b.Property("NotificationTopicId") + .HasColumnType("integer") + .HasColumnName("notification_topic_id"); + + b.HasKey("NotificationTypeId", "NotificationTopicId") + .HasName("pk_notification_type_assigned_topics"); + + b.HasIndex("NotificationTopicId") + .HasDatabaseName("ix_notification_type_assigned_topics_notification_topic_id"); + + b.HasIndex("NotificationTypeId") + .IsUnique() + .HasDatabaseName("ix_notification_type_assigned_topics_notification_type_id"); + + b.ToTable("notification_type_assigned_topics", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("ContactEmail") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("contact_email"); + + b.Property("ContactNumber") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("contact_number"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("DateReleased") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_released"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LicenseTypeId") + .HasColumnType("integer") + .HasColumnName("license_type_id"); + + b.Property("MarketingUrl") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("marketing_url"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("OfferStatusId") + .HasColumnType("integer") + .HasColumnName("offer_status_id"); + + b.Property("OfferTypeId") + .HasColumnType("integer") + .HasColumnName("offer_type_id"); + + b.Property("Provider") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("provider"); + + b.Property("ProviderCompanyId") + .HasColumnType("uuid") + .HasColumnName("provider_company_id"); + + b.Property("SalesManagerId") + .HasColumnType("uuid") + .HasColumnName("sales_manager_id"); + + b.HasKey("Id") + .HasName("pk_offers"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_offers_last_editor_id"); + + b.HasIndex("LicenseTypeId") + .HasDatabaseName("ix_offers_license_type_id"); + + b.HasIndex("OfferStatusId") + .HasDatabaseName("ix_offers_offer_status_id"); + + b.HasIndex("OfferTypeId") + .HasDatabaseName("ix_offers_offer_type_id"); + + b.HasIndex("ProviderCompanyId") + .HasDatabaseName("ix_offers_provider_company_id"); + + b.HasIndex("SalesManagerId") + .HasDatabaseName("ix_offers_sales_manager_id"); + + b.ToTable("offers", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_OFFER", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_OFFER() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_OFFER$\r\nBEGIN\r\n INSERT INTO portal.audit_offer20230406 (\"id\", \"name\", \"date_created\", \"date_released\", \"marketing_url\", \"contact_email\", \"contact_number\", \"provider\", \"offer_type_id\", \"sales_manager_id\", \"provider_company_id\", \"offer_status_id\", \"license_type_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.name, \r\n OLD.date_created, \r\n OLD.date_released, \r\n OLD.marketing_url, \r\n OLD.contact_email, \r\n OLD.contact_number, \r\n OLD.provider, \r\n OLD.offer_type_id, \r\n OLD.sales_manager_id, \r\n OLD.provider_company_id, \r\n OLD.offer_status_id, \r\n OLD.license_type_id, \r\n OLD.date_last_changed, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_OFFER$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_OFFER AFTER DELETE\r\nON portal.offers\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_OFFER();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_OFFER", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_OFFER() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_OFFER$\r\nBEGIN\r\n INSERT INTO portal.audit_offer20230406 (\"id\", \"name\", \"date_created\", \"date_released\", \"marketing_url\", \"contact_email\", \"contact_number\", \"provider\", \"offer_type_id\", \"sales_manager_id\", \"provider_company_id\", \"offer_status_id\", \"license_type_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.date_created, \r\n NEW.date_released, \r\n NEW.marketing_url, \r\n NEW.contact_email, \r\n NEW.contact_number, \r\n NEW.provider, \r\n NEW.offer_type_id, \r\n NEW.sales_manager_id, \r\n NEW.provider_company_id, \r\n NEW.offer_status_id, \r\n NEW.license_type_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_OFFER$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_OFFER AFTER INSERT\r\nON portal.offers\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_OFFER();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_OFFER", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_OFFER() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_OFFER$\r\nBEGIN\r\n INSERT INTO portal.audit_offer20230406 (\"id\", \"name\", \"date_created\", \"date_released\", \"marketing_url\", \"contact_email\", \"contact_number\", \"provider\", \"offer_type_id\", \"sales_manager_id\", \"provider_company_id\", \"offer_status_id\", \"license_type_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.date_created, \r\n NEW.date_released, \r\n NEW.marketing_url, \r\n NEW.contact_email, \r\n NEW.contact_number, \r\n NEW.provider, \r\n NEW.offer_type_id, \r\n NEW.sales_manager_id, \r\n NEW.provider_company_id, \r\n NEW.offer_status_id, \r\n NEW.license_type_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_OFFER$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_OFFER AFTER UPDATE\r\nON portal.offers\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_OFFER();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferAssignedDocument", b => + { + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("DocumentId") + .HasColumnType("uuid") + .HasColumnName("document_id"); + + b.HasKey("OfferId", "DocumentId") + .HasName("pk_offer_assigned_documents"); + + b.HasIndex("DocumentId") + .HasDatabaseName("ix_offer_assigned_documents_document_id"); + + b.ToTable("offer_assigned_documents", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferAssignedLicense", b => + { + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("OfferLicenseId") + .HasColumnType("uuid") + .HasColumnName("offer_license_id"); + + b.HasKey("OfferId", "OfferLicenseId") + .HasName("pk_offer_assigned_licenses"); + + b.HasIndex("OfferLicenseId") + .HasDatabaseName("ix_offer_assigned_licenses_offer_license_id"); + + b.ToTable("offer_assigned_licenses", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferAssignedPrivacyPolicy", b => + { + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("PrivacyPolicyId") + .HasColumnType("integer") + .HasColumnName("privacy_policy_id"); + + b.HasKey("OfferId", "PrivacyPolicyId") + .HasName("pk_offer_assigned_privacy_policies"); + + b.HasIndex("PrivacyPolicyId") + .HasDatabaseName("ix_offer_assigned_privacy_policies_privacy_policy_id"); + + b.ToTable("offer_assigned_privacy_policies", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferDescription", b => + { + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name"); + + b.Property("DescriptionLong") + .IsRequired() + .HasMaxLength(4096) + .HasColumnType("character varying(4096)") + .HasColumnName("description_long"); + + b.Property("DescriptionShort") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description_short"); + + b.HasKey("OfferId", "LanguageShortName") + .HasName("pk_offer_descriptions"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_offer_descriptions_language_short_name"); + + b.ToTable("offer_descriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferLicense", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Licensetext") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("licensetext"); + + b.HasKey("Id") + .HasName("pk_offer_licenses"); + + b.ToTable("offer_licenses", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_offer_statuses"); + + b.ToTable("offer_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "CREATED" + }, + new + { + Id = 2, + Label = "IN_REVIEW" + }, + new + { + Id = 3, + Label = "ACTIVE" + }, + new + { + Id = 4, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("Description") + .HasMaxLength(4096) + .HasColumnType("character varying(4096)") + .HasColumnName("description"); + + b.Property("DisplayName") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("display_name"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("OfferSubscriptionStatusId") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(1) + .HasColumnName("offer_subscription_status_id"); + + b.Property("ProcessId") + .HasColumnType("uuid") + .HasColumnName("process_id"); + + b.Property("RequesterId") + .HasColumnType("uuid") + .HasColumnName("requester_id"); + + b.HasKey("Id") + .HasName("pk_offer_subscriptions"); + + b.HasIndex("CompanyId") + .HasDatabaseName("ix_offer_subscriptions_company_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_offer_subscriptions_last_editor_id"); + + b.HasIndex("OfferId") + .HasDatabaseName("ix_offer_subscriptions_offer_id"); + + b.HasIndex("OfferSubscriptionStatusId") + .HasDatabaseName("ix_offer_subscriptions_offer_subscription_status_id"); + + b.HasIndex("ProcessId") + .IsUnique() + .HasDatabaseName("ix_offer_subscriptions_process_id"); + + b.HasIndex("RequesterId") + .HasDatabaseName("ix_offer_subscriptions_requester_id"); + + b.ToTable("offer_subscriptions", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_OFFERSUBSCRIPTION", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_OFFERSUBSCRIPTION() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_OFFERSUBSCRIPTION$\r\nBEGIN\r\n INSERT INTO portal.audit_offer_subscription20230317 (\"id\", \"company_id\", \"offer_id\", \"offer_subscription_status_id\", \"display_name\", \"description\", \"requester_id\", \"last_editor_id\", \"process_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.company_id, \r\n OLD.offer_id, \r\n OLD.offer_subscription_status_id, \r\n OLD.display_name, \r\n OLD.description, \r\n OLD.requester_id, \r\n OLD.last_editor_id, \r\n OLD.process_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_OFFERSUBSCRIPTION$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_OFFERSUBSCRIPTION AFTER DELETE\r\nON portal.offer_subscriptions\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_OFFERSUBSCRIPTION();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_OFFERSUBSCRIPTION", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_OFFERSUBSCRIPTION() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_OFFERSUBSCRIPTION$\r\nBEGIN\r\n INSERT INTO portal.audit_offer_subscription20230317 (\"id\", \"company_id\", \"offer_id\", \"offer_subscription_status_id\", \"display_name\", \"description\", \"requester_id\", \"last_editor_id\", \"process_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.company_id, \r\n NEW.offer_id, \r\n NEW.offer_subscription_status_id, \r\n NEW.display_name, \r\n NEW.description, \r\n NEW.requester_id, \r\n NEW.last_editor_id, \r\n NEW.process_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_OFFERSUBSCRIPTION$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_OFFERSUBSCRIPTION AFTER INSERT\r\nON portal.offer_subscriptions\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_OFFERSUBSCRIPTION();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_OFFERSUBSCRIPTION", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_OFFERSUBSCRIPTION() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_OFFERSUBSCRIPTION$\r\nBEGIN\r\n INSERT INTO portal.audit_offer_subscription20230317 (\"id\", \"company_id\", \"offer_id\", \"offer_subscription_status_id\", \"display_name\", \"description\", \"requester_id\", \"last_editor_id\", \"process_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.company_id, \r\n NEW.offer_id, \r\n NEW.offer_subscription_status_id, \r\n NEW.display_name, \r\n NEW.description, \r\n NEW.requester_id, \r\n NEW.last_editor_id, \r\n NEW.process_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_OFFERSUBSCRIPTION$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_OFFERSUBSCRIPTION AFTER UPDATE\r\nON portal.offer_subscriptions\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_OFFERSUBSCRIPTION();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscriptionProcessData", b => + { + b.Property("OfferSubscriptionId") + .HasColumnType("uuid") + .HasColumnName("offer_subscription_id"); + + b.Property("OfferUrl") + .IsRequired() + .HasColumnType("text") + .HasColumnName("offer_url"); + + b.HasKey("OfferSubscriptionId") + .HasName("pk_offer_subscriptions_process_datas"); + + b.ToTable("offer_subscriptions_process_datas", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscriptionStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_offer_subscription_statuses"); + + b.ToTable("offer_subscription_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "PENDING" + }, + new + { + Id = 2, + Label = "ACTIVE" + }, + new + { + Id = 3, + Label = "INACTIVE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferTag", b => + { + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("tag_name"); + + b.HasKey("OfferId", "Name") + .HasName("pk_offer_tags"); + + b.ToTable("offer_tags", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_offer_types"); + + b.ToTable("offer_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "APP" + }, + new + { + Id = 2, + Label = "CORE_COMPONENT" + }, + new + { + Id = 3, + Label = "SERVICE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.PrivacyPolicy", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_privacy_policies"); + + b.ToTable("privacy_policies", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "COMPANY_DATA" + }, + new + { + Id = 2, + Label = "USER_DATA" + }, + new + { + Id = 3, + Label = "LOCATION" + }, + new + { + Id = 4, + Label = "BROWSER_HISTORY" + }, + new + { + Id = 5, + Label = "NONE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Process", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LockExpiryDate") + .HasColumnType("timestamp with time zone") + .HasColumnName("lock_expiry_date"); + + b.Property("ProcessTypeId") + .HasColumnType("integer") + .HasColumnName("process_type_id"); + + b.Property("Version") + .IsConcurrencyToken() + .HasColumnType("uuid") + .HasColumnName("version"); + + b.HasKey("Id") + .HasName("pk_processes"); + + b.HasIndex("ProcessTypeId") + .HasDatabaseName("ix_processes_process_type_id"); + + b.ToTable("processes", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStep", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("Message") + .HasColumnType("text") + .HasColumnName("message"); + + b.Property("ProcessId") + .HasColumnType("uuid") + .HasColumnName("process_id"); + + b.Property("ProcessStepStatusId") + .HasColumnType("integer") + .HasColumnName("process_step_status_id"); + + b.Property("ProcessStepTypeId") + .HasColumnType("integer") + .HasColumnName("process_step_type_id"); + + b.HasKey("Id") + .HasName("pk_process_steps"); + + b.HasIndex("ProcessId") + .HasDatabaseName("ix_process_steps_process_id"); + + b.HasIndex("ProcessStepStatusId") + .HasDatabaseName("ix_process_steps_process_step_status_id"); + + b.HasIndex("ProcessStepTypeId") + .HasDatabaseName("ix_process_steps_process_step_type_id"); + + b.ToTable("process_steps", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStepStatus", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_process_step_statuses"); + + b.ToTable("process_step_statuses", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "TODO" + }, + new + { + Id = 2, + Label = "DONE" + }, + new + { + Id = 3, + Label = "SKIPPED" + }, + new + { + Id = 4, + Label = "FAILED" + }, + new + { + Id = 5, + Label = "DUPLICATE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStepType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_process_step_types"); + + b.ToTable("process_step_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "VERIFY_REGISTRATION" + }, + new + { + Id = 2, + Label = "CREATE_BUSINESS_PARTNER_NUMBER_PUSH" + }, + new + { + Id = 3, + Label = "CREATE_BUSINESS_PARTNER_NUMBER_PULL" + }, + new + { + Id = 4, + Label = "CREATE_BUSINESS_PARTNER_NUMBER_MANUAL" + }, + new + { + Id = 5, + Label = "CREATE_IDENTITY_WALLET" + }, + new + { + Id = 6, + Label = "RETRIGGER_IDENTITY_WALLET" + }, + new + { + Id = 7, + Label = "START_CLEARING_HOUSE" + }, + new + { + Id = 8, + Label = "RETRIGGER_CLEARING_HOUSE" + }, + new + { + Id = 9, + Label = "END_CLEARING_HOUSE" + }, + new + { + Id = 10, + Label = "START_SELF_DESCRIPTION_LP" + }, + new + { + Id = 11, + Label = "RETRIGGER_SELF_DESCRIPTION_LP" + }, + new + { + Id = 12, + Label = "ACTIVATE_APPLICATION" + }, + new + { + Id = 13, + Label = "RETRIGGER_BUSINESS_PARTNER_NUMBER_PUSH" + }, + new + { + Id = 14, + Label = "RETRIGGER_BUSINESS_PARTNER_NUMBER_PULL" + }, + new + { + Id = 15, + Label = "OVERRIDE_BUSINESS_PARTNER_NUMBER" + }, + new + { + Id = 16, + Label = "TRIGGER_OVERRIDE_CLEARING_HOUSE" + }, + new + { + Id = 17, + Label = "START_OVERRIDE_CLEARING_HOUSE" + }, + new + { + Id = 18, + Label = "FINISH_SELF_DESCRIPTION_LP" + }, + new + { + Id = 19, + Label = "DECLINE_APPLICATION" + }, + new + { + Id = 100, + Label = "TRIGGER_PROVIDER" + }, + new + { + Id = 101, + Label = "START_AUTOSETUP" + }, + new + { + Id = 102, + Label = "OFFERSUBSCRIPTION_CLIENT_CREATION" + }, + new + { + Id = 103, + Label = "SINGLE_INSTANCE_SUBSCRIPTION_DETAILS_CREATION" + }, + new + { + Id = 104, + Label = "OFFERSUBSCRIPTION_TECHNICALUSER_CREATION" + }, + new + { + Id = 105, + Label = "ACTIVATE_SUBSCRIPTION" + }, + new + { + Id = 106, + Label = "TRIGGER_PROVIDER_CALLBACK" + }, + new + { + Id = 107, + Label = "RETRIGGER_PROVIDER" + }, + new + { + Id = 108, + Label = "RETRIGGER_OFFERSUBSCRIPTION_CLIENT_CREATION" + }, + new + { + Id = 109, + Label = "RETRIGGER_OFFERSUBSCRIPTION_TECHNICALUSER_CREATION" + }, + new + { + Id = 110, + Label = "RETRIGGER_PROVIDER_CALLBACK" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_process_types"); + + b.ToTable("process_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "APPLICATION_CHECKLIST" + }, + new + { + Id = 3, + Label = "OFFER_SUBSCRIPTION" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProviderCompanyDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("AutoSetupCallbackUrl") + .HasColumnType("text") + .HasColumnName("auto_setup_callback_url"); + + b.Property("AutoSetupUrl") + .IsRequired() + .HasColumnType("text") + .HasColumnName("auto_setup_url"); + + b.Property("CompanyId") + .HasColumnType("uuid") + .HasColumnName("company_id"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_created"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.HasKey("Id") + .HasName("pk_provider_company_details"); + + b.HasIndex("CompanyId") + .IsUnique() + .HasDatabaseName("ix_provider_company_details_company_id"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_provider_company_details_last_editor_id"); + + b.ToTable("provider_company_details", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_PROVIDERCOMPANYDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_PROVIDERCOMPANYDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_PROVIDERCOMPANYDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_provider_company_detail20230614 (\"id\", \"date_created\", \"auto_setup_url\", \"auto_setup_callback_url\", \"company_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.date_created, \r\n OLD.auto_setup_url, \r\n OLD.auto_setup_callback_url, \r\n OLD.company_id, \r\n OLD.date_last_changed, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_PROVIDERCOMPANYDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_PROVIDERCOMPANYDETAIL AFTER DELETE\r\nON portal.provider_company_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_PROVIDERCOMPANYDETAIL();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_PROVIDERCOMPANYDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_PROVIDERCOMPANYDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_PROVIDERCOMPANYDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_provider_company_detail20230614 (\"id\", \"date_created\", \"auto_setup_url\", \"auto_setup_callback_url\", \"company_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.auto_setup_url, \r\n NEW.auto_setup_callback_url, \r\n NEW.company_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_PROVIDERCOMPANYDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_PROVIDERCOMPANYDETAIL AFTER INSERT\r\nON portal.provider_company_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_PROVIDERCOMPANYDETAIL();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_PROVIDERCOMPANYDETAIL", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_PROVIDERCOMPANYDETAIL() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_PROVIDERCOMPANYDETAIL$\r\nBEGIN\r\n INSERT INTO portal.audit_provider_company_detail20230614 (\"id\", \"date_created\", \"auto_setup_url\", \"auto_setup_callback_url\", \"company_id\", \"date_last_changed\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.date_created, \r\n NEW.auto_setup_url, \r\n NEW.auto_setup_callback_url, \r\n NEW.company_id, \r\n NEW.date_last_changed, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_PROVIDERCOMPANYDETAIL$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_PROVIDERCOMPANYDETAIL AFTER UPDATE\r\nON portal.provider_company_details\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_PROVIDERCOMPANYDETAIL();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ServiceDetail", b => + { + b.Property("ServiceId") + .HasColumnType("uuid") + .HasColumnName("service_id"); + + b.Property("ServiceTypeId") + .HasColumnType("integer") + .HasColumnName("service_type_id"); + + b.HasKey("ServiceId", "ServiceTypeId") + .HasName("pk_service_details"); + + b.HasIndex("ServiceTypeId") + .HasDatabaseName("ix_service_details_service_type_id"); + + b.ToTable("service_details", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ServiceType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_service_types"); + + b.ToTable("service_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "DATASPACE_SERVICE" + }, + new + { + Id = 2, + Label = "CONSULTANCE_SERVICE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.TechnicalUserProfile", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.HasKey("Id") + .HasName("pk_technical_user_profiles"); + + b.HasIndex("OfferId") + .HasDatabaseName("ix_technical_user_profiles_offer_id"); + + b.ToTable("technical_user_profiles", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.TechnicalUserProfileAssignedUserRole", b => + { + b.Property("TechnicalUserProfileId") + .HasColumnType("uuid") + .HasColumnName("technical_user_profile_id"); + + b.Property("UserRoleId") + .HasColumnType("uuid") + .HasColumnName("user_role_id"); + + b.HasKey("TechnicalUserProfileId", "UserRoleId") + .HasName("pk_technical_user_profile_assigned_user_roles"); + + b.HasIndex("UserRoleId") + .HasDatabaseName("ix_technical_user_profile_assigned_user_roles_user_role_id"); + + b.ToTable("technical_user_profile_assigned_user_roles", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UniqueIdentifier", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_unique_identifiers"); + + b.ToTable("unique_identifiers", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "COMMERCIAL_REG_NUMBER" + }, + new + { + Id = 2, + Label = "VAT_ID" + }, + new + { + Id = 3, + Label = "LEI_CODE" + }, + new + { + Id = 4, + Label = "VIES" + }, + new + { + Id = 5, + Label = "EORI" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("Shortname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("shortname"); + + b.HasKey("Id") + .HasName("pk_use_cases"); + + b.ToTable("use_cases", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCaseDescription", b => + { + b.Property("UseCaseId") + .HasColumnType("uuid") + .HasColumnName("use_case_id"); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text") + .HasColumnName("description"); + + b.HasKey("UseCaseId", "LanguageShortName") + .HasName("pk_use_case_descriptions"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_use_case_descriptions_language_short_name"); + + b.ToTable("use_case_descriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("OfferId") + .HasColumnType("uuid") + .HasColumnName("offer_id"); + + b.Property("UserRoleText") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("user_role"); + + b.HasKey("Id") + .HasName("pk_user_roles"); + + b.HasIndex("LastEditorId") + .HasDatabaseName("ix_user_roles_last_editor_id"); + + b.HasIndex("OfferId") + .HasDatabaseName("ix_user_roles_offer_id"); + + b.ToTable("user_roles", "portal"); + + b + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_USERROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_USERROLE() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_USERROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_user_role20221017 (\"id\", \"user_role\", \"offer_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.user_role, \r\n OLD.offer_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_USERROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_USERROLE AFTER DELETE\r\nON portal.user_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_USERROLE();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_USERROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_USERROLE() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_USERROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_user_role20221017 (\"id\", \"user_role\", \"offer_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.user_role, \r\n NEW.offer_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_USERROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_USERROLE AFTER INSERT\r\nON portal.user_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_USERROLE();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_USERROLE", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_USERROLE() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_USERROLE$\r\nBEGIN\r\n INSERT INTO portal.audit_user_role20221017 (\"id\", \"user_role\", \"offer_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.user_role, \r\n NEW.offer_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_USERROLE$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_USERROLE AFTER UPDATE\r\nON portal.user_roles\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_USERROLE();"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleAssignedCollection", b => + { + b.Property("UserRoleId") + .HasColumnType("uuid") + .HasColumnName("user_role_id"); + + b.Property("UserRoleCollectionId") + .HasColumnType("uuid") + .HasColumnName("user_role_collection_id"); + + b.HasKey("UserRoleId", "UserRoleCollectionId") + .HasName("pk_user_role_assigned_collections"); + + b.HasIndex("UserRoleCollectionId") + .HasDatabaseName("ix_user_role_assigned_collections_user_role_collection_id"); + + b.ToTable("user_role_assigned_collections", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.HasKey("Id") + .HasName("pk_user_role_collections"); + + b.ToTable("user_role_collections", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollectionDescription", b => + { + b.Property("UserRoleCollectionId") + .HasColumnType("uuid") + .HasColumnName("user_role_collection_id"); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description"); + + b.HasKey("UserRoleCollectionId", "LanguageShortName") + .HasName("pk_user_role_collection_descriptions"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_user_role_collection_descriptions_language_short_name"); + + b.ToTable("user_role_collection_descriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleDescription", b => + { + b.Property("UserRoleId") + .HasColumnType("uuid") + .HasColumnName("user_role_id"); + + b.Property("LanguageShortName") + .HasMaxLength(2) + .HasColumnType("character(2)") + .HasColumnName("language_short_name"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("description"); + + b.HasKey("UserRoleId", "LanguageShortName") + .HasName("pk_user_role_descriptions"); + + b.HasIndex("LanguageShortName") + .HasDatabaseName("ix_user_role_descriptions_language_short_name"); + + b.ToTable("user_role_descriptions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasColumnType("text") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_verified_credential_external_types"); + + b.ToTable("verified_credential_external_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "TRACEABILITY_CREDENTIAL" + }, + new + { + Id = 2, + Label = "PCF_CREDENTIAL" + }, + new + { + Id = 3, + Label = "BEHAVIOR_TWIN_CREDENTIAL" + }, + new + { + Id = 4, + Label = "VEHICLE_DISMANTLE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalTypeUseCaseDetailVersion", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("Expiry") + .HasColumnType("timestamp with time zone") + .HasColumnName("expiry"); + + b.Property("Template") + .IsRequired() + .HasColumnType("text") + .HasColumnName("template"); + + b.Property("ValidFrom") + .HasColumnType("timestamp with time zone") + .HasColumnName("valid_from"); + + b.Property("VerifiedCredentialExternalTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_external_type_id"); + + b.Property("Version") + .IsRequired() + .HasColumnType("text") + .HasColumnName("version"); + + b.HasKey("Id") + .HasName("pk_verified_credential_external_type_use_case_detail_versions"); + + b.HasIndex("VerifiedCredentialExternalTypeId", "Version") + .IsUnique() + .HasDatabaseName("ix_verified_credential_external_type_use_case_detail_versions_"); + + b.ToTable("verified_credential_external_type_use_case_detail_versions", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialType", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_verified_credential_types"); + + b.ToTable("verified_credential_types", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "TRACEABILITY_FRAMEWORK" + }, + new + { + Id = 2, + Label = "PCF_FRAMEWORK" + }, + new + { + Id = 3, + Label = "BEHAVIOR_TWIN_FRAMEWORK" + }, + new + { + Id = 4, + Label = "DISMANTLER_CERTIFICATE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedExternalType", b => + { + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.Property("VerifiedCredentialExternalTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_external_type_id"); + + b.HasKey("VerifiedCredentialTypeId", "VerifiedCredentialExternalTypeId") + .HasName("pk_verified_credential_type_assigned_external_types"); + + b.HasIndex("VerifiedCredentialExternalTypeId") + .HasDatabaseName("ix_verified_credential_type_assigned_external_types_verified_c"); + + b.HasIndex("VerifiedCredentialTypeId") + .IsUnique() + .HasDatabaseName("ix_verified_credential_type_assigned_external_types_verified_c1"); + + b.ToTable("verified_credential_type_assigned_external_types", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedKind", b => + { + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.Property("VerifiedCredentialTypeKindId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_kind_id"); + + b.HasKey("VerifiedCredentialTypeId", "VerifiedCredentialTypeKindId") + .HasName("pk_verified_credential_type_assigned_kinds"); + + b.HasIndex("VerifiedCredentialTypeId") + .HasDatabaseName("ix_verified_credential_type_assigned_kinds_verified_credential"); + + b.HasIndex("VerifiedCredentialTypeKindId") + .HasDatabaseName("ix_verified_credential_type_assigned_kinds_verified_credential1"); + + b.ToTable("verified_credential_type_assigned_kinds", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedUseCase", b => + { + b.Property("VerifiedCredentialTypeId") + .HasColumnType("integer") + .HasColumnName("verified_credential_type_id"); + + b.Property("UseCaseId") + .HasColumnType("uuid") + .HasColumnName("use_case_id"); + + b.HasKey("VerifiedCredentialTypeId", "UseCaseId") + .HasName("pk_verified_credential_type_assigned_use_cases"); + + b.HasIndex("UseCaseId") + .IsUnique() + .HasDatabaseName("ix_verified_credential_type_assigned_use_cases_use_case_id"); + + b.HasIndex("VerifiedCredentialTypeId") + .IsUnique() + .HasDatabaseName("ix_verified_credential_type_assigned_use_cases_verified_creden"); + + b.ToTable("verified_credential_type_assigned_use_cases", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeKind", b => + { + b.Property("Id") + .HasColumnType("integer") + .HasColumnName("id"); + + b.Property("Label") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("label"); + + b.HasKey("Id") + .HasName("pk_verified_credential_type_kinds"); + + b.ToTable("verified_credential_type_kinds", "portal"); + + b.HasData( + new + { + Id = 1, + Label = "USE_CASE" + }, + new + { + Id = 2, + Label = "CERTIFICATE" + }); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Views.CompaniesLinkedServiceAccount", b => + { + b.Property("ServiceAccountId") + .HasColumnType("uuid") + .HasColumnName("service_account_id"); + + b.Property("Owners") + .HasColumnType("uuid") + .HasColumnName("owners"); + + b.Property("Provider") + .HasColumnType("uuid") + .HasColumnName("provider"); + + b.HasKey("ServiceAccountId"); + + b.ToTable((string)null); + + b.ToView("company_linked_service_accounts", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Views.OfferSubscriptionView", b => + { + b.Property("AppInstance") + .HasColumnType("uuid") + .HasColumnName("app_instance"); + + b.Property("Connector") + .HasColumnType("uuid") + .HasColumnName("connector"); + + b.Property("OfferTypeId") + .HasColumnType("integer") + .HasColumnName("offer_type_id"); + + b.Property("SubscriptionId") + .HasColumnType("uuid") + .HasColumnName("subscription_id"); + + b.Property("TechnicalUser") + .HasColumnType("uuid") + .HasColumnName("technical_user"); + + b.ToTable((string)null); + + b.ToView("offer_subscription_view", "portal"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Address", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Country", "Country") + .WithMany("Addresses") + .HasForeignKey("CountryAlpha2Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_addresses_countries_country_temp_id"); + + b.Navigation("Country"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementCategory", "AgreementCategory") + .WithMany("Agreements") + .HasForeignKey("AgreementCategoryId") + .IsRequired() + .HasConstraintName("fk_agreements_agreement_categories_agreement_category_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", "Document") + .WithMany("Agreements") + .HasForeignKey("DocumentId") + .HasConstraintName("fk_agreements_documents_document_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "IssuerCompany") + .WithMany("Agreements") + .HasForeignKey("IssuerCompanyId") + .IsRequired() + .HasConstraintName("fk_agreements_companies_issuer_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", "UseCase") + .WithMany("Agreements") + .HasForeignKey("UseCaseId") + .HasConstraintName("fk_agreements_use_cases_use_case_id"); + + b.Navigation("AgreementCategory"); + + b.Navigation("Document"); + + b.Navigation("IssuerCompany"); + + b.Navigation("UseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementAssignedCompanyRole", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", "Agreement") + .WithMany("AgreementAssignedCompanyRoles") + .HasForeignKey("AgreementId") + .IsRequired() + .HasConstraintName("fk_agreement_assigned_company_roles_agreements_agreement_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", "CompanyRole") + .WithMany("AgreementAssignedCompanyRoles") + .HasForeignKey("CompanyRoleId") + .IsRequired() + .HasConstraintName("fk_agreement_assigned_company_roles_company_roles_company_role"); + + b.Navigation("Agreement"); + + b.Navigation("CompanyRole"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementAssignedOffer", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", "Agreement") + .WithMany("AgreementAssignedOffers") + .HasForeignKey("AgreementId") + .IsRequired() + .HasConstraintName("fk_agreement_assigned_offers_agreements_agreement_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("AgreementAssignedOffers") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_agreement_assigned_offers_offers_offer_id"); + + b.Navigation("Agreement"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementAssignedOfferType", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", "Agreement") + .WithMany("AgreementAssignedOfferTypes") + .HasForeignKey("AgreementId") + .IsRequired() + .HasConstraintName("fk_agreement_assigned_offer_types_agreements_agreement_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferType", "OfferType") + .WithMany("AgreementAssignedOfferTypes") + .HasForeignKey("OfferTypeId") + .IsRequired() + .HasConstraintName("fk_agreement_assigned_offer_types_offer_types_offer_type_id"); + + b.Navigation("Agreement"); + + b.Navigation("OfferType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppAssignedUseCase", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "App") + .WithMany() + .HasForeignKey("AppId") + .IsRequired() + .HasConstraintName("fk_app_assigned_use_cases_offers_app_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", "UseCase") + .WithMany() + .HasForeignKey("UseCaseId") + .IsRequired() + .HasConstraintName("fk_app_assigned_use_cases_use_cases_use_case_id"); + + b.Navigation("App"); + + b.Navigation("UseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstance", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "App") + .WithMany("AppInstances") + .HasForeignKey("AppId") + .OnDelete(DeleteBehavior.SetNull) + .IsRequired() + .HasConstraintName("fk_app_instances_offers_app_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IamClient", "IamClient") + .WithMany("AppInstances") + .HasForeignKey("IamClientId") + .OnDelete(DeleteBehavior.SetNull) + .IsRequired() + .HasConstraintName("fk_app_instances_iam_clients_iam_client_id"); + + b.Navigation("App"); + + b.Navigation("IamClient"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstanceAssignedCompanyServiceAccount", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstance", "AppInstance") + .WithMany("ServiceAccounts") + .HasForeignKey("AppInstanceId") + .IsRequired() + .HasConstraintName("fk_app_instance_assigned_service_accounts_app_instances_app_in"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", "CompanyServiceAccount") + .WithMany("AppInstances") + .HasForeignKey("CompanyServiceAccountId") + .IsRequired() + .HasConstraintName("fk_app_instance_assigned_service_accounts_company_service_acco"); + + b.Navigation("AppInstance"); + + b.Navigation("CompanyServiceAccount"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstanceSetup", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "App") + .WithOne("AppInstanceSetup") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstanceSetup", "AppId") + .IsRequired() + .HasConstraintName("fk_app_instance_setups_offers_app_id"); + + b.Navigation("App"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppLanguage", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "App") + .WithMany() + .HasForeignKey("AppId") + .IsRequired() + .HasConstraintName("fk_app_languages_offers_app_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany() + .HasForeignKey("LanguageShortName") + .IsRequired() + .HasConstraintName("fk_app_languages_languages_language_temp_id"); + + b.Navigation("App"); + + b.Navigation("Language"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntry", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntryStatus", "ApplicationChecklistEntryStatus") + .WithMany("ApplicationChecklistEntries") + .HasForeignKey("ApplicationChecklistEntryStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_application_checklist_application_checklist_statuses_applic"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntryType", "ApplicationChecklistEntryType") + .WithMany("ApplicationChecklistEntries") + .HasForeignKey("ApplicationChecklistEntryTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_application_checklist_application_checklist_types_applicati"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplication", "Application") + .WithMany("ApplicationChecklistEntries") + .HasForeignKey("ApplicationId") + .IsRequired() + .HasConstraintName("fk_application_checklist_company_applications_application_id"); + + b.Navigation("Application"); + + b.Navigation("ApplicationChecklistEntryStatus"); + + b.Navigation("ApplicationChecklistEntryType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppSubscriptionDetail", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstance", "AppInstance") + .WithMany("AppSubscriptionDetails") + .HasForeignKey("AppInstanceId") + .HasConstraintName("fk_app_subscription_details_app_instances_app_instance_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_app_subscription_details_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", "OfferSubscription") + .WithOne("AppSubscriptionDetail") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppSubscriptionDetail", "OfferSubscriptionId") + .IsRequired() + .HasConstraintName("fk_app_subscription_details_offer_subscriptions_offer_subscrip"); + + b.Navigation("AppInstance"); + + b.Navigation("LastEditor"); + + b.Navigation("OfferSubscription"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Address", "Address") + .WithMany("Companies") + .HasForeignKey("AddressId") + .HasConstraintName("fk_companies_addresses_address_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyStatus", "CompanyStatus") + .WithMany("Companies") + .HasForeignKey("CompanyStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_companies_company_statuses_company_status_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", "SelfDescriptionDocument") + .WithMany("Companies") + .HasForeignKey("SelfDescriptionDocumentId") + .HasConstraintName("fk_companies_documents_self_description_document_id"); + + b.Navigation("Address"); + + b.Navigation("CompanyStatus"); + + b.Navigation("SelfDescriptionDocument"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplication", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplicationStatus", "ApplicationStatus") + .WithMany("CompanyApplications") + .HasForeignKey("ApplicationStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_applications_company_application_statuses_applicati"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Process", "ChecklistProcess") + .WithOne("CompanyApplication") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplication", "ChecklistProcessId") + .HasConstraintName("fk_company_applications_processes_checklist_process_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("CompanyApplications") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_company_applications_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_company_applications_identities_last_editor_id"); + + b.Navigation("ApplicationStatus"); + + b.Navigation("ChecklistProcess"); + + b.Navigation("Company"); + + b.Navigation("LastEditor"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyAssignedRole", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("CompanyAssignedRoles") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_company_assigned_roles_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", "CompanyRole") + .WithMany("CompanyAssignedRoles") + .HasForeignKey("CompanyRoleId") + .IsRequired() + .HasConstraintName("fk_company_assigned_roles_company_roles_company_role_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_company_assigned_roles_identities_last_editor_id"); + + b.Navigation("Company"); + + b.Navigation("CompanyRole"); + + b.Navigation("LastEditor"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyAssignedUseCase", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("CompanyAssignedUseCase") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_company_assigned_use_cases_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", "UseCase") + .WithMany("CompanyAssignedUseCase") + .HasForeignKey("UseCaseId") + .IsRequired() + .HasConstraintName("fk_company_assigned_use_cases_use_cases_use_case_id"); + + b.Navigation("Company"); + + b.Navigation("UseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyIdentifier", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("CompanyIdentifiers") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_company_identifiers_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UniqueIdentifier", "UniqueIdentifier") + .WithMany("CompanyIdentifiers") + .HasForeignKey("UniqueIdentifierId") + .IsRequired() + .HasConstraintName("fk_company_identifiers_unique_identifiers_unique_identifier_id"); + + b.Navigation("Company"); + + b.Navigation("UniqueIdentifier"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyIdentityProvider", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany() + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_company_identity_providers_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProvider", "IdentityProvider") + .WithMany("CompanyIdentityProviders") + .HasForeignKey("IdentityProviderId") + .IsRequired() + .HasConstraintName("fk_company_identity_providers_identity_providers_identity_prov"); + + b.Navigation("Company"); + + b.Navigation("IdentityProvider"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleAssignedRoleCollection", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", "CompanyRole") + .WithOne("CompanyRoleAssignedRoleCollection") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleAssignedRoleCollection", "CompanyRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_role_assigned_role_collections_company_roles_compan"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollection", "UserRoleCollection") + .WithOne("CompanyRoleAssignedRoleCollection") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleAssignedRoleCollection", "UserRoleCollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_role_assigned_role_collections_user_role_collection"); + + b.Navigation("CompanyRole"); + + b.Navigation("UserRoleCollection"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleDescription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", "CompanyRole") + .WithMany("CompanyRoleDescriptions") + .HasForeignKey("CompanyRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_role_descriptions_company_roles_company_role_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany("CompanyRoleDescriptions") + .HasForeignKey("LanguageShortName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_role_descriptions_languages_language_temp_id1"); + + b.Navigation("CompanyRole"); + + b.Navigation("Language"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleRegistrationData", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", "CompanyRole") + .WithOne("CompanyRoleRegistrationData") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRoleRegistrationData", "CompanyRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_role_registration_data_company_roles_company_role_id"); + + b.Navigation("CompanyRole"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccountType", "CompanyServiceAccountType") + .WithMany("CompanyServiceAccounts") + .HasForeignKey("CompanyServiceAccountTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_service_accounts_company_service_account_types_comp"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "Identity") + .WithOne("CompanyServiceAccount") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_service_accounts_identities_identity_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", "OfferSubscription") + .WithMany("CompanyServiceAccounts") + .HasForeignKey("OfferSubscriptionId") + .HasConstraintName("fk_company_service_accounts_offer_subscriptions_offer_subscrip"); + + b.Navigation("CompanyServiceAccountType"); + + b.Navigation("Identity"); + + b.Navigation("OfferSubscription"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanySsiDetail", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("CompanySsiDetails") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanySsiDetailStatus", "CompanySsiDetailStatus") + .WithMany("CompanySsiDetails") + .HasForeignKey("CompanySsiDetailStatusId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_company_ssi_detail_statuses_company_ssi"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "CreatorUser") + .WithMany("CompanySsiDetails") + .HasForeignKey("CreatorUserId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_company_users_creator_user_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", "Document") + .WithOne("CompanySsiDetail") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanySsiDetail", "DocumentId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_documents_document_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_company_ssi_details_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalTypeUseCaseDetailVersion", "VerifiedCredentialExternalTypeUseCaseDetailVersion") + .WithMany("CompanySsiDetails") + .HasForeignKey("VerifiedCredentialExternalTypeUseCaseDetailId") + .HasConstraintName("fk_company_ssi_details_verified_credential_external_type_use_c"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithMany("CompanySsiDetails") + .HasForeignKey("VerifiedCredentialTypeId") + .IsRequired() + .HasConstraintName("fk_company_ssi_details_verified_credential_types_verified_cred"); + + b.Navigation("Company"); + + b.Navigation("CompanySsiDetailStatus"); + + b.Navigation("CreatorUser"); + + b.Navigation("Document"); + + b.Navigation("LastEditor"); + + b.Navigation("VerifiedCredentialExternalTypeUseCaseDetailVersion"); + + b.Navigation("VerifiedCredentialType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "Identity") + .WithOne("CompanyUser") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_users_identities_identity_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_company_users_identities_last_editor_id"); + + b.Navigation("Identity"); + + b.Navigation("LastEditor"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUserAssignedAppFavourite", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "App") + .WithMany() + .HasForeignKey("AppId") + .IsRequired() + .HasConstraintName("fk_company_user_assigned_app_favourites_offers_app_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "CompanyUser") + .WithMany() + .HasForeignKey("CompanyUserId") + .IsRequired() + .HasConstraintName("fk_company_user_assigned_app_favourites_company_users_company_"); + + b.Navigation("App"); + + b.Navigation("CompanyUser"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUserAssignedBusinessPartner", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "CompanyUser") + .WithMany("CompanyUserAssignedBusinessPartners") + .HasForeignKey("CompanyUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_user_assigned_business_partners_company_users_compa"); + + b.Navigation("CompanyUser"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", "CompanyServiceAccount") + .WithOne("Connector") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", "CompanyServiceAccountId") + .HasConstraintName("fk_connectors_company_service_accounts_company_service_account"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Host") + .WithMany("HostedConnectors") + .HasForeignKey("HostId") + .HasConstraintName("fk_connectors_companies_host_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_connectors_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Country", "Location") + .WithMany("Connectors") + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_connectors_countries_location_temp_id1"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Provider") + .WithMany("ProvidedConnectors") + .HasForeignKey("ProviderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_connectors_companies_provider_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", "SelfDescriptionDocument") + .WithOne("Connector") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", "SelfDescriptionDocumentId") + .HasConstraintName("fk_connectors_documents_self_description_document_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorStatus", "Status") + .WithMany("Connectors") + .HasForeignKey("StatusId") + .IsRequired() + .HasConstraintName("fk_connectors_connector_statuses_status_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorType", "Type") + .WithMany("Connectors") + .HasForeignKey("TypeId") + .IsRequired() + .HasConstraintName("fk_connectors_connector_types_type_id"); + + b.Navigation("CompanyServiceAccount"); + + b.Navigation("Host"); + + b.Navigation("LastEditor"); + + b.Navigation("Location"); + + b.Navigation("Provider"); + + b.Navigation("SelfDescriptionDocument"); + + b.Navigation("Status"); + + b.Navigation("Type"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorAssignedOfferSubscription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", "Connector") + .WithMany("ConnectorAssignedOfferSubscriptions") + .HasForeignKey("ConnectorId") + .IsRequired() + .HasConstraintName("fk_connector_assigned_offer_subscriptions_connectors_connector"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", "OfferSubscription") + .WithMany("ConnectorAssignedOfferSubscriptions") + .HasForeignKey("OfferSubscriptionId") + .IsRequired() + .HasConstraintName("fk_connector_assigned_offer_subscriptions_offer_subscriptions_"); + + b.Navigation("Connector"); + + b.Navigation("OfferSubscription"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Consent", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", "Agreement") + .WithMany("Consents") + .HasForeignKey("AgreementId") + .IsRequired() + .HasConstraintName("fk_consents_agreements_agreement_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("Consents") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_consents_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "CompanyUser") + .WithMany("Consents") + .HasForeignKey("CompanyUserId") + .IsRequired() + .HasConstraintName("fk_consents_company_users_company_user_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentStatus", "ConsentStatus") + .WithMany("Consents") + .HasForeignKey("ConsentStatusId") + .IsRequired() + .HasConstraintName("fk_consents_consent_statuses_consent_status_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", "Document") + .WithMany("Consents") + .HasForeignKey("DocumentId") + .HasConstraintName("fk_consents_documents_document_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_consents_identities_last_editor_id"); + + b.Navigation("Agreement"); + + b.Navigation("Company"); + + b.Navigation("CompanyUser"); + + b.Navigation("ConsentStatus"); + + b.Navigation("Document"); + + b.Navigation("LastEditor"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentAssignedOffer", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Consent", "Consent") + .WithMany("ConsentAssignedOffers") + .HasForeignKey("ConsentId") + .IsRequired() + .HasConstraintName("fk_consent_assigned_offers_consents_consent_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("ConsentAssignedOffers") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_consent_assigned_offers_offers_offer_id"); + + b.Navigation("Consent"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentAssignedOfferSubscription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Consent", "Consent") + .WithMany("ConsentAssignedOfferSubscriptions") + .HasForeignKey("ConsentId") + .IsRequired() + .HasConstraintName("fk_consent_assigned_offer_subscriptions_consents_consent_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", "OfferSubscription") + .WithMany("ConsentAssignedOfferSubscriptions") + .HasForeignKey("OfferSubscriptionId") + .IsRequired() + .HasConstraintName("fk_consent_assigned_offer_subscriptions_offer_subscriptions_of"); + + b.Navigation("Consent"); + + b.Navigation("OfferSubscription"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CountryAssignedIdentifier", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.BpdmIdentifier", "BpdmIdentifier") + .WithMany("CountryAssignedIdentifiers") + .HasForeignKey("BpdmIdentifierId") + .HasConstraintName("fk_country_assigned_identifiers_bpdm_identifiers_bpdm_identifi"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Country", "Country") + .WithMany("CountryAssignedIdentifiers") + .HasForeignKey("CountryAlpha2Code") + .IsRequired() + .HasConstraintName("fk_country_assigned_identifiers_countries_country_alpha2code"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UniqueIdentifier", "UniqueIdentifier") + .WithMany("CountryAssignedIdentifiers") + .HasForeignKey("UniqueIdentifierId") + .IsRequired() + .HasConstraintName("fk_country_assigned_identifiers_unique_identifiers_unique_iden"); + + b.Navigation("BpdmIdentifier"); + + b.Navigation("Country"); + + b.Navigation("UniqueIdentifier"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "CompanyUser") + .WithMany("Documents") + .HasForeignKey("CompanyUserId") + .HasConstraintName("fk_documents_company_users_company_user_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.DocumentStatus", "DocumentStatus") + .WithMany("Documents") + .HasForeignKey("DocumentStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_documents_document_status_document_status_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.DocumentType", "DocumentType") + .WithMany("Documents") + .HasForeignKey("DocumentTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_documents_document_types_document_type_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.MediaType", "MediaType") + .WithMany("Documents") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_documents_media_types_media_type_id"); + + b.Navigation("CompanyUser"); + + b.Navigation("DocumentStatus"); + + b.Navigation("DocumentType"); + + b.Navigation("MediaType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IamIdentityProvider", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProvider", "IdentityProvider") + .WithOne("IamIdentityProvider") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IamIdentityProvider", "IdentityProviderId") + .IsRequired() + .HasConstraintName("fk_iam_identity_providers_identity_providers_identity_provider"); + + b.Navigation("IdentityProvider"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("Identities") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_identities_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityType", "IdentityType") + .WithMany("Identities") + .HasForeignKey("IdentityTypeId") + .IsRequired() + .HasConstraintName("fk_identities_identity_type_identity_type_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_identities_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityUserStatus", "IdentityStatus") + .WithMany("Identities") + .HasForeignKey("UserStatusId") + .IsRequired() + .HasConstraintName("fk_identities_identity_user_statuses_identity_status_id"); + + b.Navigation("Company"); + + b.Navigation("IdentityStatus"); + + b.Navigation("IdentityType"); + + b.Navigation("LastEditor"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityAssignedRole", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "Identity") + .WithMany("IdentityAssignedRoles") + .HasForeignKey("IdentityId") + .IsRequired() + .HasConstraintName("fk_identity_assigned_roles_identities_identity_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_identity_assigned_roles_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", "UserRole") + .WithMany("IdentityAssignedRoles") + .HasForeignKey("UserRoleId") + .IsRequired() + .HasConstraintName("fk_identity_assigned_roles_user_roles_user_role_id"); + + b.Navigation("Identity"); + + b.Navigation("LastEditor"); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProvider", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProviderCategory", "IdentityProviderCategory") + .WithMany("IdentityProviders") + .HasForeignKey("IdentityProviderCategoryId") + .IsRequired() + .HasConstraintName("fk_identity_providers_identity_provider_categories_identity_pr"); + + b.Navigation("IdentityProviderCategory"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Invitation", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplication", "CompanyApplication") + .WithMany("Invitations") + .HasForeignKey("CompanyApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_invitations_company_applications_company_application_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "CompanyUser") + .WithMany("Invitations") + .HasForeignKey("CompanyUserId") + .IsRequired() + .HasConstraintName("fk_invitations_company_users_company_user_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.InvitationStatus", "InvitationStatus") + .WithMany("Invitations") + .HasForeignKey("InvitationStatusId") + .IsRequired() + .HasConstraintName("fk_invitations_invitation_statuses_invitation_status_id"); + + b.Navigation("CompanyApplication"); + + b.Navigation("CompanyUser"); + + b.Navigation("InvitationStatus"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.LanguageLongName", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "LongNameLanguage") + .WithMany("LanguageLongNameLanguages") + .HasForeignKey("LanguageShortName") + .IsRequired() + .HasConstraintName("fk_language_long_names_languages_long_name_language_short_name"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany("LanguageLongNames") + .HasForeignKey("ShortName") + .IsRequired() + .HasConstraintName("fk_language_long_names_languages_language_short_name"); + + b.Navigation("Language"); + + b.Navigation("LongNameLanguage"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Notification", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "Creator") + .WithMany("CreatedNotifications") + .HasForeignKey("CreatorUserId") + .HasConstraintName("fk_notifications_identities_creator_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationType", "NotificationType") + .WithMany("Notifications") + .HasForeignKey("NotificationTypeId") + .IsRequired() + .HasConstraintName("fk_notifications_notification_type_notification_type_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "Receiver") + .WithMany("Notifications") + .HasForeignKey("ReceiverUserId") + .IsRequired() + .HasConstraintName("fk_notifications_company_users_receiver_id"); + + b.Navigation("Creator"); + + b.Navigation("NotificationType"); + + b.Navigation("Receiver"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationTypeAssignedTopic", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationTopic", "NotificationTopic") + .WithMany("NotificationTypeAssignedTopics") + .HasForeignKey("NotificationTopicId") + .IsRequired() + .HasConstraintName("fk_notification_type_assigned_topics_notification_topic_notifi"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationType", "NotificationType") + .WithOne("NotificationTypeAssignedTopic") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationTypeAssignedTopic", "NotificationTypeId") + .IsRequired() + .HasConstraintName("fk_notification_type_assigned_topics_notification_type_notific"); + + b.Navigation("NotificationTopic"); + + b.Navigation("NotificationType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_offers_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.LicenseType", "LicenseType") + .WithMany("Offers") + .HasForeignKey("LicenseTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_offers_license_types_license_type_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferStatus", "OfferStatus") + .WithMany("Offers") + .HasForeignKey("OfferStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_offers_offer_statuses_offer_status_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferType", "OfferType") + .WithMany("Offers") + .HasForeignKey("OfferTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_offers_offer_types_offer_type_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "ProviderCompany") + .WithMany("ProvidedOffers") + .HasForeignKey("ProviderCompanyId") + .HasConstraintName("fk_offers_companies_provider_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "SalesManager") + .WithMany("SalesManagerOfOffers") + .HasForeignKey("SalesManagerId") + .HasConstraintName("fk_offers_company_users_sales_manager_id"); + + b.Navigation("LastEditor"); + + b.Navigation("LicenseType"); + + b.Navigation("OfferStatus"); + + b.Navigation("OfferType"); + + b.Navigation("ProviderCompany"); + + b.Navigation("SalesManager"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferAssignedDocument", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .IsRequired() + .HasConstraintName("fk_offer_assigned_documents_documents_document_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany() + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_offer_assigned_documents_offers_offer_id"); + + b.Navigation("Document"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferAssignedLicense", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany() + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_offer_assigned_licenses_offers_offer_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferLicense", "OfferLicense") + .WithMany() + .HasForeignKey("OfferLicenseId") + .IsRequired() + .HasConstraintName("fk_offer_assigned_licenses_offer_licenses_offer_license_id"); + + b.Navigation("Offer"); + + b.Navigation("OfferLicense"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferAssignedPrivacyPolicy", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("OfferAssignedPrivacyPolicies") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_offer_assigned_privacy_policies_offers_offer_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.PrivacyPolicy", "PrivacyPolicy") + .WithMany("OfferAssignedPrivacyPolicies") + .HasForeignKey("PrivacyPolicyId") + .IsRequired() + .HasConstraintName("fk_offer_assigned_privacy_policies_privacy_policies_privacy_po"); + + b.Navigation("Offer"); + + b.Navigation("PrivacyPolicy"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferDescription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany("AppDescriptions") + .HasForeignKey("LanguageShortName") + .IsRequired() + .HasConstraintName("fk_offer_descriptions_languages_language_short_name"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("OfferDescriptions") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_offer_descriptions_offers_offer_id"); + + b.Navigation("Language"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithMany("OfferSubscriptions") + .HasForeignKey("CompanyId") + .IsRequired() + .HasConstraintName("fk_offer_subscriptions_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_offer_subscriptions_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("OfferSubscriptions") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_offer_subscriptions_offers_offer_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscriptionStatus", "OfferSubscriptionStatus") + .WithMany("OfferSubscriptions") + .HasForeignKey("OfferSubscriptionStatusId") + .IsRequired() + .HasConstraintName("fk_offer_subscriptions_offer_subscription_statuses_offer_subsc"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Process", "Process") + .WithOne("OfferSubscription") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", "ProcessId") + .HasConstraintName("fk_offer_subscriptions_processes_process_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", "Requester") + .WithMany("RequestedSubscriptions") + .HasForeignKey("RequesterId") + .IsRequired() + .HasConstraintName("fk_offer_subscriptions_company_users_requester_id"); + + b.Navigation("Company"); + + b.Navigation("LastEditor"); + + b.Navigation("Offer"); + + b.Navigation("OfferSubscriptionStatus"); + + b.Navigation("Process"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscriptionProcessData", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", "OfferSubscription") + .WithOne("OfferSubscriptionProcessData") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscriptionProcessData", "OfferSubscriptionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_offer_subscriptions_process_datas_offer_subscriptions_offer"); + + b.Navigation("OfferSubscription"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferTag", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("Tags") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_offer_tags_offers_offer_id"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Process", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessType", "ProcessType") + .WithMany("Processes") + .HasForeignKey("ProcessTypeId") + .IsRequired() + .HasConstraintName("fk_processes_process_types_process_type_id"); + + b.Navigation("ProcessType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStep", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Process", "Process") + .WithMany("ProcessSteps") + .HasForeignKey("ProcessId") + .IsRequired() + .HasConstraintName("fk_process_steps_processes_process_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStepStatus", "ProcessStepStatus") + .WithMany("ProcessSteps") + .HasForeignKey("ProcessStepStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_process_steps_process_step_statuses_process_step_status_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStepType", "ProcessStepType") + .WithMany("ProcessSteps") + .HasForeignKey("ProcessStepTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_process_steps_process_step_types_process_step_type_id"); + + b.Navigation("Process"); + + b.Navigation("ProcessStepStatus"); + + b.Navigation("ProcessStepType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProviderCompanyDetail", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", "Company") + .WithOne("ProviderCompanyDetail") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProviderCompanyDetail", "CompanyId") + .IsRequired() + .HasConstraintName("fk_provider_company_details_companies_company_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_provider_company_details_identities_last_editor_id"); + + b.Navigation("Company"); + + b.Navigation("LastEditor"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ServiceDetail", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Service") + .WithMany("ServiceDetails") + .HasForeignKey("ServiceId") + .IsRequired() + .HasConstraintName("fk_service_details_offers_service_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ServiceType", "ServiceType") + .WithMany("ServiceDetails") + .HasForeignKey("ServiceTypeId") + .IsRequired() + .HasConstraintName("fk_service_details_service_types_service_type_id"); + + b.Navigation("Service"); + + b.Navigation("ServiceType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.TechnicalUserProfile", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("TechnicalUserProfiles") + .HasForeignKey("OfferId") + .IsRequired() + .HasConstraintName("fk_technical_user_profiles_offers_offer_id"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.TechnicalUserProfileAssignedUserRole", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.TechnicalUserProfile", "TechnicalUserProfile") + .WithMany("TechnicalUserProfileAssignedUserRoles") + .HasForeignKey("TechnicalUserProfileId") + .IsRequired() + .HasConstraintName("fk_technical_user_profile_assigned_user_roles_technical_user_p"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", "UserRole") + .WithMany("TechnicalUserProfileAssignedUserRole") + .HasForeignKey("UserRoleId") + .IsRequired() + .HasConstraintName("fk_technical_user_profile_assigned_user_roles_user_roles_user_r"); + + b.Navigation("TechnicalUserProfile"); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCaseDescription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany("UseCases") + .HasForeignKey("LanguageShortName") + .IsRequired() + .HasConstraintName("fk_use_case_descriptions_languages_language_short_name"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", "UseCase") + .WithMany("UseCaseDescriptions") + .HasForeignKey("UseCaseId") + .IsRequired() + .HasConstraintName("fk_use_case_descriptions_use_cases_use_case_id"); + + b.Navigation("Language"); + + b.Navigation("UseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", "LastEditor") + .WithMany() + .HasForeignKey("LastEditorId") + .HasConstraintName("fk_user_roles_identities_last_editor_id"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", "Offer") + .WithMany("UserRoles") + .HasForeignKey("OfferId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_user_roles_offers_offer_id"); + + b.Navigation("LastEditor"); + + b.Navigation("Offer"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleAssignedCollection", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollection", "UserRoleCollection") + .WithMany() + .HasForeignKey("UserRoleCollectionId") + .IsRequired() + .HasConstraintName("fk_user_role_assigned_collections_user_role_collections_user_r"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", "UserRole") + .WithMany() + .HasForeignKey("UserRoleId") + .IsRequired() + .HasConstraintName("fk_user_role_assigned_collections_user_roles_user_role_id"); + + b.Navigation("UserRole"); + + b.Navigation("UserRoleCollection"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollectionDescription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany() + .HasForeignKey("LanguageShortName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_user_role_collection_descriptions_languages_language_short_"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollection", "UserRoleCollection") + .WithMany("UserRoleCollectionDescriptions") + .HasForeignKey("UserRoleCollectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_user_role_collection_descriptions_user_role_collections_use"); + + b.Navigation("Language"); + + b.Navigation("UserRoleCollection"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleDescription", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", "Language") + .WithMany("UserRoleDescriptions") + .HasForeignKey("LanguageShortName") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_user_role_descriptions_languages_language_short_name"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", "UserRole") + .WithMany("UserRoleDescriptions") + .HasForeignKey("UserRoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_user_role_descriptions_user_roles_user_role_id"); + + b.Navigation("Language"); + + b.Navigation("UserRole"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalTypeUseCaseDetailVersion", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalType", "VerifiedCredentialExternalType") + .WithMany("VerifiedCredentialExternalTypeUseCaseDetailVersions") + .HasForeignKey("VerifiedCredentialExternalTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_external_type_use_case_detail_versions_"); + + b.Navigation("VerifiedCredentialExternalType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedExternalType", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalType", "VerifiedCredentialExternalType") + .WithMany("VerifiedCredentialTypeAssignedExternalTypes") + .HasForeignKey("VerifiedCredentialExternalTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_external_types_verified_c"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithOne("VerifiedCredentialTypeAssignedExternalType") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedExternalType", "VerifiedCredentialTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_external_types_verified_c1"); + + b.Navigation("VerifiedCredentialExternalType"); + + b.Navigation("VerifiedCredentialType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedKind", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithOne("VerifiedCredentialTypeAssignedKind") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedKind", "VerifiedCredentialTypeId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_kinds_verified_credential"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeKind", "VerifiedCredentialTypeKind") + .WithMany("VerifiedCredentialTypeAssignedKinds") + .HasForeignKey("VerifiedCredentialTypeKindId") + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_kinds_verified_credential1"); + + b.Navigation("VerifiedCredentialType"); + + b.Navigation("VerifiedCredentialTypeKind"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedUseCase", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", "UseCase") + .WithOne("VerifiedCredentialAssignedUseCase") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedUseCase", "UseCaseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_use_cases_use_cases_use_c"); + + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialType", "VerifiedCredentialType") + .WithOne("VerifiedCredentialTypeAssignedUseCase") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeAssignedUseCase", "VerifiedCredentialTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_verified_credential_type_assigned_use_cases_verified_creden"); + + b.Navigation("UseCase"); + + b.Navigation("VerifiedCredentialType"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Views.CompaniesLinkedServiceAccount", b => + { + b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", "CompanyServiceAccount") + .WithOne("CompaniesLinkedServiceAccount") + .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Views.CompaniesLinkedServiceAccount", "ServiceAccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("fk_company_linked_service_accounts_company_service_accounts_co"); + + b.Navigation("CompanyServiceAccount"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Address", b => + { + b.Navigation("Companies"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", b => + { + b.Navigation("AgreementAssignedCompanyRoles"); + + b.Navigation("AgreementAssignedOfferTypes"); + + b.Navigation("AgreementAssignedOffers"); + + b.Navigation("Consents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AgreementCategory", b => + { + b.Navigation("Agreements"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.AppInstance", b => + { + b.Navigation("AppSubscriptionDetails"); + + b.Navigation("ServiceAccounts"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntryStatus", b => + { + b.Navigation("ApplicationChecklistEntries"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ApplicationChecklistEntryType", b => + { + b.Navigation("ApplicationChecklistEntries"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.BpdmIdentifier", b => + { + b.Navigation("CountryAssignedIdentifiers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Company", b => + { + b.Navigation("Agreements"); + + b.Navigation("CompanyApplications"); + + b.Navigation("CompanyAssignedRoles"); + + b.Navigation("CompanyAssignedUseCase"); + + b.Navigation("CompanyIdentifiers"); + + b.Navigation("CompanySsiDetails"); + + b.Navigation("Consents"); + + b.Navigation("HostedConnectors"); + + b.Navigation("Identities"); + + b.Navigation("OfferSubscriptions"); + + b.Navigation("ProvidedConnectors"); + + b.Navigation("ProvidedOffers"); + + b.Navigation("ProviderCompanyDetail"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplication", b => + { + b.Navigation("ApplicationChecklistEntries"); + + b.Navigation("Invitations"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyApplicationStatus", b => + { + b.Navigation("CompanyApplications"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyRole", b => + { + b.Navigation("AgreementAssignedCompanyRoles"); + + b.Navigation("CompanyAssignedRoles"); + + b.Navigation("CompanyRoleAssignedRoleCollection"); + + b.Navigation("CompanyRoleDescriptions"); + + b.Navigation("CompanyRoleRegistrationData"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccount", b => + { + b.Navigation("AppInstances"); + + b.Navigation("CompaniesLinkedServiceAccount"); + + b.Navigation("Connector"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyServiceAccountType", b => + { + b.Navigation("CompanyServiceAccounts"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanySsiDetailStatus", b => + { + b.Navigation("CompanySsiDetails"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyStatus", b => + { + b.Navigation("Companies"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.CompanyUser", b => + { + b.Navigation("CompanySsiDetails"); + + b.Navigation("CompanyUserAssignedBusinessPartners"); + + b.Navigation("Consents"); + + b.Navigation("Documents"); + + b.Navigation("Invitations"); + + b.Navigation("Notifications"); + + b.Navigation("RequestedSubscriptions"); + + b.Navigation("SalesManagerOfOffers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", b => + { + b.Navigation("ConnectorAssignedOfferSubscriptions"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorStatus", b => + { + b.Navigation("Connectors"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorType", b => + { + b.Navigation("Connectors"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Consent", b => + { + b.Navigation("ConsentAssignedOfferSubscriptions"); + + b.Navigation("ConsentAssignedOffers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConsentStatus", b => + { + b.Navigation("Consents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Country", b => + { + b.Navigation("Addresses"); + + b.Navigation("Connectors"); + + b.Navigation("CountryAssignedIdentifiers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Document", b => + { + b.Navigation("Agreements"); + + b.Navigation("Companies"); + + b.Navigation("CompanySsiDetail"); + + b.Navigation("Connector"); + + b.Navigation("Consents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.DocumentStatus", b => + { + b.Navigation("Documents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.DocumentType", b => + { + b.Navigation("Documents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IamClient", b => + { + b.Navigation("AppInstances"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Identity", b => + { + b.Navigation("CompanyServiceAccount"); + + b.Navigation("CompanyUser"); + + b.Navigation("CreatedNotifications"); + + b.Navigation("IdentityAssignedRoles"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProvider", b => + { + b.Navigation("CompanyIdentityProviders"); + + b.Navigation("IamIdentityProvider"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityProviderCategory", b => + { + b.Navigation("IdentityProviders"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityType", b => + { + b.Navigation("Identities"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.IdentityUserStatus", b => + { + b.Navigation("Identities"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.InvitationStatus", b => + { + b.Navigation("Invitations"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Language", b => + { + b.Navigation("AppDescriptions"); + + b.Navigation("CompanyRoleDescriptions"); + + b.Navigation("LanguageLongNameLanguages"); + + b.Navigation("LanguageLongNames"); + + b.Navigation("UseCases"); + + b.Navigation("UserRoleDescriptions"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.LicenseType", b => + { + b.Navigation("Offers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.MediaType", b => + { + b.Navigation("Documents"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationTopic", b => + { + b.Navigation("NotificationTypeAssignedTopics"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.NotificationType", b => + { + b.Navigation("NotificationTypeAssignedTopic"); + + b.Navigation("Notifications"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Offer", b => + { + b.Navigation("AgreementAssignedOffers"); + + b.Navigation("AppInstanceSetup"); + + b.Navigation("AppInstances"); + + b.Navigation("ConsentAssignedOffers"); + + b.Navigation("OfferAssignedPrivacyPolicies"); + + b.Navigation("OfferDescriptions"); + + b.Navigation("OfferSubscriptions"); + + b.Navigation("ServiceDetails"); + + b.Navigation("Tags"); + + b.Navigation("TechnicalUserProfiles"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferStatus", b => + { + b.Navigation("Offers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscription", b => + { + b.Navigation("AppSubscriptionDetail"); + + b.Navigation("CompanyServiceAccounts"); + + b.Navigation("ConnectorAssignedOfferSubscriptions"); + + b.Navigation("ConsentAssignedOfferSubscriptions"); + + b.Navigation("OfferSubscriptionProcessData"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferSubscriptionStatus", b => + { + b.Navigation("OfferSubscriptions"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.OfferType", b => + { + b.Navigation("AgreementAssignedOfferTypes"); + + b.Navigation("Offers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.PrivacyPolicy", b => + { + b.Navigation("OfferAssignedPrivacyPolicies"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Process", b => + { + b.Navigation("CompanyApplication"); + + b.Navigation("OfferSubscription"); + + b.Navigation("ProcessSteps"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStepStatus", b => + { + b.Navigation("ProcessSteps"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessStepType", b => + { + b.Navigation("ProcessSteps"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ProcessType", b => + { + b.Navigation("Processes"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ServiceType", b => + { + b.Navigation("ServiceDetails"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.TechnicalUserProfile", b => + { + b.Navigation("TechnicalUserProfileAssignedUserRoles"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UniqueIdentifier", b => + { + b.Navigation("CompanyIdentifiers"); + + b.Navigation("CountryAssignedIdentifiers"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UseCase", b => + { + b.Navigation("Agreements"); + + b.Navigation("CompanyAssignedUseCase"); + + b.Navigation("UseCaseDescriptions"); + + b.Navigation("VerifiedCredentialAssignedUseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRole", b => + { + b.Navigation("IdentityAssignedRoles"); + + b.Navigation("TechnicalUserProfileAssignedUserRole"); + + b.Navigation("UserRoleDescriptions"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.UserRoleCollection", b => + { + b.Navigation("CompanyRoleAssignedRoleCollection"); + + b.Navigation("UserRoleCollectionDescriptions"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalType", b => + { + b.Navigation("VerifiedCredentialExternalTypeUseCaseDetailVersions"); + + b.Navigation("VerifiedCredentialTypeAssignedExternalTypes"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialExternalTypeUseCaseDetailVersion", b => + { + b.Navigation("CompanySsiDetails"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialType", b => + { + b.Navigation("CompanySsiDetails"); + + b.Navigation("VerifiedCredentialTypeAssignedExternalType"); + + b.Navigation("VerifiedCredentialTypeAssignedKind"); + + b.Navigation("VerifiedCredentialTypeAssignedUseCase"); + }); + + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.VerifiedCredentialTypeKind", b => + { + b.Navigation("VerifiedCredentialTypeAssignedKinds"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs new file mode 100644 index 0000000000..0f83489751 --- /dev/null +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs @@ -0,0 +1,128 @@ +/******************************************************************************** + * Copyright (c) 2021, 2023 BMW Group AG + * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ********************************************************************************/ + +using Microsoft.EntityFrameworkCore.Migrations; +using System; + +#nullable disable + +namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.Migrations.Migrations +{ + public partial class CPLP3105RemoveDaps : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DROP FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() CASCADE;"); + + migrationBuilder.DropTable( + name: "connector_client_details", + schema: "portal"); + + migrationBuilder.DropColumn( + name: "daps_registration_successful", + schema: "portal", + table: "connectors"); + + migrationBuilder.CreateTable( + name: "audit_connector20230803", + schema: "portal", + columns: table => new + { + audit_v1id = table.Column(type: "uuid", nullable: false), + id = table.Column(type: "uuid", nullable: false), + name = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + connector_url = table.Column(type: "character varying(255)", maxLength: 255, nullable: false), + type_id = table.Column(type: "integer", nullable: false), + status_id = table.Column(type: "integer", nullable: false), + provider_id = table.Column(type: "uuid", nullable: false), + host_id = table.Column(type: "uuid", nullable: true), + self_description_document_id = table.Column(type: "uuid", nullable: true), + location_id = table.Column(type: "character varying(2)", maxLength: 2, nullable: false), + self_description_message = table.Column(type: "text", nullable: true), + date_last_changed = table.Column(type: "timestamp with time zone", nullable: true), + company_service_account_id = table.Column(type: "uuid", nullable: true), + last_editor_id = table.Column(type: "uuid", nullable: true), + audit_v1date_last_changed = table.Column(type: "timestamp with time zone", nullable: false), + audit_v1last_editor_id = table.Column(type: "uuid", nullable: true), + audit_v1operation_id = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_audit_connector20230803", x => x.audit_v1id); + }); + + migrationBuilder.Sql("CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.name, \r\n OLD.connector_url, \r\n OLD.type_id, \r\n OLD.status_id, \r\n OLD.provider_id, \r\n OLD.host_id, \r\n OLD.self_description_document_id, \r\n OLD.location_id, \r\n OLD.self_description_message, \r\n OLD.date_last_changed, \r\n OLD.company_service_account_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_CONNECTOR AFTER DELETE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR();"); + + migrationBuilder.Sql("CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_CONNECTOR AFTER INSERT\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR();"); + + migrationBuilder.Sql("CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_CONNECTOR AFTER UPDATE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR();"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DROP FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() CASCADE;"); + + migrationBuilder.Sql("DROP FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() CASCADE;"); + + migrationBuilder.DropTable( + name: "audit_connector20230803", + schema: "portal"); + + migrationBuilder.AddColumn( + name: "daps_registration_successful", + schema: "portal", + table: "connectors", + type: "boolean", + nullable: true); + + migrationBuilder.CreateTable( + name: "connector_client_details", + schema: "portal", + columns: table => new + { + connector_id = table.Column(type: "uuid", nullable: false), + client_id = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("pk_connector_client_details", x => x.connector_id); + table.ForeignKey( + name: "fk_connector_client_details_connectors_connector_id", + column: x => x.connector_id, + principalSchema: "portal", + principalTable: "connectors", + principalColumn: "id", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.Sql("CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230503 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"daps_registration_successful\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.name, \r\n OLD.connector_url, \r\n OLD.type_id, \r\n OLD.status_id, \r\n OLD.provider_id, \r\n OLD.host_id, \r\n OLD.self_description_document_id, \r\n OLD.location_id, \r\n OLD.daps_registration_successful, \r\n OLD.self_description_message, \r\n OLD.date_last_changed, \r\n OLD.company_service_account_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_CONNECTOR AFTER DELETE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR();"); + + migrationBuilder.Sql("CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230503 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"daps_registration_successful\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.daps_registration_successful, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_CONNECTOR AFTER INSERT\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR();"); + + migrationBuilder.Sql("CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230503 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"daps_registration_successful\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.daps_registration_successful, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_CONNECTOR AFTER UPDATE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR();"); + } + } +} diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs index 879c991e3d..372bfd4928 100644 --- a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs @@ -19,8 +19,11 @@ ********************************************************************************/ // +using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; #nullable disable @@ -555,6 +558,89 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("audit_connector20230503", "portal"); }); + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditConnector20230803", b => + { + b.Property("AuditV1Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid") + .HasColumnName("audit_v1id"); + + b.Property("AuditV1DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("audit_v1date_last_changed"); + + b.Property("AuditV1LastEditorId") + .HasColumnType("uuid") + .HasColumnName("audit_v1last_editor_id"); + + b.Property("AuditV1OperationId") + .HasColumnType("integer") + .HasColumnName("audit_v1operation_id"); + + b.Property("CompanyServiceAccountId") + .HasColumnType("uuid") + .HasColumnName("company_service_account_id"); + + b.Property("ConnectorUrl") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("connector_url"); + + b.Property("DateLastChanged") + .HasColumnType("timestamp with time zone") + .HasColumnName("date_last_changed"); + + b.Property("HostId") + .HasColumnType("uuid") + .HasColumnName("host_id"); + + b.Property("Id") + .HasColumnType("uuid") + .HasColumnName("id"); + + b.Property("LastEditorId") + .HasColumnType("uuid") + .HasColumnName("last_editor_id"); + + b.Property("LocationId") + .IsRequired() + .HasMaxLength(2) + .HasColumnType("character varying(2)") + .HasColumnName("location_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("character varying(255)") + .HasColumnName("name"); + + b.Property("ProviderId") + .HasColumnType("uuid") + .HasColumnName("provider_id"); + + b.Property("SelfDescriptionDocumentId") + .HasColumnType("uuid") + .HasColumnName("self_description_document_id"); + + b.Property("SelfDescriptionMessage") + .HasColumnType("text") + .HasColumnName("self_description_message"); + + b.Property("StatusId") + .HasColumnType("integer") + .HasColumnName("status_id"); + + b.Property("TypeId") + .HasColumnType("integer") + .HasColumnName("type_id"); + + b.HasKey("AuditV1Id") + .HasName("pk_audit_connector20230803"); + + b.ToTable("audit_connector20230803", "portal"); + }); + modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities.AuditConsent20230412", b => { b.Property("AuditV1Id") @@ -2539,10 +2625,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("character varying(255)") .HasColumnName("connector_url"); - b.Property("DapsRegistrationSuccessful") - .HasColumnType("boolean") - .HasColumnName("daps_registration_successful"); - b.Property("DateLastChanged") .HasColumnType("timestamp with time zone") .HasColumnName("date_last_changed"); @@ -2619,9 +2701,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("connectors", "portal"); b - .HasAnnotation("LC_TRIGGER_AFTER_DELETE_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230503 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"daps_registration_successful\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.name, \r\n OLD.connector_url, \r\n OLD.type_id, \r\n OLD.status_id, \r\n OLD.provider_id, \r\n OLD.host_id, \r\n OLD.self_description_document_id, \r\n OLD.location_id, \r\n OLD.daps_registration_successful, \r\n OLD.self_description_message, \r\n OLD.date_last_changed, \r\n OLD.company_service_account_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_CONNECTOR AFTER DELETE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR();") - .HasAnnotation("LC_TRIGGER_AFTER_INSERT_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230503 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"daps_registration_successful\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.daps_registration_successful, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_CONNECTOR AFTER INSERT\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR();") - .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230503 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"daps_registration_successful\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.daps_registration_successful, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_CONNECTOR AFTER UPDATE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR();"); + .HasAnnotation("LC_TRIGGER_AFTER_DELETE_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_DELETE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT OLD.id, \r\n OLD.name, \r\n OLD.connector_url, \r\n OLD.type_id, \r\n OLD.status_id, \r\n OLD.provider_id, \r\n OLD.host_id, \r\n OLD.self_description_document_id, \r\n OLD.location_id, \r\n OLD.self_description_message, \r\n OLD.date_last_changed, \r\n OLD.company_service_account_id, \r\n OLD.last_editor_id, \r\n gen_random_uuid(), \r\n 3, \r\n CURRENT_DATE, \r\n OLD.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_DELETE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_DELETE_CONNECTOR AFTER DELETE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_DELETE_CONNECTOR();") + .HasAnnotation("LC_TRIGGER_AFTER_INSERT_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_INSERT_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 1, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_INSERT_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_INSERT_CONNECTOR AFTER INSERT\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_INSERT_CONNECTOR();") + .HasAnnotation("LC_TRIGGER_AFTER_UPDATE_CONNECTOR", "CREATE FUNCTION portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR() RETURNS trigger as $LC_TRIGGER_AFTER_UPDATE_CONNECTOR$\r\nBEGIN\r\n INSERT INTO portal.audit_connector20230803 (\"id\", \"name\", \"connector_url\", \"type_id\", \"status_id\", \"provider_id\", \"host_id\", \"self_description_document_id\", \"location_id\", \"self_description_message\", \"date_last_changed\", \"company_service_account_id\", \"last_editor_id\", \"audit_v1id\", \"audit_v1operation_id\", \"audit_v1date_last_changed\", \"audit_v1last_editor_id\") SELECT NEW.id, \r\n NEW.name, \r\n NEW.connector_url, \r\n NEW.type_id, \r\n NEW.status_id, \r\n NEW.provider_id, \r\n NEW.host_id, \r\n NEW.self_description_document_id, \r\n NEW.location_id, \r\n NEW.self_description_message, \r\n NEW.date_last_changed, \r\n NEW.company_service_account_id, \r\n NEW.last_editor_id, \r\n gen_random_uuid(), \r\n 2, \r\n CURRENT_DATE, \r\n NEW.last_editor_id;\r\nRETURN NEW;\r\nEND;\r\n$LC_TRIGGER_AFTER_UPDATE_CONNECTOR$ LANGUAGE plpgsql;\r\nCREATE TRIGGER LC_TRIGGER_AFTER_UPDATE_CONNECTOR AFTER UPDATE\r\nON portal.connectors\r\nFOR EACH ROW EXECUTE PROCEDURE portal.LC_TRIGGER_AFTER_UPDATE_CONNECTOR();"); }); modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorAssignedOfferSubscription", b => @@ -2643,23 +2725,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("connector_assigned_offer_subscriptions", "portal"); }); - modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorClientDetail", b => - { - b.Property("ConnectorId") - .HasColumnType("uuid") - .HasColumnName("connector_id"); - - b.Property("ClientId") - .IsRequired() - .HasColumnType("text") - .HasColumnName("client_id"); - - b.HasKey("ConnectorId") - .HasName("pk_connector_client_details"); - - b.ToTable("connector_client_details", "portal"); - }); - modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorStatus", b => { b.Property("Id") @@ -5930,18 +5995,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("OfferSubscription"); }); - modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorClientDetail", b => - { - b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", "Connector") - .WithOne("ClientDetails") - .HasForeignKey("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.ConnectorClientDetail", "ConnectorId") - .OnDelete(DeleteBehavior.SetNull) - .IsRequired() - .HasConstraintName("fk_connector_client_details_connectors_connector_id"); - - b.Navigation("Connector"); - }); - modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Consent", b => { b.HasOne("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Agreement", "Agreement") @@ -6895,8 +6948,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities.Connector", b => { - b.Navigation("ClientDetails"); - b.Navigation("ConnectorAssignedOfferSubscriptions"); }); diff --git a/src/portalbackend/PortalBackend.Migrations/Seeder/Data/connectors.consortia.json b/src/portalbackend/PortalBackend.Migrations/Seeder/Data/connectors.consortia.json index d92883c13f..463f361d1a 100644 --- a/src/portalbackend/PortalBackend.Migrations/Seeder/Data/connectors.consortia.json +++ b/src/portalbackend/PortalBackend.Migrations/Seeder/Data/connectors.consortia.json @@ -8,8 +8,7 @@ "provider_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206834", @@ -20,8 +19,7 @@ "provider_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206835", @@ -32,8 +30,7 @@ "provider_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206836", @@ -44,8 +41,7 @@ "provider_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "host_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206837", @@ -56,8 +52,7 @@ "provider_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "host_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206838", @@ -68,7 +63,6 @@ "provider_id": "cac8fa6a-9db7-4bad-9cbd-56298b74bac2", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null } -] \ No newline at end of file +] diff --git a/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs new file mode 100644 index 0000000000..bee876476e --- /dev/null +++ b/src/portalbackend/PortalBackend.PortalEntities/AuditEntities/AuditConnector20230803.cs @@ -0,0 +1,61 @@ +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Auditing; +using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Enums; +using System.ComponentModel.DataAnnotations; + +namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.AuditEntities; + +public class AuditConnector20230803 : IAuditEntityV1 +{ + public AuditConnector20230803() + { + Name = null!; + ConnectorUrl = null!; + LocationId = null!; + } + + /// + [Key] + public Guid AuditV1Id { get; set; } + + public Guid Id { get; private set; } + + [MaxLength(255)] + public string Name { get; set; } + + [MaxLength(255)] + public string ConnectorUrl { get; set; } + + public ConnectorTypeId TypeId { get; set; } + + public ConnectorStatusId StatusId { get; set; } + + public Guid ProviderId { get; set; } + + public Guid? HostId { get; set; } + + /// + /// Link to the self description document + /// + public Guid? SelfDescriptionDocumentId { get; set; } + + [StringLength(2, MinimumLength = 2)] + public string LocationId { get; set; } + + public string? SelfDescriptionMessage { get; set; } + + public DateTimeOffset? DateLastChanged { get; private set; } + + public Guid? CompanyServiceAccountId { get; set; } + + [AuditLastEditorV1] + public Guid? LastEditorId { get; set; } + + /// + public DateTimeOffset AuditV1DateLastChanged { get; set; } + + /// + public Guid? AuditV1LastEditorId { get; set; } + + /// + public AuditOperationId AuditV1OperationId { get; set; } +} diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs index 4d6a593ab6..5bf71f60a9 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/Entities/Connector.cs @@ -26,7 +26,7 @@ namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; -[AuditEntityV1(typeof(AuditConnector20230503))] +[AuditEntityV1(typeof(AuditConnector20230803))] public class Connector : IAuditableV1, IBaseEntity { public Connector(Guid id, string name, string locationId, string connectorUrl) @@ -62,8 +62,6 @@ public Connector(Guid id, string name, string locationId, string connectorUrl) [StringLength(2, MinimumLength = 2)] public string LocationId { get; set; } - public bool? DapsRegistrationSuccessful { get; set; } - public string? SelfDescriptionMessage { get; set; } public DateTimeOffset? DateLastChanged { get; set; } @@ -79,7 +77,6 @@ public Connector(Guid id, string name, string locationId, string connectorUrl) public virtual Company? Provider { get; set; } public virtual Company? Host { get; set; } public virtual Country? Location { get; set; } - public virtual ConnectorClientDetail? ClientDetails { get; set; } public virtual CompanyServiceAccount? CompanyServiceAccount { get; set; } public virtual Identity? LastEditor { get; set; } diff --git a/src/portalbackend/PortalBackend.PortalEntities/Entities/ConnectorClientDetail.cs b/src/portalbackend/PortalBackend.PortalEntities/Entities/ConnectorClientDetail.cs deleted file mode 100644 index 0ecd91d410..0000000000 --- a/src/portalbackend/PortalBackend.PortalEntities/Entities/ConnectorClientDetail.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities.Entities; - -public class ConnectorClientDetail -{ - private ConnectorClientDetail() - { - ClientId = null!; - } - - public ConnectorClientDetail(Guid connectorId, string clientId) - : this() - { - this.ConnectorId = connectorId; - this.ClientId = clientId; - } - - public Guid ConnectorId { get; set; } - - public string ClientId { get; set; } - - public virtual Connector? Connector { get; set; } -} diff --git a/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs b/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs index a2743c3f52..e5ac6cf959 100644 --- a/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs +++ b/src/portalbackend/PortalBackend.PortalEntities/PortalDbContext.cs @@ -78,6 +78,7 @@ public PortalDbContext(DbContextOptions options, IIdentityServi public virtual DbSet AuditCompanyUser20230523 { get; set; } = default!; public virtual DbSet AuditConnector20230405 { get; set; } = default!; public virtual DbSet AuditConnector20230503 { get; set; } = default!; + public virtual DbSet AuditConnector20230803 { get; set; } = default!; public virtual DbSet AuditIdentity20230526 { get; set; } = default!; public virtual DbSet AuditUserRole20221017 { get; set; } = default!; public virtual DbSet AuditCompanyUserAssignedRole20221018 { get; set; } = default!; @@ -106,7 +107,6 @@ public PortalDbContext(DbContextOptions options, IIdentityServi public virtual DbSet CompanyUserAssignedBusinessPartners { get; set; } = default!; public virtual DbSet Connectors { get; set; } = default!; public virtual DbSet ConnectorAssignedOfferSubscriptions { get; set; } = default!; - public virtual DbSet ConnectorClientDetails { get; set; } = default!; public virtual DbSet ConnectorStatuses { get; set; } = default!; public virtual DbSet ConnectorTypes { get; set; } = default!; public virtual DbSet Consents { get; set; } = default!; @@ -946,17 +946,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasForeignKey(d => d.CompanyServiceAccountId) .OnDelete(DeleteBehavior.ClientSetNull); - entity.HasAuditV1Triggers(); - }); - - modelBuilder.Entity(entity => - { - entity.HasKey(x => x.ConnectorId); - - entity.HasOne(c => c.Connector) - .WithOne(c => c.ClientDetails) - .HasForeignKey(c => c.ConnectorId) - .OnDelete(DeleteBehavior.SetNull); + entity.HasAuditV1Triggers(); }); modelBuilder.Entity() diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs index a67c47afa0..5f36df4783 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs @@ -18,14 +18,12 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.BusinessLogic; using Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Models; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; +using Org.Eclipse.TractusX.Portal.Backend.Framework.Web; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Repositories; @@ -36,6 +34,7 @@ using Org.Eclipse.TractusX.Portal.Backend.SdFactory.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using System.Collections.Immutable; +using ConnectorData = Org.Eclipse.TractusX.Portal.Backend.PortalBackend.DBAccess.Models.ConnectorData; namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.BusinessLogic; @@ -67,10 +66,10 @@ public class ConnectorsBusinessLogicTests private readonly IPortalRepositories _portalRepositories; private readonly ISdFactoryBusinessLogic _sdFactoryBusinessLogic; private readonly ConnectorsBusinessLogic _logic; - private readonly IDapsService _dapsService; private readonly ConnectorsSettings _settings; private readonly IDocumentRepository _documentRepository; private readonly IServiceAccountRepository _serviceAccountRepository; + private readonly IIdentityService _identityService; public ConnectorsBusinessLogicTests() { @@ -87,7 +86,7 @@ public ConnectorsBusinessLogicTests() _sdFactoryBusinessLogic = A.Fake(); _serviceAccountRepository = A.Fake(); _offerSubscriptionRepository = A.Fake(); - _dapsService = A.Fake(); + _identityService = A.Fake(); _connectors = new List(); var options = A.Fake>(); _settings = new ConnectorsSettings @@ -104,28 +103,45 @@ public ConnectorsBusinessLogicTests() SetupRepositoryMethods(); A.CallTo(() => options.Value).Returns(_settings); + A.CallTo(() => _identityService.IdentityData).Returns(_identity); - _logic = new ConnectorsBusinessLogic(_portalRepositories, options, _sdFactoryBusinessLogic, _dapsService); + _logic = new ConnectorsBusinessLogic(_portalRepositories, options, _sdFactoryBusinessLogic, _identityService); } + #region GetAllCompanyConnectorDatas + + [Fact] + public async Task GetAllCompanyConnectorDatas_WithValidData_ReturnsExpected() + { + // Arrange + var connectors = new AsyncEnumerableStub(_fixture.CreateMany(5)); + A.CallTo(() => _connectorsRepository.GetAllCompanyConnectorsForCompanyId(_identity.CompanyId)) + .Returns(connectors.AsQueryable()); + + // Act + var result = await _logic.GetAllCompanyConnectorDatas(0, 10).ConfigureAwait(false); + + // Assert + result.Content.Should().HaveCount(connectors.Count()); + result.Meta.NumberOfElements.Should().Be(connectors.Count()); + } + + #endregion + #region Create Connector [Fact] public async Task CreateConnectorAsync_WithValidInput_ReturnsCreatedConnectorData() { // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", file, ServiceAccountUserId); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns(new DapsResponse("12345")); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", ServiceAccountUserId); // Act - var result = await _logic.CreateConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + var result = await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert result.Should().NotBeEmpty(); _connectors.Should().HaveCount(1); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.CreateConnectorAssignedSubscriptions(A._, A._)).MustNotHaveHappened(); } @@ -134,13 +150,10 @@ public async Task CreateConnectorAsync_WithInvalidTechnicalUser_ThrowsController { // Arrange var saId = Guid.NewGuid(); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", file, saId); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns(new DapsResponse("12345")); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", saId); // Act - async Task Act() => await _logic.CreateConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -152,29 +165,25 @@ public async Task CreateConnectorAsync_WithInvalidTechnicalUser_ThrowsController public async Task CreateConnectorAsync_WithClientIdNull_DoesntSaveData() { // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", file, null); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns((DapsResponse?)null); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", null); // Act - var result = await _logic.CreateConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + var result = await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert result.Should().NotBeEmpty(); _connectors.Should().HaveCount(1); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); } [Fact] public async Task CreateConnectorAsync_WithoutSelfDescriptionDocument_ThrowsUnexpectedException() { // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", file, null); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", null); + A.CallTo(() => _identityService.IdentityData).Returns(_identityWithoutSdDocument); // Act - async Task Act() => await _logic.CreateConnectorAsync(connectorInput, _identityWithoutSdDocument.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var exception = await Assert.ThrowsAsync(Act); @@ -185,10 +194,10 @@ public async Task CreateConnectorAsync_WithoutSelfDescriptionDocument_ThrowsUnex public async Task CreateConnectorAsync_WithInvalidLocation_ThrowsControllerArgumentException() { // Arrange - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "invalid", null, null); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "invalid", null); // Act - async Task Act() => await _logic.CreateConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var exception = await Assert.ThrowsAsync(Act); @@ -199,10 +208,11 @@ public async Task CreateConnectorAsync_WithInvalidLocation_ThrowsControllerArgum public async Task CreateConnectorAsync_WithCompanyWithoutBpn_ThrowsUnexpectedConditionException() { // Arrange - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", null, null); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", null); + A.CallTo(() => _identityService.IdentityData).Returns(_identityWithoutBpn); // Act - async Task Act() => await _logic.CreateConnectorAsync(connectorInput, _identityWithoutBpn.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var exception = await Assert.ThrowsAsync(Act); @@ -213,36 +223,17 @@ public async Task CreateConnectorAsync_WithCompanyWithoutBpn_ThrowsUnexpectedCon public async Task CreateConnectorAsync_WithFailingDapsService_ReturnsCreatedConnectorData() { // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", file, null); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, - A._, A._)).Throws(new ServiceException("Service failed")); + var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", null); // Act - var result = await _logic.CreateConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + var result = await _logic.CreateConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert result.Should().NotBeEmpty(); _connectors.Should().HaveCount(1); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.CreateConnectorAssignedSubscriptions(A._, A._)).MustNotHaveHappened(); } - [Fact] - public async Task CreateConnectorAsync_WithWrongFileType_ThrowsUnsupportedMediaTypeException() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pdf", "application/pdf"); - var connectorInput = new ConnectorInputModel("connectorName", "https://test.de", "de", file, null); - - // Act - async Task Act() => await _logic.CreateConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); - - // Assert - var exception = await Assert.ThrowsAsync(Act); - exception.Message.Should().Be($"Only {string.Join(",", _settings.ValidCertificationContentTypes)} files are allowed."); - } - #endregion #region CreateManagedConnectorAsync @@ -251,18 +242,14 @@ public async Task CreateConnectorAsync_WithWrongFileType_ThrowsUnsupportedMediaT public async Task CreateManagedConnectorAsync_WithValidInput_ReturnsCreatedConnectorData() { // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pdf", "application/x-pem-file"); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", ValidOfferSubscriptionId, file, ServiceAccountUserId); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns(new DapsResponse("12345")); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", ValidOfferSubscriptionId, ServiceAccountUserId); // Act - var result = await _logic.CreateManagedConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + var result = await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert result.Should().NotBeEmpty(); _connectors.Should().HaveCount(1); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.CreateConnectorAssignedSubscriptions(A._, ValidOfferSubscriptionId)).MustHaveHappenedOnceExactly(); } @@ -270,44 +257,26 @@ public async Task CreateManagedConnectorAsync_WithValidInput_ReturnsCreatedConne public async Task CreateManagedConnectorAsync_WithTechnicalUser_ReturnsCreatedConnectorData() { // Arrange - var file = FormFileHelper.GetFormFile("this is just random content", "cert.pem", "application/x-pem-file"); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", ValidOfferSubscriptionId, file, null); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns(new DapsResponse("12345")); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", ValidOfferSubscriptionId, null); + A.CallTo(() => _identityService.IdentityData).Returns(_technicalUserIdentity); // Act - var result = await _logic.CreateManagedConnectorAsync(connectorInput, _technicalUserIdentity.CompanyId, CancellationToken.None).ConfigureAwait(false); + var result = await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert result.Should().NotBeEmpty(); _connectors.Should().HaveCount(1); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.CreateConnectorAssignedSubscriptions(A._, ValidOfferSubscriptionId)).MustHaveHappenedOnceExactly(); } - [Fact] - public async Task CreateManagedConnectorAsync_WithWrongFileType_ThrowsUnsupportedMediaTypeException() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pdf", "application/pdf"); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", Guid.NewGuid(), file, null); - - // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); - - // Assert - var exception = await Assert.ThrowsAsync(Act); - exception.Message.Should().Be($"Only {string.Join(",", _settings.ValidCertificationContentTypes)} files are allowed."); - } - [Fact] public async Task CreateManagedConnectorAsync_WithInvalidLocation_ThrowsControllerArgumentException() { // Arrange - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "invalid", ValidOfferSubscriptionId, null, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "invalid", ValidOfferSubscriptionId, null); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var exception = await Assert.ThrowsAsync(Act); @@ -321,10 +290,11 @@ public async Task CreateManagedConnectorAsync_WithNotExistingSubscription_Throws var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.CheckOfferSubscriptionWithOfferProvider(subscriptionId, _technicalUserIdentity.CompanyId)) .Returns((false, default, default, default, default, default, default)); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null); + A.CallTo(() => _identityService.IdentityData).Returns(_technicalUserIdentity); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _technicalUserIdentity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -338,10 +308,11 @@ public async Task CreateManagedConnectorAsync_WithCallerNotOfferProvider_ThrowsF var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.CheckOfferSubscriptionWithOfferProvider(subscriptionId, _technicalUserIdentity.CompanyId)) .Returns((true, false, default, default, default, default, default)); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null); + A.CallTo(() => _identityService.IdentityData).Returns(_technicalUserIdentity); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _technicalUserIdentity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -355,10 +326,11 @@ public async Task CreateManagedConnectorAsync_WithOfferAlreadyLinked_ThrowsUnexp var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.CheckOfferSubscriptionWithOfferProvider(subscriptionId, _technicalUserIdentity.CompanyId)) .Returns((true, true, true, default, default, default, default)); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null); + A.CallTo(() => _identityService.IdentityData).Returns(_technicalUserIdentity); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _technicalUserIdentity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -372,10 +344,11 @@ public async Task CreateManagedConnectorAsync_WithInactiveSubscription_ThrowsUne var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.CheckOfferSubscriptionWithOfferProvider(subscriptionId, _technicalUserIdentity.CompanyId)) .Returns((true, true, false, OfferSubscriptionStatusId.INACTIVE, default, default, default)); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null); + A.CallTo(() => _identityService.IdentityData).Returns(_technicalUserIdentity); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _technicalUserIdentity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -389,11 +362,10 @@ public async Task CreateManagedConnectorAsync_WithoutExistingSelfDescriptionDocu var subscriptionId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.CheckOfferSubscriptionWithOfferProvider(subscriptionId, A.That.Matches(x => x == _identity.CompanyId || x == _technicalUserIdentity.CompanyId))) .Returns((true, true, false, OfferSubscriptionStatusId.ACTIVE, null, ValidCompanyId, ValidCompanyBpn)); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pdf", "application/x-pem-file"); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, file, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var exception = await Assert.ThrowsAsync(Act); @@ -408,10 +380,11 @@ public async Task CreateManagedConnectorAsync_WithSubscribingCompanyWithoutBpn_T var companyId = Guid.NewGuid(); A.CallTo(() => _offerSubscriptionRepository.CheckOfferSubscriptionWithOfferProvider(subscriptionId, _technicalUserIdentity.CompanyId)) .Returns((true, true, false, OfferSubscriptionStatusId.ACTIVE, Guid.NewGuid(), companyId, null)); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null, null); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", subscriptionId, null); + A.CallTo(() => _identityService.IdentityData).Returns(_technicalUserIdentity); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _technicalUserIdentity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -423,13 +396,10 @@ public async Task CreateManagedConnectorAsync_WithInvalidTechnicalUser_ThrowsCon { // Arrange var saId = Guid.NewGuid(); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pdf", "application/x-pem-file"); - var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", ValidOfferSubscriptionId, file, saId); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns(new DapsResponse("12345")); + var connectorInput = new ManagedConnectorInputModel("connectorName", "https://test.de", "de", ValidOfferSubscriptionId, saId); // Act - async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.CreateManagedConnectorAsync(connectorInput, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -439,76 +409,6 @@ public async Task CreateManagedConnectorAsync_WithInvalidTechnicalUser_ThrowsCon #endregion - #region TriggerDaps - - [Fact] - public async Task TriggerDaps_WithValidInput_CallsDaps() - { - // Arrange - _connectors.Add(new Connector(ExistingConnectorId, "test", "de", "https://www.api.connector.com")); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns(new DapsResponse("12345")); - - // Act - await _logic.TriggerDapsAsync(ExistingConnectorId, file, (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); - - // Assert - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); - } - - [Fact] - public async Task TriggerDaps_WithFailingDapsCall_ThrowsConflictException() - { - // Arrange - _connectors.Add(new Connector(ExistingConnectorId, "test", "de", "https://www.api.connector.com")); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)) - .Returns((DapsResponse?)null); - - // Act - async Task Act() => await _logic.TriggerDapsAsync(ExistingConnectorId, file, (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); - - // Assert - var ex = await Assert.ThrowsAsync(Act); - ex.Message.Should().Be("Client Id should be set here"); - A.CallTo(() => _dapsService.EnableDapsAuthAsync(A._, A._, A._, A._, A._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _portalRepositories.SaveAsync()).MustNotHaveHappened(); - } - - [Fact] - public async Task TriggerDaps_WithNotExistingConnector_ThrowsNotFoundException() - { - // Arrange - var notExistingConnectorId = Guid.NewGuid(); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - - // Act - async Task Act() => await _logic.TriggerDapsAsync(notExistingConnectorId, file, (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); - - // Assert - var exception = await Assert.ThrowsAsync(Act); - exception.Message.Should().Be($"Connector {notExistingConnectorId} does not exists"); - } - - [Fact] - public async Task TriggerDaps_WithWrongUser_ThrowsForbiddenException() - { - // Arrange - var identity = _fixture.Create<(Guid, Guid)>(); - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - - // Act - async Task Act() => await _logic.TriggerDapsAsync(ExistingConnectorId, file, identity, CancellationToken.None).ConfigureAwait(false); - - // Assert - var exception = await Assert.ThrowsAsync(Act); - exception.Message.Should().Be("User is not provider of the connector"); - } - - #endregion - #region ProcessClearinghouseSelfDescription [Fact] @@ -521,7 +421,7 @@ public async Task ProcessClearinghouseSelfDescription_WithValidData_CallsExpecte .Returns((connectorId, (Guid?)null)); // Act - await _logic.ProcessClearinghouseSelfDescription(data, _identity.UserId, CancellationToken.None).ConfigureAwait(false); + await _logic.ProcessClearinghouseSelfDescription(data, CancellationToken.None).ConfigureAwait(false); // Assert A.CallTo(() => _connectorsRepository.GetConnectorDataById(connectorId)).MustHaveHappenedOnceExactly(); @@ -540,7 +440,7 @@ public async Task ProcessClearinghouseSelfDescription_WithNotExistingApplication .Returns(((Guid, Guid?))default); // Act - async Task Act() => await _logic.ProcessClearinghouseSelfDescription(data, _identity.UserId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.ProcessClearinghouseSelfDescription(data, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -558,7 +458,7 @@ public async Task ProcessClearinghouseSelfDescription_WithExistingSelfDescriptio .Returns((connectorId, Guid.NewGuid())); // Act - async Task Act() => await _logic.ProcessClearinghouseSelfDescription(data, _identity.UserId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.ProcessClearinghouseSelfDescription(data, CancellationToken.None).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -579,13 +479,13 @@ public async Task DeleteConnectorAsync_WithDocumentId_ExpectedCalls() var connector = new Connector(connectorId, null!, null!, null!); var selfDescriptionDocumentId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) - .Returns((true, true, "123", selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.ACTIVE, true)); + .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.ACTIVE)); A.CallTo(() => _documentRepository.AttachAndModifyDocument(A._, A>._, A>._)) - .Invokes((Guid DocId, Action? initialize, Action modify) + .Invokes((Guid docId, Action? initialize, Action modify) => { - var document = new Document(DocId, null!, null!, null!, default, default, default, default); + var document = new Document(docId, null!, null!, null!, default, default, default, default); initialize?.Invoke(document); modify(document); }); @@ -597,53 +497,64 @@ public async Task DeleteConnectorAsync_WithDocumentId_ExpectedCalls() }); // Act - await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); // Assert connector.StatusId.Should().Be(ConnectorStatusId.INACTIVE); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); A.CallTo(() => _documentRepository.AttachAndModifyDocument(selfDescriptionDocumentId, A>._, A>._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.AttachAndModifyConnector(connectorId, A>._, A>._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _connectorsRepository.DeleteConnectorClientDetails(connectorId)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _dapsService.DeleteDapsClient("123", A._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); } [Fact] - public async Task DeleteConnectorAsync_WithOutDocumentId_ExpectedCalls() + public async Task DeleteConnectorAsync_WithPendingAndWithoutDocumentId_ExpectedCalls() { // Arrange var connectorId = Guid.NewGuid(); - var connector = new Connector(connectorId, null!, null!, null!); - A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, true, "12345", null, null, ConnectorStatusId.ACTIVE, true)); - A.CallTo(() => _connectorsRepository.AttachAndModifyConnector(A._, A>._, A>._)) - .Invokes((Guid _, Action? initialize, Action setOptionalFields) => - { - initialize?.Invoke(connector); - setOptionalFields.Invoke(connector); - }); + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) + .Returns((true, true, null, null, ConnectorStatusId.PENDING)); // Act - await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); // Assert - connector.StatusId.Should().Be(ConnectorStatusId.INACTIVE); - A.CallTo(() => _connectorsRepository.AttachAndModifyConnector(connectorId, A>._, A>._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _documentRepository.AttachAndModifyDocument(A._, A>._, A>._)).MustNotHaveHappened(); + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnector(connectorId)).MustHaveHappenedOnceExactly(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); } [Fact] - public async Task DeleteConnectorAsync_WithInactiveConnector_ThrowsConflictException() + public async Task DeleteConnectorAsync_WithPendingAndDocumentId_ExpectedCalls() + { + // Arrange + const DocumentStatusId documentStatusId = DocumentStatusId.LOCKED; + var connectorId = Guid.NewGuid(); + var selfDescriptionDocumentId = Guid.NewGuid(); + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) + .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.PENDING)); + + // Act + await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); + + // Assert + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _documentRepository.RemoveDocument(selfDescriptionDocumentId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnector(connectorId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); + } + + [Fact] + public async Task DeleteConnectorAsync_WithOutDocumentId_ExpectedCalls() { // Arrange var connectorId = Guid.NewGuid(); + var connector = new Connector(connectorId, null!, null!, null!); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, true, null, null, null, ConnectorStatusId.ACTIVE, false)); + .Returns((true, true, null, null, ConnectorStatusId.ACTIVE)); // Act - async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -651,19 +562,19 @@ public async Task DeleteConnectorAsync_WithInactiveConnector_ThrowsConflictExcep } [Fact] - public async Task DeleteConnectorAsync_WithEmptyDapsClientId_ThrowsUnexpectedConditionException() + public async Task DeleteConnectorAsync_WithInactiveConnector_ThrowsConflictException() { // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, true, null, null, null, ConnectorStatusId.ACTIVE, true)); + .Returns((true, true, null, null, ConnectorStatusId.ACTIVE)); // Act - async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); - ex.Message.Should().Be("DapsClientId must be set"); + ex.Message.Should().Be("Connector status does not match a deletion scenario. Deletion declined"); } [Fact] @@ -672,10 +583,10 @@ public async Task DeleteConnectorAsync_ThrowsNotFoundException() // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns(((bool, bool, string?, Guid?, DocumentStatusId?, ConnectorStatusId, bool))default); + .Returns((false, false, null, null, ConnectorStatusId.ACTIVE)); // Act - async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -688,10 +599,10 @@ public async Task DeleteConnectorAsync_ThrowsForbiddenException() // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, false, null, null, null, default, true)); + .Returns((true, false, null, null, default)); // Act - async Task Act() => await _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -717,7 +628,7 @@ public async Task GetManagedConnectorForIamUserAsync_GetExpected(int page, int s .Returns((int skip, int take) => Task.FromResult((Pagination.Source?)new Pagination.Source(data.Length, data.Skip(skip).Take(take)))); // Act - var result = await _logic.GetManagedConnectorForCompany(_identity.CompanyId, page, size); + var result = await _logic.GetManagedConnectorForCompany(page, size); // Assert A.CallTo(() => _connectorsRepository.GetManagedConnectorsForCompany(_identity.CompanyId)).MustHaveHappenedOnceExactly(); @@ -737,7 +648,7 @@ public async Task GetManagedConnectorForIamUserAsync_EmptyResult_GetExpected() .Returns((int _, int _) => Task.FromResult((Pagination.Source?)null)); // Act - var result = await _logic.GetManagedConnectorForCompany(_identity.CompanyId, 0, 10); + var result = await _logic.GetManagedConnectorForCompany(0, 10); // Assert A.CallTo(() => _connectorsRepository.GetManagedConnectorsForCompany(_identity.CompanyId)).MustHaveHappenedOnceExactly(); @@ -762,7 +673,7 @@ public async Task UpdateConnectorUrl_WithoutConnector_ThrowsNotFoundException() .Returns((ConnectorUpdateInformation?)null); // Act - async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://test.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://test.de")).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -781,11 +692,10 @@ public async Task UpdateConnectorUrl_WithSameUrlAsStored_ReturnsWithoutDoing() .Returns(data); // Act - await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://test.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://test.de")).ConfigureAwait(false); // Assert A.CallTo(() => _portalRepositories.SaveAsync()).MustNotHaveHappened(); - A.CallTo(() => _dapsService.UpdateDapsConnectorUrl(A._, A._, A._, A._)).MustNotHaveHappened(); } [Fact] @@ -801,7 +711,7 @@ public async Task UpdateConnectorUrl_WithUserNotOfHostCompany_ThrowsForbiddenExc .Returns(data); // Act - async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de")).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -822,35 +732,13 @@ public async Task UpdateConnectorUrl_WithInactiveConnector_ThrowsConflictExcepti .Returns(data); // Act - async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de")).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); ex.Message.Should().Be($"Connector {connectorId} is in state {ConnectorStatusId.INACTIVE}"); } - [Fact] - public async Task UpdateConnectorUrl_WithoutDapsClientId_ThrowsConflictException() - { - // Arrange - var connectorId = Guid.NewGuid(); - var data = _fixture.Build() - .With(x => x.ConnectorUrl, "https://old.de") - .With(x => x.IsHostCompany, true) - .With(x => x.Status, ConnectorStatusId.ACTIVE) - .With(x => x.DapsClientId, (string?)null) - .Create(); - A.CallTo(() => _connectorsRepository.GetConnectorUpdateInformation(connectorId, _identity.CompanyId)) - .Returns(data); - - // Act - async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); - - // Assert - var ex = await Assert.ThrowsAsync(Act); - ex.Message.Should().Be($"Connector {connectorId} has no client id"); - } - [Fact] public async Task UpdateConnectorUrl_WithBpnNotSet_ThrowsConflictException() { @@ -860,7 +748,6 @@ public async Task UpdateConnectorUrl_WithBpnNotSet_ThrowsConflictException() .With(x => x.ConnectorUrl, "https://old.de") .With(x => x.IsHostCompany, true) .With(x => x.Status, ConnectorStatusId.ACTIVE) - .With(x => x.DapsClientId, "1234") .With(x => x.Type, ConnectorTypeId.CONNECTOR_AS_A_SERVICE) .With(x => x.Bpn, (string?)null) .Create(); @@ -868,7 +755,7 @@ public async Task UpdateConnectorUrl_WithBpnNotSet_ThrowsConflictException() .Returns(data); // Act - async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de")).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -884,7 +771,6 @@ public async Task UpdateConnectorUrl_WithCompanyBpnNotSet_ThrowsConflictExceptio .With(x => x.ConnectorUrl, "https://old.de") .With(x => x.IsHostCompany, true) .With(x => x.Status, ConnectorStatusId.ACTIVE) - .With(x => x.DapsClientId, "1234") .With(x => x.Type, ConnectorTypeId.COMPANY_CONNECTOR) .With(x => x.Bpn, "BPNL123456789") .Create(); @@ -894,7 +780,7 @@ public async Task UpdateConnectorUrl_WithCompanyBpnNotSet_ThrowsConflictExceptio .Returns((string?)null); // Act - async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + async Task Act() => await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de")).ConfigureAwait(false); // Assert var ex = await Assert.ThrowsAsync(Act); @@ -913,7 +799,6 @@ public async Task UpdateConnectorUrl_WithValidData_CallsExpected() .With(x => x.ConnectorUrl, "https://old.de") .With(x => x.IsHostCompany, true) .With(x => x.Status, ConnectorStatusId.ACTIVE) - .With(x => x.DapsClientId, "1234") .With(x => x.Type, ConnectorTypeId.CONNECTOR_AS_A_SERVICE) .With(x => x.Bpn, "BPNL123456789") .Create(); @@ -927,17 +812,18 @@ public async Task UpdateConnectorUrl_WithValidData_CallsExpected() }); // Act - await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de"), (_identity.UserId, _identity.CompanyId), CancellationToken.None).ConfigureAwait(false); + await _logic.UpdateConnectorUrl(connectorId, new ConnectorUpdateRequest("https://new.de")).ConfigureAwait(false); // Assert A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.AttachAndModifyConnector(connectorId, null, A>._)).MustHaveHappenedOnceExactly(); - A.CallTo(() => _dapsService.UpdateDapsConnectorUrl("1234", "https://new.de", A._, A._)).MustHaveHappenedOnceExactly(); connector.ConnectorUrl.Should().Be("https://new.de"); } #endregion + #region GetCompanyConnectorEndPointAsync + [Fact] public async Task GetCompanyConnectorEndPoint_WithValidData_ReturnsExpectedResult() { @@ -990,6 +876,8 @@ public async Task GetCompanyConnectorEndPoint_WithInValidBpn_ThrowsArgumentExcep ex.Message.Should().Be($"Incorrect BPN [{bpns[0]}] attribute value"); } + #endregion + #region GetConnectorOfferSubscriptionData [Fact] @@ -997,11 +885,11 @@ public async Task GetConnectorOfferSubscriptionData_ReturnsList() { // Arrange var data = _fixture.CreateMany(5); - A.CallTo(() => _offerSubscriptionRepository.GetConnectorOfferSubscriptionData(null, _identity.CompanyId))! + A.CallTo(() => _offerSubscriptionRepository.GetConnectorOfferSubscriptionData(null, _identity.CompanyId)) .Returns(data.ToAsyncEnumerable()); // Act - var result = await _logic.GetConnectorOfferSubscriptionData(null, _identity.CompanyId).ToListAsync().ConfigureAwait(false); + var result = await _logic.GetConnectorOfferSubscriptionData(null).ToListAsync().ConfigureAwait(false); // Assert result.Should().HaveCount(data.Count()); @@ -1009,6 +897,61 @@ public async Task GetConnectorOfferSubscriptionData_ReturnsList() #endregion + #region GetCompanyConnectorData + + [Fact] + public async Task GetCompanyConnectorData_WithInvalid_ThrowsForbiddenException() + { + // Arrange + var connectorId = Guid.NewGuid(); + var connectorData = _fixture.Create(); + A.CallTo(() => _connectorsRepository.GetConnectorByIdForCompany(connectorId, _identity.CompanyId)) + .Returns((connectorData, false)); + + // Act + async Task Act() => await _logic.GetCompanyConnectorData(connectorId).ConfigureAwait(false); + + // Assert + var ex = await Assert.ThrowsAsync(Act); + ex.Message.Should().Be($"company {_identity.CompanyId} is not provider of connector {connectorId}"); + } + + [Fact] + public async Task GetCompanyConnectorData_WithNotExisting_ThrowsNotFoundException() + { + // Arrange + var connectorId = Guid.NewGuid(); + A.CallTo(() => _connectorsRepository.GetConnectorByIdForCompany(connectorId, _identity.CompanyId)) + .Returns(new ValueTuple()); + + // Act + async Task Act() => await _logic.GetCompanyConnectorData(connectorId).ConfigureAwait(false); + + // Assert + var ex = await Assert.ThrowsAsync(Act); + ex.Message.Should().Be($"connector {connectorId} does not exist"); + } + + [Fact] + public async Task GetCompanyConnectorData_WithValid_ReturnsExpected() + { + // Arrange + var connectorId = Guid.NewGuid(); + var connectorData = _fixture.Build() + .With(x => x.Name, "Test Connector") + .Create(); + A.CallTo(() => _connectorsRepository.GetConnectorByIdForCompany(connectorId, _identity.CompanyId)) + .Returns((connectorData, true)); + + // Act + var result = await _logic.GetCompanyConnectorData(connectorId).ConfigureAwait(false); + + // Assert + result.Name.Should().Be("Test Connector"); + } + + #endregion + #region Setup private void SetupRepositoryMethods() diff --git a/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs b/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs index 345f812a5b..3da771779c 100644 --- a/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs +++ b/tests/administration/Administration.Service.Tests/Controllers/ConnectorsControllerTests.cs @@ -34,7 +34,6 @@ namespace Org.Eclipse.TractusX.Portal.Backend.Administration.Service.Tests.Contr public class ConnectorsControllerTests { - private readonly IdentityData _identity = new("4C1A6851-D4E7-4E10-A011-3732CD045E8A", Guid.NewGuid(), IdentityTypeId.COMPANY_USER, Guid.NewGuid()); private const string AccessToken = "superSafeToken"; private readonly IConnectorsBusinessLogic _logic; private readonly ConnectorsController _controller; @@ -45,7 +44,8 @@ public ConnectorsControllerTests() _fixture = new Fixture(); _logic = A.Fake(); this._controller = new ConnectorsController(_logic); - _controller.AddControllerContextWithClaimAndBearer(AccessToken, _identity); + var identity = new IdentityData("4C1A6851-D4E7-4E10-A011-3732CD045E8A", Guid.NewGuid(), IdentityTypeId.COMPANY_USER, Guid.NewGuid()); + _controller.AddControllerContextWithClaimAndBearer(AccessToken, identity); } [Fact] @@ -53,14 +53,14 @@ public async Task GetManagedConnectorsForCurrentUserAsync_WithValidData_ReturnsE { //Arrange var paginationResponse = new Pagination.Response(new Pagination.Metadata(15, 1, 1, 15), _fixture.CreateMany(5)); - A.CallTo(() => _logic.GetManagedConnectorForCompany(A._, A._, A._)) + A.CallTo(() => _logic.GetManagedConnectorForCompany(A._, A._)) .Returns(paginationResponse); //Act var result = await this._controller.GetManagedConnectorsForCurrentUserAsync().ConfigureAwait(false); //Assert - A.CallTo(() => _logic.GetManagedConnectorForCompany(_identity.CompanyId, 0, 15)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.GetManagedConnectorForCompany(0, 15)).MustHaveHappenedOnceExactly(); result.Content.Should().HaveCount(5); } @@ -72,17 +72,16 @@ public async Task CreateConnectorAsync_WithValidData_ReturnsExpectedResult() "New Connector", "https://connec-tor.com", "the location", - null, null); var connectorId = _fixture.Create(); - A.CallTo(() => _logic.CreateConnectorAsync(A._, A._, A._)) + A.CallTo(() => _logic.CreateConnectorAsync(A._, A._)) .Returns(connectorId); //Act var result = await this._controller.CreateConnectorAsync(connectorInputModel, CancellationToken.None).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.CreateConnectorAsync(connectorInputModel, _identity.CompanyId, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.CreateConnectorAsync(connectorInputModel, A._)).MustHaveHappenedOnceExactly(); Assert.IsType(result); result.Value.Should().Be(connectorId); } @@ -96,51 +95,33 @@ public async Task CreateManagedConnectorAsync_WithValidData_ReturnsExpectedResul "https://connec-tor.com", "the location", Guid.NewGuid(), - null, null); var connectorId = _fixture.Create(); - A.CallTo(() => _logic.CreateManagedConnectorAsync(A._, A._, A._)) + A.CallTo(() => _logic.CreateManagedConnectorAsync(A._, A._)) .Returns(connectorId); //Act var result = await this._controller.CreateManagedConnectorAsync(connectorInputModel, CancellationToken.None).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.CreateManagedConnectorAsync(connectorInputModel, _identity.CompanyId, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.CreateManagedConnectorAsync(connectorInputModel, A._)).MustHaveHappenedOnceExactly(); Assert.IsType(result); result.Value.Should().Be(connectorId); } - [Fact] - public async Task TriggerDaps_WithValidData_ReturnsExpectedResult() - { - //Arrange - var connectorId = Guid.NewGuid(); - var file = FormFileHelper.GetFormFile("this is just random content", "cert.pem", "application/x-pem-file"); - A.CallTo(() => _logic.TriggerDapsAsync(A._, A._, A<(Guid, Guid)>._, A._)) - .Returns(true); - - //Act - var result = await this._controller.TriggerDapsAuth(connectorId, file, CancellationToken.None).ConfigureAwait(false); - - //Assert - A.CallTo(() => _logic.TriggerDapsAsync(connectorId, file, new(_identity.UserId, _identity.CompanyId), A._)).MustHaveHappenedOnceExactly(); - result.Should().BeTrue(); - } - [Fact] public async Task GetCompanyConnectorsForCurrentUser_WithValidData_ReturnsExpectedResult() { //Arrange var paginationResponse = new Pagination.Response(new Pagination.Metadata(15, 1, 1, 15), _fixture.CreateMany(5)); - A.CallTo(() => _logic.GetAllCompanyConnectorDatas(A._, A._, A._)) + A.CallTo(() => _logic.GetAllCompanyConnectorDatas(A._, A._)) .Returns(paginationResponse); //Act var result = await this._controller.GetCompanyConnectorsForCurrentUserAsync().ConfigureAwait(false); //Assert - A.CallTo(() => _logic.GetAllCompanyConnectorDatas(_identity.CompanyId, 0, 15)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.GetAllCompanyConnectorDatas(0, 15)).MustHaveHappenedOnceExactly(); result.Content.Should().HaveCount(5); } @@ -150,14 +131,14 @@ public async Task GetCompanyConnectorByIdForCurrentUserAsync_WithValidData_Retur //Arrange var data = _fixture.Create(); var connectorId = Guid.NewGuid(); - A.CallTo(() => _logic.GetCompanyConnectorData(A._, A._)) + A.CallTo(() => _logic.GetCompanyConnectorData(A._)) .Returns(data); //Act var result = await this._controller.GetCompanyConnectorByIdForCurrentUserAsync(connectorId).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.GetCompanyConnectorData(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.GetCompanyConnectorData(connectorId)).MustHaveHappenedOnceExactly(); result.Should().Be(data); } @@ -168,10 +149,10 @@ public async Task DeleteConnector_WithValidData_ReturnsExpectedResult() var connectorId = Guid.NewGuid(); //Act - await this._controller.DeleteConnectorAsync(connectorId, CancellationToken.None).ConfigureAwait(false); + await this._controller.DeleteConnectorAsync(connectorId).ConfigureAwait(false); //Assert - A.CallTo(() => _logic.DeleteConnectorAsync(connectorId, _identity.CompanyId, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.DeleteConnectorAsync(connectorId)).MustHaveHappenedOnceExactly(); } [Fact] @@ -205,7 +186,7 @@ public async Task ProcessClearinghouseSelfDescription_ReturnsExpectedResult() var result = await this._controller.ProcessClearinghouseSelfDescription(data, CancellationToken.None); // Assert - A.CallTo(() => _logic.ProcessClearinghouseSelfDescription(data, _identity.UserId, A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.ProcessClearinghouseSelfDescription(data, A._)).MustHaveHappenedOnceExactly(); result.Should().BeOfType(); } @@ -217,10 +198,10 @@ public async Task UpdateConnectorUrl_ReturnsExpectedResult() var data = new ConnectorUpdateRequest("https://test.com"); // Act - var result = await this._controller.UpdateConnectorUrl(connectorId, data, CancellationToken.None); + var result = await this._controller.UpdateConnectorUrl(connectorId, data); // Assert - A.CallTo(() => _logic.UpdateConnectorUrl(connectorId, data, new(_identity.UserId, _identity.CompanyId), A._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _logic.UpdateConnectorUrl(connectorId, data)).MustHaveHappenedOnceExactly(); result.Should().BeOfType(); } @@ -229,7 +210,7 @@ public async Task GetConnectorOfferSubscriptionData_ReturnsExpectedResult() { // Arrange var offerSubscriptionData = _fixture.CreateMany(5); - A.CallTo(() => _logic.GetConnectorOfferSubscriptionData(null, _identity.CompanyId)) + A.CallTo(() => _logic.GetConnectorOfferSubscriptionData(null)) .Returns(offerSubscriptionData.ToAsyncEnumerable()); // Act diff --git a/tests/administration/Administration.Service.Tests/appsettings.IntegrationTests.json b/tests/administration/Administration.Service.Tests/appsettings.IntegrationTests.json index 05f5c2cad4..570fea9907 100644 --- a/tests/administration/Administration.Service.Tests/appsettings.IntegrationTests.json +++ b/tests/administration/Administration.Service.Tests/appsettings.IntegrationTests.json @@ -244,9 +244,6 @@ "COMMERCIAL_REGISTER_EXTRACT" ] }, - "Daps":{ - "DapsUrl": "https://api.test.com" - }, "Invitation": { "RegistrationAppAddress": "https://test-registration.azurewebsites.net", "InvitedUserInitialRoles": [ diff --git a/tests/externalsystems/Daps.Library.Tests/Daps.Library.Tests.csproj b/tests/externalsystems/Daps.Library.Tests/Daps.Library.Tests.csproj deleted file mode 100644 index a3c5ac2fc9..0000000000 --- a/tests/externalsystems/Daps.Library.Tests/Daps.Library.Tests.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - - net6.0 - enable - enable - false - Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Tests - Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Tests - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - diff --git a/tests/externalsystems/Daps.Library.Tests/DapsServiceTests.cs b/tests/externalsystems/Daps.Library.Tests/DapsServiceTests.cs deleted file mode 100644 index 44c8a13e05..0000000000 --- a/tests/externalsystems/Daps.Library.Tests/DapsServiceTests.cs +++ /dev/null @@ -1,365 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; -using Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; -using Org.Eclipse.TractusX.Portal.Backend.Framework.Models; -using Org.Eclipse.TractusX.Portal.Backend.Framework.Token; -using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; -using System.Net; - -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Tests; - -public class DapsServiceTests -{ - #region Initialization - - private readonly ITokenService _tokenService; - private readonly IOptions _options; - private readonly ILogger _logger; - private readonly IMockLogger _mockLogger; - - public DapsServiceTests() - { - var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization { ConfigureMembers = true }); - fixture.Behaviors.OfType().ToList() - .ForEach(b => fixture.Behaviors.Remove(b)); - fixture.Behaviors.Add(new OmitOnRecursionBehavior()); - - _options = Options.Create(new DapsSettings - { - IsActive = true, - DapsUrl = "https://www.api.daps-not-existing.com", - Password = "passWord", - Scope = "test", - Username = "user@name", - ClientId = "CatenaX", - ClientSecret = "pass@Secret", - GrantType = "cred", - KeycloakTokenAddress = "https://key.cloak.com", - }); - _tokenService = A.Fake(); - _mockLogger = A.Fake>(); - _logger = new MockLogger(_mockLogger); - } - - #endregion - - #region EnableDapsAuth - - [Fact] - public async Task EnableDapsAuthAsync_WithDapsInactive_ReturnsExpected() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - const string clientName = "Connec Tor"; - const string referringConnector = "https://connect-tor.com"; - const string businessPartnerNumber = "BPNL000000000009"; - var service = new DapsService(_tokenService, _logger, Options.Create(new DapsSettings { IsActive = false })); - - // Act - var result = await service.EnableDapsAuthAsync(clientName, referringConnector, businessPartnerNumber, file, CancellationToken.None).ConfigureAwait(false); - - // Assert - result.Should().BeNull(); - A.CallTo(() => _tokenService.GetAuthorizedClient(A._, A._)).MustNotHaveHappened(); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, "daps-post call skipped due to daps is disabled")).MustHaveHappened(); - } - - [Fact] - public async Task EnableDapsAuthAsync_WithValidCall_ReturnsExpected() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - - var content = "{\"daps\": {\"jwks\": \"https://daps-pen.int.demo.catena-x.net/jwks.json\"},\"clientId\": \"11:11:11:11:11:ED:E2:EF:EF:72:14:BA:87:95:CF:C1:AC:B0:84:E5:keyid:1C:AA:6E:30:30:ED:E2:EF:EF:72:14:BA:87:95:CF:11:11:11:11:11\"}"; - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.Created, new StringContent(content)); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - const string clientName = "Connec Tor"; - const string referringConnector = "https://connect-tor.com"; - const string businessPartnerNumber = "BPNL000000000009"; - var service = new DapsService(_tokenService, _logger, _options); - - // Act - var result = await service.EnableDapsAuthAsync(clientName, referringConnector, businessPartnerNumber, file, CancellationToken.None).ConfigureAwait(false); - - // Assert - result.Should().NotBeNull(); - result!.ClientId.Should().Be("11:11:11:11:11:ED:E2:EF:EF:72:14:BA:87:95:CF:C1:AC:B0:84:E5:keyid:1C:AA:6E:30:30:ED:E2:EF:EF:72:14:BA:87:95:CF:11:11:11:11:11"); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task EnableDapsAuthAsync_WithUnsuccessfulStatusCode_ThrowsException() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - - var httpMessageHandlerMock = - new HttpMessageHandlerMock(HttpStatusCode.BadRequest); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - const string clientName = "Connec Tor"; - const string referringConnector = "https://connect-tor.com"; - const string businessPartnerNumber = "BPNL000000000009"; - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.EnableDapsAuthAsync(clientName, referringConnector, businessPartnerNumber, file, CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task EnableDapsAuthAsync_WithException_ThrowsException() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - - var httpMessageHandlerMock = - new HttpMessageHandlerMock(HttpStatusCode.BadRequest, ex: new HttpRequestException("DNS Error")); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - const string clientName = "Connec Tor"; - const string referringConnector = "https://connect-tor.com"; - const string businessPartnerNumber = "BPNL000000000009"; - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.EnableDapsAuthAsync(clientName, referringConnector, businessPartnerNumber, file, CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task EnableDapsAuthAsync_WithInvalidUrl_ThrowsException() - { - // Arrange - var file = FormFileHelper.GetFormFile("Content of the super secure certificate", "test.pem", "application/x-pem-file"); - - var httpMessageHandlerMock = - new HttpMessageHandlerMock(HttpStatusCode.BadRequest, ex: new HttpRequestException("DNS Error")); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - const string clientName = "Connec Tor"; - const string referringConnector = "test.com"; - const string businessPartnerNumber = "BPNL000000000009"; - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.EnableDapsAuthAsync(clientName, referringConnector, businessPartnerNumber, file, CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - #endregion - - #region DeleteDapsAuth - - [Fact] - public async Task DeleteDapsAuth_WithDapsInactive_ReturnsExpected() - { - // Arrange - var service = new DapsService(_tokenService, _logger, Options.Create(new DapsSettings { IsActive = false })); - - // Act - var result = await service.DeleteDapsClient("1234", CancellationToken.None).ConfigureAwait(false); - - // Assert - result.Should().BeTrue(); - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .MustNotHaveHappened(); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, "daps-delete call skipped due to daps is disabled")) - .MustHaveHappenedOnceExactly(); - } - - [Fact] - public async Task DeleteDapsAuth_WithValidCall_ReturnsExpected() - { - // Arrange - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.OK); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - var service = new DapsService(_tokenService, _logger, _options); - - // Act - var result = await service.DeleteDapsClient("1234", CancellationToken.None).ConfigureAwait(false); - - // Assert - result.Should().BeTrue(); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task DeleteDapsClient_WithUnsuccessfulStatusCode_ThrowsException() - { - // Arrange - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.DeleteDapsClient("1234", CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task DeleteDapsClient_WithException_ThrowsException() - { - // Arrange - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest, ex: new HttpRequestException("DNS Error")); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.DeleteDapsClient("12345", CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - #endregion - - #region UpdateDapsConnectorUrl - - [Fact] - public async Task UpdateDapsConnectorUrl_WithDapsInactive_ReturnsExpected() - { - // Arrange - var service = new DapsService(_tokenService, _logger, Options.Create(new DapsSettings { IsActive = false })); - - // Act - var result = await service.UpdateDapsConnectorUrl("1234", "https://test.url.com", "BPNL123456789", CancellationToken.None).ConfigureAwait(false); - - // Assert - result.Should().BeTrue(); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, "daps-update call skipped due to daps is disabled")).MustHaveHappenedOnceExactly(); - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .MustNotHaveHappened(); - } - - [Fact] - public async Task UpdateDapsConnectorUrl_WithValidCall_ReturnsExpected() - { - // Arrange - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.OK); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - var service = new DapsService(_tokenService, _logger, _options); - - // Act - var result = await service.UpdateDapsConnectorUrl("1234", "https://test.url.com", "BPNL123456789", CancellationToken.None).ConfigureAwait(false); - - // Assert - result.Should().BeTrue(); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task UpdateDapsConnectorUrl_WithUnsuccessfulStatusCode_ThrowsException() - { - // Arrange - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.UpdateDapsConnectorUrl("1234", "https://test.url.com", "BPNL123456789", CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - [Fact] - public async Task UpdateDapsConnectorUrl_WithException_ThrowsException() - { - // Arrange - var httpMessageHandlerMock = new HttpMessageHandlerMock(HttpStatusCode.BadRequest, ex: new HttpRequestException("DNS Error")); - var httpClient = new HttpClient(httpMessageHandlerMock) - { - BaseAddress = new Uri("https://base.address.com") - }; - A.CallTo(() => _tokenService.GetAuthorizedClient(_options.Value, A._)) - .Returns(httpClient); - var service = new DapsService(_tokenService, _logger, _options); - - // Act - async Task Act() => await service.UpdateDapsConnectorUrl("12345", "https://test.url.com", "BPNL123456789", CancellationToken.None).ConfigureAwait(false); - - // Assert - await Assert.ThrowsAsync(Act).ConfigureAwait(false); - A.CallTo(() => _mockLogger.Log(A.That.IsEqualTo(LogLevel.Information), A._, A._)).MustNotHaveHappened(); - } - - #endregion -} diff --git a/tests/externalsystems/Daps.Library.Tests/Usings.cs b/tests/externalsystems/Daps.Library.Tests/Usings.cs deleted file mode 100644 index d0c35ff438..0000000000 --- a/tests/externalsystems/Daps.Library.Tests/Usings.cs +++ /dev/null @@ -1,25 +0,0 @@ -/******************************************************************************** - * Copyright (c) 2021, 2023 BMW Group AG - * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ********************************************************************************/ - -global using AutoFixture; -global using AutoFixture.AutoFakeItEasy; -global using FakeItEasy; -global using FluentAssertions; -global using Xunit; diff --git a/tests/externalsystems/OfferProvider.Library/OfferProviderServiceTests.cs b/tests/externalsystems/OfferProvider.Library/OfferProviderServiceTests.cs index a4194b8a93..a088cd2457 100644 --- a/tests/externalsystems/OfferProvider.Library/OfferProviderServiceTests.cs +++ b/tests/externalsystems/OfferProvider.Library/OfferProviderServiceTests.cs @@ -21,13 +21,12 @@ using Microsoft.Extensions.Options; using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling; using Org.Eclipse.TractusX.Portal.Backend.Framework.Token; -using Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library; using Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library.DependencyInjection; using Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library.Models; using Org.Eclipse.TractusX.Portal.Backend.Tests.Shared; using System.Net; -namespace Org.Eclipse.TractusX.Portal.Backend.Daps.Library.Tests; +namespace Org.Eclipse.TractusX.Portal.Backend.OfferProvider.Library.Tests; public class OfferProviderServiceTests { diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs index 324c5219d0..a6de158a78 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs @@ -47,6 +47,26 @@ public ConnectorRepositoryTests(TestDbFixture testDbFixture) _dbTestDbFixture = testDbFixture; } + #region GetAllCompanyConnectorsForCompanyId + + [Fact] + public async Task GetAllCompanyConnectorsForCompanyId_ReturnsExpectedAppCount() + { + // Arrange + var (sut, _) = await CreateSut().ConfigureAwait(false); + + // Act + var result = await sut.GetAllCompanyConnectorsForCompanyId(_userCompanyId).ToListAsync().ConfigureAwait(false); + + // Assert + result.Should().NotBeNull(); + result.Should().HaveCount(2).And.Satisfy( + x => x.Name == "Test Connector 6", + x => x.Name == "Test Connector 1"); + } + + #endregion + #region CreateConnector [Fact] @@ -261,7 +281,6 @@ public async Task GetSelfDescriptionDocumentDataAsync_WithoutDocumentId_ReturnsE result.IsValidConnectorId.Should().BeTrue(); result.IsProvidingOrHostCompany.Should().BeTrue(); result.SelfDescriptionDocumentId.Should().BeNull(); - result.DocumentStatusId.Should().BeNull(); } [Fact] @@ -309,53 +328,6 @@ public async Task GetSelfDescriptionDocumentDataAsync_WithoutExistingConnectorId result.Should().NotBeNull(); result.IsValidConnectorId.Should().BeFalse(); result.SelfDescriptionDocumentId.Should().BeNull(); - result.DocumentStatusId.Should().BeNull(); - } - - #endregion - - #region CreateConnectorClientDetails - - [Fact] - public async Task CreateConnectorClientDetails_ReturnsExpected() - { - // Arrange - var (sut, context) = await CreateSut().ConfigureAwait(false); - - // Act - sut.CreateConnectorClientDetails(new Guid("ca7259eb-a3a3-4cc6-9e53-463bf0700af5"), "12345"); - - // Assert - var changeTracker = context.ChangeTracker; - var changedEntries = changeTracker.Entries().ToList(); - changeTracker.HasChanges().Should().BeTrue(); - changedEntries.Should().NotBeEmpty(); - changedEntries.Should().HaveCount(1); - changedEntries.Single().Entity.Should().BeOfType().Which.ClientId.Should().Be("12345"); - } - - #endregion - - #region DeleteConnectorClientDetails - - [Fact] - public async Task DeleteConnectorClientDetails_ReturnsExpectedResult() - { - // Arrange - var (sut, context) = await CreateSut().ConfigureAwait(false); - - // Act - sut.DeleteConnectorClientDetails(new Guid("f032a035-d035-11ec-9d64-0242ac120002")); - - // Assert - var changeTracker = context.ChangeTracker; - var changedEntries = changeTracker.Entries().ToList(); - changeTracker.HasChanges().Should().BeTrue(); - changedEntries.Should().NotBeEmpty(); - changedEntries.Should().HaveCount(1); - var entry = changedEntries.Single(); - entry.Entity.Should().BeOfType(); - entry.State.Should().Be(EntityState.Deleted); } #endregion @@ -458,6 +430,54 @@ public async Task GetConnectorEndPointDataAsync_WithExistingConnector_ReturnsExp #endregion + #region DeleteConnector + + [Fact] + public async Task DeleteConnector_ExecutesExpected() + { + // Arrange + var (sut, context) = await CreateSut().ConfigureAwait(false); + + // Act + sut.DeleteConnector(new Guid("7e86a0b8-6903-496b-96d1-0ef508206833")); + + // Assert + var changeTracker = context.ChangeTracker; + var changedEntries = changeTracker.Entries().ToList(); + changeTracker.HasChanges().Should().BeTrue(); + changedEntries.Should().NotBeEmpty(); + changedEntries.Should().HaveCount(1); + var removedEntity = changedEntries.Single(); + removedEntity.State.Should().Be(EntityState.Deleted); + } + + #endregion + + #region CreateConnectorAssignedSubscriptions + + [Fact] + public async Task CreateConnectorAssignedSubscriptions_ExecutesExpected() + { + // Arrange + var (sut, context) = await CreateSut().ConfigureAwait(false); + + // Act + var result = sut.CreateConnectorAssignedSubscriptions(new Guid("7e86a0b8-6903-496b-96d1-0ef508206833"), new Guid("0b2ca541-206d-48ad-bc02-fb61fbcb5552")); + + // Assert + var changeTracker = context.ChangeTracker; + var changedEntries = changeTracker.Entries().ToList(); + result.OfferSubscriptionId.Should().Be("0b2ca541-206d-48ad-bc02-fb61fbcb5552"); + result.ConnectorId.Should().Be("7e86a0b8-6903-496b-96d1-0ef508206833"); + changeTracker.HasChanges().Should().BeTrue(); + changedEntries.Should().NotBeEmpty(); + changedEntries.Should().HaveCount(1); + changedEntries.Single().State.Should().Be(EntityState.Added); + changedEntries.Single().Entity.Should().BeOfType().Which.OfferSubscriptionId.Should().Be("0b2ca541-206d-48ad-bc02-fb61fbcb5552"); + } + + #endregion + private async Task<(ConnectorsRepository, PortalDbContext)> CreateSut() { var context = await _dbTestDbFixture.GetPortalDbContext().ConfigureAwait(false); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/connectors.test.json b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/connectors.test.json index f891cf9512..ad2bafac39 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/connectors.test.json +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/Seeder/Data/connectors.test.json @@ -8,8 +8,7 @@ "provider_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "host_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "595a5784-3f28-4ec3-a986-651342d1be81", @@ -20,8 +19,7 @@ "provider_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "727365d6-5599-4598-a888-58733fa138e7", @@ -32,8 +30,7 @@ "provider_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "host_id": "ac861325-bc54-4583-bcdc-9e9f2a38ff84", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "8e10b910-523c-435e-b700-4a0c7b31f044", @@ -44,8 +41,7 @@ "provider_id": "41fd2ab8-71cd-4546-9bef-a388d91b2542", "host_id": "41fd2ab8-71cd-4546-9bef-a388d91b2542", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206833", @@ -56,8 +52,7 @@ "provider_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206839", @@ -68,8 +63,7 @@ "provider_id": "41fd2ab8-71cd-4546-9bef-a388d91b2542", "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", - "self_description_document_id": "e020787d-1e04-4c0b-9c06-bd1cd44724b3", - "daps_registration_successful": null + "self_description_document_id": "e020787d-1e04-4c0b-9c06-bd1cd44724b3" }, { "id": "7e86a0b8-6903-496b-96d1-0ef508206838", @@ -81,7 +75,6 @@ "host_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f87", "location_id": "DE", "self_description_document_id": null, - "daps_registration_successful": null, "company_service_account_id": "d0c8ae19-d4f3-49cc-9cb4-6c766d4680f4" }, { @@ -93,8 +86,7 @@ "provider_id": "41fd2ab8-71cd-4546-9bef-a388d91b2542", "host_id": "41fd2ab8-7123-4546-9bef-a388d91b2999", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null }, { "id": "bd644d9c-ca12-4488-ae38-6eb902c9bec0", @@ -105,7 +97,6 @@ "provider_id": "2dc4249f-b5ca-4d42-bef1-7a7a950a4f88", "host_id": "41fd2ab8-7123-4546-9bef-a388d91b2999", "location_id": "DE", - "self_description_document_id": null, - "daps_registration_successful": null + "self_description_document_id": null } ] From 564e0354931af9e8af97b698eeae7c469105f40a Mon Sep 17 00:00:00 2001 From: Phil Schneider Date: Thu, 3 Aug 2023 15:41:40 +0200 Subject: [PATCH 2/3] fix(connector): fix delete connector remove assigned offersubscriptions from connector when deleting the connector Refs: CPLP-3105 --- .../BusinessLogic/ConnectorsBusinessLogic.cs | 26 ++++++++---- .../Repositories/ConnectorsRepository.cs | 11 +++-- .../Repositories/IConnectorsRepository.cs | 4 +- .../ConnectorsBusinessLogicTests.cs | 42 +++++++++++++++---- .../ConnectorRepositoryTests.cs | 23 ++++++++++ 5 files changed, 86 insertions(+), 20 deletions(-) diff --git a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs index a975bedaaf..4c3ed29a6e 100644 --- a/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs +++ b/src/administration/Administration.Service/BusinessLogic/ConnectorsBusinessLogic.cs @@ -272,7 +272,7 @@ public async Task DeleteConnectorAsync(Guid connectorId) { var companyId = _identityService.IdentityData.CompanyId; var connectorsRepository = _portalRepositories.GetInstance(); - var (isValidConnectorId, isProvidingOrHostCompany, selfDescriptionDocumentId, documentStatusId, connectorStatus) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false); + var (isValidConnectorId, isProvidingOrHostCompany, selfDescriptionDocumentId, documentStatusId, connectorStatus, assignedOfferSubscriptions) = await connectorsRepository.GetConnectorDeleteDataAsync(connectorId, companyId).ConfigureAwait(false); if (!isValidConnectorId) { @@ -287,26 +287,26 @@ public async Task DeleteConnectorAsync(Guid connectorId) switch (connectorStatus) { case ConnectorStatusId.PENDING when selfDescriptionDocumentId == null: - await DeleteConnectorWithoutDocuments(connectorId, connectorsRepository); + await DeleteConnectorWithoutDocuments(connectorId, assignedOfferSubscriptions, connectorsRepository); break; case ConnectorStatusId.PENDING: - await DeleteConnectorWithDocuments(connectorId, selfDescriptionDocumentId.Value, connectorsRepository); + await DeleteConnectorWithDocuments(connectorId, assignedOfferSubscriptions, selfDescriptionDocumentId.Value, connectorsRepository); break; case ConnectorStatusId.ACTIVE when selfDescriptionDocumentId != null && documentStatusId != null: - await DeleteConnector(connectorId, selfDescriptionDocumentId.Value, documentStatusId.Value, connectorsRepository); + await DeleteConnector(connectorId, assignedOfferSubscriptions, selfDescriptionDocumentId.Value, documentStatusId.Value, connectorsRepository); break; default: throw new ConflictException("Connector status does not match a deletion scenario. Deletion declined"); } } - private async Task DeleteConnector(Guid connectorId, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository) + private async Task DeleteConnector(Guid connectorId, IEnumerable assignedOfferSubscriptions, Guid selfDescriptionDocumentId, DocumentStatusId documentStatus, IConnectorsRepository connectorsRepository) { _portalRepositories.GetInstance().AttachAndModifyDocument( selfDescriptionDocumentId, a => { a.DocumentStatusId = documentStatus; }, a => { a.DocumentStatusId = DocumentStatusId.INACTIVE; }); - + RemoveConnectorAssignedOfferSubscriptions(connectorId, assignedOfferSubscriptions, connectorsRepository); await DeleteUpdateConnectorDetail(connectorId, connectorsRepository); } @@ -320,19 +320,29 @@ private async Task DeleteUpdateConnectorDetail(Guid connectorId, IConnectorsRepo await _portalRepositories.SaveAsync(); } - private async Task DeleteConnectorWithDocuments(Guid connectorId, Guid selfDescriptionDocumentId, IConnectorsRepository connectorsRepository) + private async Task DeleteConnectorWithDocuments(Guid connectorId, IEnumerable assignedOfferSubscriptions, Guid selfDescriptionDocumentId, IConnectorsRepository connectorsRepository) { _portalRepositories.GetInstance().RemoveDocument(selfDescriptionDocumentId); + RemoveConnectorAssignedOfferSubscriptions(connectorId, assignedOfferSubscriptions, connectorsRepository); connectorsRepository.DeleteConnector(connectorId); await _portalRepositories.SaveAsync(); } - private async Task DeleteConnectorWithoutDocuments(Guid connectorId, IConnectorsRepository connectorsRepository) + private async Task DeleteConnectorWithoutDocuments(Guid connectorId, IEnumerable assignedOfferSubscriptions, IConnectorsRepository connectorsRepository) { + RemoveConnectorAssignedOfferSubscriptions(connectorId, assignedOfferSubscriptions, connectorsRepository); connectorsRepository.DeleteConnector(connectorId); await _portalRepositories.SaveAsync(); } + private static void RemoveConnectorAssignedOfferSubscriptions(Guid connectorId, IEnumerable assignedOfferSubscriptions, IConnectorsRepository connectorsRepository) + { + if (assignedOfferSubscriptions.Any()) + { + connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, assignedOfferSubscriptions); + } + } + /// public IAsyncEnumerable GetCompanyConnectorEndPointAsync(IEnumerable bpns) { diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs index 97e0b8b161..b37a5449fa 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/ConnectorsRepository.cs @@ -137,15 +137,16 @@ public Connector AttachAndModifyConnector(Guid connectorId, Action? i .SingleOrDefaultAsync(); /// - public Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId) => + public Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, IEnumerable AssignedOfferSubscriptions)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId) => _context.Connectors .Where(x => x.Id == connectorId) - .Select(connector => new ValueTuple( + .Select(connector => new ValueTuple>( true, connector.ProviderId == companyId || connector.HostId == companyId, connector.SelfDescriptionDocumentId, connector.SelfDescriptionDocument!.DocumentStatusId, - connector.StatusId + connector.StatusId, + connector.ConnectorAssignedOfferSubscriptions.Select(x => x.OfferSubscriptionId) )).SingleOrDefaultAsync(); /// @@ -167,4 +168,8 @@ public void DeleteConnector(Guid connectorId) => /// public ConnectorAssignedOfferSubscription CreateConnectorAssignedSubscriptions(Guid connectorId, Guid subscriptionId) => _context.ConnectorAssignedOfferSubscriptions.Add(new ConnectorAssignedOfferSubscription(connectorId, subscriptionId)).Entity; + + /// + public void DeleteConnectorAssignedSubscriptions(Guid connectorId, IEnumerable assignedOfferSubscriptions) => + _context.ConnectorAssignedOfferSubscriptions.RemoveRange(assignedOfferSubscriptions.Select(x => new ConnectorAssignedOfferSubscription(connectorId, x))); } diff --git a/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs b/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs index 7a0a94d29b..c797c6cdf2 100644 --- a/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs +++ b/src/portalbackend/PortalBackend.DBAccess/Repositories/IConnectorsRepository.cs @@ -87,7 +87,7 @@ public interface IConnectorsRepository /// Id of the connector /// Id of the company /// returns SelfDescriptionDocument Data/c> - Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId); + Task<(bool IsValidConnectorId, bool IsProvidingOrHostCompany, Guid? SelfDescriptionDocumentId, DocumentStatusId? DocumentStatusId, ConnectorStatusId ConnectorStatus, IEnumerable AssignedOfferSubscriptions)> GetConnectorDeleteDataAsync(Guid connectorId, Guid companyId); /// /// Gets the data required for the connector update @@ -104,4 +104,6 @@ public interface IConnectorsRepository void DeleteConnector(Guid connectorId); ConnectorAssignedOfferSubscription CreateConnectorAssignedSubscriptions(Guid connectorId, Guid subscriptionId); + + void DeleteConnectorAssignedSubscriptions(Guid connectorId, IEnumerable assignedOfferSubscriptions); } diff --git a/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs b/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs index 5f36df4783..49c2aec538 100644 --- a/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs +++ b/tests/administration/Administration.Service.Tests/BusinessLogic/ConnectorsBusinessLogicTests.cs @@ -478,8 +478,9 @@ public async Task DeleteConnectorAsync_WithDocumentId_ExpectedCalls() var connectorId = Guid.NewGuid(); var connector = new Connector(connectorId, null!, null!, null!); var selfDescriptionDocumentId = Guid.NewGuid(); + var assignedOfferSubscriptions = _fixture.CreateMany(2); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) - .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.ACTIVE)); + .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.ACTIVE, assignedOfferSubscriptions)); A.CallTo(() => _documentRepository.AttachAndModifyDocument(A._, A>._, A>._)) .Invokes((Guid docId, Action? initialize, Action modify) @@ -504,6 +505,7 @@ public async Task DeleteConnectorAsync_WithDocumentId_ExpectedCalls() A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); A.CallTo(() => _documentRepository.AttachAndModifyDocument(selfDescriptionDocumentId, A>._, A>._)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.AttachAndModifyConnector(connectorId, A>._, A>._)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, A>.That.Matches(x => x.Count() == 2))).MustHaveHappenedOnceExactly(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); } @@ -512,8 +514,9 @@ public async Task DeleteConnectorAsync_WithPendingAndWithoutDocumentId_ExpectedC { // Arrange var connectorId = Guid.NewGuid(); + var assignedOfferSubscriptions = _fixture.CreateMany(2); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) - .Returns((true, true, null, null, ConnectorStatusId.PENDING)); + .Returns((true, true, null, null, ConnectorStatusId.PENDING, assignedOfferSubscriptions)); // Act await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); @@ -521,6 +524,7 @@ public async Task DeleteConnectorAsync_WithPendingAndWithoutDocumentId_ExpectedC // Assert A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.DeleteConnector(connectorId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, A>.That.Matches(x => x.Count() == 2))).MustHaveHappenedOnceExactly(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); } @@ -531,8 +535,9 @@ public async Task DeleteConnectorAsync_WithPendingAndDocumentId_ExpectedCalls() const DocumentStatusId documentStatusId = DocumentStatusId.LOCKED; var connectorId = Guid.NewGuid(); var selfDescriptionDocumentId = Guid.NewGuid(); + var assignedOfferSubscriptions = _fixture.CreateMany(2); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) - .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.PENDING)); + .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.PENDING, assignedOfferSubscriptions)); // Act await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); @@ -541,6 +546,28 @@ public async Task DeleteConnectorAsync_WithPendingAndDocumentId_ExpectedCalls() A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); A.CallTo(() => _documentRepository.RemoveDocument(selfDescriptionDocumentId)).MustHaveHappenedOnceExactly(); A.CallTo(() => _connectorsRepository.DeleteConnector(connectorId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, A>.That.Matches(x => x.Count() == 2))).MustHaveHappenedOnceExactly(); + A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); + } + + [Fact] + public async Task DeleteConnectorAsync_WithoutAssignedOfferSubscriptions_ExpectedCalls() + { + // Arrange + const DocumentStatusId documentStatusId = DocumentStatusId.LOCKED; + var connectorId = Guid.NewGuid(); + var selfDescriptionDocumentId = Guid.NewGuid(); + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(A._, _identity.CompanyId)) + .Returns((true, true, selfDescriptionDocumentId, documentStatusId, ConnectorStatusId.PENDING, Enumerable.Empty())); + + // Act + await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); + + // Assert + A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _documentRepository.RemoveDocument(selfDescriptionDocumentId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnector(connectorId)).MustHaveHappenedOnceExactly(); + A.CallTo(() => _connectorsRepository.DeleteConnectorAssignedSubscriptions(connectorId, A>._)).MustNotHaveHappened(); A.CallTo(() => _portalRepositories.SaveAsync()).MustHaveHappenedOnceExactly(); } @@ -549,9 +576,8 @@ public async Task DeleteConnectorAsync_WithOutDocumentId_ExpectedCalls() { // Arrange var connectorId = Guid.NewGuid(); - var connector = new Connector(connectorId, null!, null!, null!); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, true, null, null, ConnectorStatusId.ACTIVE)); + .Returns((true, true, null, null, ConnectorStatusId.ACTIVE, Enumerable.Empty())); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); @@ -567,7 +593,7 @@ public async Task DeleteConnectorAsync_WithInactiveConnector_ThrowsConflictExcep // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, true, null, null, ConnectorStatusId.ACTIVE)); + .Returns((true, true, null, null, ConnectorStatusId.ACTIVE, Enumerable.Empty())); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); @@ -583,7 +609,7 @@ public async Task DeleteConnectorAsync_ThrowsNotFoundException() // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((false, false, null, null, ConnectorStatusId.ACTIVE)); + .Returns((false, false, null, null, ConnectorStatusId.ACTIVE, Enumerable.Empty())); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); @@ -599,7 +625,7 @@ public async Task DeleteConnectorAsync_ThrowsForbiddenException() // Arrange var connectorId = Guid.NewGuid(); A.CallTo(() => _connectorsRepository.GetConnectorDeleteDataAsync(connectorId, _identity.CompanyId)) - .Returns((true, false, null, null, default)); + .Returns((true, false, null, null, default, Enumerable.Empty())); // Act async Task Act() => await _logic.DeleteConnectorAsync(connectorId).ConfigureAwait(false); diff --git a/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs b/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs index a6de158a78..5860d72910 100644 --- a/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs +++ b/tests/portalbackend/PortalBackend.DBAccess.Tests/ConnectorRepositoryTests.cs @@ -478,6 +478,29 @@ public async Task CreateConnectorAssignedSubscriptions_ExecutesExpected() #endregion + #region DeleteConnector + + [Fact] + public async Task DeleteConnectorAssignedSubscriptions_ExecutesExpected() + { + // Arrange + var (sut, context) = await CreateSut().ConfigureAwait(false); + + // Act + sut.DeleteConnectorAssignedSubscriptions(new Guid("7e86a0b8-6903-496b-96d1-0ef508206833"), Enumerable.Repeat(new Guid("0b2ca541-206d-48ad-bc02-fb61fbcb5552"), 1)); + + // Assert + var changeTracker = context.ChangeTracker; + var changedEntries = changeTracker.Entries().ToList(); + changeTracker.HasChanges().Should().BeTrue(); + changedEntries.Should().NotBeEmpty(); + changedEntries.Should().HaveCount(1); + var removedEntity = changedEntries.Single(); + removedEntity.State.Should().Be(EntityState.Deleted); + } + + #endregion + private async Task<(ConnectorsRepository, PortalDbContext)> CreateSut() { var context = await _dbTestDbFixture.GetPortalDbContext().ConfigureAwait(false); From acfa4a9c3df730f27b730f3cd9dc033600a7b693 Mon Sep 17 00:00:00 2001 From: Norbert Truchsess Date: Fri, 4 Aug 2023 09:18:59 +0200 Subject: [PATCH 3/3] cosmetics --- .../Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs | 3 --- .../Migrations/20230803131109_CPLP-3105-RemoveDaps.cs | 1 - .../Migrations/PortalDbContextModelSnapshot.cs | 3 --- 3 files changed, 7 deletions(-) diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs index 1351d02498..90cbbb29aa 100644 --- a/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.Designer.cs @@ -19,12 +19,9 @@ ********************************************************************************/ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; #nullable disable diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs index 0f83489751..ccb390967a 100644 --- a/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/20230803131109_CPLP-3105-RemoveDaps.cs @@ -19,7 +19,6 @@ ********************************************************************************/ using Microsoft.EntityFrameworkCore.Migrations; -using System; #nullable disable diff --git a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs index 372bfd4928..2dfa4a7322 100644 --- a/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs +++ b/src/portalbackend/PortalBackend.Migrations/Migrations/PortalDbContextModelSnapshot.cs @@ -19,11 +19,8 @@ ********************************************************************************/ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using Org.Eclipse.TractusX.Portal.Backend.PortalBackend.PortalEntities; #nullable disable