diff --git a/src/main/riddl/Events/eventContext.riddl b/src/main/riddl/Events/eventContext.riddl index 2fa39a3b..bff1dbb4 100644 --- a/src/main/riddl/Events/eventContext.riddl +++ b/src/main/riddl/Events/eventContext.riddl @@ -41,7 +41,7 @@ context EventContext is { handler EventHandler is { on command CreateEvent { - send event EventCreated to outlet EventEvents.Events + send event EventCreated to outlet EventEventsSource.Events morph entity Event to state DraftEvent with record DraftEventState } on other { @@ -60,7 +60,7 @@ context EventContext is { on command ScheduleEvent{ if "all required info fields are present" then { "set a scheduled Akka call for emitting StartEvent at DraftEventState.info.expectedStart" - send event EventScheduled to outlet EventEvents.Events + send event EventScheduled to outlet EventEventsSource.Events morph entity Event to state ScheduledEvent with record ScheduledEventState } } @@ -68,12 +68,12 @@ context EventContext is { set field DraftEventState.info to "EventContext.newEditableInfoFromFieldsPresentInEditable" set field DraftEventState.meta to "EventMetaInfo" send event EventRescheduled - to outlet EventEvents.Events + to outlet EventEventsSource.Events } on command CancelEvent{ if "all required info fields are present" then { "cancel associated scheduled call to emit StartEvent" - send event EventCancelled to outlet EventEvents.Events + send event EventCancelled to outlet EventEventsSource.Events morph entity Event to state ScheduledEvent with record ScheduledEventState } } @@ -82,13 +82,13 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field DraftEventState.info to "EditableEventInfo" set field DraftEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on command DelayEvent{ if "all required info fields are present" then { "adjust associated scheduled call to emit StartEvent" - send event EventDelayed to outlet EventEvents.Events + send event EventDelayed to outlet EventEventsSource.Events morph entity Event to state ScheduledEvent with record ScheduledEventState } } @@ -127,21 +127,21 @@ context EventContext is { on command EditEventInfo { set field ScheduledEventState.info to "EventContext.newInfoFromFieldsPresentInEditable" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventInfoEdited to outlet EventEvents.Events + send event EventInfoEdited to outlet EventEventsSource.Events } on command CancelEvent { "cancel associated scheduled call to emit StartEvent" - send event EventCancelled to outlet EventEvents.Events + send event EventCancelled to outlet EventEventsSource.Events become entity Event to handler CancelledEventHandler } on command DelayEvent { "adjust associated scheduled Akka call to emit StartEvent" - send event EventDelayed to outlet EventEvents.Events + send event EventDelayed to outlet EventEventsSource.Events become entity Event to handler DelayedEventHandler } on command StartEvent{ "create scheduled Akka call using ScheduledEventState.info.expectedEnd to emit EndEvent" - send event EventStarted to outlet EventEvents.Events + send event EventStarted to outlet EventEventsSource.Events become entity Event to handler InProgressEventHandler } briefly "to be invoked by Akka scheduler upon ScheduleEvent reception" on command RescheduleEvent { @@ -149,7 +149,7 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on command EndEvent{ @@ -178,14 +178,14 @@ context EventContext is { } on command DelayEvent{ "adjust associated scheduled Akka call to emit StartEvent" - send event EventDelayed to outlet EventEvents.Events + send event EventDelayed to outlet EventEventsSource.Events become entity Event to handler DelayedEventHandler } on command StartEvent { error "Event is already started. Cannot start an event that is already in progress" } on command EndEvent { - send event EventEnded to outlet EventEvents.Events + send event EventEnded to outlet EventEventsSource.Events become entity Event to handler PastEventHandler } // TODO: specify AddLiveUpdate on clause @@ -203,11 +203,11 @@ context EventContext is { on command EditEventInfo{ set field ScheduledEventState.info to "EventContext.newInfoFromFieldsPresentInEditable" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventInfoEdited to outlet EventEvents.Events + send event EventInfoEdited to outlet EventEventsSource.Events } on command CancelEvent{ "cancel associated scheduled call to emit StartEvent" - send event EventCancelled to outlet EventEvents.Events + send event EventCancelled to outlet EventEventsSource.Events become entity Event to handler CancelledEventHandler } on command RescheduleEvent{ @@ -215,7 +215,7 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on command DelayEvent{ @@ -223,7 +223,7 @@ context EventContext is { } on command StartEvent{ "create scheduled Akka call using ScheduledEventState.info.expectedEnd to emit EndEvent" - send event EventStarted to outlet EventEvents.Events + send event EventStarted to outlet EventEventsSource.Events become entity Event to handler InProgressEventHandler } briefly "to be invoked by Akka scheduler upon ScheduleEvent reception" on command EndEvent{ @@ -240,7 +240,7 @@ context EventContext is { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" set field ScheduledEventState.meta to "EventMetaInfo" - send event EventRescheduled to outlet EventEvents.Events + send event EventRescheduled to outlet EventEventsSource.Events } } on other { diff --git a/src/main/riddl/Events/eventSources.riddl b/src/main/riddl/Events/eventSources.riddl index 358a869b..8bfd9150 100644 --- a/src/main/riddl/Events/eventSources.riddl +++ b/src/main/riddl/Events/eventSources.riddl @@ -3,16 +3,54 @@ // } explained as "This is a source for things that happen as an event progresses" //ReservationAddedToEvent, -type PublicEventEvent is one of { - Events.EventContext.EventInfoEdited, - Events.EventContext.EventCreated, - Events.EventContext.EventScheduled, - Events.EventContext.EventCancelled, - Events.EventContext.EventRescheduled, - Events.EventContext.EventDelayed, - Events.EventContext.EventStarted, - Events.EventContext.EventEnded + +connector EventCommandsChannel is { + from outlet EventCommandsSource.Commands to + inlet EventCommandsSink.Commands +} + +connector EventEventsChannel is { + from outlet EventEventsSource.Events to + inlet EventEventsSink.Events +} + +source EventCommandsSource is { + outlet Commands is type EventCommand +} + +sink EventCommandsSink is { + inlet Commands is type EventCommand } -source EventEvents is { - outlet Events is type PublicEventEvent -} explained as "This is a source for event from Events entities" \ No newline at end of file + +source EventEventsSource is { + outlet Events is type EventEvent +} + +sink EventEventsSink is { + inlet Events is type EventEvent +} + +type EventCommand is one of { + EditEventInfo, + CreateEvent, + ScheduleEvent, + CancelEvent, + RescheduleEvent, + DelayEvent, + StartEvent, + EndEvent, + TerminateEvent, + AddLiveUpdate +} + +type EventEvent is one of { + EventInfoEdited, + EventCreated, + EventScheduled, + EventCancelled, + EventRescheduled, + EventDelayed, + EventStarted, + EventEnded, + EventTerminated +} \ No newline at end of file diff --git a/src/main/riddl/Tenant/tenant.riddl b/src/main/riddl/Tenant/tenant.riddl index bdf09820..eac278da 100644 --- a/src/main/riddl/Tenant/tenant.riddl +++ b/src/main/riddl/Tenant/tenant.riddl @@ -19,7 +19,7 @@ context TenantContext is { if "primaryContact info is not complete" then { error "primaryContact must be complete in order to establish a Tenant" } else { - send event TenantEstablished to outlet TenantEvents.Events + send event TenantEstablished to outlet TenantEventsSource.Events morph entity Tenant to state EstablishedTenant with record EstablishedTenantState } @@ -155,14 +155,14 @@ context TenantContext is { "Copy fields which are present from TenantContext.EditInfo.newInfo into info fields" set field EstablishedTenantState.meta to "record TenantContext.TenantMetaInfo" send event TenantContext.InfoEdited - to outlet TenantEvents.Events + to outlet TenantEventsSource.Events } on command SuspendTenant { if "updating user is not authorized to suspend tenant" then { error "User is not authorized to suspend Tenant" } else { set field EstablishedTenantState.meta to "record TenantContext.TenantMetaInfo" - send event TenantContext.TenantSuspended to outlet TenantEvents.Events + send event TenantContext.TenantSuspended to outlet TenantEventsSource.Events become entity Tenant to handler SuspendedTenantHandler } } @@ -171,7 +171,7 @@ context TenantContext is { error "User is not authorized to modify Tenant" } else { set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" - send event TenantContext.TenantTerminated to outlet TenantEvents.Events + send event TenantContext.TenantTerminated to outlet TenantEventsSource.Events morph entity Tenant to state TerminatedTenant with record TerminatedTenantState } } @@ -215,14 +215,14 @@ context TenantContext is { "Copy fields which are present from TenantContext.EditInfo.newInfo into info fields" set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" send event TenantContext.InfoEdited - to outlet TenantEvents.Events + to outlet TenantEventsSource.Events } on command ActivateTenant { if "updating user is not authorized to activate the tenant" then{ error "User is not authorized to Activate Tenant" } else { set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" - send event TenantContext.TenantSuspended to outlet TenantEvents.Events + send event TenantContext.TenantSuspended to outlet TenantEventsSource.Events become entity Tenant to handler ActiveTenantHandler } } @@ -232,7 +232,7 @@ context TenantContext is { } else { // set field EstablishedTenantState.meta to "TenantContext.TenantMetaInfo" send event TenantContext.TenantTerminated - to outlet TenantEvents.Events + to outlet TenantEventsSource.Events morph entity Tenant to state TerminatedTenant with record TerminatedTenantState } } diff --git a/src/main/riddl/Tenant/tenantSources.riddl b/src/main/riddl/Tenant/tenantSources.riddl index 8fc30c76..0b7ca6ff 100644 --- a/src/main/riddl/Tenant/tenantSources.riddl +++ b/src/main/riddl/Tenant/tenantSources.riddl @@ -1,10 +1,41 @@ -type PublicTenantEvent is one of { - TenantContext.InfoEdited, - TenantContext.TenantActivated, - TenantContext.TenantSuspended, - TenantContext.TenantTerminated +connector TenantCommandsChannel is { + from outlet TenantCommandsSource.Commands to + inlet TenantCommandsSink.Commands } -source TenantEvents is { - outlet Events is type PublicTenantEvent -} explained as "This is a source for Tenant Events" +connector TenantEventsChannel is { + from outlet TenantEventsSource.Events to + inlet TenantEventsSink.Events +} + +source TenantCommandsSource is { + outlet Commands is type TenantCommand +} + +sink TenantCommandsSink is { + inlet Commands is type TenantCommand +} + +source TenantEventsSource is { + outlet Events is type TenantEvent +} + +sink TenantEventsSink is { + inlet Events is type TenantEvent +} + +type TenantCommand is one of { + EstablishTenant, + ActivateTenant, + SuspendTenant, + TerminateTenant, + EditInfo +} + +type TenantEvent is one of { + TenantEstablished, + TenantActivated, + TenantSuspended, + TenantTerminated, + InfoEdited +}