-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RequestCalculatedEnergyTimeSeriesTriggerV1
- Loading branch information
1 parent
39a7369
commit e4cf282
Showing
11 changed files
with
317 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
source/ProcessManager.Client/Processes/BRS_026_028/V1/Model/RequestCalculatedDataInputV1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Client.Processes.BRS_026_028.V1.Model; | ||
|
||
public record RequestCalculatedDataInputV1<TInput>( | ||
string MessageId, | ||
TInput Input) | ||
where TInput : class; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ssManager.Orchestrations/Processes/BRS_026/V1/RequestCalculatedEnergyTimeSeriesHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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.Application; | ||
using Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_026.V1.Models; | ||
|
||
namespace Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_026.V1; | ||
|
||
public class RequestCalculatedEnergyTimeSeriesHandler( | ||
IOrchestrationInstanceManager manager) | ||
{ | ||
private readonly IOrchestrationInstanceManager _manager = manager; | ||
|
||
public async Task StartRequestCalculatedEnergyTimeSeriesAsync(RequestCalculatedEnergyTimeSeriesInputV1 input) | ||
{ | ||
await _manager.StartNewOrchestrationInstanceAsync( | ||
"BRS_026", | ||
1, | ||
input, | ||
[]) | ||
.ConfigureAwait(false); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...r.Orchestrations/Processes/BRS_026/V1/RequestCalculatedEnergyTimeSeriesOrchestrationV1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// 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.Processes.BRS_026.V1.Models; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.DurableTask; | ||
|
||
namespace Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_026.V1; | ||
|
||
// TODO: Implement according to guidelines: https://energinet.atlassian.net/wiki/spaces/D3/pages/824803345/Durable+Functions+Development+Guidelines | ||
internal class RequestCalculatedEnergyTimeSeriesOrchestrationV1 | ||
{ | ||
[Function(nameof(RequestCalculatedEnergyTimeSeriesOrchestrationV1))] | ||
public async Task<string> Run( | ||
[OrchestrationTrigger] TaskOrchestrationContext context) | ||
{ | ||
var input = context.GetOrchestrationParameterValue<RequestCalculatedEnergyTimeSeriesInputV1>(); | ||
|
||
if (input == null) | ||
return "Error: No input specified."; | ||
|
||
await Task.CompletedTask; | ||
|
||
/* | ||
* Steps: | ||
* 1. Deserialize input | ||
* 2. Async validation | ||
* 3. Query databricks and upload to storage account | ||
* 4. Enqueue Messages in EDI | ||
* 5. Wait for notify from EDI | ||
* 6. Complete process in database | ||
*/ | ||
|
||
return $"Success (BusinessReason={input.BusinessReason})"; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...Manager.Orchestrations/Processes/BRS_026/V1/RequestCalculatedEnergyTimeSeriesTriggerV1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 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 System.Text.Json; | ||
using Azure.Messaging.ServiceBus; | ||
using Energinet.DataHub.ProcessManager.Orchestrations.Contracts; | ||
using Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_026.V1.Models; | ||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_026.V1; | ||
|
||
public class RequestCalculatedEnergyTimeSeriesTriggerV1( | ||
ILogger<RequestCalculatedEnergyTimeSeriesTriggerV1> logger, | ||
RequestCalculatedEnergyTimeSeriesHandler handler) | ||
{ | ||
private readonly ILogger<RequestCalculatedEnergyTimeSeriesTriggerV1> _logger = logger; | ||
private readonly RequestCalculatedEnergyTimeSeriesHandler _handler = handler; | ||
|
||
/// <summary> | ||
/// Schedule a BRS-023 or BRS-027 calculation and return its id. | ||
/// </summary> | ||
[Function(nameof(RequestCalculatedEnergyTimeSeriesTriggerV1))] | ||
public async Task Run( | ||
[ServiceBusTrigger("queue", Connection = "ServiceBusConnection")] ServiceBusReceivedMessage message) | ||
{ | ||
using var serviceBusMessageLoggerScope = _logger.BeginScope(new | ||
{ | ||
ServiceBusMessage = new | ||
{ | ||
message.MessageId, | ||
message.CorrelationId, | ||
message.Subject, | ||
}, | ||
}); | ||
|
||
var jsonMessage = message.Body.ToString(); | ||
var startOrchestrationDto = StartOrchestrationDto.Parser.ParseJson(jsonMessage); | ||
using var startOrchestrationLoggerScope = _logger.BeginScope(new | ||
{ | ||
StartOrchestration = new | ||
{ | ||
startOrchestrationDto.OrchestrationName, | ||
startOrchestrationDto.OrchestrationVersion, | ||
}, | ||
}); | ||
|
||
var requestCalculatedEnergyTimeSeriesDto = JsonSerializer.Deserialize<RequestCalculatedEnergyTimeSeriesInputV1>(startOrchestrationDto.JsonInput); | ||
if (requestCalculatedEnergyTimeSeriesDto is null) | ||
{ | ||
_logger.LogWarning($"Unable to deserialize {nameof(startOrchestrationDto.JsonInput)} to {nameof(RequestCalculatedEnergyTimeSeriesInputV1)} type:{Environment.NewLine}{0}", startOrchestrationDto.JsonInput); | ||
throw new ArgumentException($"Unable to deserialize {nameof(startOrchestrationDto.JsonInput)} to {nameof(RequestCalculatedEnergyTimeSeriesInputV1)} type"); | ||
} | ||
|
||
await _handler.StartRequestCalculatedEnergyTimeSeriesAsync(requestCalculatedEnergyTimeSeriesDto) | ||
.ConfigureAwait(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.