Skip to content

Commit c19f47a

Browse files
arealmaasoskogstad
andauthored
feat(schema): undo setting performed by if not set (#802)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue(s) - #760 - Reverting #628 - Changing PerformedBy to be a string value ## Verification - [X] **Your** code builds clean without any errors or warnings - [X] Manual testing done (required) - [x] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) --------- Co-authored-by: Ole Jørgen Skogstad <skogstad@softis.net>
1 parent 47e377a commit c19f47a

File tree

30 files changed

+1424
-190
lines changed

30 files changed

+1424
-190
lines changed

docs/schema/V1/schema.verified.graphql

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Activity {
1717
type: ActivityType!
1818
relatedActivityId: UUID
1919
dialogElementId: UUID
20-
performedBy: [Localization!]
20+
performedBy: String
2121
description: [Localization!]!
2222
}
2323

@@ -289,4 +289,4 @@ scalar DateTime @specifiedBy(url: "https:\/\/www.graphql-scalars.com\/date-time"
289289

290290
scalar URL @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc3986")
291291

292-
scalar UUID @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc4122")
292+
scalar UUID @specifiedBy(url: "https:\/\/tools.ietf.org\/html\/rfc4122")

docs/schema/V1/swagger.verified.json

+13-37
Original file line numberDiff line numberDiff line change
@@ -322,16 +322,7 @@
322322
"Type": 3,
323323
"RelatedActivityId": null,
324324
"DialogElementId": null,
325-
"PerformedBy": [
326-
{
327-
"Value": "Some performer",
328-
"CultureCode": "en-us"
329-
},
330-
{
331-
"Value": "En utfører",
332-
"CultureCode": "nb-no"
333-
}
334-
],
325+
"PerformedBy": "Some performed",
335326
"Description": [
336327
{
337328
"Value": "Some description",
@@ -2809,10 +2800,8 @@
28092800
"nullable": true
28102801
},
28112802
"performedBy": {
2812-
"type": "array",
2813-
"items": {
2814-
"$ref": "#/components/schemas/LocalizationDto"
2815-
}
2803+
"type": "string",
2804+
"nullable": true
28162805
},
28172806
"description": {
28182807
"type": "array",
@@ -3308,11 +3297,8 @@
33083297
"nullable": true
33093298
},
33103299
"performedBy": {
3311-
"type": "array",
3312-
"nullable": true,
3313-
"items": {
3314-
"$ref": "#/components/schemas/LocalizationDto"
3315-
}
3300+
"type": "string",
3301+
"nullable": true
33163302
},
33173303
"description": {
33183304
"type": "array",
@@ -3642,10 +3628,8 @@
36423628
"nullable": true
36433629
},
36443630
"performedBy": {
3645-
"type": "array",
3646-
"items": {
3647-
"$ref": "#/components/schemas/LocalizationDto"
3648-
}
3631+
"type": "string",
3632+
"nullable": true
36493633
},
36503634
"description": {
36513635
"type": "array",
@@ -3761,10 +3745,8 @@
37613745
"nullable": true
37623746
},
37633747
"performedBy": {
3764-
"type": "array",
3765-
"items": {
3766-
"$ref": "#/components/schemas/LocalizationDto"
3767-
}
3748+
"type": "string",
3749+
"nullable": true
37683750
},
37693751
"description": {
37703752
"type": "array",
@@ -3997,11 +3979,8 @@
39973979
"nullable": true
39983980
},
39993981
"performedBy": {
4000-
"type": "array",
4001-
"nullable": true,
4002-
"items": {
4003-
"$ref": "#/components/schemas/LocalizationDto"
4004-
}
3982+
"type": "string",
3983+
"nullable": true
40053984
},
40063985
"description": {
40073986
"type": "array",
@@ -4380,11 +4359,8 @@
43804359
"nullable": true
43814360
},
43824361
"performedBy": {
4383-
"type": "array",
4384-
"nullable": true,
4385-
"items": {
4386-
"$ref": "#/components/schemas/LocalizationDto"
4387-
}
4362+
"type": "string",
4363+
"nullable": true
43884364
},
43894365
"description": {
43904366
"type": "array",

src/Digdir.Domain.Dialogporten.Application/ApplicationExtensions.cs

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Digdir.Domain.Dialogporten.Application.Common.Behaviours;
33
using Digdir.Domain.Dialogporten.Application.Common.Extensions;
44
using Digdir.Domain.Dialogporten.Application.Common.Extensions.OptionExtensions;
5-
using Digdir.Domain.Dialogporten.Application.Common.Services;
65
using FluentValidation;
76
using MediatR;
87
using Microsoft.Extensions.Configuration;
@@ -45,7 +44,6 @@ public static IServiceCollection AddApplication(this IServiceCollection services
4544
.AddTransient<IUserResourceRegistry, UserResourceRegistry>()
4645
.AddTransient<IUserRegistry, UserRegistry>()
4746
.AddTransient<IUserParties, UserParties>()
48-
.AddTransient<IDialogActivityService, DialogActivityService>()
4947
.AddTransient<IClock, Clock>()
5048
.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>))
5149
.AddTransient(typeof(IPipelineBehavior<,>), typeof(DomainContextBehaviour<,>));

src/Digdir.Domain.Dialogporten.Application/Common/IUserOrganizationRegistry.cs

-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ namespace Digdir.Domain.Dialogporten.Application.Common;
77
public interface IUserOrganizationRegistry
88
{
99
Task<string?> GetCurrentUserOrgShortName(CancellationToken cancellationToken);
10-
Task<IList<ServiceOwnerLongName>?> GetCurrentUserOrgLongNames(CancellationToken cancellationToken);
1110
}
1211

1312
public class UserOrganizationRegistry : IUserOrganizationRegistry
@@ -33,24 +32,11 @@ public UserOrganizationRegistry(IUser user, IServiceOwnerNameRegistry serviceOwn
3332
return orgInfo?.ShortName;
3433
}
3534

36-
public async Task<IList<ServiceOwnerLongName>?> GetCurrentUserOrgLongNames(CancellationToken cancellationToken)
37-
{
38-
if (!_user.TryGetOrganizationNumber(out var orgNumber))
39-
{
40-
return null;
41-
}
42-
43-
var orgInfo = await _serviceOwnerNameRegistry.GetServiceOwnerInfo(orgNumber, cancellationToken);
44-
45-
return orgInfo?.LongNames.ToArray();
46-
}
4735
}
4836

4937
internal sealed class LocalDevelopmentUserOrganizationRegistryDecorator : IUserOrganizationRegistry
5038
{
5139
public LocalDevelopmentUserOrganizationRegistryDecorator(IUserOrganizationRegistry _) { }
5240

5341
public Task<string?> GetCurrentUserOrgShortName(CancellationToken cancellationToken) => Task.FromResult("digdir")!;
54-
public Task<IList<ServiceOwnerLongName>?> GetCurrentUserOrgLongNames(CancellationToken cancellationToken) =>
55-
Task.FromResult<IList<ServiceOwnerLongName>?>(new[] { new ServiceOwnerLongName { LongName = "Digdir", Language = "nb" } });
5642
}

src/Digdir.Domain.Dialogporten.Application/Common/Services/DialogActivityService.cs

-34
This file was deleted.

src/Digdir.Domain.Dialogporten.Application/Externals/IServiceOwnerNameRegistry.cs

-7
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,8 @@ public interface IServiceOwnerNameRegistry
55
Task<ServiceOwnerInfo?> GetServiceOwnerInfo(string orgNumber, CancellationToken cancellationToken);
66
}
77

8-
public sealed class ServiceOwnerLongName
9-
{
10-
public required string LongName { get; init; }
11-
public required string Language { get; init; }
12-
}
13-
148
public sealed class ServiceOwnerInfo
159
{
1610
public required string OrgNumber { get; init; }
1711
public required string ShortName { get; init; }
18-
public required IList<ServiceOwnerLongName> LongNames { get; init; }
1912
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogActivities/Queries/Get/GetDialogActivityDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public sealed class GetDialogActivityDto
1414
public Guid? RelatedActivityId { get; set; }
1515
public Guid? DialogElementId { get; set; }
1616

17-
public List<LocalizationDto>? PerformedBy { get; set; } = [];
17+
public string? PerformedBy { get; set; }
1818
public List<LocalizationDto> Description { get; set; } = [];
1919
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/GetDialogDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public sealed class GetDialogDialogActivityDto
6767
public Guid? RelatedActivityId { get; set; }
6868
public Guid? DialogElementId { get; set; }
6969

70-
public List<LocalizationDto>? PerformedBy { get; set; } = [];
70+
public string? PerformedBy { get; set; }
7171
public List<LocalizationDto> Description { get; set; } = [];
7272
}
7373

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/GetDialogQuery.cs

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ public async Task<GetDialogResult> Handle(GetDialogQuery request, CancellationTo
7070
.ThenInclude(x => x.Title!.Localizations.OrderBy(x => x.CreatedAt).ThenBy(x => x.CultureCode))
7171
.Include(x => x.ApiActions.OrderBy(x => x.CreatedAt).ThenBy(x => x.Id))
7272
.ThenInclude(x => x.Endpoints.OrderBy(x => x.CreatedAt).ThenBy(x => x.Id))
73-
.Include(x => x.Activities).ThenInclude(x => x.PerformedBy!.Localizations)
7473
.Include(x => x.Activities).ThenInclude(x => x.Description!.Localizations)
7574
.Include(x => x.SeenLog
7675
.Where(x => x.CreatedAt >= x.Dialog.UpdatedAt)

src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Search/SearchDialogDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public sealed class SearchDialogDialogActivityDto
5656
public Guid? RelatedActivityId { get; set; }
5757
public Guid? DialogElementId { get; set; }
5858

59-
public List<LocalizationDto>? PerformedBy { get; set; } = [];
59+
public string? PerformedBy { get; set; }
6060
public List<LocalizationDto> Description { get; set; } = [];
6161
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/DialogActivities/Queries/Get/GetDialogActivityDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public sealed class GetDialogActivityDto
1616
public Guid? RelatedActivityId { get; set; }
1717
public Guid? DialogElementId { get; set; }
1818

19-
public List<LocalizationDto>? PerformedBy { get; set; } = [];
19+
public string? PerformedBy { get; set; }
2020
public List<LocalizationDto> Description { get; set; } = [];
2121
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using AutoMapper;
33
using Digdir.Domain.Dialogporten.Application.Common;
44
using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes;
5-
using Digdir.Domain.Dialogporten.Application.Common.Services;
65
using Digdir.Domain.Dialogporten.Application.Externals;
76
using Digdir.Domain.Dialogporten.Domain.Common;
87
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
@@ -30,7 +29,6 @@ internal sealed class CreateDialogCommandHandler : IRequestHandler<CreateDialogC
3029
private readonly IDomainContext _domainContext;
3130
private readonly IUserResourceRegistry _userResourceRegistry;
3231
private readonly IUserOrganizationRegistry _userOrganizationRegistry;
33-
private readonly IDialogActivityService _dialogActivityService;
3432

3533
internal static readonly ValidationFailure ProgressValidationFailure = new(nameof(CreateDialogCommand.Progress), "Progress cannot be set for correspondence dialogs.");
3634

@@ -40,16 +38,14 @@ public CreateDialogCommandHandler(
4038
IUnitOfWork unitOfWork,
4139
IDomainContext domainContext,
4240
IUserResourceRegistry userResourceRegistry,
43-
IUserOrganizationRegistry userOrganizationRegistry,
44-
IDialogActivityService dialogActivityService)
41+
IUserOrganizationRegistry userOrganizationRegistry)
4542
{
4643
_db = db ?? throw new ArgumentNullException(nameof(db));
4744
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
4845
_unitOfWork = unitOfWork ?? throw new ArgumentNullException(nameof(unitOfWork));
4946
_domainContext = domainContext ?? throw new ArgumentNullException(nameof(domainContext));
5047
_userResourceRegistry = userResourceRegistry ?? throw new ArgumentNullException(nameof(userResourceRegistry));
5148
_userOrganizationRegistry = userOrganizationRegistry ?? throw new ArgumentNullException(nameof(userOrganizationRegistry));
52-
_dialogActivityService = dialogActivityService ?? throw new ArgumentNullException(nameof(dialogActivityService));
5349
}
5450

5551
public async Task<CreateDialogResult> Handle(CreateDialogCommand request, CancellationToken cancellationToken)
@@ -101,8 +97,6 @@ public async Task<CreateDialogResult> Handle(CreateDialogCommand request, Cancel
10197
_domainContext.AddError(DomainFailure.EntityExists<DialogElement>(existingElementIds));
10298
}
10399

104-
await _dialogActivityService.EnsurePerformedByIsSetForActivities(dialog.Activities, cancellationToken);
105-
106100
await _db.Dialogs.AddAsync(dialog, cancellationToken);
107101

108102
var saveResult = await _unitOfWork.SaveChangesAsync(cancellationToken);

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommandValidator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public CreateDialogDialogActivityDtoValidator(
269269
.NotEqual(x => x.Id)
270270
.When(x => x.RelatedActivityId.HasValue);
271271
RuleFor(x => x.PerformedBy)
272-
.SetValidator(localizationsValidator);
272+
.MaximumLength(Constants.DefaultMaxStringLength);
273273
RuleFor(x => x.Description)
274274
.NotEmpty()
275275
.SetValidator(localizationsValidator);

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public sealed class CreateDialogDialogActivityDto
5353
public Guid? RelatedActivityId { get; set; }
5454
public Guid? DialogElementId { get; set; }
5555

56-
public List<LocalizationDto> PerformedBy { get; set; } = [];
56+
public string? PerformedBy { get; set; }
5757
public List<LocalizationDto> Description { get; set; } = [];
5858
}
5959

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommand.cs

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Digdir.Domain.Dialogporten.Application.Common.Extensions.Enumerables;
44
using Digdir.Domain.Dialogporten.Application.Common.ResourceRegistry;
55
using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes;
6-
using Digdir.Domain.Dialogporten.Application.Common.Services;
76
using Digdir.Domain.Dialogporten.Application.Externals;
87
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
98
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Actions;
@@ -35,7 +34,6 @@ internal sealed class UpdateDialogCommandHandler : IRequestHandler<UpdateDialogC
3534
private readonly IUnitOfWork _unitOfWork;
3635
private readonly IDomainContext _domainContext;
3736
private readonly IUserResourceRegistry _userResourceRegistry;
38-
private readonly IDialogActivityService _dialogActivityService;
3937

4038
private readonly ValidationFailure _progressValidationFailure = new(nameof(UpdateDialogDto.Progress), "Progress cannot be set for correspondence dialogs.");
4139

@@ -44,15 +42,13 @@ public UpdateDialogCommandHandler(
4442
IMapper mapper,
4543
IUnitOfWork unitOfWork,
4644
IDomainContext domainContext,
47-
IUserResourceRegistry userResourceRegistry,
48-
IDialogActivityService dialogActivityService)
45+
IUserResourceRegistry userResourceRegistry)
4946
{
5047
_db = db ?? throw new ArgumentNullException(nameof(db));
5148
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
5249
_unitOfWork = unitOfWork ?? throw new ArgumentNullException(nameof(unitOfWork));
5350
_domainContext = domainContext ?? throw new ArgumentNullException(nameof(domainContext));
5451
_userResourceRegistry = userResourceRegistry ?? throw new ArgumentNullException(nameof(userResourceRegistry));
55-
_dialogActivityService = dialogActivityService ?? throw new ArgumentNullException(nameof(dialogActivityService));
5652
}
5753

5854
public async Task<UpdateDialogResult> Handle(UpdateDialogCommand request, CancellationToken cancellationToken)
@@ -184,9 +180,6 @@ private async Task AppendActivity(DialogEntity dialog, UpdateDialogDto dto, Canc
184180
{
185181
var newDialogActivities = _mapper.Map<List<DialogActivity>>(dto.Activities);
186182

187-
188-
await _dialogActivityService.EnsurePerformedByIsSetForActivities(newDialogActivities, cancellationToken);
189-
190183
var existingIds = await _db.GetExistingIds(newDialogActivities, cancellationToken);
191184
if (existingIds.Count != 0)
192185
{

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogCommandValidator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ public UpdateDialogDialogActivityDtoValidator(
268268
.NotEqual(x => x.Id)
269269
.When(x => x.RelatedActivityId.HasValue);
270270
RuleFor(x => x.PerformedBy)
271-
.SetValidator(localizationsValidator);
271+
.MaximumLength(Constants.DefaultMaxStringLength);
272272
RuleFor(x => x.Description)
273273
.NotEmpty()
274274
.SetValidator(localizationsValidator);

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class UpdateDialogDialogActivityDto
5151
public Guid? RelatedActivityId { get; set; }
5252
public Guid? DialogElementId { get; set; }
5353

54-
public List<LocalizationDto> PerformedBy { get; set; } = [];
54+
public string? PerformedBy { get; set; }
5555
public List<LocalizationDto> Description { get; set; } = [];
5656
}
5757

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogDto.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public sealed class GetDialogDialogActivityDto
7272
public Guid? RelatedActivityId { get; set; }
7373
public Guid? DialogElementId { get; set; }
7474

75-
public List<LocalizationDto>? PerformedBy { get; set; } = [];
75+
public string? PerformedBy { get; set; }
7676
public List<LocalizationDto> Description { get; set; } = [];
7777
}
7878

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Get/GetDialogQuery.cs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public async Task<GetDialogResult> Handle(GetDialogQuery request, CancellationTo
5656
.ThenInclude(x => x.Title!.Localizations.OrderBy(x => x.CreatedAt).ThenBy(x => x.CultureCode))
5757
.Include(x => x.ApiActions.OrderBy(x => x.CreatedAt).ThenBy(x => x.Id))
5858
.ThenInclude(x => x.Endpoints.OrderBy(x => x.CreatedAt).ThenBy(x => x.Id))
59-
.Include(x => x.Activities).ThenInclude(x => x.PerformedBy!.Localizations)
6059
.Include(x => x.Activities).ThenInclude(x => x.Description!.Localizations)
6160
.Include(x => x.SeenLog
6261
.Where(x => x.CreatedAt >= x.Dialog.UpdatedAt)

0 commit comments

Comments
 (0)