feat(domain): BIG Domain Service skeleton with the Registration aggregate (closes #6) #61
@@ -20,8 +20,17 @@ public sealed class OpenZaakWorker(IRegistrationStore store, IAclClient acl)
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(job);
|
ArgumentNullException.ThrowIfNull(job);
|
||||||
|
|
||||||
// STUB (red): does not load, call the ACL, or attach.
|
var registration = await store.GetAsync(job.RegistrationId, ct)
|
||||||
await Task.CompletedTask;
|
?? throw new InvalidOperationException(
|
||||||
return new Uri("about:blank");
|
$"No registration {job.RegistrationId} for OpenZaakAanmaken job {job.JobId}.");
|
||||||
|
|
||||||
|
// A redelivered job whose zaak was already opened completes without opening a second one.
|
||||||
|
if (registration.ZaakUrl is not null)
|
||||||
|
return registration.ZaakUrl;
|
||||||
|
|
||||||
|
var zaakUrl = await acl.OpenZaakAsync(registration.Bsn, ct);
|
||||||
|
registration.AttachZaak(zaakUrl);
|
||||||
|
await store.SaveAsync(registration, ct);
|
||||||
|
return zaakUrl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,16 @@ public sealed class SubmitRegistration(IRegistrationStore store, IWorkflowClient
|
|||||||
{
|
{
|
||||||
ArgumentNullException.ThrowIfNull(command);
|
ArgumentNullException.ThrowIfNull(command);
|
||||||
|
|
||||||
// STUB (red): no persistence, no process start.
|
var registration = Registration.Submit(command.Bsn);
|
||||||
await Task.CompletedTask;
|
|
||||||
return RegistrationId.New();
|
// Persist before starting the process so the worker can correlate the OpenZaakAanmaken
|
||||||
|
// job back to an aggregate that already exists (ADR-0009).
|
||||||
|
await store.SaveAsync(registration, ct);
|
||||||
|
|
||||||
|
var processInstanceId = await workflow.StartRegistrationProcessAsync(registration.Id, ct);
|
||||||
|
registration.RecordProcessStarted(processInstanceId);
|
||||||
|
await store.SaveAsync(registration, ct);
|
||||||
|
|
||||||
|
return registration.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user