Skip to content

Commit

Permalink
feat: create orchestration for brs21 metered data (#31)
Browse files Browse the repository at this point in the history
* Added initial BRS021 models and classes
Co-authored-by: Anders Balling Petersen <[email protected]>
  • Loading branch information
MadsDue authored Dec 9, 2024
1 parent d6818f3 commit c9c80dd
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<PropertyGroup>
<PackageId>Energinet.DataHub.ProcessManager.Orchestrations.Abstractions</PackageId>
<PackageVersion>0.1.0$(VersionSuffix)</PackageVersion>
<PackageVersion>0.2.0$(VersionSuffix)</PackageVersion>
<Title>DH3 Process Manager Orchestrations Abstractions library</Title>
<Company>Energinet-DataHub</Company>
<Authors>Energinet-DataHub</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// An immutable input to start the orchestration instance for "BRS_021_ForwardMeteredData" V1.
/// </summary>
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<string>? DelegatedGridAreaCodes,
IReadOnlyCollection<EnergyObservation> EnergyObservations)
: IInputParameterDto;
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Command for starting a BRS-021-ForwardMeteredData.
/// Must be JSON serializable.
/// </summary>
public record StartForwardMeteredDataCommandV1
: StartOrchestrationInstanceCommand<ActorIdentityDto, MeteredDataForMeasurementPointMessageInputV1>
{
/// <summary>
/// Construct command.
/// </summary>
/// <param name="operatingIdentity">Identity of the user executing the command.</param>
/// <param name="inputParameter">Contains the Durable Functions orchestration input parameter value.</param>
public StartForwardMeteredDataCommandV1(
ActorIdentityDto operatingIdentity,
MeteredDataForMeasurementPointMessageInputV1 inputParameter)
: base(
operatingIdentity,
orchestrationDescriptionUniqueName: new Brs_021_ForwardedMeteredData_V1(),
inputParameter)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Api\Mappers\" />
<Folder Include="Processes\BRS_021\ForwardMeteredData\" />
<Folder Include="Processes\BRS_026\V1\Activities\" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string> Run(
[OrchestrationTrigger] TaskOrchestrationContext context)
{
var input = context.GetOrchestrationParameterValue<MeteredDataForMeasurementPointMessageInputV1>();

if (input == null)
return "Error: No input specified.";

await Task.CompletedTask;

/*
* Activities:
*/
// TODO: Implementing activities coming in next PR.

return "Success";
}
}
24 changes: 24 additions & 0 deletions source/ProcessManager.Orchestrations/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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];
});
Expand Down Expand Up @@ -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<MeteredDataForMeasurementPointMessageInputV1>();
description.AppendStepDescription("Asynkron validering");
description.AppendStepDescription("Gemmer");
description.AppendStepDescription("Finder modtagere");
description.AppendStepDescription("Udsend beskeder");

return description;
}

0 comments on commit c9c80dd

Please sign in to comment.