Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove related activity #1278

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/schema/V1/schema.verified.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type Activity {
createdAt: DateTime
extendedType: URL
type: ActivityType!
relatedActivityId: UUID
transmissionId: UUID
performedBy: Actor!
description: [Localization!]!
Expand Down
63 changes: 0 additions & 63 deletions docs/schema/V1/swagger.verified.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the request body.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.\nMust be present in the request body.",
"format": "guid",
Expand Down Expand Up @@ -387,12 +381,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the request body.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.\nMust be present in the request body.",
"format": "guid",
Expand Down Expand Up @@ -965,11 +953,6 @@
"performedBy": {
"$ref": "#/components/schemas/GetDialogActivityPerformedByActorDto"
},
"relatedActivityId": {
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"format": "guid",
"nullable": true,
Expand Down Expand Up @@ -1012,11 +995,6 @@
"performedBy": {
"$ref": "#/components/schemas/GetDialogActivityPerformedByActorDtoSO"
},
"relatedActivityId": {
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"format": "guid",
"nullable": true,
Expand Down Expand Up @@ -1221,12 +1199,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the current dialog.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.",
"format": "guid",
Expand Down Expand Up @@ -1279,12 +1251,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the current dialog.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.",
"format": "guid",
Expand Down Expand Up @@ -3293,11 +3259,6 @@
"format": "guid",
"type": "string"
},
"relatedActivityId": {
"format": "guid",
"nullable": true,
"type": "string"
},
"seenByEndUserIdHash": {
"nullable": true,
"type": "string"
Expand Down Expand Up @@ -3334,11 +3295,6 @@
"format": "guid",
"type": "string"
},
"relatedActivityId": {
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"format": "guid",
"nullable": true,
Expand Down Expand Up @@ -3465,12 +3421,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the current dialog.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.",
"format": "guid",
Expand Down Expand Up @@ -3523,12 +3473,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the current dialog.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.",
"format": "guid",
Expand Down Expand Up @@ -4401,12 +4345,6 @@
}
]
},
"relatedActivityId": {
"description": "The related activity identifier, if applicable. Must be present in the request body.",
"format": "guid",
"nullable": true,
"type": "string"
},
"transmissionId": {
"description": "If the activity is related to a particular transmission, this field will contain the transmission identifier.\nMust be present in the request body.",
"format": "guid",
Expand Down Expand Up @@ -6439,7 +6377,6 @@
"ActorName": null,
"ActorType": 2
},
"RelatedActivityId": null,
"TransmissionId": null,
"Type": 3
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ private static Dictionary<string, object> GetCloudEventData(DialogActivityCreate
data["extendedActivityType"] = domainEvent.ExtendedType.ToString();
}

if (domainEvent.RelatedActivityId is not null)
{
data["relatedActivityId"] = domainEvent.RelatedActivityId.ToString()!;
}

if (domainEvent.Process is not null)
{
data["process"] = domainEvent.Process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public sealed class GetDialogActivityDto

public DialogActivityType.Values Type { get; set; }

public Guid? RelatedActivityId { get; set; }
public Guid? TransmissionId { get; set; }

public GetDialogActivityPerformedByActorDto PerformedBy { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ public sealed class SearchDialogActivityDto

public DialogActivityType.Values Type { get; set; }

public Guid? RelatedActivityId { get; set; }
public Guid? TransmissionId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,6 @@ public sealed class GetDialogDialogActivityDto
/// </summary>
public DialogActivityType.Values Type { get; set; }

/// <summary>
/// The related activity identifier, if applicable. Must be present in the current dialog.
/// </summary>
public Guid? RelatedActivityId { get; set; }

/// <summary>
/// If the activity is related to a particular transmission, this field will contain the transmission identifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ public sealed class SearchDialogDialogActivityDto
/// </summary>
public DialogActivityType.Values Type { get; set; }

/// <summary>
/// The related activity identifier, if applicable. Must be present in the current dialog.
/// </summary>
public Guid? RelatedActivityId { get; set; }

/// <summary>
/// If the activity is related to a particular transmission, this field will contain the transmission identifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public sealed class GetDialogActivityDto

public DateTimeOffset? DeletedAt { get; set; }

public Guid? RelatedActivityId { get; set; }
public Guid? TransmissionId { get; set; }

public GetDialogActivityPerformedByActorDto PerformedBy { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ public sealed class SearchDialogActivityDto

public DateTimeOffset? DeletedAt { get; set; }

public Guid? RelatedActivityId { get; set; }
public Guid? TransmissionId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,6 @@ public CreateDialogCommandValidator(
.IsIn(x => x.Transmissions,
dependentKeySelector: activity => activity.TransmissionId,
principalKeySelector: transmission => transmission.Id)
.IsIn(x => x.Activities,
dependentKeySelector: activity => activity.RelatedActivityId,
principalKeySelector: activity => activity.Id)
.SetValidator(activityValidator);

RuleFor(x => x.Process)
Expand Down Expand Up @@ -401,10 +398,6 @@ public CreateDialogDialogActivityDtoValidator(
.MaximumLength(Constants.DefaultMaxUriLength);
RuleFor(x => x.Type)
.IsInEnum();
RuleFor(x => x.RelatedActivityId)
.NotEqual(x => x.Id)
.WithMessage(x => $"An activity cannot reference itself ({nameof(x.RelatedActivityId)} is equal to {nameof(x.Id)}, '{x.Id}').")
.When(x => x.RelatedActivityId.HasValue);
RuleFor(x => x.PerformedBy)
.NotNull()
.SetValidator(actorValidator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ public sealed class CreateDialogDialogActivityDto
/// </summary>
public DialogActivityType.Values Type { get; set; }

/// <summary>
/// The related activity identifier, if applicable. Must be present in the request body.
/// </summary>
public Guid? RelatedActivityId { get; set; }

/// <summary>
/// If the activity is related to a particular transmission, this field will contain the transmission identifier.
/// Must be present in the request body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public async Task<UpdateDialogResult> Handle(UpdateDialogCommand request, Cancel
ValidateTimeFields(dialog);

await AppendActivity(dialog, request.Dto, cancellationToken);
VerifyActivityRelations(dialog);

await AppendTransmission(dialog, request.Dto, cancellationToken);
VerifyTransmissionRelations(dialog);
Expand Down Expand Up @@ -244,33 +243,6 @@ private void VerifyActivityTransmissionRelations(DialogEntity dialog)
}
}

private void VerifyActivityRelations(DialogEntity dialog)
{
var relatedActivityIds = dialog.Activities
.Where(x => x.RelatedActivityId is not null)
.Select(x => x.RelatedActivityId)
.ToList();

if (relatedActivityIds.Count == 0)
{
return;
}

var activityIds = dialog.Activities.Select(x => x.Id).ToList();

var invalidRelatedActivityIds = relatedActivityIds
.Where(id => !activityIds.Contains(id!.Value))
.ToList();

if (invalidRelatedActivityIds.Count != 0)
{
_domainContext.AddError(
nameof(UpdateDialogDto.Activities),
$"Invalid '{nameof(DialogActivity.RelatedActivityId)}, entity '{nameof(DialogActivity)}'" +
$" with the following key(s) does not exist: ({string.Join(", ", invalidRelatedActivityIds)}) in '{nameof(dialog.Activities)}'");
}
}

private async Task AppendTransmission(DialogEntity dialog, UpdateDialogDto dto, CancellationToken cancellationToken)
{
var newDialogTransmissions = _mapper.Map<List<DialogTransmission>>(dto.Transmissions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,6 @@ public UpdateDialogDialogActivityDtoValidator(
.MaximumLength(Constants.DefaultMaxUriLength);
RuleFor(x => x.Type)
.IsInEnum();
RuleFor(x => x.RelatedActivityId)
.NotEqual(x => x.Id)
.WithMessage(x => $"An activity cannot reference itself ({nameof(x.RelatedActivityId)} is equal to {nameof(x.Id)}, '{x.Id}').")
.When(x => x.RelatedActivityId.HasValue);
RuleFor(x => x.PerformedBy)
.NotNull()
.SetValidator(actorValidator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ public class UpdateDialogDialogActivityDto
/// </summary>
public DialogActivityType.Values Type { get; set; }

/// <summary>
/// The related activity identifier, if applicable. Must be present in the request body.
/// </summary>
public Guid? RelatedActivityId { get; set; }

/// <summary>
/// If the activity is related to a particular transmission, this field will contain the transmission identifier.
/// Must be present in the request body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,6 @@ public sealed class GetDialogDialogActivityDto
/// </summary>
public DialogActivityType.Values Type { get; set; }

/// <summary>
/// The related activity identifier, if applicable. Must be present in the current dialog.
/// </summary>
public Guid? RelatedActivityId { get; set; }

/// <summary>
/// If the activity is related to a particular transmission, this field will contain the transmission identifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ public sealed class SearchDialogDialogActivityDto
/// </summary>
public DialogActivityType.Values Type { get; set; }

/// <summary>
/// The related activity identifier, if applicable. Must be present in the current dialog.
/// </summary>
public Guid? RelatedActivityId { get; set; }

/// <summary>
/// If the activity is related to a particular transmission, this field will contain the transmission identifier.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public sealed class DialogActivity : IImmutableEntity, IAggregateCreatedHandler,
public Guid DialogId { get; set; }
public DialogEntity Dialog { get; set; } = null!;

public Guid? RelatedActivityId { get; set; }
public DialogActivity? RelatedActivity { get; set; }

public Guid? TransmissionId { get; set; }
public DialogTransmission? Transmission { get; set; }

Expand All @@ -34,14 +31,11 @@ public sealed class DialogActivity : IImmutableEntity, IAggregateCreatedHandler,
[AggregateChild]
public DialogActivityPerformedByActor PerformedBy { get; set; } = null!;

public List<DialogActivity> RelatedActivities { get; set; } = [];

public void OnCreate(AggregateNode self, DateTimeOffset utcNow)
{
_domainEvents.Add(new DialogActivityCreatedDomainEvent(
DialogId, Id, TypeId, Dialog.Party,
Dialog.ServiceResource, Dialog.Process, Dialog.PrecedingProcess, ExtendedType,
RelatedActivityId));
Dialog.ServiceResource, Dialog.Process, Dialog.PrecedingProcess, ExtendedType));
}

private readonly List<IDomainEvent> _domainEvents = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ public sealed record DialogActivityCreatedDomainEvent(
string ServiceResource,
string? Process,
string? PrecedingProcess,
Uri? ExtendedType,
Guid? RelatedActivityId) : DomainEvent;
Uri? ExtendedType) : DomainEvent;
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public sealed class Activity

public ActivityType Type { get; set; }

public Guid? RelatedActivityId { get; set; }
public Guid? TransmissionId { get; set; }

public Actor PerformedBy { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ internal sealed class DialogActivityConfiguration : IEntityTypeConfiguration<Dia
{
public void Configure(EntityTypeBuilder<DialogActivity> builder)
{
builder.HasOne(x => x.RelatedActivity)
.WithMany(x => x.RelatedActivities)
.OnDelete(DeleteBehavior.SetNull);

builder.HasOne(x => x.Transmission)
.WithMany(x => x.Activities)
.OnDelete(DeleteBehavior.SetNull);
Expand Down
Loading
Loading