Skip to content

Commit

Permalink
feat(breaking): Renaming dialog activity types (#919)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
- Adds validation that ensures Description only can be set if Type is
Information
- Rename values for DialogActivity according to issue
- Fix tests and add migration for the refactor

<!--- Describe your changes in detail -->

## Related Issue(s)

- #858 

## Verification

- [ ] **Your** code builds clean without any errors or warnings
- [ ] Manual testing done (required)
- [ ] 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>
  • Loading branch information
arealmaas and oskogstad authored Jul 25, 2024
1 parent 5b45539 commit af262b1
Showing 14 changed files with 1,569 additions and 94 deletions.
22 changes: 11 additions & 11 deletions docs/schema/V1/schema.verified.graphql
Original file line number Diff line number Diff line change
@@ -230,18 +230,18 @@ input SearchDialogInput {
}

enum ActivityType {
"Refers to a submission made by a party that has been received by the service provider."
SUBMISSION
"Indicates feedback from the service provider on a submission. Contains a reference to the current submission."
FEEDBACK
"Information from the service provider, not (directly) related to any submission."
"Refers to a dialog that has been created."
DIALOG_CREATED
"Refers to a dialog that has been closed."
DIALOG_CLOSED
"Information from the service provider, not (directly) related to any transmission."
INFORMATION
"Used to indicate an error situation, typically on a submission. Contains a service-specific activityErrorCode."
ERROR
"Indicates that the dialog is closed for further changes. This typically happens when the dialog is completed or deleted."
CLOSED
"When the dialog is forwarded (delegated access) by someone with access to others."
FORWARDED
"Refers to a transmission that has been opened."
TRANSMISSION_OPENED
"Indicates that payment has been made."
PAYMENT_MADE
"Indicates that a signature has been provided."
SIGNATURE_PROVIDED
}

enum ActorType {
22 changes: 11 additions & 11 deletions docs/schema/V1/swagger.verified.json
Original file line number Diff line number Diff line change
@@ -2350,20 +2350,20 @@
"type": "string",
"description": "",
"x-enumNames": [
"Submission",
"Feedback",
"DialogCreated",
"DialogClosed",
"Information",
"Error",
"Closed",
"Forwarded"
"TransmissionOpened",
"PaymentMade",
"SignatureProvided"
],
"enum": [
"Submission",
"Feedback",
"DialogCreated",
"DialogClosed",
"Information",
"Error",
"Closed",
"Forwarded"
"TransmissionOpened",
"PaymentMade",
"SignatureProvided"
]
},
"UpdateDialogDialogActivityActorDto": {
@@ -4166,4 +4166,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@ internal static class CloudEventTypes
nameof(DialogSeenDomainEvent) => "dialogporten.dialog.seen.v1",

// Dialog activity
nameof(DialogActivityType.Values.Submission) => "dialogporten.dialog.activity.submission.v1",
nameof(DialogActivityType.Values.Feedback) => "dialogporten.dialog.activity.feedback.v1",
nameof(DialogActivityType.Values.DialogCreated) => "dialogporten.dialog.activity.created.v1",
nameof(DialogActivityType.Values.DialogClosed) => "dialogporten.dialog.activity.closed.v1",
nameof(DialogActivityType.Values.Information) => "dialogporten.dialog.activity.information.v1",
nameof(DialogActivityType.Values.Error) => "dialogporten.dialog.activity.error.v1",
nameof(DialogActivityType.Values.Closed) => "dialogporten.dialog.activity.closed.v1",
nameof(DialogActivityType.Values.Forwarded) => "dialogporten.dialog.activity.forwarded.v1",
nameof(DialogActivityType.Values.TransmissionOpened) => "dialogporten.dialog.activity.transmission-opened.v1",
nameof(DialogActivityType.Values.PaymentMade) => "dialogporten.dialog.activity.payment-made.v1",
nameof(DialogActivityType.Values.SignatureProvided) => "dialogporten.dialog.activity.signature-provided.v1",

_ => throw new ArgumentOutOfRangeException(nameof(eventName), eventName, null)
};
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@ public MappingProfile()
CreateMap<IntermediateSearchDialogDto, SearchDialogDto>();
CreateMap<DialogEntity, IntermediateSearchDialogDto>()
.ForMember(dest => dest.LatestActivity, opt => opt.MapFrom(src => src.Activities
.Where(activity => activity.TypeId != DialogActivityType.Values.Forwarded)
.OrderByDescending(activity => activity.CreatedAt).ThenByDescending(activity => activity.Id)
.FirstOrDefault()
))
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Localizations;
using Digdir.Domain.Dialogporten.Domain.Common;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Actions;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Activities;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Actors;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Content;
using Digdir.Domain.Dialogporten.Domain.Http;
@@ -281,7 +282,13 @@ public CreateDialogDialogActivityDtoValidator(
.SetValidator(actorValidator);
RuleFor(x => x.Description)
.NotEmpty()
.SetValidator(localizationsValidator);
.WithMessage("Description is required when the type is '" + nameof(DialogActivityType.Values.Information) + "'.")
.SetValidator(localizationsValidator)
.When(x => x.Type == DialogActivityType.Values.Information);
RuleFor(x => x.Description)
.Empty()
.WithMessage("Description is only allowed when the type is '" + nameof(DialogActivityType.Values.Information) + "'.")
.When(x => x.Type != DialogActivityType.Values.Information);
}
}

Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
using Digdir.Domain.Dialogporten.Application.Features.V1.Common.Localizations;
using Digdir.Domain.Dialogporten.Domain.Common;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Actions;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Activities;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Actors;
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities.Content;
using Digdir.Domain.Dialogporten.Domain.Http;
@@ -280,7 +281,13 @@ public UpdateDialogDialogActivityDtoValidator(
.SetValidator(actorValidator);
RuleFor(x => x.Description)
.NotEmpty()
.SetValidator(localizationsValidator);
.WithMessage("Description is required when the type is '" + nameof(DialogActivityType.Values.Information) + "'.")
.SetValidator(localizationsValidator)
.When(x => x.Type == DialogActivityType.Values.Information);
RuleFor(x => x.Description)
.Empty()
.WithMessage("Description is only allowed when the type is '" + nameof(DialogActivityType.Values.Information) + "'.")
.When(x => x.Type != DialogActivityType.Values.Information);
}
}

Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ public MappingProfile()
CreateMap<IntermediateSearchDialogDto, SearchDialogDto>();
CreateMap<DialogEntity, IntermediateSearchDialogDto>()
.ForMember(dest => dest.LatestActivity, opt => opt.MapFrom(src => src.Activities
.Where(activity => activity.TypeId != DialogActivityType.Values.Forwarded)
.OrderByDescending(activity => activity.CreatedAt).ThenByDescending(activity => activity.Id)
.FirstOrDefault()
))
Original file line number Diff line number Diff line change
@@ -10,36 +10,33 @@ public DialogActivityType(Values id) : base(id) { }
public enum Values
{
/// <summary>
/// Refererer en innsending utført av party som er mottatt hos tjenestetilbyder.
/// Refers to a dialog that has been created.
/// </summary>
Submission = 1,
DialogCreated = 1,

/// <summary>
/// Indikerer en tilbakemelding fra tjenestetilbyder på en innsending. Inneholder
/// referanse til den aktuelle innsendingen.
/// Refers to a dialog that has been closed.
/// </summary>
Feedback = 2,
DialogClosed = 2,

/// <summary>
/// Informasjon fra tjenestetilbyder, ikke (direkte) relatert til noen innsending.
/// Information from the service provider, not (directly) related to any transmission.
/// </summary>
Information = 3,

/// <summary>
/// Brukes for å indikere en feilsituasjon, typisk på en innsending. Inneholder en
/// tjenestespesifikk activityErrorCode.
/// Refers to a transmission that has been opened.
/// </summary>
Error = 4,
TransmissionOpened = 4,

/// <summary>
/// Indikerer at dialogen er lukket for videre endring. Dette skjer typisk ved fullføring
/// av dialogen, eller sletting.
/// Indicates that payment has been made.
/// </summary>
Closed = 5,
PaymentMade = 5,

/// <summary>
/// Når dialogen blir videresendt (tilgang delegert) av noen med tilgang til andre.
/// Indicates that a signature has been provided.
/// </summary>
Forwarded = 7
SignatureProvided = 6
}
}
Original file line number Diff line number Diff line change
@@ -52,23 +52,23 @@ public enum ActorType

public enum ActivityType
{
[GraphQLDescription("Refers to a submission made by a party that has been received by the service provider.")]
Submission = 1,
[GraphQLDescription("Refers to a dialog that has been created.")]
DialogCreated = 1,

[GraphQLDescription("Indicates feedback from the service provider on a submission. Contains a reference to the current submission.")]
Feedback = 2,
[GraphQLDescription("Refers to a dialog that has been closed.")]
DialogClosed = 2,

[GraphQLDescription("Information from the service provider, not (directly) related to any submission.")]
[GraphQLDescription("Information from the service provider, not (directly) related to any transmission.")]
Information = 3,

[GraphQLDescription("Used to indicate an error situation, typically on a submission. Contains a service-specific activityErrorCode.")]
Error = 4,
[GraphQLDescription("Refers to a transmission that has been opened.")]
TransmissionOpened = 4,

[GraphQLDescription("Indicates that the dialog is closed for further changes. This typically happens when the dialog is completed or deleted.")]
Closed = 5,
[GraphQLDescription("Indicates that payment has been made.")]
PaymentMade = 5,

[GraphQLDescription("When the dialog is forwarded (delegated access) by someone with access to others.")]
Forwarded = 7
[GraphQLDescription("Indicates that a signature has been provided.")]
SignatureProvided = 6
}

public enum DialogStatus
Loading

0 comments on commit af262b1

Please sign in to comment.