From c9c80dd177e5e87f62d65e0f06e9f1ce3c0d4017 Mon Sep 17 00:00:00 2001 From: Mads Magnus Due Date: Mon, 9 Dec 2024 21:10:08 +0100 Subject: [PATCH] feat: create orchestration for brs21 metered data (#31) * Added initial BRS021 models and classes Co-authored-by: Anders Balling Petersen --- .../ReleaseNotes/ReleaseNotes.md | 5 ++ ...Manager.Orchestrations.Abstractions.csproj | 2 +- .../V1/Model/Brs_021_ForwardMeteredData_V1.cs | 20 ++++++++ .../V1/Model/EnergyObservation.cs | 20 ++++++++ ...edDataForMeasurementPointMessageInputV1.cs | 36 ++++++++++++++ .../Model/StartMeteredDataForwardCommandV1.cs | 41 ++++++++++++++++ .../ProcessManager.Orchestrations.csproj | 1 + ...estration_Brs_021_ForwardMeteredData_V1.cs | 47 +++++++++++++++++++ .../ProcessManager.Orchestrations/Program.cs | 24 ++++++++++ 9 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/Brs_021_ForwardMeteredData_V1.cs create mode 100644 source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/EnergyObservation.cs create mode 100644 source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/MeteredDataForMeasurementPointMessageInputV1.cs create mode 100644 source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/StartMeteredDataForwardCommandV1.cs create mode 100644 source/ProcessManager.Orchestrations/Processes/BRS_021/ForwardMeteredData/V1/Orchestration_Brs_021_ForwardMeteredData_V1.cs diff --git a/docs/ProcessManager.Orchestrations.Abstractions/ReleaseNotes/ReleaseNotes.md b/docs/ProcessManager.Orchestrations.Abstractions/ReleaseNotes/ReleaseNotes.md index ff0f1f0b..030e4338 100644 --- a/docs/ProcessManager.Orchestrations.Abstractions/ReleaseNotes/ReleaseNotes.md +++ b/docs/ProcessManager.Orchestrations.Abstractions/ReleaseNotes/ReleaseNotes.md @@ -1,5 +1,10 @@ # ProcessManager.Orchestrations.Abstractions Release Notes +## Version 0.2.0 + +- Implemented `Brs_021_ForwardMeteredData_V1` +- Implemented `StartForwardMeteredDataCommandV1` + ## Version 0.1.0 - Support start/schedule orchestration instance with no input parameter. diff --git a/source/ProcessManager.Orchestrations.Abstractions/ProcessManager.Orchestrations.Abstractions.csproj b/source/ProcessManager.Orchestrations.Abstractions/ProcessManager.Orchestrations.Abstractions.csproj index e2613138..1635f139 100644 --- a/source/ProcessManager.Orchestrations.Abstractions/ProcessManager.Orchestrations.Abstractions.csproj +++ b/source/ProcessManager.Orchestrations.Abstractions/ProcessManager.Orchestrations.Abstractions.csproj @@ -7,7 +7,7 @@ Energinet.DataHub.ProcessManager.Orchestrations.Abstractions - 0.1.0$(VersionSuffix) + 0.2.0$(VersionSuffix) DH3 Process Manager Orchestrations Abstractions library Energinet-DataHub Energinet-DataHub diff --git a/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/Brs_021_ForwardMeteredData_V1.cs b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/Brs_021_ForwardMeteredData_V1.cs new file mode 100644 index 00000000..bd388f24 --- /dev/null +++ b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/Brs_021_ForwardMeteredData_V1.cs @@ -0,0 +1,20 @@ +// Copyright 2020 Energinet DataHub A/S +// +// Licensed under the Apache License, Version 2.0 (the "License2"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. + +using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationDescription; + +namespace Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ForwardMeteredData.V1.Model; + +public record Brs_021_ForwardedMeteredData_V1() + : OrchestrationDescriptionUniqueNameDto("BRS_021_ForwardMeteredData", 1); diff --git a/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/EnergyObservation.cs b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/EnergyObservation.cs new file mode 100644 index 00000000..6dd30733 --- /dev/null +++ b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/EnergyObservation.cs @@ -0,0 +1,20 @@ +// Copyright 2020 Energinet DataHub A/S +// +// Licensed under the Apache License, Version 2.0 (the "License2"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. + +namespace Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ForwardMeteredData.V1.Model; + +public record EnergyObservation( + string? Position, + string? EnergyQuantity, + string? QuantityQuality); diff --git a/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/MeteredDataForMeasurementPointMessageInputV1.cs b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/MeteredDataForMeasurementPointMessageInputV1.cs new file mode 100644 index 00000000..3f2045c1 --- /dev/null +++ b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/MeteredDataForMeasurementPointMessageInputV1.cs @@ -0,0 +1,36 @@ +// Copyright 2020 Energinet DataHub A/S +// +// Licensed under the Apache License, Version 2.0 (the "License2"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. + +using Energinet.DataHub.ProcessManager.Abstractions.Api.Model; + +namespace Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ForwardMeteredData.V1.Model; + +/// +/// An immutable input to start the orchestration instance for "BRS_021_ForwardMeteredData" V1. +/// +public record MeteredDataForMeasurementPointMessageInputV1( + Guid AuthenticatedActorId, + string TransactionId, + string? MeteringPointId, + string? MeteringPointType, + string? ProductNumber, + string? MeasureUnit, + string RegistrationDateTime, + string? Resolution, + string StartDateTime, + string? EndDateTime, + string GridAccessProviderNumber, + IReadOnlyCollection? DelegatedGridAreaCodes, + IReadOnlyCollection EnergyObservations) + : IInputParameterDto; diff --git a/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/StartMeteredDataForwardCommandV1.cs b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/StartMeteredDataForwardCommandV1.cs new file mode 100644 index 00000000..41f081cb --- /dev/null +++ b/source/ProcessManager.Orchestrations.Abstractions/Processes/BRS_021/ForwardMeteredData/V1/Model/StartMeteredDataForwardCommandV1.cs @@ -0,0 +1,41 @@ +// Copyright 2020 Energinet DataHub A/S +// +// Licensed under the Apache License, Version 2.0 (the "License2"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. + +using Energinet.DataHub.ProcessManager.Abstractions.Api.Model; +using Energinet.DataHub.ProcessManager.Abstractions.Api.Model.OrchestrationInstance; + +namespace Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ForwardMeteredData.V1.Model; + +/// +/// Command for starting a BRS-021-ForwardMeteredData. +/// Must be JSON serializable. +/// +public record StartForwardMeteredDataCommandV1 + : StartOrchestrationInstanceCommand +{ + /// + /// Construct command. + /// + /// Identity of the user executing the command. + /// Contains the Durable Functions orchestration input parameter value. + public StartForwardMeteredDataCommandV1( + ActorIdentityDto operatingIdentity, + MeteredDataForMeasurementPointMessageInputV1 inputParameter) + : base( + operatingIdentity, + orchestrationDescriptionUniqueName: new Brs_021_ForwardedMeteredData_V1(), + inputParameter) + { + } +} diff --git a/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj b/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj index c0a8e5e4..c05e1e31 100644 --- a/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj +++ b/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj @@ -33,6 +33,7 @@ + diff --git a/source/ProcessManager.Orchestrations/Processes/BRS_021/ForwardMeteredData/V1/Orchestration_Brs_021_ForwardMeteredData_V1.cs b/source/ProcessManager.Orchestrations/Processes/BRS_021/ForwardMeteredData/V1/Orchestration_Brs_021_ForwardMeteredData_V1.cs new file mode 100644 index 00000000..6f672e90 --- /dev/null +++ b/source/ProcessManager.Orchestrations/Processes/BRS_021/ForwardMeteredData/V1/Orchestration_Brs_021_ForwardMeteredData_V1.cs @@ -0,0 +1,47 @@ +// Copyright 2020 Energinet DataHub A/S +// +// Licensed under the Apache License, Version 2.0 (the "License2"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://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. + +using Energinet.DataHub.ProcessManagement.Core.Infrastructure.Extensions.DurableTask; +using Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ForwardMeteredData.V1.Model; +using Microsoft.Azure.Functions.Worker; +using Microsoft.DurableTask; + +namespace Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_021.ForwardMeteredData.V1; + +internal class Orchestration_Brs_021_ForwardMeteredData_V1 +{ + internal const int ValidatingStep = 1; + internal const int StoringMeteredDataStep = 2; + internal const int FindReceiverStep = 3; + internal const int EnqueueMessagesStep = 4; + + [Function(nameof(Orchestration_Brs_021_ForwardMeteredData_V1))] + public async Task Run( + [OrchestrationTrigger] TaskOrchestrationContext context) + { + var input = context.GetOrchestrationParameterValue(); + + if (input == null) + return "Error: No input specified."; + + await Task.CompletedTask; + + /* + * Activities: + */ + // TODO: Implementing activities coming in next PR. + + return "Success"; + } +} diff --git a/source/ProcessManager.Orchestrations/Program.cs b/source/ProcessManager.Orchestrations/Program.cs index 540ab8f3..a350f976 100644 --- a/source/ProcessManager.Orchestrations/Program.cs +++ b/source/ProcessManager.Orchestrations/Program.cs @@ -20,10 +20,12 @@ using Energinet.DataHub.ProcessManagement.Core.Infrastructure.Extensions.Startup; using Energinet.DataHub.ProcessManagement.Core.Infrastructure.Telemetry; using Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ElectricalHeatingCalculation.V1.Model; +using Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_021.ForwardMeteredData.V1.Model; using Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_023_027.V1.Model; using Energinet.DataHub.ProcessManager.Orchestrations.Abstractions.Processes.BRS_026.V1.Model; using Energinet.DataHub.ProcessManager.Orchestrations.Extensions.DependencyInjection; using Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_021.ElectricalHeatingCalculation.V1; +using Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_021.ForwardMeteredData.V1; using Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_023_027.V1; using Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_026.V1; using Microsoft.Extensions.DependencyInjection; @@ -50,9 +52,11 @@ var brs_021_ElectricalHeatingCalculation_v1 = CreateDescription_Brs_021_ElectricalHeatingCalculation_V1(); var brs_023_027_v1 = CreateBrs_023_027_V1Description(); var brs_026_v1 = CreateBrs_026_V1Description(); + var brs_021_ForwardMeteredData_v1 = CreateBrs_021_ForwardMeteredData_V1Description(); return [ brs_021_ElectricalHeatingCalculation_v1, + brs_021_ForwardMeteredData_v1, brs_023_027_v1, brs_026_v1]; }); @@ -129,3 +133,23 @@ OrchestrationDescription CreateBrs_026_V1Description() return description; } + +OrchestrationDescription CreateBrs_021_ForwardMeteredData_V1Description() +{ + var orchestrationDescriptionUniqueName = new Brs_021_ForwardedMeteredData_V1(); + + var description = new OrchestrationDescription( + uniqueName: new OrchestrationDescriptionUniqueName( + orchestrationDescriptionUniqueName.Name, + orchestrationDescriptionUniqueName.Version), + canBeScheduled: false, + functionName: nameof(Orchestration_Brs_021_ForwardMeteredData_V1)); + + description.ParameterDefinition.SetFromType(); + description.AppendStepDescription("Asynkron validering"); + description.AppendStepDescription("Gemmer"); + description.AppendStepDescription("Finder modtagere"); + description.AppendStepDescription("Udsend beskeder"); + + return description; +}