Skip to content

Commit

Permalink
feat: Typify MDFMPMS-dto in IOMC
Browse files Browse the repository at this point in the history
  • Loading branch information
MWO1024 committed Dec 6, 2024
1 parent 026dd95 commit b15d665
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ private Document ParseFrom(OutgoingMessageHeader header, IReadOnlyCollection<str
{
meteredDataForMeasurementPoints.Add(
new MeteredDataForMeasurementPoint(
activityRecord.TransactionId,
activityRecord.TransactionId.Value,
activityRecord.MarketEvaluationPointNumber,
activityRecord.MarketEvaluationPointType,
activityRecord.OriginalTransactionIdReferenceId,
activityRecord.OriginalTransactionIdReferenceId?.Value,
activityRecord.Product,
activityRecord.QuantityMeasureUnit,
activityRecord.RegistrationDateTime,
activityRecord.QuantityMeasureUnit.Code,
activityRecord.RegistrationDateTime.ToString(),
new Period(
activityRecord.Resolution.Code,
new TimeInterval(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ protected override async Task WriteMarketActivityRecordsAsync(
{
var seriesElement = new XElement(
@namespace + "Series",
new XElement(@namespace + "mRID", activityRecord.TransactionId),
new XElement(@namespace + "mRID", activityRecord.TransactionId.Value),
new XElement(
@namespace + "originalTransactionIDReference_Series.mRID",
activityRecord.OriginalTransactionIdReferenceId),
activityRecord.OriginalTransactionIdReferenceId?.Value),
new XElement(
@namespace + "marketEvaluationPoint.mRID",
new XAttribute("codingScheme", "A10"),
activityRecord.MarketEvaluationPointNumber),
new XElement(@namespace + "marketEvaluationPoint.type", activityRecord.MarketEvaluationPointType),
new XElement(@namespace + "registration_DateAndOrTime.dateTime", activityRecord.RegistrationDateTime),
new XElement(@namespace + "product", activityRecord.Product),
new XElement(@namespace + "quantity_Measure_Unit.name", activityRecord.QuantityMeasureUnit),
new XElement(@namespace + "quantity_Measure_Unit.name", activityRecord.QuantityMeasureUnit.Code),
new XElement(
@namespace + "Period",
new XElement(@namespace + "resolution", activityRecord.Resolution.Code),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
namespace Energinet.DataHub.EDI.OutgoingMessages.Domain.DocumentWriters.RSM012;

public sealed record MeteredDateForMeasurementPointMarketActivityRecord(
string TransactionId,
TransactionId TransactionId,
string MarketEvaluationPointNumber,
string MarketEvaluationPointType,
string? OriginalTransactionIdReferenceId,
TransactionId? OriginalTransactionIdReferenceId,
string Product,
string QuantityMeasureUnit,
string RegistrationDateTime,
MeasurementUnit QuantityMeasureUnit,
Instant RegistrationDateTime,
Resolution Resolution,
Instant StartedDateTime,
Instant EndedDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public sealed record MeteredDataForMeasurementPointMessageSeriesDto(
TransactionId TransactionId,
string MarketEvaluationPointNumber,
string MarketEvaluationPointType,
string? OriginalTransactionIdReferenceId,
TransactionId? OriginalTransactionIdReferenceId,
string Product,
string QuantityMeasureUnit,
string RegistrationDateTime,
MeasurementUnit QuantityMeasureUnit,
Instant RegistrationDateTime,
Resolution Resolution,
Instant StartedDateTime,
Instant EndedDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ await _outgoingMessagesClient.EnqueueAndCommitAsync(
series.MeteringPointType!,
null,
series.ProductNumber!,
series.ProductUnitType!,
marketMessage.CreatedAt,
MeasurementUnit.FromCode(series.ProductUnitType!),
InstantPattern.General.Parse(marketMessage.CreatedAt).Value,
Resolution.FromCode(series.Resolution!),
InstantPattern.Create("yyyy-MM-ddTHH:mm'Z'", CultureInfo.InvariantCulture)
.Parse(series.StartDateTime)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public OutgoingMessageHeader BuildHeader()
public MeteredDateForMeasurementPointMarketActivityRecord BuildMeteredDataForMeasurementPoint()
{
return new MeteredDateForMeasurementPointMarketActivityRecord(
SampleData.TransactionId.Value,
SampleData.TransactionId,
SampleData.MeteringPointNumber,
SampleData.MeteringPointType,
SampleData.OriginalTransactionIdReferenceId,
SampleData.Product,
SampleData.QuantityMeasureUnit,
SampleData.RegistrationDateTime,
Resolution.FromCode(SampleData.Resolution),
InstantPattern.CreateWithInvariantCulture("yyyy-MM-ddTHH:mm'Z'").Parse(SampleData.StartedDateTime).Value,
InstantPattern.CreateWithInvariantCulture("yyyy-MM-ddTHH:mm'Z'").Parse(SampleData.EndedDateTime).Value,
SampleData.Resolution,
SampleData.StartedDateTime,
SampleData.EndedDateTime,
SampleData.Points);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Globalization;
using System.Text.Encodings.Web;
using Energinet.DataHub.EDI.BuildingBlocks.Domain.Models;
using Energinet.DataHub.EDI.BuildingBlocks.Infrastructure.Extensions.DependencyInjection;
Expand Down Expand Up @@ -63,13 +64,13 @@ await AssertDocument(document, DocumentFormat.FromName(documentFormat))
.HasTransactionId(SampleData.TransactionId)
.HasMeteringPointNumber(SampleData.MeteringPointNumber, "A10")
.HasMeteringPointType(SampleData.MeteringPointType)
.HasOriginalTransactionIdReferenceId(SampleData.OriginalTransactionIdReferenceId)
.HasOriginalTransactionIdReferenceId(SampleData.OriginalTransactionIdReferenceId?.Value)
.HasProduct(SampleData.Product)
.HasQuantityMeasureUnit(SampleData.QuantityMeasureUnit)
.HasRegistrationDateTime(SampleData.RegistrationDateTime)
.HasResolution(SampleData.Resolution)
.HasStartedDateTime(SampleData.StartedDateTime)
.HasEndedDateTime(SampleData.EndedDateTime)
.HasQuantityMeasureUnit(SampleData.QuantityMeasureUnit.Code)
.HasRegistrationDateTime(SampleData.RegistrationDateTime.ToString())
.HasResolution(SampleData.Resolution.Code)
.HasStartedDateTime(SampleData.StartedDateTime.ToString("yyyy-MM-dd'T'HH:mm'Z'", CultureInfo.InvariantCulture))
.HasEndedDateTime(SampleData.EndedDateTime.ToString("yyyy-MM-dd'T'HH:mm'Z'", CultureInfo.InvariantCulture))
.HasPoints(SampleData.Points)
.DocumentIsValidAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,19 @@ internal static class SampleData

public static string MeteringPointType => "E17";

public static string? OriginalTransactionIdReferenceId => "C1875000";
public static TransactionId? OriginalTransactionIdReferenceId => TransactionId.From("C1875000");

public static string Product => "8716867000030";

public static string QuantityMeasureUnit => MeasurementUnit.Kwh.Code;
public static MeasurementUnit QuantityMeasureUnit => MeasurementUnit.Kwh;

public static string RegistrationDateTime => "2022-12-17T07:30:00Z";
public static Instant RegistrationDateTime => InstantPattern.General.Parse("2022-12-17T07:30:00Z").Value;

public static string Resolution => "PT1H";
public static Resolution Resolution => Resolution.Hourly;

public static string StartedDateTime => "2022-08-15T22:00Z";
public static Instant StartedDateTime => InstantPattern.General.Parse("2022-08-15T22:00:00Z").Value;

public static string EndedDateTime => "2022-08-15T04:00Z";
public static Instant EndedDateTime => InstantPattern.General.Parse("2022-08-15T04:00:00Z").Value;

public static IReadOnlyList<PointActivityRecord> Points => new List<PointActivityRecord>
{
Expand Down

0 comments on commit b15d665

Please sign in to comment.