diff --git a/docker/Dockerfile-dim-migrations b/docker/Dockerfile-dim-migrations
index 0e5ec7e..a543764 100644
--- a/docker/Dockerfile-dim-migrations
+++ b/docker/Dockerfile-dim-migrations
@@ -23,7 +23,6 @@ ARG TARGETARCH
WORKDIR /
COPY LICENSE /
COPY /src/database /src/database
-COPY /src/processes/Processes.Worker.Library /src/processes/Processes.Worker.Library
WORKDIR /src/database/Dim.Migrations
RUN dotnet publish "Dim.Migrations.csproj" -c Release -o /migrations/publish
diff --git a/src/Dim.sln b/src/Dim.sln
index f52c3a4..cb42844 100644
--- a/src/Dim.sln
+++ b/src/Dim.sln
@@ -6,12 +6,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "clients", "clients", "{B84A
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dim.Clients", "clients\Dim.Clients\Dim.Clients.csproj", "{8356C7AF-6F88-4A62-B3E9-5656634A6FEA}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Library", "processes\Processes.Library\Processes.Library.csproj", "{BFDDFCF5-8F35-4348-A568-57D8E34DF289}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker", "processes\Processes.Worker\Processes.Worker.csproj", "{E5F65B6F-BD8F-4FAF-80A2-69C9DA20DCC2}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker.Library", "processes\Processes.Worker.Library\Processes.Worker.Library.csproj", "{4F40B8F2-12D4-403B-B666-8F0540354455}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "database", "database", "{4A305F87-23B4-4929-B138-4B7D2710526F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dim.DbAccess", "database\Dim.DbAccess\Dim.DbAccess.csproj", "{6984539B-7B5A-481E-A955-3AE537D43166}"
@@ -30,10 +26,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dim.Web", "web\Dim.Web\Dim.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{CB1B7D43-9AFC-47EF-8915-A547F7F553AB}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Library.Tests", "..\tests\processes\Processes.Library.Tests\Processes.Library.Tests.csproj", "{AA29EECC-CD77-4452-B48E-CC038E4FBB69}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Processes.Worker.Library.Tests", "..\tests\processes\Processes.Worker.Library.Tests\Processes.Worker.Library.Tests.csproj", "{9888C703-CC13-47EB-89F0-B8A34D64BD07}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests.Shared", "..\tests\shared\Tests.Shared\Tests.Shared.csproj", "{0D288AF0-1CE5-4B2B-9F80-532040F24BCF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DimProcess.Executor.Tests", "..\tests\processes\DimProcess.Executor.Tests\DimProcess.Executor.Tests.csproj", "{A44447B0-794D-451A-A571-E3B761174B48}"
@@ -56,18 +48,10 @@ Global
{8356C7AF-6F88-4A62-B3E9-5656634A6FEA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8356C7AF-6F88-4A62-B3E9-5656634A6FEA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8356C7AF-6F88-4A62-B3E9-5656634A6FEA}.Release|Any CPU.Build.0 = Release|Any CPU
- {BFDDFCF5-8F35-4348-A568-57D8E34DF289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {BFDDFCF5-8F35-4348-A568-57D8E34DF289}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {BFDDFCF5-8F35-4348-A568-57D8E34DF289}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {BFDDFCF5-8F35-4348-A568-57D8E34DF289}.Release|Any CPU.Build.0 = Release|Any CPU
{E5F65B6F-BD8F-4FAF-80A2-69C9DA20DCC2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5F65B6F-BD8F-4FAF-80A2-69C9DA20DCC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5F65B6F-BD8F-4FAF-80A2-69C9DA20DCC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5F65B6F-BD8F-4FAF-80A2-69C9DA20DCC2}.Release|Any CPU.Build.0 = Release|Any CPU
- {4F40B8F2-12D4-403B-B666-8F0540354455}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {4F40B8F2-12D4-403B-B666-8F0540354455}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {4F40B8F2-12D4-403B-B666-8F0540354455}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {4F40B8F2-12D4-403B-B666-8F0540354455}.Release|Any CPU.Build.0 = Release|Any CPU
{6984539B-7B5A-481E-A955-3AE537D43166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6984539B-7B5A-481E-A955-3AE537D43166}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6984539B-7B5A-481E-A955-3AE537D43166}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -92,14 +76,6 @@ Global
{1B50DC13-DB8A-41CF-9D40-A8740B068AC2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B50DC13-DB8A-41CF-9D40-A8740B068AC2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B50DC13-DB8A-41CF-9D40-A8740B068AC2}.Release|Any CPU.Build.0 = Release|Any CPU
- {AA29EECC-CD77-4452-B48E-CC038E4FBB69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {AA29EECC-CD77-4452-B48E-CC038E4FBB69}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {AA29EECC-CD77-4452-B48E-CC038E4FBB69}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {AA29EECC-CD77-4452-B48E-CC038E4FBB69}.Release|Any CPU.Build.0 = Release|Any CPU
- {9888C703-CC13-47EB-89F0-B8A34D64BD07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9888C703-CC13-47EB-89F0-B8A34D64BD07}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9888C703-CC13-47EB-89F0-B8A34D64BD07}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9888C703-CC13-47EB-89F0-B8A34D64BD07}.Release|Any CPU.Build.0 = Release|Any CPU
{0D288AF0-1CE5-4B2B-9F80-532040F24BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0D288AF0-1CE5-4B2B-9F80-532040F24BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0D288AF0-1CE5-4B2B-9F80-532040F24BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -127,17 +103,13 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8356C7AF-6F88-4A62-B3E9-5656634A6FEA} = {B84A3CAB-AC86-4B2D-A490-79E1002350FF}
- {BFDDFCF5-8F35-4348-A568-57D8E34DF289} = {30AA679F-7CF6-4FBE-9A13-BEF98BCFE3D2}
{E5F65B6F-BD8F-4FAF-80A2-69C9DA20DCC2} = {30AA679F-7CF6-4FBE-9A13-BEF98BCFE3D2}
- {4F40B8F2-12D4-403B-B666-8F0540354455} = {30AA679F-7CF6-4FBE-9A13-BEF98BCFE3D2}
{6984539B-7B5A-481E-A955-3AE537D43166} = {4A305F87-23B4-4929-B138-4B7D2710526F}
{0A85DB84-41A0-4EE0-815B-D922329A8BCA} = {4A305F87-23B4-4929-B138-4B7D2710526F}
{41AA384E-E433-440E-A02E-83F03AC98A63} = {30AA679F-7CF6-4FBE-9A13-BEF98BCFE3D2}
{F14C5E02-DC54-4A27-B2DE-513A644E6473} = {30AA679F-7CF6-4FBE-9A13-BEF98BCFE3D2}
{1621A06B-9AF2-421C-BB48-08028560E108} = {4A305F87-23B4-4929-B138-4B7D2710526F}
{1B50DC13-DB8A-41CF-9D40-A8740B068AC2} = {D20B95EF-D7D9-45BA-B5A4-C8D3B64AC745}
- {AA29EECC-CD77-4452-B48E-CC038E4FBB69} = {CB1B7D43-9AFC-47EF-8915-A547F7F553AB}
- {9888C703-CC13-47EB-89F0-B8A34D64BD07} = {CB1B7D43-9AFC-47EF-8915-A547F7F553AB}
{0D288AF0-1CE5-4B2B-9F80-532040F24BCF} = {CB1B7D43-9AFC-47EF-8915-A547F7F553AB}
{A44447B0-794D-451A-A571-E3B761174B48} = {CB1B7D43-9AFC-47EF-8915-A547F7F553AB}
{85D316A0-17BE-4983-AB06-5C72365ABD9B} = {CB1B7D43-9AFC-47EF-8915-A547F7F553AB}
diff --git a/src/clients/Dim.Clients/Dim.Clients.csproj b/src/clients/Dim.Clients/Dim.Clients.csproj
index 7897523..83ece78 100644
--- a/src/clients/Dim.Clients/Dim.Clients.csproj
+++ b/src/clients/Dim.Clients/Dim.Clients.csproj
@@ -36,9 +36,9 @@
-
-
-
+
+
+
diff --git a/src/database/Dim.DbAccess/Dim.DbAccess.csproj b/src/database/Dim.DbAccess/Dim.DbAccess.csproj
index fdb9fcb..c58a42b 100644
--- a/src/database/Dim.DbAccess/Dim.DbAccess.csproj
+++ b/src/database/Dim.DbAccess/Dim.DbAccess.csproj
@@ -30,8 +30,8 @@
-
-
+
+
diff --git a/src/database/Dim.DbAccess/DimProcessDbContextAccess.cs b/src/database/Dim.DbAccess/DimProcessDbContextAccess.cs
new file mode 100644
index 0000000..dab8978
--- /dev/null
+++ b/src/database/Dim.DbAccess/DimProcessDbContextAccess.cs
@@ -0,0 +1,40 @@
+/********************************************************************************
+ * Copyright (c) 2025 BMW Group AG
+ * Copyright 2025 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
+ *
+ * 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 Dim.Entities;
+using Dim.Entities.Entities;
+using Dim.Entities.Enums;
+using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.DBAccess;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
+
+namespace Dim.DbAccess;
+
+public class DimProcessDbContextAccess(DimDbContext dbContext) :
+ IProcessRepositoryContextAccess, ProcessStep, ProcessStepType, ProcessTypeId, ProcessStepTypeId>
+{
+ public DbSet Processes => dbContext.Processes;
+ public DbSet> ProcessSteps => dbContext.ProcessSteps;
+ public DbSet> ProcessStepStatuses => dbContext.ProcessStepStatuses;
+
+ public Process CreateProcess(Guid id, ProcessTypeId processTypeId, Guid version) => new(id, processTypeId, version);
+ public ProcessStep CreateProcessStep(Guid id, ProcessStepTypeId processStepTypeId, ProcessStepStatusId processStepStatusId, Guid processId, DateTimeOffset now) => new(id, processStepTypeId, processStepStatusId, processId, now);
+}
diff --git a/src/database/Dim.DbAccess/DimRepositories.cs b/src/database/Dim.DbAccess/DimRepositories.cs
index 370cbf9..e8ba9cf 100644
--- a/src/database/Dim.DbAccess/DimRepositories.cs
+++ b/src/database/Dim.DbAccess/DimRepositories.cs
@@ -20,53 +20,25 @@
using Dim.DbAccess.Repositories;
using Dim.Entities;
-using Microsoft.EntityFrameworkCore;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
+using Dim.Entities.Entities;
+using Dim.Entities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.DBAccess;
using System.Collections.Immutable;
namespace Dim.DbAccess;
-public class DimRepositories(DimDbContext dbContext)
- : IDimRepositories
+public class DimRepositories(DimDbContext dbContext) :
+ AbstractRepositories(dbContext),
+ IDimRepositories
{
- private static readonly IReadOnlyDictionary> Types = new Dictionary> {
- { typeof(IProcessStepRepository), context => new ProcessStepRepository(context) },
- { typeof(ITenantRepository), context => new TenantRepository(context) },
- { typeof(ITechnicalUserRepository), context => new TechnicalUserRepository(context) }
- }.ToImmutableDictionary();
-
- public RepositoryType GetInstance()
- {
- object? repository = default;
-
- if (Types.TryGetValue(typeof(RepositoryType), out var createFunc))
- {
- repository = createFunc(dbContext);
- }
-
- return (RepositoryType)(repository ?? throw new ArgumentException($"unexpected type {typeof(RepositoryType).Name}", nameof(RepositoryType)));
- }
-
- ///
- public TEntity Attach(TEntity entity, Action? setOptionalParameters = null) where TEntity : class
- {
- var attachedEntity = dbContext.Attach(entity).Entity;
- setOptionalParameters?.Invoke(attachedEntity);
-
- return attachedEntity;
- }
-
- public Task SaveAsync()
- {
- try
- {
- return dbContext.SaveChangesAsync();
- }
- catch (DbUpdateConcurrencyException e)
- {
- throw new ConflictException("while processing a concurrent update was saved to the database (reason could also be data to be deleted is no longer existing)", e);
- }
- }
-
- public void Clear() => dbContext.ChangeTracker.Clear();
+ protected override IReadOnlyDictionary> RepositoryTypes => Types;
+
+ private static readonly IReadOnlyDictionary> Types = ImmutableDictionary.CreateRange(
+ [
+ CreateTypeEntry(context => new TenantRepository(context)),
+ CreateTypeEntry(context => new TechnicalUserRepository(context)),
+ CreateTypeEntry>(context => new ProcessStepRepository, ProcessStep, ProcessStepType, ProcessTypeId, ProcessStepTypeId>(new DimProcessDbContextAccess(context))),
+ ]);
}
diff --git a/src/database/Dim.DbAccess/IDimRepositories.cs b/src/database/Dim.DbAccess/IDimRepositories.cs
index 1670e59..4785868 100644
--- a/src/database/Dim.DbAccess/IDimRepositories.cs
+++ b/src/database/Dim.DbAccess/IDimRepositories.cs
@@ -18,12 +18,8 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
+using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess;
+
namespace Dim.DbAccess;
-public interface IDimRepositories
-{
- RepositoryType GetInstance();
- TEntity Attach(TEntity entity, Action? setOptionalParameters = null) where TEntity : class;
- Task SaveAsync();
- void Clear();
-}
+public interface IDimRepositories : IRepositories;
diff --git a/src/database/Dim.DbAccess/Models/ProcessData.cs b/src/database/Dim.DbAccess/Models/ProcessData.cs
index 2656d8e..76e29f9 100644
--- a/src/database/Dim.DbAccess/Models/ProcessData.cs
+++ b/src/database/Dim.DbAccess/Models/ProcessData.cs
@@ -19,6 +19,7 @@
********************************************************************************/
using Dim.Entities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
namespace Dim.DbAccess.Models;
diff --git a/src/database/Dim.DbAccess/Models/VerifyProcessData.cs b/src/database/Dim.DbAccess/Models/VerifyProcessData.cs
deleted file mode 100644
index e07b2af..0000000
--- a/src/database/Dim.DbAccess/Models/VerifyProcessData.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Entities;
-
-namespace Dim.DbAccess.Models;
-
-public record VerifyProcessData(
- Process? Process,
- IEnumerable? ProcessSteps
-);
diff --git a/src/database/Dim.DbAccess/Repositories/IProcessStepRepository.cs b/src/database/Dim.DbAccess/Repositories/IProcessStepRepository.cs
deleted file mode 100644
index e225f61..0000000
--- a/src/database/Dim.DbAccess/Repositories/IProcessStepRepository.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.DbAccess.Models;
-using Dim.Entities.Entities;
-using Dim.Entities.Enums;
-
-namespace Dim.DbAccess.Repositories;
-
-///
-/// Repository for accessing and creating processSteps on persistence layer.
-///
-public interface IProcessStepRepository
-{
- Process CreateProcess(ProcessTypeId processTypeId);
- ProcessStep CreateProcessStep(ProcessStepTypeId processStepTypeId, ProcessStepStatusId processStepStatusId, Guid processId);
- IEnumerable CreateProcessStepRange(IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId, Guid ProcessId)> processStepTypeStatus);
- void AttachAndModifyProcessStep(Guid processStepId, Action? initialize, Action modify);
- void AttachAndModifyProcessSteps(IEnumerable<(Guid ProcessStepId, Action? Initialize, Action Modify)> processStepIdsInitializeModifyData);
- IAsyncEnumerable GetActiveProcesses(IEnumerable processTypeIds, IEnumerable processStepTypeIds, DateTimeOffset lockExpiryDate);
- IAsyncEnumerable<(Guid ProcessStepId, ProcessStepTypeId ProcessStepTypeId)> GetProcessStepData(Guid processId);
- Task<(bool ProcessExists, VerifyProcessData ProcessData)> IsValidProcess(Guid processId, ProcessTypeId processTypeId, IEnumerable processSetpTypeIds);
-}
diff --git a/src/database/Dim.DbAccess/Repositories/ProcessStepRepository.cs b/src/database/Dim.DbAccess/Repositories/ProcessStepRepository.cs
deleted file mode 100644
index 3e7d703..0000000
--- a/src/database/Dim.DbAccess/Repositories/ProcessStepRepository.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.DbAccess.Models;
-using Dim.Entities;
-using Dim.Entities.Entities;
-using Dim.Entities.Enums;
-using Microsoft.EntityFrameworkCore;
-using ProcessTypeId = Dim.Entities.Enums.ProcessTypeId;
-
-namespace Dim.DbAccess.Repositories;
-
-public class ProcessStepRepository(DimDbContext dbContext)
- : IProcessStepRepository
-{
- public Process CreateProcess(ProcessTypeId processTypeId) =>
- dbContext.Add(new Process(Guid.NewGuid(), processTypeId, Guid.NewGuid())).Entity;
-
- public ProcessStep CreateProcessStep(ProcessStepTypeId processStepTypeId, ProcessStepStatusId processStepStatusId, Guid processId) =>
- dbContext.Add(new ProcessStep(Guid.NewGuid(), processStepTypeId, processStepStatusId, processId, DateTimeOffset.UtcNow)).Entity;
-
- public IEnumerable CreateProcessStepRange(IEnumerable<(ProcessStepTypeId ProcessStepTypeId, ProcessStepStatusId ProcessStepStatusId, Guid ProcessId)> processStepTypeStatus)
- {
- var processSteps = processStepTypeStatus.Select(x => new ProcessStep(Guid.NewGuid(), x.ProcessStepTypeId, x.ProcessStepStatusId, x.ProcessId, DateTimeOffset.UtcNow)).ToList();
- dbContext.AddRange(processSteps);
- return processSteps;
- }
-
- public void AttachAndModifyProcessStep(Guid processStepId, Action? initialize, Action modify)
- {
- var step = new ProcessStep(processStepId, default, default, Guid.Empty, default);
- initialize?.Invoke(step);
- dbContext.Attach(step);
- step.DateLastChanged = DateTimeOffset.UtcNow;
- modify(step);
- }
-
- public void AttachAndModifyProcessSteps(IEnumerable<(Guid ProcessStepId, Action? Initialize, Action Modify)> processStepIdsInitializeModifyData)
- {
- var stepModifyData = processStepIdsInitializeModifyData.Select(data =>
- {
- var step = new ProcessStep(data.ProcessStepId, default, default, Guid.Empty, default);
- data.Initialize?.Invoke(step);
- return (Step: step, data.Modify);
- }).ToList();
- dbContext.AttachRange(stepModifyData.Select(data => data.Step));
- stepModifyData.ForEach(data =>
- {
- data.Step.DateLastChanged = DateTimeOffset.UtcNow;
- data.Modify(data.Step);
- });
- }
-
- public IAsyncEnumerable GetActiveProcesses(IEnumerable processTypeIds, IEnumerable processStepTypeIds, DateTimeOffset lockExpiryDate) =>
- dbContext.Processes
- .AsNoTracking()
- .Where(process =>
- processTypeIds.Contains(process.ProcessTypeId) &&
- process.ProcessSteps.Any(step => processStepTypeIds.Contains(step.ProcessStepTypeId) && step.ProcessStepStatusId == ProcessStepStatusId.TODO) &&
- (process.LockExpiryDate == null || process.LockExpiryDate < lockExpiryDate))
- .AsAsyncEnumerable();
-
- public IAsyncEnumerable<(Guid ProcessStepId, ProcessStepTypeId ProcessStepTypeId)> GetProcessStepData(Guid processId) =>
- dbContext.ProcessSteps
- .AsNoTracking()
- .Where(step =>
- step.ProcessId == processId &&
- step.ProcessStepStatusId == ProcessStepStatusId.TODO)
- .OrderBy(step => step.ProcessStepTypeId)
- .Select(step =>
- new ValueTuple(
- step.Id,
- step.ProcessStepTypeId))
- .AsAsyncEnumerable();
-
- public Task<(bool ProcessExists, VerifyProcessData ProcessData)> IsValidProcess(Guid processId, ProcessTypeId processTypeId, IEnumerable processStepTypeIds) =>
- dbContext.Processes
- .AsNoTracking()
- .Where(x => x.Id == processId && x.ProcessTypeId == processTypeId)
- .Select(x => new ValueTuple(
- true,
- new VerifyProcessData(
- x,
- x.ProcessSteps
- .Where(step =>
- processStepTypeIds.Contains(step.ProcessStepTypeId) &&
- step.ProcessStepStatusId == ProcessStepStatusId.TODO))
- ))
- .SingleOrDefaultAsync();
-}
diff --git a/src/database/Dim.Entities/Dim.Entities.csproj b/src/database/Dim.Entities/Dim.Entities.csproj
index dfbf9a3..805633a 100644
--- a/src/database/Dim.Entities/Dim.Entities.csproj
+++ b/src/database/Dim.Entities/Dim.Entities.csproj
@@ -34,6 +34,7 @@
all
-
+
+
diff --git a/src/database/Dim.Entities/DimDbContext.cs b/src/database/Dim.Entities/DimDbContext.cs
index 61df8bb..7d2cd36 100644
--- a/src/database/Dim.Entities/DimDbContext.cs
+++ b/src/database/Dim.Entities/DimDbContext.cs
@@ -21,25 +21,13 @@
using Dim.Entities.Entities;
using Dim.Entities.Enums;
using Microsoft.EntityFrameworkCore;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Context;
namespace Dim.Entities;
-public class DimDbContext : DbContext
+public class DimDbContext(DbContextOptions options) :
+ ProcessDbContext(options)
{
- protected DimDbContext()
- {
- }
-
- public DimDbContext(DbContextOptions options)
- : base(options)
- {
- }
-
- public virtual DbSet Processes { get; set; } = default!;
- public virtual DbSet ProcessSteps { get; set; } = default!;
- public virtual DbSet ProcessStepStatuses { get; set; } = default!;
- public virtual DbSet ProcessStepTypes { get; set; } = default!;
- public virtual DbSet ProcessTypes { get; set; } = default!;
public virtual DbSet Tenants { get; set; } = default!;
public virtual DbSet TechnicalUsers { get; set; } = default!;
@@ -53,38 +41,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.HasAnnotation("Relational:Collation", "en_US.utf8");
modelBuilder.HasDefaultSchema("dim");
- modelBuilder.Entity()
- .HasOne(d => d.ProcessType)
- .WithMany(p => p.Processes)
- .HasForeignKey(d => d.ProcessTypeId)
- .OnDelete(DeleteBehavior.ClientSetNull);
-
- modelBuilder.Entity()
- .HasOne(d => d.Process)
- .WithMany(p => p.ProcessSteps)
- .HasForeignKey(d => d.ProcessId)
- .OnDelete(DeleteBehavior.ClientSetNull);
-
- modelBuilder.Entity()
- .HasData(
- Enum.GetValues(typeof(ProcessTypeId))
- .Cast()
- .Select(e => new ProcessType(e))
- );
-
- modelBuilder.Entity()
- .HasData(
- Enum.GetValues(typeof(ProcessStepStatusId))
- .Cast()
- .Select(e => new ProcessStepStatus(e))
- );
-
- modelBuilder.Entity()
- .HasData(
- Enum.GetValues(typeof(ProcessStepTypeId))
- .Cast()
- .Select(e => new ProcessStepType(e))
- );
+ base.OnModelCreating(modelBuilder);
modelBuilder.Entity(t =>
{
diff --git a/src/database/Dim.Entities/Entities/Process.cs b/src/database/Dim.Entities/Entities/Process.cs
index 048c4f3..b3dbf2f 100644
--- a/src/database/Dim.Entities/Entities/Process.cs
+++ b/src/database/Dim.Entities/Entities/Process.cs
@@ -20,38 +20,13 @@
using Dim.Entities.Enums;
using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities;
using System.ComponentModel.DataAnnotations;
namespace Dim.Entities.Entities;
-public class Process : ILockableEntity
+public class Process(Guid id, ProcessTypeId processTypeId, Guid version) : AbstractProcess(id, processTypeId, version)
{
- private Process()
- {
- ProcessSteps = new HashSet();
- Tenants = new HashSet();
- TechnicalUsers = new HashSet();
- }
-
- public Process(Guid id, ProcessTypeId processTypeId, Guid version) : this()
- {
- Id = id;
- ProcessTypeId = processTypeId;
- Version = version;
- }
-
- public Guid Id { get; private set; }
-
- public ProcessTypeId ProcessTypeId { get; set; }
-
- public DateTimeOffset? LockExpiryDate { get; set; }
-
- [ConcurrencyCheck]
- public Guid Version { get; set; }
-
- // Navigation properties
- public virtual ProcessType? ProcessType { get; set; }
- public virtual ICollection ProcessSteps { get; private set; }
public virtual ICollection Tenants { get; private set; }
public virtual ICollection TechnicalUsers { get; private set; }
}
diff --git a/src/database/Dim.Entities/Entities/ProcessStep.cs b/src/database/Dim.Entities/Entities/ProcessStep.cs
deleted file mode 100644
index 513d5ad..0000000
--- a/src/database/Dim.Entities/Entities/ProcessStep.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-
-namespace Dim.Entities.Entities;
-
-public class ProcessStep(
- Guid id,
- ProcessStepTypeId processStepTypeId,
- ProcessStepStatusId processStepStatusId,
- Guid processId,
- DateTimeOffset dateCreated)
-{
- public Guid Id { get; private set; } = id;
-
- public ProcessStepTypeId ProcessStepTypeId { get; private set; } = processStepTypeId;
-
- public ProcessStepStatusId ProcessStepStatusId { get; set; } = processStepStatusId;
-
- public Guid ProcessId { get; private set; } = processId;
-
- public DateTimeOffset DateCreated { get; private set; } = dateCreated;
-
- public DateTimeOffset? DateLastChanged { get; set; }
-
- public string? Message { get; set; }
-
- // Navigation properties
- public virtual ProcessStepType? ProcessStepType { get; private set; }
- public virtual ProcessStepStatus? ProcessStepStatus { get; set; }
- public virtual Process? Process { get; private set; }
-}
diff --git a/src/database/Dim.Entities/Entities/ProcessStepStatus.cs b/src/database/Dim.Entities/Entities/ProcessStepStatus.cs
deleted file mode 100644
index ef7619e..0000000
--- a/src/database/Dim.Entities/Entities/ProcessStepStatus.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-using System.ComponentModel.DataAnnotations;
-
-namespace Dim.Entities.Entities;
-
-public class ProcessStepStatus
-{
- private ProcessStepStatus()
- {
- this.Label = null!;
- this.ProcessSteps = new HashSet();
- }
-
- public ProcessStepStatus(ProcessStepStatusId processStepStatusId) : this()
- {
- Id = processStepStatusId;
- Label = processStepStatusId.ToString();
- }
-
- public ProcessStepStatusId Id { get; private set; }
-
- [MaxLength(255)]
- public string Label { get; private set; }
-
- // Navigation properties
- public virtual ICollection ProcessSteps { get; private set; }
-}
diff --git a/src/database/Dim.Entities/Entities/ProcessStepType.cs b/src/database/Dim.Entities/Entities/ProcessStepType.cs
deleted file mode 100644
index 87d1ccc..0000000
--- a/src/database/Dim.Entities/Entities/ProcessStepType.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-using System.ComponentModel.DataAnnotations;
-
-namespace Dim.Entities.Entities;
-
-public class ProcessStepType
-{
- private ProcessStepType()
- {
- this.Label = null!;
- this.ProcessSteps = new HashSet();
- }
-
- public ProcessStepType(ProcessStepTypeId processStepTypeId) : this()
- {
- Id = processStepTypeId;
- Label = processStepTypeId.ToString();
- }
-
- public ProcessStepTypeId Id { get; private set; }
-
- [MaxLength(255)]
- public string Label { get; private set; }
-
- // Navigation properties
- public virtual ICollection ProcessSteps { get; private set; }
-}
diff --git a/src/database/Dim.Entities/Entities/ProcessType.cs b/src/database/Dim.Entities/Entities/ProcessType.cs
deleted file mode 100644
index b8ff4cc..0000000
--- a/src/database/Dim.Entities/Entities/ProcessType.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-using System.ComponentModel.DataAnnotations;
-
-namespace Dim.Entities.Entities;
-
-public class ProcessType
-{
- private ProcessType()
- {
- this.Label = null!;
- this.Processes = new HashSet();
- }
-
- public ProcessType(ProcessTypeId processTypeId) : this()
- {
- Id = processTypeId;
- Label = processTypeId.ToString();
- }
-
- public ProcessTypeId Id { get; private set; }
-
- [MaxLength(255)]
- public string Label { get; private set; }
-
- // Navigation properties
- public virtual ICollection Processes { get; private set; }
-}
diff --git a/src/database/Dim.Entities/Enums/ProcessStepStatusId.cs b/src/database/Dim.Entities/Enums/ProcessStepStatusId.cs
deleted file mode 100644
index 061e605..0000000
--- a/src/database/Dim.Entities/Enums/ProcessStepStatusId.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-
-public enum ProcessStepStatusId
-{
- TODO = 1,
- DONE = 2,
- SKIPPED = 3,
- FAILED = 4,
- DUPLICATE = 5
-}
diff --git a/src/database/Dim.Migrations/Dim.Migrations.csproj b/src/database/Dim.Migrations/Dim.Migrations.csproj
index 37075ae..45bb901 100644
--- a/src/database/Dim.Migrations/Dim.Migrations.csproj
+++ b/src/database/Dim.Migrations/Dim.Migrations.csproj
@@ -44,9 +44,9 @@
-
-
-
+
+
+
diff --git a/src/database/Dim.Migrations/Migrations/20250127143528_3-UseProcessWorkerPackage.Designer.cs b/src/database/Dim.Migrations/Migrations/20250127143528_3-UseProcessWorkerPackage.Designer.cs
new file mode 100644
index 0000000..342b454
--- /dev/null
+++ b/src/database/Dim.Migrations/Migrations/20250127143528_3-UseProcessWorkerPackage.Designer.cs
@@ -0,0 +1,591 @@
+/********************************************************************************
+ * Copyright (c) 2024 BMW Group AG
+ * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
+ *
+ * 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 Dim.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Dim.Migrations.Migrations
+{
+ [DbContext(typeof(DimDbContext))]
+ [Migration("20250127143528_3-UseProcessWorkerPackage")]
+ partial class _3UseProcessWorkerPackage
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("dim")
+ .UseCollation("en_US.utf8")
+ .HasAnnotation("ProductVersion", "8.0.11")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Dim.Entities.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", "dim");
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.TechnicalUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid")
+ .HasColumnName("id");
+
+ b.Property("ClientId")
+ .HasColumnType("text")
+ .HasColumnName("client_id");
+
+ b.Property("ClientSecret")
+ .HasColumnType("bytea")
+ .HasColumnName("client_secret");
+
+ b.Property("EncryptionMode")
+ .HasColumnType("integer")
+ .HasColumnName("encryption_mode");
+
+ b.Property("ExternalId")
+ .HasColumnType("uuid")
+ .HasColumnName("external_id");
+
+ b.Property("InitializationVector")
+ .HasColumnType("bytea")
+ .HasColumnName("initialization_vector");
+
+ b.Property("OperationId")
+ .HasColumnType("uuid")
+ .HasColumnName("operation_id");
+
+ b.Property("ProcessId")
+ .HasColumnType("uuid")
+ .HasColumnName("process_id");
+
+ b.Property("ServiceKeyId")
+ .HasColumnType("uuid")
+ .HasColumnName("service_key_id");
+
+ b.Property("TechnicalUserName")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("technical_user_name");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("TokenAddress")
+ .HasColumnType("text")
+ .HasColumnName("token_address");
+
+ b.HasKey("Id")
+ .HasName("pk_technical_users");
+
+ b.HasIndex("ProcessId")
+ .HasDatabaseName("ix_technical_users_process_id");
+
+ b.HasIndex("TenantId")
+ .HasDatabaseName("ix_technical_users_tenant_id");
+
+ b.ToTable("technical_users", "dim");
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid")
+ .HasColumnName("id");
+
+ b.Property("BaseUrl")
+ .HasColumnType("text")
+ .HasColumnName("base_url");
+
+ b.Property("Bpn")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("bpn");
+
+ b.Property("ClientId")
+ .HasColumnType("text")
+ .HasColumnName("client_id");
+
+ b.Property("ClientSecret")
+ .HasColumnType("bytea")
+ .HasColumnName("client_secret");
+
+ b.Property("CompanyId")
+ .HasColumnType("uuid")
+ .HasColumnName("company_id");
+
+ b.Property("CompanyName")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("company_name");
+
+ b.Property("Did")
+ .HasColumnType("text")
+ .HasColumnName("did");
+
+ b.Property("DidDocumentLocation")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("did_document_location");
+
+ b.Property("DidDownloadUrl")
+ .HasColumnType("text")
+ .HasColumnName("did_download_url");
+
+ b.Property("EncryptionMode")
+ .HasColumnType("integer")
+ .HasColumnName("encryption_mode");
+
+ b.Property("InitializationVector")
+ .HasColumnType("bytea")
+ .HasColumnName("initialization_vector");
+
+ b.Property("IsIssuer")
+ .HasColumnType("boolean")
+ .HasColumnName("is_issuer");
+
+ b.Property("OperationId")
+ .HasColumnType("uuid")
+ .HasColumnName("operation_id");
+
+ b.Property("OperatorId")
+ .HasColumnType("uuid")
+ .HasColumnName("operator_id");
+
+ b.Property("ProcessId")
+ .HasColumnType("uuid")
+ .HasColumnName("process_id");
+
+ b.Property("TokenAddress")
+ .HasColumnType("text")
+ .HasColumnName("token_address");
+
+ b.Property("WalletId")
+ .HasColumnType("uuid")
+ .HasColumnName("wallet_id");
+
+ b.HasKey("Id")
+ .HasName("pk_tenants");
+
+ b.HasIndex("ProcessId")
+ .HasDatabaseName("ix_tenants_process_id");
+
+ b.ToTable("tenants", "dim");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.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", "dim");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.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", "dim");
+
+ 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.Framework.Processes.Library.Concrete.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", "dim");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Label = "CREATE_WALLET"
+ },
+ new
+ {
+ Id = 2,
+ Label = "CHECK_OPERATION"
+ },
+ new
+ {
+ Id = 3,
+ Label = "GET_COMPANY"
+ },
+ new
+ {
+ Id = 4,
+ Label = "GET_DID_DOCUMENT"
+ },
+ new
+ {
+ Id = 5,
+ Label = "CREATE_STATUS_LIST"
+ },
+ new
+ {
+ Id = 6,
+ Label = "SEND_CALLBACK"
+ },
+ new
+ {
+ Id = 7,
+ Label = "RETRIGGER_CREATE_WALLET"
+ },
+ new
+ {
+ Id = 8,
+ Label = "RETRIGGER_CHECK_OPERATION"
+ },
+ new
+ {
+ Id = 9,
+ Label = "RETRIGGER_GET_COMPANY"
+ },
+ new
+ {
+ Id = 10,
+ Label = "RETRIGGER_GET_DID_DOCUMENT"
+ },
+ new
+ {
+ Id = 11,
+ Label = "RETRIGGER_CREATE_STATUS_LIST"
+ },
+ new
+ {
+ Id = 12,
+ Label = "RETRIGGER_SEND_CALLBACK"
+ },
+ new
+ {
+ Id = 100,
+ Label = "CREATE_TECHNICAL_USER"
+ },
+ new
+ {
+ Id = 101,
+ Label = "GET_TECHNICAL_USER_DATA"
+ },
+ new
+ {
+ Id = 102,
+ Label = "GET_TECHNICAL_USER_SERVICE_KEY"
+ },
+ new
+ {
+ Id = 103,
+ Label = "SEND_TECHNICAL_USER_CREATION_CALLBACK"
+ },
+ new
+ {
+ Id = 104,
+ Label = "RETRIGGER_CREATE_TECHNICAL_USER"
+ },
+ new
+ {
+ Id = 105,
+ Label = "RETRIGGER_GET_TECHNICAL_USER_DATA"
+ },
+ new
+ {
+ Id = 106,
+ Label = "RETRIGGER_GET_TECHNICAL_USER_SERVICE_KEY"
+ },
+ new
+ {
+ Id = 107,
+ Label = "RETRIGGER_SEND_TECHNICAL_USER_CREATION_CALLBACK"
+ },
+ new
+ {
+ Id = 200,
+ Label = "DELETE_TECHNICAL_USER"
+ },
+ new
+ {
+ Id = 201,
+ Label = "SEND_TECHNICAL_USER_DELETION_CALLBACK"
+ },
+ new
+ {
+ Id = 202,
+ Label = "RETRIGGER_DELETE_TECHNICAL_USER"
+ },
+ new
+ {
+ Id = 203,
+ Label = "RETRIGGER_SEND_TECHNICAL_USER_DELETION_CALLBACK"
+ });
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.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", "dim");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Label = "SETUP_DIM"
+ },
+ new
+ {
+ Id = 2,
+ Label = "TECHNICAL_USER"
+ });
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.Process", b =>
+ {
+ b.HasOne("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessType", "ProcessType")
+ .WithMany("Processes")
+ .HasForeignKey("ProcessTypeId")
+ .IsRequired()
+ .HasConstraintName("fk_processes_process_types_process_type_id");
+
+ b.Navigation("ProcessType");
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.TechnicalUser", b =>
+ {
+ b.HasOne("Dim.Entities.Entities.Process", "Process")
+ .WithMany("TechnicalUsers")
+ .HasForeignKey("ProcessId")
+ .IsRequired()
+ .HasConstraintName("fk_technical_users_processes_process_id");
+
+ b.HasOne("Dim.Entities.Entities.Tenant", "Tenant")
+ .WithMany("TechnicalUsers")
+ .HasForeignKey("TenantId")
+ .IsRequired()
+ .HasConstraintName("fk_technical_users_tenants_tenant_id");
+
+ b.Navigation("Process");
+
+ b.Navigation("Tenant");
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
+ {
+ b.HasOne("Dim.Entities.Entities.Process", "Process")
+ .WithMany("Tenants")
+ .HasForeignKey("ProcessId")
+ .IsRequired()
+ .HasConstraintName("fk_tenants_processes_process_id");
+
+ b.Navigation("Process");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStep", b =>
+ {
+ b.HasOne("Dim.Entities.Entities.Process", "Process")
+ .WithMany("ProcessSteps")
+ .HasForeignKey("ProcessId")
+ .IsRequired()
+ .HasConstraintName("fk_process_steps_processes_process_id");
+
+ b.HasOne("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepStatus", "ProcessStepStatus")
+ .WithMany("ProcessSteps")
+ .HasForeignKey("ProcessStepStatusId")
+ .IsRequired()
+ .HasConstraintName("fk_process_steps_process_step_statuses_process_step_status_id");
+
+ b.HasOne("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.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("Dim.Entities.Entities.Process", b =>
+ {
+ b.Navigation("ProcessSteps");
+
+ b.Navigation("TechnicalUsers");
+
+ b.Navigation("Tenants");
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
+ {
+ b.Navigation("TechnicalUsers");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepStatus", b =>
+ {
+ b.Navigation("ProcessSteps");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepType", b =>
+ {
+ b.Navigation("ProcessSteps");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessType", b =>
+ {
+ b.Navigation("Processes");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/database/Dim.Migrations/Migrations/20250127143528_3-UseProcessWorkerPackage.cs b/src/database/Dim.Migrations/Migrations/20250127143528_3-UseProcessWorkerPackage.cs
new file mode 100644
index 0000000..fd6aa9e
--- /dev/null
+++ b/src/database/Dim.Migrations/Migrations/20250127143528_3-UseProcessWorkerPackage.cs
@@ -0,0 +1,68 @@
+/********************************************************************************
+ * Copyright (c) 2024 BMW Group AG
+ * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
+ *
+ * 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 Dim.Migrations.Migrations
+{
+ ///
+ public partial class _3UseProcessWorkerPackage : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "fk_process_steps_process_step_statuses_process_step_status_id",
+ schema: "dim",
+ table: "process_steps");
+
+ migrationBuilder.AddForeignKey(
+ name: "fk_process_steps_process_step_statuses_process_step_status_id",
+ schema: "dim",
+ table: "process_steps",
+ column: "process_step_status_id",
+ principalSchema: "dim",
+ principalTable: "process_step_statuses",
+ principalColumn: "id");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "fk_process_steps_process_step_statuses_process_step_status_id",
+ schema: "dim",
+ table: "process_steps");
+
+ migrationBuilder.AddForeignKey(
+ name: "fk_process_steps_process_step_statuses_process_step_status_id",
+ schema: "dim",
+ table: "process_steps",
+ column: "process_step_status_id",
+ principalSchema: "dim",
+ principalTable: "process_step_statuses",
+ principalColumn: "id",
+ onDelete: ReferentialAction.Cascade);
+ }
+ }
+}
diff --git a/src/database/Dim.Migrations/Migrations/DimDbContextModelSnapshot.cs b/src/database/Dim.Migrations/Migrations/DimDbContextModelSnapshot.cs
index 74825a6..f284e5f 100644
--- a/src/database/Dim.Migrations/Migrations/DimDbContextModelSnapshot.cs
+++ b/src/database/Dim.Migrations/Migrations/DimDbContextModelSnapshot.cs
@@ -1,4 +1,4 @@
-/********************************************************************************
+/********************************************************************************
* Copyright (c) 2024 BMW Group AG
* Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
*
@@ -35,7 +35,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
modelBuilder
.HasDefaultSchema("dim")
.UseCollation("en_US.utf8")
- .HasAnnotation("ProductVersion", "8.0.7")
+ .HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@@ -69,7 +69,158 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("processes", "dim");
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessStep", b =>
+ modelBuilder.Entity("Dim.Entities.Entities.TechnicalUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid")
+ .HasColumnName("id");
+
+ b.Property("ClientId")
+ .HasColumnType("text")
+ .HasColumnName("client_id");
+
+ b.Property("ClientSecret")
+ .HasColumnType("bytea")
+ .HasColumnName("client_secret");
+
+ b.Property("EncryptionMode")
+ .HasColumnType("integer")
+ .HasColumnName("encryption_mode");
+
+ b.Property("ExternalId")
+ .HasColumnType("uuid")
+ .HasColumnName("external_id");
+
+ b.Property("InitializationVector")
+ .HasColumnType("bytea")
+ .HasColumnName("initialization_vector");
+
+ b.Property("OperationId")
+ .HasColumnType("uuid")
+ .HasColumnName("operation_id");
+
+ b.Property("ProcessId")
+ .HasColumnType("uuid")
+ .HasColumnName("process_id");
+
+ b.Property("ServiceKeyId")
+ .HasColumnType("uuid")
+ .HasColumnName("service_key_id");
+
+ b.Property("TechnicalUserName")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("technical_user_name");
+
+ b.Property("TenantId")
+ .HasColumnType("uuid")
+ .HasColumnName("tenant_id");
+
+ b.Property("TokenAddress")
+ .HasColumnType("text")
+ .HasColumnName("token_address");
+
+ b.HasKey("Id")
+ .HasName("pk_technical_users");
+
+ b.HasIndex("ProcessId")
+ .HasDatabaseName("ix_technical_users_process_id");
+
+ b.HasIndex("TenantId")
+ .HasDatabaseName("ix_technical_users_tenant_id");
+
+ b.ToTable("technical_users", "dim");
+ });
+
+ modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid")
+ .HasColumnName("id");
+
+ b.Property("BaseUrl")
+ .HasColumnType("text")
+ .HasColumnName("base_url");
+
+ b.Property("Bpn")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("bpn");
+
+ b.Property("ClientId")
+ .HasColumnType("text")
+ .HasColumnName("client_id");
+
+ b.Property("ClientSecret")
+ .HasColumnType("bytea")
+ .HasColumnName("client_secret");
+
+ b.Property("CompanyId")
+ .HasColumnType("uuid")
+ .HasColumnName("company_id");
+
+ b.Property("CompanyName")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("company_name");
+
+ b.Property("Did")
+ .HasColumnType("text")
+ .HasColumnName("did");
+
+ b.Property("DidDocumentLocation")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("did_document_location");
+
+ b.Property("DidDownloadUrl")
+ .HasColumnType("text")
+ .HasColumnName("did_download_url");
+
+ b.Property("EncryptionMode")
+ .HasColumnType("integer")
+ .HasColumnName("encryption_mode");
+
+ b.Property("InitializationVector")
+ .HasColumnType("bytea")
+ .HasColumnName("initialization_vector");
+
+ b.Property("IsIssuer")
+ .HasColumnType("boolean")
+ .HasColumnName("is_issuer");
+
+ b.Property("OperationId")
+ .HasColumnType("uuid")
+ .HasColumnName("operation_id");
+
+ b.Property("OperatorId")
+ .HasColumnType("uuid")
+ .HasColumnName("operator_id");
+
+ b.Property("ProcessId")
+ .HasColumnType("uuid")
+ .HasColumnName("process_id");
+
+ b.Property("TokenAddress")
+ .HasColumnType("text")
+ .HasColumnName("token_address");
+
+ b.Property("WalletId")
+ .HasColumnType("uuid")
+ .HasColumnName("wallet_id");
+
+ b.HasKey("Id")
+ .HasName("pk_tenants");
+
+ b.HasIndex("ProcessId")
+ .HasDatabaseName("ix_tenants_process_id");
+
+ b.ToTable("tenants", "dim");
+ });
+
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStep", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
@@ -115,7 +266,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("process_steps", "dim");
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessStepStatus", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepStatus", b =>
{
b.Property("Id")
.HasColumnType("integer")
@@ -160,7 +311,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
});
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessStepType", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepType", b =>
{
b.Property("Id")
.HasColumnType("integer")
@@ -300,7 +451,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
});
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessType", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessType", b =>
{
b.Property("Id")
.HasColumnType("integer")
@@ -330,169 +481,48 @@ protected override void BuildModel(ModelBuilder modelBuilder)
});
});
- modelBuilder.Entity("Dim.Entities.Entities.TechnicalUser", b =>
+ modelBuilder.Entity("Dim.Entities.Entities.Process", b =>
{
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid")
- .HasColumnName("id");
-
- b.Property("ClientId")
- .HasColumnType("text")
- .HasColumnName("client_id");
-
- b.Property("ClientSecret")
- .HasColumnType("bytea")
- .HasColumnName("client_secret");
-
- b.Property("EncryptionMode")
- .HasColumnType("integer")
- .HasColumnName("encryption_mode");
-
- b.Property("ExternalId")
- .HasColumnType("uuid")
- .HasColumnName("external_id");
-
- b.Property("InitializationVector")
- .HasColumnType("bytea")
- .HasColumnName("initialization_vector");
-
- b.Property("OperationId")
- .HasColumnType("uuid")
- .HasColumnName("operation_id");
-
- b.Property("ProcessId")
- .HasColumnType("uuid")
- .HasColumnName("process_id");
-
- b.Property("ServiceKeyId")
- .HasColumnType("uuid")
- .HasColumnName("service_key_id");
-
- b.Property("TechnicalUserName")
+ b.HasOne("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessType", "ProcessType")
+ .WithMany("Processes")
+ .HasForeignKey("ProcessTypeId")
.IsRequired()
- .HasColumnType("text")
- .HasColumnName("technical_user_name");
-
- b.Property("TenantId")
- .HasColumnType("uuid")
- .HasColumnName("tenant_id");
-
- b.Property("TokenAddress")
- .HasColumnType("text")
- .HasColumnName("token_address");
-
- b.HasKey("Id")
- .HasName("pk_technical_users");
-
- b.HasIndex("ProcessId")
- .HasDatabaseName("ix_technical_users_process_id");
-
- b.HasIndex("TenantId")
- .HasDatabaseName("ix_technical_users_tenant_id");
+ .HasConstraintName("fk_processes_process_types_process_type_id");
- b.ToTable("technical_users", "dim");
+ b.Navigation("ProcessType");
});
- modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
+ modelBuilder.Entity("Dim.Entities.Entities.TechnicalUser", b =>
{
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("uuid")
- .HasColumnName("id");
-
- b.Property("BaseUrl")
- .HasColumnType("text")
- .HasColumnName("base_url");
-
- b.Property("Bpn")
- .IsRequired()
- .HasColumnType("text")
- .HasColumnName("bpn");
-
- b.Property("ClientId")
- .HasColumnType("text")
- .HasColumnName("client_id");
-
- b.Property("ClientSecret")
- .HasColumnType("bytea")
- .HasColumnName("client_secret");
-
- b.Property("CompanyId")
- .HasColumnType("uuid")
- .HasColumnName("company_id");
-
- b.Property("CompanyName")
+ b.HasOne("Dim.Entities.Entities.Process", "Process")
+ .WithMany("TechnicalUsers")
+ .HasForeignKey("ProcessId")
.IsRequired()
- .HasColumnType("text")
- .HasColumnName("company_name");
-
- b.Property("Did")
- .HasColumnType("text")
- .HasColumnName("did");
+ .HasConstraintName("fk_technical_users_processes_process_id");
- b.Property("DidDocumentLocation")
+ b.HasOne("Dim.Entities.Entities.Tenant", "Tenant")
+ .WithMany("TechnicalUsers")
+ .HasForeignKey("TenantId")
.IsRequired()
- .HasColumnType("text")
- .HasColumnName("did_document_location");
-
- b.Property("DidDownloadUrl")
- .HasColumnType("text")
- .HasColumnName("did_download_url");
-
- b.Property("EncryptionMode")
- .HasColumnType("integer")
- .HasColumnName("encryption_mode");
-
- b.Property("InitializationVector")
- .HasColumnType("bytea")
- .HasColumnName("initialization_vector");
-
- b.Property("IsIssuer")
- .HasColumnType("boolean")
- .HasColumnName("is_issuer");
-
- b.Property("OperationId")
- .HasColumnType("uuid")
- .HasColumnName("operation_id");
-
- b.Property("OperatorId")
- .HasColumnType("uuid")
- .HasColumnName("operator_id");
-
- b.Property("ProcessId")
- .HasColumnType("uuid")
- .HasColumnName("process_id");
-
- b.Property("TokenAddress")
- .HasColumnType("text")
- .HasColumnName("token_address");
-
- b.Property("WalletId")
- .HasColumnType("uuid")
- .HasColumnName("wallet_id");
-
- b.HasKey("Id")
- .HasName("pk_tenants");
+ .HasConstraintName("fk_technical_users_tenants_tenant_id");
- b.HasIndex("ProcessId")
- .HasDatabaseName("ix_tenants_process_id");
+ b.Navigation("Process");
- b.ToTable("tenants", "dim");
+ b.Navigation("Tenant");
});
- modelBuilder.Entity("Dim.Entities.Entities.Process", b =>
+ modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
{
- b.HasOne("Dim.Entities.Entities.ProcessType", "ProcessType")
- .WithMany("Processes")
- .HasForeignKey("ProcessTypeId")
+ b.HasOne("Dim.Entities.Entities.Process", "Process")
+ .WithMany("Tenants")
+ .HasForeignKey("ProcessId")
.IsRequired()
- .HasConstraintName("fk_processes_process_types_process_type_id");
+ .HasConstraintName("fk_tenants_processes_process_id");
- b.Navigation("ProcessType");
+ b.Navigation("Process");
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessStep", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStep", b =>
{
b.HasOne("Dim.Entities.Entities.Process", "Process")
.WithMany("ProcessSteps")
@@ -500,14 +530,13 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasConstraintName("fk_process_steps_processes_process_id");
- b.HasOne("Dim.Entities.Entities.ProcessStepStatus", "ProcessStepStatus")
+ b.HasOne("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepStatus", "ProcessStepStatus")
.WithMany("ProcessSteps")
.HasForeignKey("ProcessStepStatusId")
- .OnDelete(DeleteBehavior.Cascade)
.IsRequired()
.HasConstraintName("fk_process_steps_process_step_statuses_process_step_status_id");
- b.HasOne("Dim.Entities.Entities.ProcessStepType", "ProcessStepType")
+ b.HasOne("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepType", "ProcessStepType")
.WithMany("ProcessSteps")
.HasForeignKey("ProcessStepTypeId")
.OnDelete(DeleteBehavior.Cascade)
@@ -521,36 +550,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("ProcessStepType");
});
- modelBuilder.Entity("Dim.Entities.Entities.TechnicalUser", b =>
- {
- b.HasOne("Dim.Entities.Entities.Process", "Process")
- .WithMany("TechnicalUsers")
- .HasForeignKey("ProcessId")
- .IsRequired()
- .HasConstraintName("fk_technical_users_processes_process_id");
-
- b.HasOne("Dim.Entities.Entities.Tenant", "Tenant")
- .WithMany("TechnicalUsers")
- .HasForeignKey("TenantId")
- .IsRequired()
- .HasConstraintName("fk_technical_users_tenants_tenant_id");
-
- b.Navigation("Process");
-
- b.Navigation("Tenant");
- });
-
- modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
- {
- b.HasOne("Dim.Entities.Entities.Process", "Process")
- .WithMany("Tenants")
- .HasForeignKey("ProcessId")
- .IsRequired()
- .HasConstraintName("fk_tenants_processes_process_id");
-
- b.Navigation("Process");
- });
-
modelBuilder.Entity("Dim.Entities.Entities.Process", b =>
{
b.Navigation("ProcessSteps");
@@ -560,24 +559,24 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("Tenants");
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessStepStatus", b =>
+ modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
{
- b.Navigation("ProcessSteps");
+ b.Navigation("TechnicalUsers");
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessStepType", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepStatus", b =>
{
b.Navigation("ProcessSteps");
});
- modelBuilder.Entity("Dim.Entities.Entities.ProcessType", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessStepType", b =>
{
- b.Navigation("Processes");
+ b.Navigation("ProcessSteps");
});
- modelBuilder.Entity("Dim.Entities.Entities.Tenant", b =>
+ modelBuilder.Entity("Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities.ProcessType", b =>
{
- b.Navigation("TechnicalUsers");
+ b.Navigation("Processes");
});
#pragma warning restore 612, 618
}
diff --git a/src/database/Dim.Migrations/Seeder/BatchInsertSeeder.cs b/src/database/Dim.Migrations/Seeder/BatchInsertSeeder.cs
index da9b66d..c2b8889 100644
--- a/src/database/Dim.Migrations/Seeder/BatchInsertSeeder.cs
+++ b/src/database/Dim.Migrations/Seeder/BatchInsertSeeder.cs
@@ -20,8 +20,10 @@
using Dim.Entities;
using Dim.Entities.Entities;
+using Dim.Entities.Enums;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Concrete.Entities;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Seeding;
namespace Dim.Migrations.Seeder;
@@ -48,7 +50,7 @@ public async Task ExecuteAsync(CancellationToken cancellationToken)
logger.LogInformation("Start BaseEntityBatch Seeder");
await SeedTable("tenants", x => x.Id, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
- await SeedTable("process_steps", x => x.Id, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
+ await SeedTable>("process_steps", x => x.Id, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
await SeedTable("processes", x => x.Id, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
await SeedTable("technical_users", x => x.Id, cancellationToken).ConfigureAwait(ConfigureAwaitOptions.None);
diff --git a/src/processes/DimProcess.Executor/DependencyInjection/DimProcessCollectionExtensions.cs b/src/processes/DimProcess.Executor/DependencyInjection/DimProcessCollectionExtensions.cs
index 741d88c..08a758d 100644
--- a/src/processes/DimProcess.Executor/DependencyInjection/DimProcessCollectionExtensions.cs
+++ b/src/processes/DimProcess.Executor/DependencyInjection/DimProcessCollectionExtensions.cs
@@ -18,10 +18,11 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
+using Dim.Entities.Enums;
using DimProcess.Library.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
-using Processes.Worker.Library;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Worker.Library;
namespace DimProcess.Executor.DependencyInjection;
@@ -29,11 +30,11 @@ public static class DimProcessCollectionExtensions
{
public static IServiceCollection AddDimProcessExecutor(this IServiceCollection services, IConfiguration config) =>
services
- .AddTransient()
+ .AddTransient, DimProcessTypeExecutor>()
.AddDimProcessHandler(config);
public static IServiceCollection AddTechnicalUserProcessExecutor(this IServiceCollection services, IConfiguration config) =>
services
- .AddTransient()
+ .AddTransient, TechnicalUserProcessTypeExecutor>()
.AddTechnicalUserProcessHandler(config);
}
diff --git a/src/processes/DimProcess.Executor/DimProcess.Executor.csproj b/src/processes/DimProcess.Executor/DimProcess.Executor.csproj
index 214c8fc..800c751 100644
--- a/src/processes/DimProcess.Executor/DimProcess.Executor.csproj
+++ b/src/processes/DimProcess.Executor/DimProcess.Executor.csproj
@@ -31,11 +31,11 @@
+
-
diff --git a/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs b/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
index e890d10..74f6ab8 100644
--- a/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
+++ b/src/processes/DimProcess.Executor/DimProcessTypeExecutor.cs
@@ -24,7 +24,8 @@
using Dim.Entities.Extensions;
using DimProcess.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
-using Processes.Worker.Library;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Worker.Library;
using System.Collections.Immutable;
namespace DimProcess.Executor;
@@ -32,7 +33,7 @@ namespace DimProcess.Executor;
public class DimProcessTypeExecutor(
IDimRepositories dimRepositories,
IDimProcessHandler dimProcessHandler)
- : IProcessTypeExecutor
+ : IProcessTypeExecutor
{
private readonly IEnumerable _executableProcessSteps = ImmutableArray.Create(
ProcessStepTypeId.CREATE_WALLET,
@@ -50,7 +51,7 @@ public class DimProcessTypeExecutor(
public IEnumerable GetExecutableStepTypeIds() => _executableProcessSteps;
public ValueTask IsLockRequested(ProcessStepTypeId processStepTypeId) => new(false);
- public async ValueTask InitializeProcess(Guid processId, IEnumerable processStepTypeIds)
+ public async ValueTask.InitializationResult> InitializeProcess(Guid processId, IEnumerable processStepTypeIds)
{
var (exists, tenantId, companyName, bpn) = await dimRepositories.GetInstance().GetTenantDataForProcessId(processId).ConfigureAwait(ConfigureAwaitOptions.None);
if (!exists)
@@ -60,10 +61,10 @@ public class DimProcessTypeExecutor(
_tenantId = tenantId;
_tenantName = $"{bpn}{companyName}";
- return new IProcessTypeExecutor.InitializationResult(false, null);
+ return new IProcessTypeExecutor.InitializationResult(false, null);
}
- public async ValueTask ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable processStepTypeIds, CancellationToken cancellationToken)
+ public async ValueTask.StepExecutionResult> ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable processStepTypeIds, CancellationToken cancellationToken)
{
if (_tenantId == Guid.Empty || _tenantName is null)
{
@@ -100,7 +101,7 @@ public class DimProcessTypeExecutor(
modified = true;
}
- return new IProcessTypeExecutor.StepExecutionResult(modified, stepStatusId, nextStepTypeIds, null, processMessage);
+ return new IProcessTypeExecutor.StepExecutionResult(modified, stepStatusId, nextStepTypeIds, null, processMessage);
}
private static (ProcessStepStatusId StatusId, string? ProcessMessage, IEnumerable? nextSteps) ProcessError(Exception ex, ProcessStepTypeId processStepTypeId)
diff --git a/src/processes/DimProcess.Executor/TechnicalUserProcessTypeExecutor.cs b/src/processes/DimProcess.Executor/TechnicalUserProcessTypeExecutor.cs
index 70ca15e..038d0fa 100644
--- a/src/processes/DimProcess.Executor/TechnicalUserProcessTypeExecutor.cs
+++ b/src/processes/DimProcess.Executor/TechnicalUserProcessTypeExecutor.cs
@@ -24,7 +24,8 @@
using Dim.Entities.Extensions;
using DimProcess.Library;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
-using Processes.Worker.Library;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Worker.Library;
using System.Collections.Immutable;
namespace DimProcess.Executor;
@@ -32,7 +33,7 @@ namespace DimProcess.Executor;
public class TechnicalUserProcessTypeExecutor(
IDimRepositories dimRepositories,
ITechnicalUserProcessHandler technicalUserProcessHandler)
- : IProcessTypeExecutor
+ : IProcessTypeExecutor
{
private readonly IEnumerable _executableProcessSteps = ImmutableArray.Create(
ProcessStepTypeId.CREATE_TECHNICAL_USER,
@@ -49,7 +50,7 @@ public class TechnicalUserProcessTypeExecutor(
public IEnumerable GetExecutableStepTypeIds() => _executableProcessSteps;
public ValueTask IsLockRequested(ProcessStepTypeId processStepTypeId) => new(false);
- public async ValueTask InitializeProcess(Guid processId, IEnumerable processStepTypeIds)
+ public async ValueTask.InitializationResult> InitializeProcess(Guid processId, IEnumerable processStepTypeIds)
{
var (exists, technicalUserId) = await dimRepositories.GetInstance().GetTenantDataForTechnicalUserProcessId(processId).ConfigureAwait(ConfigureAwaitOptions.None);
if (!exists)
@@ -58,10 +59,10 @@ public class TechnicalUserProcessTypeExecutor(
}
_technicalUserId = technicalUserId;
- return new IProcessTypeExecutor.InitializationResult(false, null);
+ return new IProcessTypeExecutor.InitializationResult(false, null);
}
- public async ValueTask ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable processStepTypeIds, CancellationToken cancellationToken)
+ public async ValueTask.StepExecutionResult> ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable processStepTypeIds, CancellationToken cancellationToken)
{
if (_technicalUserId == Guid.Empty)
{
@@ -98,7 +99,7 @@ public class TechnicalUserProcessTypeExecutor(
modified = true;
}
- return new IProcessTypeExecutor.StepExecutionResult(modified, stepStatusId, nextStepTypeIds, null, processMessage);
+ return new IProcessTypeExecutor.StepExecutionResult(modified, stepStatusId, nextStepTypeIds, null, processMessage);
}
private static (ProcessStepStatusId StatusId, string? ProcessMessage, IEnumerable? nextSteps) ProcessError(Exception ex, ProcessStepTypeId processStepTypeId)
diff --git a/src/processes/DimProcess.Library/DimProcess.Library.csproj b/src/processes/DimProcess.Library/DimProcess.Library.csproj
index 4cbbf96..8d9e7b0 100644
--- a/src/processes/DimProcess.Library/DimProcess.Library.csproj
+++ b/src/processes/DimProcess.Library/DimProcess.Library.csproj
@@ -32,8 +32,8 @@
-
-
+
+
diff --git a/src/processes/DimProcess.Library/DimProcessHandler.cs b/src/processes/DimProcess.Library/DimProcessHandler.cs
index d484c58..5aa089a 100644
--- a/src/processes/DimProcess.Library/DimProcessHandler.cs
+++ b/src/processes/DimProcess.Library/DimProcessHandler.cs
@@ -31,6 +31,7 @@
using Microsoft.Extensions.Options;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
using System.Text.Json;
namespace DimProcess.Library;
diff --git a/src/processes/DimProcess.Library/IDimProcessHandler.cs b/src/processes/DimProcess.Library/IDimProcessHandler.cs
index 964da62..9dcce8c 100644
--- a/src/processes/DimProcess.Library/IDimProcessHandler.cs
+++ b/src/processes/DimProcess.Library/IDimProcessHandler.cs
@@ -19,6 +19,7 @@
********************************************************************************/
using Dim.Entities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
namespace DimProcess.Library;
diff --git a/src/processes/DimProcess.Library/ITechnicalUserProcessHandler.cs b/src/processes/DimProcess.Library/ITechnicalUserProcessHandler.cs
index a0e58ff..4c19667 100644
--- a/src/processes/DimProcess.Library/ITechnicalUserProcessHandler.cs
+++ b/src/processes/DimProcess.Library/ITechnicalUserProcessHandler.cs
@@ -19,6 +19,7 @@
********************************************************************************/
using Dim.Entities.Enums;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
namespace DimProcess.Library;
diff --git a/src/processes/DimProcess.Library/TechnicalUserProcessHandler.cs b/src/processes/DimProcess.Library/TechnicalUserProcessHandler.cs
index 0f5ec0d..928613d 100644
--- a/src/processes/DimProcess.Library/TechnicalUserProcessHandler.cs
+++ b/src/processes/DimProcess.Library/TechnicalUserProcessHandler.cs
@@ -30,6 +30,7 @@
using Microsoft.Extensions.Options;
using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Models.Configuration;
+using Org.Eclipse.TractusX.Portal.Backend.Framework.Processes.Library.Enums;
namespace DimProcess.Library;
diff --git a/src/processes/Processes.Library/ManualProcessStepData.cs b/src/processes/Processes.Library/ManualProcessStepData.cs
deleted file mode 100644
index 5cc0011..0000000
--- a/src/processes/Processes.Library/ManualProcessStepData.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.DbAccess;
-using Dim.Entities.Entities;
-using Dim.Entities.Enums;
-
-namespace Dim.Processes.Library;
-
-public record ManualProcessStepData(
- ProcessStepTypeId ProcessStepTypeId,
- Process Process,
- IEnumerable ProcessSteps,
- IDimRepositories PortalRepositories
-);
diff --git a/src/processes/Processes.Library/ManualProcessStepDataExtensions.cs b/src/processes/Processes.Library/ManualProcessStepDataExtensions.cs
deleted file mode 100644
index f6f8522..0000000
--- a/src/processes/Processes.Library/ManualProcessStepDataExtensions.cs
+++ /dev/null
@@ -1,140 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.DbAccess;
-using Dim.DbAccess.Models;
-using Dim.DbAccess.Repositories;
-using Dim.Entities.Entities;
-using Dim.Entities.Enums;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
-
-namespace Dim.Processes.Library;
-
-public static class VerifyProcessDataExtensions
-{
- public static ManualProcessStepData CreateManualProcessData(
- this VerifyProcessData? processData,
- ProcessStepTypeId processStepTypeId,
- IDimRepositories portalRepositories,
- Func getProcessEntityName)
- {
- if (processData is null)
- {
- throw new NotFoundException($"{getProcessEntityName()} does not exist");
- }
-
- if (processData.Process == null)
- {
- throw new ConflictException($"{getProcessEntityName()} is not associated with any process");
- }
-
- if (processData.Process.IsLocked())
- {
- throw new ConflictException($"process {processData.Process.Id} associated with {getProcessEntityName()} is locked, lock expiry is set to {processData.Process.LockExpiryDate}");
- }
-
- if (processData.ProcessSteps == null)
- {
- throw new UnexpectedConditionException("processSteps should never be null here");
- }
-
- if (processData.ProcessSteps.Any(step => step.ProcessStepStatusId != ProcessStepStatusId.TODO))
- {
- throw new UnexpectedConditionException($"processSteps should never have any other status than TODO here");
- }
-
- if (processData.ProcessSteps.All(step => step.ProcessStepTypeId != processStepTypeId))
- {
- throw new ConflictException($"{getProcessEntityName()}, process step {processStepTypeId} is not eligible to run");
- }
-
- return new(processStepTypeId, processData.Process, processData.ProcessSteps, portalRepositories);
- }
-}
-
-public static class ManualProcessStepDataExtensions
-{
- public static void RequestLock(this ManualProcessStepData context, DateTimeOffset lockExpiryDate)
- {
- context.PortalRepositories.Attach(context.Process);
-
- var isLocked = context.Process.TryLock(lockExpiryDate);
- if (!isLocked)
- {
- throw new UnexpectedConditionException("process TryLock should never fail here");
- }
- }
-
- public static void SkipProcessSteps(this ManualProcessStepData context, IEnumerable processStepTypeIds) =>
- context.PortalRepositories.GetInstance()
- .AttachAndModifyProcessSteps(
- context.ProcessSteps
- .Where(step => step.ProcessStepTypeId != context.ProcessStepTypeId)
- .GroupBy(step => step.ProcessStepTypeId)
- .IntersectBy(processStepTypeIds, group => group.Key)
- .SelectMany(group => ModifyStepStatusRange(group, ProcessStepStatusId.SKIPPED)));
-
- public static void SkipProcessStepsExcept(this ManualProcessStepData context, IEnumerable processStepTypeIds) =>
- context.PortalRepositories.GetInstance()
- .AttachAndModifyProcessSteps(
- context.ProcessSteps
- .Where(step => step.ProcessStepTypeId != context.ProcessStepTypeId)
- .GroupBy(step => step.ProcessStepTypeId)
- .ExceptBy(processStepTypeIds, group => group.Key)
- .SelectMany(group => ModifyStepStatusRange(group, ProcessStepStatusId.SKIPPED)));
-
- public static void ScheduleProcessSteps(this ManualProcessStepData context, IEnumerable processStepTypeIds) =>
- context.PortalRepositories.GetInstance()
- .CreateProcessStepRange(
- processStepTypeIds
- .Except(context.ProcessSteps.Select(step => step.ProcessStepTypeId))
- .Select(stepTypeId => (stepTypeId, ProcessStepStatusId.TODO, context.Process.Id)));
-
- public static void FinalizeProcessStep(this ManualProcessStepData context)
- {
- context.PortalRepositories.GetInstance().AttachAndModifyProcessSteps(
- ModifyStepStatusRange(context.ProcessSteps.Where(step => step.ProcessStepTypeId == context.ProcessStepTypeId), ProcessStepStatusId.DONE));
-
- context.PortalRepositories.Attach(context.Process);
- if (!context.Process.ReleaseLock())
- {
- context.Process.UpdateVersion();
- }
- }
-
- private static IEnumerable<(Guid, Action?, Action)> ModifyStepStatusRange(IEnumerable steps, ProcessStepStatusId processStepStatusId)
- {
- var firstStep = steps.FirstOrDefault();
-
- if (firstStep == null)
- yield break;
-
- foreach (var step in steps)
- {
- yield return (
- step.Id,
- null,
- ps => ps.ProcessStepStatusId = ps.Id == firstStep.Id
- ? processStepStatusId
- : ProcessStepStatusId.DUPLICATE);
- }
- }
-}
diff --git a/src/processes/Processes.Library/Processes.Library.csproj b/src/processes/Processes.Library/Processes.Library.csproj
deleted file mode 100644
index a55a5c6..0000000
--- a/src/processes/Processes.Library/Processes.Library.csproj
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- Dim.Processes.Library
- Dim.Processes.Library
- net8.0
- enable
- enable
- 76a1cf69-39e1-43a7-b6a7-fef83be5359f
-
-
-
-
-
-
-
-
diff --git a/src/processes/Processes.Worker.Library/IProcessExecutor.cs b/src/processes/Processes.Worker.Library/IProcessExecutor.cs
deleted file mode 100644
index 22bb752..0000000
--- a/src/processes/Processes.Worker.Library/IProcessExecutor.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-
-namespace Processes.Worker.Library;
-
-public interface IProcessExecutor
-{
- enum ProcessExecutionResult
- {
- SaveRequested = 1,
- LockRequested = 2,
- Unmodified = 3
- }
- IAsyncEnumerable ExecuteProcess(Guid processId, ProcessTypeId processTypeId, CancellationToken cancellationToken);
- IEnumerable GetRegisteredProcessTypeIds();
- IEnumerable GetExecutableStepTypeIds();
-}
diff --git a/src/processes/Processes.Worker.Library/IProcessTypeExecutor.cs b/src/processes/Processes.Worker.Library/IProcessTypeExecutor.cs
deleted file mode 100644
index 213de9f..0000000
--- a/src/processes/Processes.Worker.Library/IProcessTypeExecutor.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.Entities.Enums;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
-
-namespace Processes.Worker.Library;
-
-public interface IProcessTypeExecutor
-{
- record InitializationResult(bool Modified, IEnumerable? ScheduleStepTypeIds);
- record StepExecutionResult(bool Modified, ProcessStepStatusId ProcessStepStatusId, IEnumerable? ScheduleStepTypeIds, IEnumerable? SkipStepTypeIds, string? ProcessMessage);
-
- ValueTask InitializeProcess(Guid processId, IEnumerable processStepTypeIds);
- ValueTask IsLockRequested(ProcessStepTypeId processStepTypeId);
-
- ///
- /// tbd
- ///
- ///
- ///
- ///
- /// Is thrown if entity is not found
- /// Is thrown if ...
- ///
- ValueTask ExecuteProcessStep(ProcessStepTypeId processStepTypeId, IEnumerable processStepTypeIds, CancellationToken cancellationToken);
- bool IsExecutableStepTypeId(ProcessStepTypeId processStepTypeId);
- ProcessTypeId GetProcessTypeId();
- IEnumerable GetExecutableStepTypeIds();
-}
diff --git a/src/processes/Processes.Worker.Library/ProcessExecutionService.cs b/src/processes/Processes.Worker.Library/ProcessExecutionService.cs
deleted file mode 100644
index 6f0e449..0000000
--- a/src/processes/Processes.Worker.Library/ProcessExecutionService.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.DbAccess;
-using Dim.DbAccess.Repositories;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using Microsoft.Extensions.Options;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.DBAccess;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
-
-namespace Processes.Worker.Library;
-
-///
-/// Service that reads all open/pending processSteps of a checklist and triggers their execution.
-///
-public class ProcessExecutionService
-{
- private readonly IServiceScopeFactory _serviceScopeFactory;
- private readonly IDateTimeProvider _dateTimeProvider;
- private readonly ProcessExecutionServiceSettings _settings;
- private readonly ILogger _logger;
-
- ///
- /// Creates a new instance of
- ///
- /// access to the services
- /// date time provider
- /// access to the options
- /// the logger
- public ProcessExecutionService(
- IServiceScopeFactory serviceScopeFactory,
- IDateTimeProvider dateTimeProvider,
- IOptions options,
- ILogger logger)
- {
- _serviceScopeFactory = serviceScopeFactory;
- _dateTimeProvider = dateTimeProvider;
- _settings = options.Value;
- _logger = logger;
- }
-
- ///
- /// Handles the checklist processing
- ///
- /// Cancellation Token
- public async Task ExecuteAsync(CancellationToken stoppingToken)
- {
- try
- {
- using var processServiceScope = _serviceScopeFactory.CreateScope();
- var executorRepositories = processServiceScope.ServiceProvider.GetRequiredService();
- var processExecutor = processServiceScope.ServiceProvider.GetRequiredService();
-
- using var outerLoopScope = _serviceScopeFactory.CreateScope();
- var outerLoopRepositories = outerLoopScope.ServiceProvider.GetRequiredService();
-
- var lockExpiryTime = new TimeSpan(_settings.LockExpirySeconds * 10000000L);
- var activeProcesses = outerLoopRepositories.GetInstance().GetActiveProcesses(processExecutor.GetRegisteredProcessTypeIds(), processExecutor.GetExecutableStepTypeIds(), _dateTimeProvider.OffsetNow);
- await foreach (var process in activeProcesses.WithCancellation(stoppingToken).ConfigureAwait(false))
- {
- try
- {
- if (process.IsLocked())
- {
- _logger.LogInformation("skipping locked process {processId} type {processType}, lock expires at {lockExpireDate}", process.Id, process.ProcessTypeId, process.LockExpiryDate);
- continue;
- }
- _logger.LogInformation("start processing process {processId} type {processType}", process.Id, process.ProcessTypeId);
-
- bool EnsureLock()
- {
- if (process.IsLocked())
- {
- return false;
- }
- var isLocked = process.TryLock(_dateTimeProvider.OffsetNow.Add(lockExpiryTime));
- if (!isLocked)
- {
- throw new UnexpectedConditionException("process TryLock should never fail here");
- }
- return true;
- }
-
- bool UpdateVersion()
- {
- if (!process.IsLocked())
- {
- process.UpdateVersion();
- }
- return true;
- }
-
- await foreach (var executionResult in processExecutor.ExecuteProcess(process.Id, process.ProcessTypeId, stoppingToken).ConfigureAwait(false))
- {
- if (executionResult switch
- {
- IProcessExecutor.ProcessExecutionResult.LockRequested => EnsureLock(),
- IProcessExecutor.ProcessExecutionResult.SaveRequested => UpdateVersion(),
- _ => false
- })
- {
- await executorRepositories.SaveAsync().ConfigureAwait(ConfigureAwaitOptions.None);
- }
- executorRepositories.Clear();
- }
-
- if (process.ReleaseLock())
- {
- await executorRepositories.SaveAsync().ConfigureAwait(ConfigureAwaitOptions.None);
- executorRepositories.Clear();
- }
- _logger.LogInformation("finished processing process {processId}", process.Id);
- }
- catch (Exception ex) when (ex is not SystemException)
- {
- _logger.LogInformation(ex, "error processing process {processId} type {processType}: {message}", process.Id, process.ProcessTypeId, ex.Message);
- executorRepositories.Clear();
- }
- }
- }
- catch (Exception ex)
- {
- Environment.ExitCode = 1;
- _logger.LogError(ex, "processing failed with following Exception {ExceptionMessage}", ex.Message);
- }
- }
-}
diff --git a/src/processes/Processes.Worker.Library/ProcessExecutionServiceExtensions.cs b/src/processes/Processes.Worker.Library/ProcessExecutionServiceExtensions.cs
deleted file mode 100644
index 8fd0c74..0000000
--- a/src/processes/Processes.Worker.Library/ProcessExecutionServiceExtensions.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Org.Eclipse.TractusX.Portal.Backend.Framework.DateTimeProvider;
-
-namespace Processes.Worker.Library;
-
-public static class ProcessExecutionServiceExtensions
-{
- public static IServiceCollection AddProcessExecutionService(this IServiceCollection services, IConfigurationSection section)
- {
- services.AddOptions().Bind(section);
- services
- .AddTransient()
- .AddTransient()
- .AddTransient();
- return services;
- }
-}
diff --git a/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs b/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs
deleted file mode 100644
index 3f31291..0000000
--- a/src/processes/Processes.Worker.Library/ProcessExecutionServiceSettings.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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.ComponentModel.DataAnnotations;
-
-namespace Processes.Worker.Library;
-
-public class ProcessExecutionServiceSettings
-{
- [Required]
- public int LockExpirySeconds { get; set; }
-}
diff --git a/src/processes/Processes.Worker.Library/ProcessExecutor.cs b/src/processes/Processes.Worker.Library/ProcessExecutor.cs
deleted file mode 100644
index 2c31944..0000000
--- a/src/processes/Processes.Worker.Library/ProcessExecutor.cs
+++ /dev/null
@@ -1,215 +0,0 @@
-/********************************************************************************
- * Copyright (c) 2024 BMW Group AG
- * Copyright 2024 SAP SE or an SAP affiliate company and ssi-dim-middle-layer contributors.
- *
- * 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 Dim.DbAccess;
-using Dim.DbAccess.Repositories;
-using Dim.Entities.Enums;
-using Microsoft.Extensions.Logging;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.Async;
-using Org.Eclipse.TractusX.Portal.Backend.Framework.ErrorHandling;
-using System.Collections.Immutable;
-using System.Runtime.CompilerServices;
-
-namespace Processes.Worker.Library;
-
-public class ProcessExecutor : IProcessExecutor
-{
- private readonly ImmutableDictionary _executors;
- private readonly IProcessStepRepository _processStepRepository;
- private readonly ILogger _logger;
-
- public ProcessExecutor(IEnumerable executors, IDimRepositories portalRepositories, ILogger logger)
- {
- _processStepRepository = portalRepositories.GetInstance();
- _executors = executors.ToImmutableDictionary(executor => executor.GetProcessTypeId());
- _logger = logger;
- }
-
- public IEnumerable GetRegisteredProcessTypeIds() => _executors.Keys;
- public IEnumerable GetExecutableStepTypeIds() => _executors.Values.SelectMany(executor => executor.GetExecutableStepTypeIds());
-
- public async IAsyncEnumerable ExecuteProcess(Guid processId, ProcessTypeId processTypeId, [EnumeratorCancellation] CancellationToken cancellationToken)
- {
- if (!_executors.TryGetValue(processTypeId, out var executor))
- {
- throw new UnexpectedConditionException($"processType {processTypeId} is not a registered executable processType.");
- }
-
- var allSteps = await _processStepRepository
- .GetProcessStepData(processId)
- .PreSortedGroupBy(x => x.ProcessStepTypeId, x => x.ProcessStepId)
- .ToDictionaryAsync(g => g.Key, g => g.AsEnumerable(), cancellationToken)
- .ConfigureAwait(false);
-
- var context = new ProcessContext(
- processId,
- allSteps,
- new ProcessStepTypeSet(allSteps.Keys.Where(x => executor.IsExecutableStepTypeId(x))),
- executor);
-
- var (modified, initialStepTypeIds) = await executor.InitializeProcess(processId, context.AllSteps.Keys).ConfigureAwait(false);
-
- modified |= ScheduleProcessStepTypeIds(initialStepTypeIds, context);
-
- yield return modified
- ? IProcessExecutor.ProcessExecutionResult.SaveRequested
- : IProcessExecutor.ProcessExecutionResult.Unmodified;
-
- while (context.ExecutableStepTypeIds.TryGetNext(out var stepTypeId))
- {
- if (await executor.IsLockRequested(stepTypeId).ConfigureAwait(false))
- {
- yield return IProcessExecutor.ProcessExecutionResult.LockRequested;
- }
-
- ProcessStepStatusId resultStepStatusId;
- IEnumerable? scheduleStepTypeIds;
- IEnumerable? skipStepTypeIds;
- string? processMessage;
- bool success;
- try
- {
- (modified, resultStepStatusId, scheduleStepTypeIds, skipStepTypeIds, processMessage) = await executor.ExecuteProcessStep(stepTypeId, context.AllSteps.Keys, cancellationToken).ConfigureAwait(false);
- success = true;
- }
- catch (Exception e) when (e is not SystemException)
- {
- resultStepStatusId = ProcessStepStatusId.FAILED;
- processMessage = $"{e.GetType()}: {e.Message}";
- scheduleStepTypeIds = null;
- skipStepTypeIds = null;
- modified = false;
- success = false;
- }
- if (!success)
- {
- yield return IProcessExecutor.ProcessExecutionResult.Unmodified;
- }
- modified |= SetProcessStepStatus(stepTypeId, resultStepStatusId, context, processMessage);
- modified |= SkipProcessStepTypeIds(skipStepTypeIds, context);
- modified |= ScheduleProcessStepTypeIds(scheduleStepTypeIds, context);
-
- yield return modified
- ? IProcessExecutor.ProcessExecutionResult.SaveRequested
- : IProcessExecutor.ProcessExecutionResult.Unmodified;
- }
- }
-
- private bool ScheduleProcessStepTypeIds(IEnumerable? scheduleStepTypeIds, ProcessContext context)
- {
- if (scheduleStepTypeIds == null || !scheduleStepTypeIds.Any())
- {
- return false;
- }
-
- var newStepTypeIds = scheduleStepTypeIds.Except(context.AllSteps.Keys).ToList();
- if (!newStepTypeIds.Any())
- {
- return false;
- }
- foreach (var newStep in _processStepRepository.CreateProcessStepRange(newStepTypeIds.Select(stepTypeId => (stepTypeId, ProcessStepStatusId.TODO, context.ProcessId))))
- {
- context.AllSteps.Add(newStep.ProcessStepTypeId, new[] { newStep.Id });
- if (context.Executor.IsExecutableStepTypeId(newStep.ProcessStepTypeId))
- {
- context.ExecutableStepTypeIds.Add(newStep.ProcessStepTypeId);
- }
- }
- return true;
- }
-
- private bool SkipProcessStepTypeIds(IEnumerable