Skip to content

Commit

Permalink
feat(seeding): add purpose policies
Browse files Browse the repository at this point in the history
Refs: CPLP-3362
  • Loading branch information
Phil91 committed Nov 23, 2023
1 parent 535f1ab commit 7ee1e76
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ namespace Org.Eclipse.TractusX.PolicyHub.DbAccess.Models;

public record PolicyTypeResponse
(
PolicyKindId Name,
string TechnicalKey,
IEnumerable<PolicyTypeId> Type,
string Description,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public IAsyncEnumerable<PolicyTypeResponse> GetPolicyTypes(PolicyTypeId? type, U
(type == null || p.Types.Any(x => x.Id == type)) &&
(useCase == null || p.UseCases.Any(x => x.Id == useCase)))
.Select(p => new PolicyTypeResponse(
p.KindId,
p.TechnicalKey,
p.Types.Where(t => t.IsActive).Select(t => t.Id),
p.Description,
Expand Down
16 changes: 12 additions & 4 deletions src/database/PolicyHub.Migrations/Seeder/Data/policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300b7",
"kind_id": 4,
"technical_key": "purpose",
"description": "tbd",
"technical_key": "purpose.trace.v1.TraceBattery",
"description": "Facilitating compliance with mandatory regulatory requirements for tracking and reporting battery cells, modules & high-voltage batteries.",
"is_active": true,
"attribute_key_id": 2
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300b8",
"kind_id": 4,
"technical_key": "purpose",
"description": "tbd",
"technical_key": "purpose.trace.v1.aspects",
"description": "Establishing a digital representation of the automotive supply chain to enable a component specific data exchange.",
"is_active": true,
"attribute_key_id": 3
},
Expand All @@ -71,5 +71,13 @@
"description": "tbd",
"is_active": true,
"attribute_key_id": 4
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300c1",
"kind_id": 4,
"technical_key": "purpose.trace.v1.qualityanalysis",
"description": " The data can be used for quality analysis to identify and select affected components and to send quality notifications to affected customers or suppliers.",
"is_active": true,
"attribute_key_id": 3
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b7", "policy_type_id": 2, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", "policy_type_id": 2, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "policy_type_id": 1, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "policy_type_id": 2, "is_active": true }
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "policy_type_id": 2, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "policy_type_id": 2, "is_active": true }
]
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b6", "use_case_id": 4, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b7", "use_case_id": 1, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", "use_case_id": 1, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", "use_case_id": 2, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", "use_case_id": 3, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", "use_case_id": 4, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", "use_case_id": 5, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "use_case_id": 1, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "use_case_id": 2, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "use_case_id": 3, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "use_case_id": 4, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "use_case_id": 5, "is_active": true }
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", "use_case_id": 5, "is_active": true },
{ "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "use_case_id": 1, "is_active": true }
]
9 changes: 9 additions & 0 deletions src/hub/PolicyHub.Service/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using Org.Eclipse.TractusX.PolicyHub.Service.Authentication;
using Org.Eclipse.TractusX.PolicyHub.Service.Controllers;
using Org.Eclipse.TractusX.Portal.Backend.Framework.Web;
using System.Text.Json.Serialization;

const string Version = "v2";

Expand All @@ -30,6 +31,14 @@
{
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddHubRepositories(builder.Configuration);
builder.Services.ConfigureHttpJsonOptions(options =>
{
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
builder.Services.Configure<Microsoft.AspNetCore.Mvc.JsonOptions>(options =>
{
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
},
(app, _) =>
{
Expand Down

0 comments on commit 7ee1e76

Please sign in to comment.