-
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.
Merge branch 'main' into xedkn/edi-start-request-process
- Loading branch information
Showing
98 changed files
with
1,107 additions
and
394 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
8 changes: 2 additions & 6 deletions
8
source/ArchivedMessages.Application/ArchivedMessages.Application.csproj
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
43 changes: 43 additions & 0 deletions
43
source/ArchivedMessages.Application/Mapping/ArchivedMessageMapper.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,43 @@ | ||
// 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.EDI.ArchivedMessages.Domain.Exceptions; | ||
using Energinet.DataHub.EDI.ArchivedMessages.Domain.Models; | ||
using Energinet.DataHub.EDI.ArchivedMessages.Interfaces.Models; | ||
using Energinet.DataHub.EDI.BuildingBlocks.Domain.Validation; | ||
|
||
namespace Energinet.DataHub.EDI.ArchivedMessages.Application.Mapping; | ||
|
||
public static class ArchivedMessageMapper | ||
{ | ||
public static ArchivedMessage Map(ArchivedMessageDto dto) | ||
{ | ||
return !EnumCompatibilityChecker.AreEnumsCompatible<ArchivedMessageType, ArchivedMessageTypeDto>() | ||
? throw new InvalidEnumMappingException($"Enum of type {nameof(ArchivedMessageType)} cannot be mapped to type {nameof(ArchivedMessageTypeDto)}.") | ||
: new ArchivedMessage( | ||
id: new ArchivedMessageId(dto.Id.Value), | ||
messageId: dto.MessageId, | ||
eventIds: dto.EventIds, | ||
documentType: dto.DocumentType, | ||
senderNumber: dto.SenderNumber, | ||
senderRole: dto.SenderRole, | ||
receiverNumber: dto.ReceiverNumber, | ||
receiverRole: dto.ReceiverRole, | ||
createdAt: dto.CreatedAt, | ||
businessReason: dto.BusinessReason, | ||
archivedMessageType: (ArchivedMessageType)dto.ArchivedMessageType, | ||
archivedMessageStream: new ArchivedMessageStream(dto.ArchivedMessageStream.Stream), | ||
relatedToMessageId: dto.RelatedToMessageId); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
source/ArchivedMessages.Application/Mapping/GetMessagesQueryMapper.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,74 @@ | ||
// 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.EDI.ArchivedMessages.Domain.Models; | ||
using Energinet.DataHub.EDI.ArchivedMessages.Interfaces.Models; | ||
|
||
namespace Energinet.DataHub.EDI.ArchivedMessages.Application.Mapping; | ||
|
||
internal static class GetMessagesQueryMapper | ||
{ | ||
internal static GetMessagesQuery Map(GetMessagesQueryDto dto) | ||
{ | ||
return new GetMessagesQuery( | ||
Pagination: SetSortedCursorBasedPagination(dto.Pagination), | ||
CreationPeriod: SetMessageCreationPeriod(dto.CreationPeriod), | ||
MessageId: dto.MessageId, | ||
SenderNumber: dto.SenderNumber, | ||
SenderRoleCode: dto.SenderRoleCode, | ||
ReceiverNumber: dto.ReceiverNumber, | ||
ReceiverRoleCode: dto.ReceiverRoleCode, | ||
DocumentTypes: dto.DocumentTypes, | ||
BusinessReasons: dto.BusinessReasons, | ||
IncludeRelatedMessages: dto.IncludeRelatedMessages); | ||
} | ||
|
||
private static SortedCursorBasedPagination SetSortedCursorBasedPagination(SortedCursorBasedPaginationDto dto) | ||
{ | ||
return new SortedCursorBasedPagination( | ||
cursor: SetSortingCursor(dto.Cursor), | ||
pageSize: dto.PageSize, | ||
navigationForward: dto.NavigationForward, | ||
fieldToSortBy: SetFieldToSortBy(dto.FieldToSortBy), | ||
directionToSortBy: SetDirectionToSortBy(dto.DirectionToSortBy)); | ||
} | ||
|
||
private static MessageCreationPeriod? SetMessageCreationPeriod(MessageCreationPeriodDto? messageCreationPeriod) | ||
{ | ||
return messageCreationPeriod is not null | ||
? new MessageCreationPeriod(messageCreationPeriod.DateToSearchFrom, messageCreationPeriod.DateToSearchTo) | ||
: null; | ||
} | ||
|
||
private static SortingCursor? SetSortingCursor(SortingCursorDto? sortingCursor) | ||
{ | ||
return sortingCursor is not null | ||
? new SortingCursor(sortingCursor.SortedFieldValue, sortingCursor.RecordId) | ||
: null; | ||
} | ||
|
||
private static FieldToSortBy? SetFieldToSortBy(FieldToSortByDto? fieldToSortBy) | ||
{ | ||
return fieldToSortBy is not null | ||
? new FieldToSortBy(fieldToSortBy.Value.Identifier) | ||
: null; | ||
} | ||
|
||
private static DirectionToSortBy? SetDirectionToSortBy(DirectionToSortByDto? directionToSortBy) | ||
{ | ||
return directionToSortBy is not null | ||
? new DirectionToSortBy(directionToSortBy.Value.Identifier) | ||
: null; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
source/ArchivedMessages.Application/Mapping/MessagesSearchResultMapper.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,44 @@ | ||
// 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.Collections.ObjectModel; | ||
using Energinet.DataHub.EDI.ArchivedMessages.Domain.Models; | ||
using Energinet.DataHub.EDI.ArchivedMessages.Interfaces.Models; | ||
|
||
namespace Energinet.DataHub.EDI.ArchivedMessages.Application.Mapping; | ||
|
||
internal static class MessagesSearchResultMapper | ||
{ | ||
internal static MessageSearchResultDto Map(MessageSearchResult messageSearchResult) | ||
{ | ||
return new MessageSearchResultDto(SetMessageInfoCollection(messageSearchResult.Messages), messageSearchResult.TotalAmountOfMessages); | ||
} | ||
|
||
private static ReadOnlyCollection<MessageInfoDto> SetMessageInfoCollection(IReadOnlyCollection<MessageInfo> collection) | ||
{ | ||
return collection.Select(mi => new MessageInfoDto( | ||
RecordId: mi.RecordId, | ||
Id: mi.Id, | ||
MessageId: mi.MessageId, | ||
DocumentType: mi.DocumentType, | ||
SenderNumber: mi.SenderNumber, | ||
SenderRoleCode: mi.SenderRoleCode, | ||
ReceiverNumber: mi.ReceiverNumber, | ||
ReceiverRoleCode: mi.ReceiverRoleCode, | ||
CreatedAt: mi.CreatedAt, | ||
BusinessReason: mi.BusinessReason)) | ||
.ToList() | ||
.AsReadOnly(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
source/ArchivedMessages.Domain/ArchivedMessages.Domain.csproj
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<AssemblyName>Energinet.DataHub.EDI.ArchivedMessages.Domain</AssemblyName> | ||
<RootNamespace>Energinet.DataHub.EDI.ArchivedMessages.Domain</RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.11.20"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\BuildingBlocks.Domain\BuildingBlocks.Domain.csproj" /> | ||
</ItemGroup> | ||
</Project> |
32 changes: 32 additions & 0 deletions
32
source/ArchivedMessages.Domain/Exceptions/InvalidEnumMappingException.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,32 @@ | ||
// 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.EDI.ArchivedMessages.Domain.Exceptions; | ||
|
||
public class InvalidEnumMappingException : Exception | ||
{ | ||
public InvalidEnumMappingException() | ||
{ | ||
} | ||
|
||
public InvalidEnumMappingException(string message) | ||
: base(message) | ||
{ | ||
} | ||
|
||
public InvalidEnumMappingException(string message, Exception innerException) | ||
: base(message, innerException) | ||
{ | ||
} | ||
} |
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
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.