Skip to content

Commit 0b76f08

Browse files
author
Thomas Fuchs
committed
Include operator management
1 parent 6ca1670 commit 0b76f08

File tree

247 files changed

+41598
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+41598
-73
lines changed

Directory.Packages.props

Lines changed: 72 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,90 @@
11
<Project>
2-
<PropertyGroup>
3-
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4-
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5-
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
6-
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">false</RestoreLockedMode>
7-
<CentralPackageFloatingVersionsEnabled>false</CentralPackageFloatingVersionsEnabled>
8-
<!-- Set to true to allow floating versions if necessary. Only works with .net sdk >8.0.200 -->
9-
</PropertyGroup>
2+
<PropertyGroup>
3+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
4+
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
5+
<RestorePackagesWithLockFile>false</RestorePackagesWithLockFile>
6+
<RestoreLockedMode Condition="'$(ContinuousIntegrationBuild)' == 'true'">false</RestoreLockedMode>
7+
<CentralPackageFloatingVersionsEnabled>false</CentralPackageFloatingVersionsEnabled>
8+
<!-- Set to true to allow floating versions if necessary. Only works with .net sdk >8.0.200 -->
9+
</PropertyGroup>
1010

11-
<!-- Global version definitions need to be done here, this file is loaded before all others-->
12-
<PropertyGroup>
13-
<dotnetVersion>8.0.1</dotnetVersion>
14-
<efCoreVersion>8.0.11</efCoreVersion>
11+
<!-- Global version definitions need to be done here, this file is loaded before all others-->
12+
<PropertyGroup>
13+
<dotnetVersion>8.0.1</dotnetVersion>
14+
<efCoreVersion>8.0.11</efCoreVersion>
1515

16-
<AspNetCoreVersion>8.0.11</AspNetCoreVersion>
17-
</PropertyGroup>
16+
<AspNetCoreVersion>8.0.11</AspNetCoreVersion>
17+
</PropertyGroup>
1818

19-
<ItemGroup>
20-
<!-- Test libraries -->
21-
<PackageVersion Include="Moq" Version="4.20.72" />
22-
<PackageVersion Include="NUnit" Version="4.3.2" />
23-
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
24-
<PackageVersion Include="NUnit.Analyzers" Version="4.6.0" />
25-
<PackageVersion Include="WireMock.Net" Version="1.6.2" />
26-
<PackageVersion Include="WireMock.Net.FluentAssertions" Version="1.5.62" />
27-
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
19+
<ItemGroup>
20+
<!-- Test libraries -->
21+
<PackageVersion Include="Moq" Version="4.20.72" />
22+
<PackageVersion Include="NUnit" Version="4.3.2" />
23+
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
24+
<PackageVersion Include="NUnit.Analyzers" Version="4.6.0" />
25+
<PackageVersion Include="WireMock.Net" Version="1.6.2" />
26+
<PackageVersion Include="WireMock.Net.FluentAssertions" Version="1.5.62" />
27+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
2828

29-
<!-- Bereits vorhandene Einträge (aus deiner Migration) -->
30-
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="$(AspNetCoreVersion)" />
31-
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
32-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
33-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
29+
<!-- Bereits vorhandene Einträge (aus deiner Migration) -->
30+
<PackageVersion Include="Microsoft.Extensions.Http.Polly" Version="$(AspNetCoreVersion)" />
31+
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="$(dotnetVersion)" />
32+
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="$(dotnetVersion)" />
33+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
34+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
3435

35-
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(AspNetCoreVersion)" />
36-
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNetCoreVersion)" />
37-
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
38-
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
39-
<PackageVersion Include="Microsoft.AspNetCore.Identity.UI" Version="$(AspNetCoreVersion)" />
40-
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="$(AspNetCoreVersion)" />
41-
<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="$(AspNetCoreVersion)" />
36+
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="$(AspNetCoreVersion)" />
37+
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(AspNetCoreVersion)" />
38+
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
39+
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
40+
<PackageVersion Include="Microsoft.AspNetCore.Identity.UI" Version="$(AspNetCoreVersion)" />
41+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="$(AspNetCoreVersion)" />
42+
<PackageVersion Include="Microsoft.AspNetCore.Authorization" Version="$(AspNetCoreVersion)" />
4243

43-
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
44-
<PackageVersion Include="Microsoft.Identity.Web" Version="3.9.4" />
45-
<PackageVersion Include="Microsoft.Identity.Web.DownstreamApi" Version="3.9.4" />
46-
<PackageVersion Include="Microsoft.Identity.Web.UI" Version="3.9.4" />
44+
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" />
45+
<PackageVersion Include="Microsoft.Identity.Web" Version="3.9.4" />
46+
<PackageVersion Include="Microsoft.Identity.Web.DownstreamApi" Version="3.9.4" />
47+
<PackageVersion Include="Microsoft.Identity.Web.UI" Version="3.9.4" />
4748

48-
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
49-
<PackageVersion Include="JunitXml.TestLogger" Version="5.0.0" />
49+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
50+
<PackageVersion Include="JunitXml.TestLogger" Version="5.0.0" />
5051

51-
<!-- Übertragene Einträge aus Build.targets -->
52-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
53-
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
54-
<PackageVersion Include="AutoMapper" Version="14.0.0" />
55-
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.4" />
52+
<!-- Übertragene Einträge aus Build.targets -->
53+
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
54+
<PackageVersion Include="CommandLineParser" Version="2.9.1" />
55+
<PackageVersion Include="AutoMapper" Version="14.0.0" />
56+
<PackageVersion Include="Swashbuckle.AspNetCore" Version="8.1.4" />
5657

57-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(dotnetVersion)" />
58-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
59-
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="$(dotnetVersion)" />
60-
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(dotnetVersion)" />
61-
<PackageVersion Include="Microsoft.Data.Sqlite" Version="$(dotnetVersion)" />
58+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(dotnetVersion)" />
59+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
60+
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="$(dotnetVersion)" />
61+
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(dotnetVersion)" />
62+
<PackageVersion Include="Microsoft.Data.Sqlite" Version="$(dotnetVersion)" />
6263

63-
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(efCoreVersion)" />
64-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="$(efCoreVersion)" />
65-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="$(efCoreVersion)" />
66-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="$(efCoreVersion)" />
67-
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(efCoreVersion)" />
68-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(efCoreVersion)" />
69-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="$(efCoreVersion)" />
70-
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(efCoreVersion)" />
64+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(efCoreVersion)" />
65+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="$(efCoreVersion)" />
66+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="$(efCoreVersion)" />
67+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="$(efCoreVersion)" />
68+
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(efCoreVersion)" />
69+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="$(efCoreVersion)" />
70+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="$(efCoreVersion)" />
71+
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(efCoreVersion)" />
7172

72-
<PackageVersion Include="System.IO.Ports" Version="$(dotnetVersion)" />
73-
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
73+
<PackageVersion Include="System.IO.Ports" Version="$(dotnetVersion)" />
74+
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
7475

75-
<PackageVersion Include="Castle.Windsor" Version="6.0.0" />
76+
<PackageVersion Include="Castle.Windsor" Version="6.0.0" />
7677

77-
<!-- Dependencies for drivers and adapters -->
78-
<PackageVersion Include="MQTTnet" Version="4.3.1.873" />
79-
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.5.376.213" />
78+
<!-- Dependencies for drivers and adapters -->
79+
<PackageVersion Include="MQTTnet" Version="4.3.1.873" />
80+
<PackageVersion Include="OPCFoundation.NetStandard.Opc.Ua.Client" Version="1.5.376.213" />
8081

81-
<PackageVersion Include="InfluxDB.LineProtocol" Version="1.1.1" />
82-
<PackageVersion Include="InfluxDB.Client" Version="4.18.0" />
83-
<PackageVersion Include="CsvHelper" Version="33.0.1" />
82+
<PackageVersion Include="InfluxDB.LineProtocol" Version="1.1.1" />
83+
<PackageVersion Include="InfluxDB.Client" Version="4.18.0" />
84+
<PackageVersion Include="CsvHelper" Version="33.0.1" />
8485

85-
<PackageVersion Include="MimeTypeMapOfficial" Version="1.0.17" />
86-
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.8" />
86+
<PackageVersion Include="MimeTypeMapOfficial" Version="1.0.17" />
87+
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.8" />
8788

88-
</ItemGroup>
89+
</ItemGroup>
8990
</Project>

MORYX-Framework.sln

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Analytics.Server", "s
301301
EndProject
302302
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Analytics.Web", "src\Moryx.Analytics.Web\Moryx.Analytics.Web.csproj", "{3340BFF4-132F-496C-8D70-6F3800330F7E}"
303303
EndProject
304+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Operators", "Operators", "{8DF13E64-63FC-44A9-A54C-ADEFC356CDE8}"
305+
EndProject
306+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Operators", "src\Moryx.Operators\Moryx.Operators.csproj", "{A7D7385D-F4FD-4026-A01F-11D811774327}"
307+
EndProject
308+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Operators.Management", "src\Moryx.Operators.Management\Moryx.Operators.Management.csproj", "{5F2DA8C5-9C92-4F50-AEA0-F646D6BAB2E6}"
309+
EndProject
310+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Operators.Endpoints", "src\Moryx.Operators.Endpoints\Moryx.Operators.Endpoints.csproj", "{0A1E7D04-BF6D-4C8D-A967-C19CDA0E3C90}"
311+
EndProject
312+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Operators.Web", "src\Moryx.Operators.Web\Moryx.Operators.Web.csproj", "{D73F1F9A-7387-47F3-A7C8-376DB45B81A7}"
313+
EndProject
314+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Moryx.Operators.Management.Integration.Tests", "src\Tests\Moryx.Operators.Management.Integration.Tests\Moryx.Operators.Management.Integration.Tests.csproj", "{95EE50ED-817D-4F99-96FF-25E80334A3BE}"
315+
EndProject
304316
Global
305317
GlobalSection(SolutionConfigurationPlatforms) = preSolution
306318
Debug|Any CPU = Debug|Any CPU
@@ -787,6 +799,26 @@ Global
787799
{3340BFF4-132F-496C-8D70-6F3800330F7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
788800
{3340BFF4-132F-496C-8D70-6F3800330F7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
789801
{3340BFF4-132F-496C-8D70-6F3800330F7E}.Release|Any CPU.Build.0 = Release|Any CPU
802+
{A7D7385D-F4FD-4026-A01F-11D811774327}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
803+
{A7D7385D-F4FD-4026-A01F-11D811774327}.Debug|Any CPU.Build.0 = Debug|Any CPU
804+
{A7D7385D-F4FD-4026-A01F-11D811774327}.Release|Any CPU.ActiveCfg = Release|Any CPU
805+
{A7D7385D-F4FD-4026-A01F-11D811774327}.Release|Any CPU.Build.0 = Release|Any CPU
806+
{5F2DA8C5-9C92-4F50-AEA0-F646D6BAB2E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
807+
{5F2DA8C5-9C92-4F50-AEA0-F646D6BAB2E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
808+
{5F2DA8C5-9C92-4F50-AEA0-F646D6BAB2E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
809+
{5F2DA8C5-9C92-4F50-AEA0-F646D6BAB2E6}.Release|Any CPU.Build.0 = Release|Any CPU
810+
{0A1E7D04-BF6D-4C8D-A967-C19CDA0E3C90}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
811+
{0A1E7D04-BF6D-4C8D-A967-C19CDA0E3C90}.Debug|Any CPU.Build.0 = Debug|Any CPU
812+
{0A1E7D04-BF6D-4C8D-A967-C19CDA0E3C90}.Release|Any CPU.ActiveCfg = Release|Any CPU
813+
{0A1E7D04-BF6D-4C8D-A967-C19CDA0E3C90}.Release|Any CPU.Build.0 = Release|Any CPU
814+
{D73F1F9A-7387-47F3-A7C8-376DB45B81A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
815+
{D73F1F9A-7387-47F3-A7C8-376DB45B81A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
816+
{D73F1F9A-7387-47F3-A7C8-376DB45B81A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
817+
{D73F1F9A-7387-47F3-A7C8-376DB45B81A7}.Release|Any CPU.Build.0 = Release|Any CPU
818+
{95EE50ED-817D-4F99-96FF-25E80334A3BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
819+
{95EE50ED-817D-4F99-96FF-25E80334A3BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
820+
{95EE50ED-817D-4F99-96FF-25E80334A3BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
821+
{95EE50ED-817D-4F99-96FF-25E80334A3BE}.Release|Any CPU.Build.0 = Release|Any CPU
790822
EndGlobalSection
791823
GlobalSection(SolutionProperties) = preSolution
792824
HideSolutionNode = FALSE
@@ -907,10 +939,15 @@ Global
907939
{EB50C7EF-7092-434B-84C5-93F075D7FA6D} = {0A466330-6ED6-4861-9C94-31B1949CDDB9}
908940
{58A936FD-D155-4397-B9AC-7E5679546F2A} = {EFA3F41A-1DEF-4E49-B3F0-D34DFA4BD56B}
909941
{3340BFF4-132F-496C-8D70-6F3800330F7E} = {EFA3F41A-1DEF-4E49-B3F0-D34DFA4BD56B}
942+
{A7D7385D-F4FD-4026-A01F-11D811774327} = {8DF13E64-63FC-44A9-A54C-ADEFC356CDE8}
943+
{5F2DA8C5-9C92-4F50-AEA0-F646D6BAB2E6} = {8DF13E64-63FC-44A9-A54C-ADEFC356CDE8}
944+
{0A1E7D04-BF6D-4C8D-A967-C19CDA0E3C90} = {8DF13E64-63FC-44A9-A54C-ADEFC356CDE8}
945+
{D73F1F9A-7387-47F3-A7C8-376DB45B81A7} = {8DF13E64-63FC-44A9-A54C-ADEFC356CDE8}
946+
{95EE50ED-817D-4F99-96FF-25E80334A3BE} = {8517D209-5BC1-47BD-A7C7-9CF9ADD9F5B6}
910947
EndGlobalSection
911948
GlobalSection(ExtensibilityGlobals) = postSolution
912-
RESX_ShowErrorsInErrorList = True
913-
RESX_TaskErrorCategory = Message
914949
SolutionGuid = {36EFC961-F4E7-49DC-A36A-99594FFB8243}
950+
RESX_TaskErrorCategory = Message
951+
RESX_ShowErrorsInErrorList = True
915952
EndGlobalSection
916953
EndGlobal
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG
2+
// Licensed under the Apache License, Version 2.0
3+
4+
using Moryx.AbstractionLayer.Capabilities;
5+
using Moryx.Operators.Extensions;
6+
using Moryx.Operators.Skills;
7+
using Moryx.Serialization;
8+
using Moryx.Tools;
9+
10+
namespace Moryx.Operators.Endpoints;
11+
12+
internal static class Converter
13+
{
14+
private static readonly Dictionary<Type, Entry> _capabilitiyPrototypes;
15+
16+
static Converter()
17+
{
18+
_capabilitiyPrototypes = ReflectionTool.GetPublicClasses(typeof(ICapabilities))
19+
// Abstract classes and those without parameterles ctor will throw an exception
20+
.Where(c => !c.IsAbstract && c.GetConstructor(Type.EmptyTypes) is not null)
21+
.ToDictionary(t => t, t => EntryConvert.Prototype(new EntryPrototype(t.Name, Activator.CreateInstance(t))));
22+
}
23+
24+
internal static SkillTypeCreationContext ToContext(this SkillTypeCreationContextModel model)
25+
=> new(VerifyNotNull(model.Name), CreateInstance(VerifyNotNull(model.Capabilities)))
26+
{
27+
Duration = model.Duration,
28+
};
29+
30+
internal static SkillCreationContext ToContext(this SkillCreationContextModel model,
31+
IOperatorManagement operators,
32+
ISkillManagement skills) =>
33+
new(operators.GetOperator(VerifyNotNull(model.OperatorIdentifier)) ?? throw new KeyNotFoundException($"No operator with identifier {model.OperatorIdentifier} could be found."),
34+
skills.GetSkillType(model.TypeId) ?? throw new KeyNotFoundException($"No skill with id {model.OperatorIdentifier} could be found.")) { ObtainedOn = model.ObtainedOn };
35+
36+
37+
internal static ExtendedOperatorModel ToModel(this AssignableOperator @operator) => new()
38+
{
39+
FirstName = @operator.FirstName,
40+
LastName = @operator.LastName,
41+
Pseudonym = @operator.Pseudonym,
42+
Identifier = @operator.Identifier,
43+
AssignedResources = @operator.AssignedResources.Select(ToModel)
44+
};
45+
46+
internal static SkillTypeModel ToModel(this SkillType type, bool full)
47+
{
48+
var model = new SkillTypeModel { Id = type.Id, Name = type.Name, Duration = type.Duration };
49+
var capabilitySerialize = EntryConvert.EncodeObject(type.AcquiredCapabilities);
50+
model.Capabilities = capabilitySerialize;
51+
52+
if (!full) return model;
53+
54+
// Only serialize prototypes for detail view
55+
model.Capabilities.Prototypes = [.. _capabilitiyPrototypes.Values];
56+
model.Capabilities.Value.Possible = [.. _capabilitiyPrototypes.Keys.Select(t => t.Name)];
57+
return model;
58+
}
59+
60+
internal static ResourceModel ToModel(IOperatorAssignable resource) => new()
61+
{
62+
Id = resource.Id,
63+
Name = resource.Name
64+
};
65+
66+
internal static SkillModel ToModel(this Skill skill) => new()
67+
{
68+
Id = skill.Id,
69+
TypeId = skill.Type.Id,
70+
OperatorIdentifier = skill.Operator.Identifier,
71+
ObtainedOn = skill.ObtainedOn,
72+
IsExpired = skill.IsExpired,
73+
ExpiresOn = skill.ObtainedOn.AddDays((int)skill.Type.Duration.TotalDays)
74+
};
75+
76+
77+
internal static Operator ToType(this OperatorModel @operator) => new(VerifyNotNull(@operator.Identifier))
78+
{
79+
FirstName = @operator.FirstName,
80+
LastName = @operator.LastName,
81+
Pseudonym = @operator.Pseudonym,
82+
};
83+
84+
internal static SkillType ToType(this SkillTypeModel model) => new(VerifyNotNull(model.Name), CreateInstance(VerifyNotNull(model.Capabilities)))
85+
{
86+
Id = model.Id,
87+
Duration = model.Duration,
88+
};
89+
90+
private static ICapabilities CreateInstance(Entry capabilityEntry)
91+
{
92+
var type = _capabilitiyPrototypes.Keys.FirstOrDefault(type => type.Name == capabilityEntry.Value.Current);
93+
try
94+
{
95+
return (ICapabilities)EntryConvert.CreateInstance(type, capabilityEntry);
96+
}
97+
catch (Exception e)
98+
{
99+
return new FaultyCapabilities()
100+
{
101+
OriginalType = capabilityEntry.Value.Current,
102+
Exception = e.ToString()
103+
};
104+
}
105+
106+
}
107+
108+
109+
private static Entry VerifyNotNull(Entry? entry) => entry ?? throw new ArgumentNullException(nameof(entry));
110+
111+
private static string VerifyNotNull(string? name) => name ?? throw new ArgumentNullException(nameof(name));
112+
113+
}
114+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright (c) 2025, Phoenix Contact GmbH & Co. KG
2+
// Licensed under the Apache License, Version 2.0
3+
4+
namespace Moryx.Operators.Endpoints;
5+
6+
public class ExtendedOperatorModel : OperatorModel
7+
{
8+
public IEnumerable<ResourceModel>? AssignedResources { get; set; }
9+
}
10+

0 commit comments

Comments
 (0)