diff --git a/src/main/riddl/Events/eventContext.riddl b/src/main/riddl/Events/eventContext.riddl index 951274d7..4ec94df1 100644 --- a/src/main/riddl/Events/eventContext.riddl +++ b/src/main/riddl/Events/eventContext.riddl @@ -41,31 +41,8 @@ context EventContext is { handler EventHandler is { on command CreateEvent { - send event EventCreated - // ( - // eventId = @CreateEvent.eventId, - // info = @CreateEvent.info, - // meta = !EventMetaInfo( - // createdOn = now(), - // createdBy = @CreateEvent.onBehalfOf, - // lastUpdatedOn = now(), - // lastUpdatedBy = @CreateEvent.onBehalfOf, - // currentState = @EventStates.Draft - // ) - // ) - to outlet EventEvents.Events + send event EventCreated to outlet EventEvents.Events morph entity Event to state DraftEvent with record DraftEventState - // ( - // eventId = @CreateEvent.eventId, - // info = @CreateEvent.info, - // meta = !EventMetaInfo( - // createdOn = now(), - // createdBy = @CreateEvent.onBehalfOf, - // lastUpdatedOn = now(), - // lastUpdatedBy = @CreateEvent.onBehalfOf, - // currentState = @OrganizationStates.Draft - // ) - // ) } on other { error "You must first create an event using ScheduleEvent command." @@ -83,218 +60,36 @@ 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 - // ( - // eventId = @ScheduleEvent.eventId, - // info = !EventInfo( - // eventName = @DraftEventState.info.eventName, - // description = @DraftEventState.info.description, - // eventURL = @DraftEventState.info.eventURL, - // sponsoringOrg = @DraftEventState.info.sponsoringOrg, - // expectedStart = @DraftEventState.info.expectedStart, - // expectedEnd = @DraftEventState.info.expectedEnd, - // isPrivate = @DraftEventState.info.isPrivate, - // eventStatusInfo = !ScheduledEventInfo() - // ), - // meta = !EventMetaInfo( - // createdOn = @DraftEventState.meta.createdOn, - // createdBy = @DraftEventState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @ScheduleEvent.onBehalfOf, - // currentState = @EventStates.Scheduled - // ) - // ) - to outlet EventEvents.Events - morph entity Event to state ScheduledEvent - with record ScheduledEventState - // ( - // eventId = @ScheduleEvent.eventId, - // info = !EventInfo( - // eventName = @DraftEventState.info.eventName, - // description = @DraftEventState.info.description, - // eventURL = @DraftEventState.info.eventURL, - // sponsoringOrg = @DraftEventState.info.sponsoringOrg, - // expectedStart = @DraftEventState.info.expectedStart, - // expectedEnd = @DraftEventState.info.expectedEnd, - // isPrivate = @DraftEventState.info.isPrivate, - // eventStatusInfo = !ScheduledEventInfo() - // ), - // meta = !EventMetaInfo( - // createdOn = @DraftEventState.meta.createdOn, - // createdBy = @DraftEventState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @ScheduleEvent.onBehalfOf, - // currentState = @EventStates.Scheduled - // ) - // ) + send event EventScheduled to outlet EventEvents.Events + morph entity Event to state ScheduledEvent with record ScheduledEventState } } on command EditEventInfo{ set field DraftEventState.info to "EventContext.newEditableInfoFromFieldsPresentInEditable" - // ( - // editable = @EditEventInfo.info, - // oldInfo = @DraftEventState.info - // ) set field DraftEventState.meta to "EventMetaInfo" -// ( -// createdOn = @DraftEventState.meta.createdOn, -// createdBy = @DraftEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @EditEventInfo.onBehalfOf, -// currentState = @EventStates.Draft -// ) send event EventRescheduled -// ( -// eventId = @DraftEventState.id, -// info = @DraftEventState.info, -// meta = @DraftEventState.meta -// ) to outlet EventEvents.Events } on command CancelEvent{ if "all required info fields are present" then { "cancel associated scheduled call to emit StartEvent" - send event EventCancelled -// ( -// eventId = @CancelEvent.eventId, -// info = !EventInfo( -// eventName = @DraftEventState.info.eventName, -// description = @DraftEventState.info.description, -// eventURL = @DraftEventState.info.eventURL, -// sponsoringOrg = @DraftEventState.info.sponsoringOrg, -// expectedStart = @DraftEventState.info.expectedStart, -// expectedEnd = @DraftEventState.info.expectedEnd, -// isPrivate = @DraftEventState.info.isPrivate, -// eventStatusInfo = !CancelledEventInfo( -// reason = @CancelEvent.reason, -// timeStarted = startTimeIfPast(startTime = @DraftEventState.info.expectedStart), -// timeEnded = nowIfStartIsPast(startTime = @DraftEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @DraftEventState.meta.createdOn, -// createdBy = @DraftEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @CancelEvent.onBehalfOf, -// currentState = @EventStates.Cancelled -// ) -// ) - to outlet EventEvents.Events + send event EventCancelled to outlet EventEvents.Events morph entity Event to state ScheduledEvent with record ScheduledEventState -// ( -// eventId = @ScheduleEvent.eventId, -// info = !EventInfo( -// eventName = @DraftEventState.info.eventName, -// description = @DraftEventState.info.description, -// eventURL = @DraftEventState.info.eventURL, -// sponsoringOrg = @DraftEventState.info.sponsoringOrg, -// expectedStart = @DraftEventState.info.expectedStart, -// expectedEnd = @DraftEventState.info.expectedEnd, -// isPrivate = @DraftEventState.info.isPrivate, -// eventStatusInfo = !CancelledEventInfo( -// reason = @CancelEvent.reason, -// timeStarted = startTimeIfPast(startTime = @DraftEventState.info.expectedStart), -// timeEnded = nowIfStartIsPast(startTime = @DraftEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @DraftEventState.meta.createdOn, -// createdBy = @DraftEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @CancelEvent.onBehalfOf, -// currentState = @EventStates.Cancelled -// ) -// ) } } on command RescheduleEvent { if "start is validated to be before end in command" then { "adjust associated scheduled call to emit StartEvent" set field DraftEventState.info to "EditableEventInfo" -// ( -// eventName = @DraftEventState.info.eventName, -// description = @DraftEventState.info.description, -// eventURL = @DraftEventState.info.eventURL, -// sponsoringOrg = @DraftEventState.info.sponsoringOrg, -// expectedStart = @RescheduleEvent.start, -// expectedEnd = @RescheduleEvent.end, -// isPrivate = @DraftEventState.info.isPrivate -// ) set field DraftEventState.meta to "EventMetaInfo" -// ( -// createdOn = @DraftEventState.meta.createdOn, -// createdBy = @DraftEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @RescheduleEvent.onBehalfOf, -// currentState = @EventStates.Draft -// ) - send event EventRescheduled -// ( -// eventId = @DraftEventState.id, -// info = @DraftEventState.info, -// meta = @DraftEventState.meta -// ) - to outlet EventEvents.Events + send event EventRescheduled to outlet EventEvents.Events } } on command DelayEvent{ if "all required info fields are present" then { "adjust associated scheduled call to emit StartEvent" - send event EventDelayed -// ( -// eventId = @DelayEvent.eventId, -// info = !EventInfo( -// eventName = @DraftEventState.info.eventName, -// description = @DraftEventState.info.description, -// eventURL = @DraftEventState.info.eventURL, -// sponsoringOrg = @DraftEventState.info.sponsoringOrg, -// expectedStart = incrementDelayedEventTime( -// originalTime = @DraftEventState.info.expectedStart, -// duration = @DelayEvent.expectedDuration -// ), -// expectedEnd = incrementDelayedEventTime( -// originalTime = @DraftEventState.info.expectedEnd, -// duration = @DelayEvent.expectedDuration -// ), -// isPrivate = @DraftEventState.info.isPrivate, -// eventStatusInfo = !DelayedEventInfo( -// reason = @DelayEvent.reason, -// timeStartedOpt = false -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @DraftEventState.meta.createdOn, -// createdBy = @DraftEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @DelayEvent.onBehalfOf, -// currentState = @EventStates.Delayed -// ) -// ) - to outlet EventEvents.Events + send event EventDelayed to outlet EventEvents.Events morph entity Event to state ScheduledEvent with record ScheduledEventState -// ( -// eventId = @ScheduleEvent.eventId, -// info = !EventInfo( -// eventName = @DraftEventState.info.eventName, -// description = @DraftEventState.info.description, -// eventURL = @DraftEventState.info.eventURL, -// sponsoringOrg = @DraftEventState.info.sponsoringOrg, -// expectedStart = @DraftEventState.info.expectedStart, -// expectedEnd = @DraftEventState.info.expectedEnd, -// isPrivate = @DraftEventState.info.isPrivate, -// eventStatusInfo = !DelayedEventInfo( -// reason = @DelayEvent.reason, -// timeStartedOpt = startTimeIfPast(startTime = @ScheduledEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @DraftEventState.meta.createdOn, -// createdBy = @DraftEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @CancelEvent.onBehalfOf, -// currentState = @EventStates.Delayed -// ) -// ) } } on command StartEvent{ @@ -303,8 +98,9 @@ context EventContext is { on command EndEvent{ error "Cannot end an event that has not started." } + // TODO: write AddLiveUpdate on clause on command AddLiveUpdate{ - ??? // TODO: write AddLiveUpdate on clause + ??? } } } @@ -330,148 +126,30 @@ context EventContext is { //} on command EditEventInfo { set field ScheduledEventState.info to "EventContext.newInfoFromFieldsPresentInEditable" -// ( -// editable = @EditEventInfo.info, -// oldInfo = @ScheduledEventState.info -// ) set field ScheduledEventState.meta to "EventMetaInfo" -// ( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @EditEventInfo.onBehalfOf, -// currentState = @EventStates.Scheduled -// ) - send event EventInfoEdited -// ( -// eventId = @ScheduledEventState.id, -// info = @ScheduledEventState.info, -// meta = @ScheduledEventState.meta -// ) - to outlet EventEvents.Events + send event EventInfoEdited to outlet EventEvents.Events } on command CancelEvent { "cancel associated scheduled call to emit StartEvent" - send event EventCancelled -// ( -// eventId = @CancelEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @ScheduledEventState.info.expectedStart, -// expectedEnd = @ScheduledEventState.info.expectedEnd, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !CancelledEventInfo( -// reason = @CancelEvent.reason, -// timeStarted = startTimeIfPast(startTime = @ScheduledEventState.info.expectedStart), -// timeEnded = nowIfStartIsPast(startTime = @ScheduledEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @CancelEvent.onBehalfOf, -// currentState = @EventStates.Cancelled -// ) -// ) - to outlet EventEvents.Events + send event EventCancelled to outlet EventEvents.Events become entity Event to handler CancelledEventHandler } on command DelayEvent { "adjust associated scheduled Akka call to emit StartEvent" - send event EventDelayed -// ( -// eventId = @DelayEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = incrementDelayedEventTime( -// originalTime = @ScheduledEventState.info.expectedStart, -// duration = @DelayEvent.expectedDuration -// ), -// expectedEnd = incrementDelayedEventTime( -// originalTime = @ScheduledEventState.info.expectedEnd, -// duration = @DelayEvent.expectedDuration -// ), -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !CancelledEventInfo( -// reason = @CancelEvent.reason, -// timeStarted = startTimeIfPast(startTime = @ScheduledEventState.info.expectedStart), -// timeEnded = nowIfStartIsPast(startTime = @ScheduledEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @DelayEvent.onBehalfOf, -// currentState = @EventStates.Delayed -// ) -// ) - to outlet EventEvents.Events + send event EventDelayed to outlet EventEvents.Events become entity Event to handler DelayedEventHandler } on command StartEvent{ "create scheduled Akka call using ScheduledEventState.info.expectedEnd to emit EndEvent" - send event EventStarted -// ( -// eventId = @StartEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @ScheduledEventState.info.expectedStart, -// expectedEnd = @ScheduledEventState.info.expectedEnd, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !InProgressEventInfo( -// timeStarted = now() -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @StartEvent.onBehalfOf, -// currentState = @EventStates.InProgress -// ) -// ) - to outlet EventEvents.Events + send event EventStarted to outlet EventEvents.Events become entity Event to handler InProgressEventHandler } briefly "to be invoked by Akka scheduler upon ScheduleEvent reception" on command RescheduleEvent { if "start is validated to be before end in command" then { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" -// ( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @RescheduleEvent.start, -// expectedEnd = @RescheduleEvent.end, -// isPrivate = @ScheduledEventState.info.isPrivate -// ) set field ScheduledEventState.meta to "EventMetaInfo" -// ( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @RescheduleEvent.onBehalfOf, -// currentState = @EventStates.Scheduled -// ) - send event EventRescheduled -// ( -// eventId = @ScheduledEventState.id, -// info = @ScheduledEventState.info, -// meta = @ScheduledEventState.meta -// ) - to outlet EventEvents.Events + send event EventRescheduled to outlet EventEvents.Events } } on command EndEvent{ @@ -499,68 +177,14 @@ context EventContext is { } on command DelayEvent{ "adjust associated scheduled Akka call to emit StartEvent" - send event EventDelayed -// ( -// eventId = @DelayEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = incrementDelayedEventTime( -// originalTime = @ScheduledEventState.info.expectedStart, -// duration = @DelayEvent.expectedDuration -// ), -// expectedEnd = incrementDelayedEventTime( -// originalTime = @ScheduledEventState.info.expectedEnd, -// duration = @DelayEvent.expectedDuration -// ), -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !DelayedEventInfo( -// reason = @DelayEvent.reason, -// timeStartedOpt = startTimeIfPast(startTime = @ScheduledEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @DelayEvent.onBehalfOf, -// currentState = @EventStates.Delayed -// ) -// ) - to outlet EventEvents.Events + send event EventDelayed to outlet EventEvents.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 -// ( -// eventId = @EndEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @ScheduledEventState.info.expectedStart, -// expectedEnd = @ScheduledEventState.info.expectedEnd, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !PastEventInfo( -// timeStarted = @ScheduledEventState.info.eventStatusInfo.timeStarted, -// timeEnded = @ScheduledEventState.info.expectedStart -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @EndEvent.onBehalfOf, -// currentState = @EventStates.Past -// ) -// ) - to outlet EventEvents.Events + send event EventEnded to outlet EventEvents.Events become entity Event to handler PastEventHandler } on command AddLiveUpdate { @@ -576,85 +200,20 @@ context EventContext is { //} on command EditEventInfo{ set field ScheduledEventState.info to "EventContext.newInfoFromFieldsPresentInEditable" -// ( -// editable = @EditEventInfo.info, -// oldInfo = @ScheduledEventState.info -// ) set field ScheduledEventState.meta to "EventMetaInfo" -// ( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @EditEventInfo.onBehalfOf, -// currentState = @EventStates.Delayed -// ) - send event EventInfoEdited -// ( -// eventId = @ScheduledEventState.id, -// info = @ScheduledEventState.info, -// meta = @ScheduledEventState.meta -// ) - to outlet EventEvents.Events + send event EventInfoEdited to outlet EventEvents.Events } on command CancelEvent{ "cancel associated scheduled call to emit StartEvent" - send event EventCancelled -// ( -// eventId = @CancelEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @ScheduledEventState.info.expectedStart, -// expectedEnd = @ScheduledEventState.info.expectedEnd, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !CancelledEventInfo( -// reason = @CancelEvent.reason, -// timeStarted = startTimeIfPast(startTime = @ScheduledEventState.info.expectedStart), -// timeEnded = nowIfStartIsPast(startTime = @ScheduledEventState.info.expectedStart) -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @CancelEvent.onBehalfOf, -// currentState = @EventStates.Cancelled -// ) -// ) - to outlet EventEvents.Events + send event EventCancelled to outlet EventEvents.Events become entity Event to handler CancelledEventHandler } on command RescheduleEvent{ if "start is validated to be before end in command" then { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" -// ( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @RescheduleEvent.start, -// expectedEnd = @RescheduleEvent.end, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !ScheduledEventInfo() -// ) set field ScheduledEventState.meta to "EventMetaInfo" -// ( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @RescheduleEvent.onBehalfOf, -// currentState = @EventStates.Delayed -// ) - send event EventRescheduled -// ( -// eventId = @ScheduledEventState.id, -// info = @ScheduledEventState.info, -// meta = @ScheduledEventState.meta -// ) - to outlet EventEvents.Events + send event EventRescheduled to outlet EventEvents.Events } } on command DelayEvent{ @@ -662,30 +221,7 @@ context EventContext is { } on command StartEvent{ "create scheduled Akka call using ScheduledEventState.info.expectedEnd to emit EndEvent" - send event EventStarted -// ( -// eventId = @StartEvent.eventId, -// info = !EventInfo( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @ScheduledEventState.info.expectedStart, -// expectedEnd = @ScheduledEventState.info.expectedEnd, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !InProgressEventInfo( -// timeStarted = now() -// ) -// ), -// meta = !EventMetaInfo( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @StartEvent.onBehalfOf, -// currentState = @EventStates.InProgress -// ) -// ) - to outlet EventEvents.Events + send event EventStarted to outlet EventEvents.Events become entity Event to handler InProgressEventHandler } briefly "to be invoked by Akka scheduler upon ScheduleEvent reception" on command EndEvent{ @@ -700,31 +236,8 @@ context EventContext is { if "start is validated to be before end in command" then { "adjust associated scheduled call to emit StartEvent" set field ScheduledEventState.info to "EventInfo" -// ( -// eventName = @ScheduledEventState.info.eventName, -// description = @ScheduledEventState.info.description, -// eventURL = @ScheduledEventState.info.eventURL, -// sponsoringOrg = @ScheduledEventState.info.sponsoringOrg, -// expectedStart = @RescheduleEvent.start, -// expectedEnd = @RescheduleEvent.end, -// isPrivate = @ScheduledEventState.info.isPrivate, -// eventStatusInfo = !ScheduledEventInfo() -// ) set field ScheduledEventState.meta to "EventMetaInfo" -// ( -// createdOn = @ScheduledEventState.meta.createdOn, -// createdBy = @ScheduledEventState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @RescheduleEvent.onBehalfOf, -// currentState = @EventStates.Scheduled -// ) - send event EventRescheduled -// ( -// eventId = @ScheduledEventState.id, -// info = @ScheduledEventState.info, -// meta = @ScheduledEventState.meta -// ) - to outlet EventEvents.Events + send event EventRescheduled to outlet EventEvents.Events } } on other { diff --git a/src/main/riddl/Members/members.riddl b/src/main/riddl/Members/members.riddl index a16c4d4b..a204b9f7 100644 --- a/src/main/riddl/Members/members.riddl +++ b/src/main/riddl/Members/members.riddl @@ -222,16 +222,6 @@ context MemberContext is { handler MemberHandler is { on command RegisterMember { morph entity Member to state DraftMemberState with record DraftMember -// ( -// info = @MemberRegistered.info, -// meta = !MemberContext.MetaInfo( -// createdOn = now(), -// createdBy = @RegisterMember.onBehalfOf, -// lastUpdatedOn = now(), -// lastUpdatedBy = @RegisterMember.onBehalfOf, -// currentState = @MemberStates.Draft -// ) -// ) } //on command RegisterMemberList { @@ -259,32 +249,7 @@ context MemberContext is { if "all required fields in requiredInfo are not None or Empty" then { send event MemberRegistered to outlet MemberEvents.Events -// ( -// memberId = @DraftMemberState.id, -// info = !MemberContext.EditableInfo( -// contact = @DraftMemberState.info.contact, -// handle = @DraftMemberState.info.handle, -// avatar = @DraftMemberState.info.avatar, -// firstName = @DraftMemberState.info.firstName, -// lastName = @DraftMemberState.info.lastName, -// notificationPreference = @DraftMemberState.info.notificationPreference, -// organizationMembership = @DraftMemberState.info.organizationMembership, -// tenant = @DraftMemberState.info.tenant -// ), -// meta = !MemberContext.MetaInfo( -// createdOn = @DraftMemberState.meta.createdOn, -// createdBy = @DraftMemberState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @EditOrganizationInfo.editingMember, -// currentState = @OrganizationStates.Active -// ) -// ) - morph entity Member to state RegisteredMemberState with - record RegisteredMember -// ( -// info = @DraftMemberState.info, -// orgMeta = @DraftMemberState.meta -// ) + morph entity Member to state RegisteredMemberState with record RegisteredMember } else { if "all required fields in state are not present" then { @@ -294,31 +259,8 @@ context MemberContext is { } on command EditMemberInfo { set field DraftMemberState.info to "MemberContext.EditableInfo" -// ( -// contact = @EditMemberInfo.info.contact, -// handle = @EditMemberInfo.info.handle, -// avatar = @EditMemberInfo.info.avatar, -// firstName = @EditMemberInfo.info.firstName, -// lastName = @EditMemberInfo.info.lastName, -// tenant = @EditMemberInfo.info.tenant, -// notificationPreference = @EditMemberInfo.info.notificationPreference, -// organizationMembership = @EditMemberInfo.info.organizationMembership -// ) set field DraftMemberState.meta to "MemberContext.MetaInfo" -// ( -// createdOn = @DraftMemberState.meta.createdOn, -// createdBy = @DraftMemberState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @EditMemberInfo.editingMember, -// currentState = @MemberStates.Draft -// ) - send event MemberInfoEdited -// ( -// memberId = @DraftMemberState.id, -// info = @DraftMemberState.info, -// meta = @DraftMemberState.meta -// ) - to outlet MemberEvents.Events + send event MemberInfoEdited to outlet MemberEvents.Events } // For GetMemberData, eventually probably only admins and self should be able to make this call. Also // potentially allow other roles to get some limited information (this will require adding another @@ -367,50 +309,17 @@ context MemberContext is { lastUpdatedBy = @EditMemberInfo.editingMember, currentState = @MemberStates.Draft )" - send event MemberInfoEdited - // memberId = @DraftMemberState.id, - // info = !MemberContext.Info( - // contact = @RegisteredMemberState.info.contact, - // handle = @RegisteredMemberState.info.handle, - // avatar = @RegisteredMemberState.info.avatar, - // firstName = @RegisteredMemberState.info.firstName, - // lastName = @RegisteredMemberState.info.lastName, - // notificationPreference = @RegisteredMemberState.info.notificationPreference, - // organizationMembership = @RegisteredMemberState.info.organizationMembership, - // tenant = @RegisteredMemberState.info.tenant - // ), - // meta = @RegisteredMemberState.meta) - to outlet MemberEvents.Events + send event MemberInfoEdited to outlet MemberEvents.Events } on command SuspendMember { if "all required fields in requiredInfo are not None or Empty" then { - send event MemberSuspended - // ( - // memberId = @RegisteredMemberState.id, - // info = @RegisteredMemberState.info, - // meta = !MemberContext.MetaInfo( - // createdOn = @RegisteredMemberState.meta.createdOn, - // createdBy = @RegisteredMemberState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @SuspendMember.suspendingMember, - // currentState = @MemberStates.Suspended - // ) - to outlet MemberEvents.Events + send event MemberSuspended to outlet MemberEvents.Events become entity Member to handler SuspendedMemberHandler } } on command TerminateMember { - set field RegisteredMemberState.meta to - "record MemberContext.MetaInfo" - // ( - // createdOn = @RegisteredMemberState.meta, - // createdBy = @RegisteredMemberState.meta, - // lastUpdatedOn = now(), - // lastUpdatedBy = @TerminateMember.terminatingMember, - // currentState = @RegisteredMemberState.meta - // ) - morph entity Member to state TerminatedMember - with record TerminatedMemberState + set field RegisteredMemberState.meta to "record MemberContext.MetaInfo" + morph entity Member to state TerminatedMember with record TerminatedMemberState } on query GetMemberData { reply record MemberInfo @@ -421,56 +330,16 @@ context MemberContext is { error "Member has already been registered." } on command ActivateMember { - send event MemberActivated - // ( - // memberId = @RegisteredMemberState.id, - // info = @RegisteredMemberState.info, - // meta = !MemberContext.MetaInfo( - // createdOn = @RegisteredMemberState.meta.createdOn, - // createdBy = @RegisteredMemberState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @ActivateMember.activatingMember, - // currentState = @MemberStates.Active - // ) - //) - to outlet MemberEvents.Events + send event MemberActivated to outlet MemberEvents.Events become entity Member to handler ActiveMemberHandler } on command SuspendMember { set field RegisteredMemberState.meta to "MemberContext.MetaInfo" - // ( - // createdOn = @RegisteredMemberState.meta.createdOn, - // createdBy = @RegisteredMemberState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @SuspendMember.suspendingMember, - // currentState = @MemberStates.Suspended - // ) - send event MemberSuspended - // ( - // memberId = @RegisteredMemberState.id, - // info = @RegisteredMemberState.info, - // meta = !MemberContext.MetaInfo( - // createdOn = @RegisteredMemberState.meta.createdOn, - // createdBy = @RegisteredMemberState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @SuspendMember.suspendingMember, - // currentState = @MemberStates.Suspended - // ) - //) - to outlet MemberEvents.Events + send event MemberSuspended to outlet MemberEvents.Events } briefly "A suspension reason can be updated by re-issuing the command" on command TerminateMember { set field RegisteredMemberState.meta to "MemberContext.MetaInfo" - // ( - // createdOn = @RegisteredMemberState.meta.createdOn, - // createdBy = @RegisteredMemberState.meta.createdBy, - // lastUpdatedOn = now(), - // lastUpdatedBy = @TerminateMember.terminatingMember, - // currentState = @RegisteredMemberState.meta - // ) - morph entity Member to state TerminatedMember - with record TerminatedMemberState - // (lastMeta = @RegisteredMemberState.meta) + morph entity Member to state TerminatedMember with record TerminatedMemberState } on query GetMemberData { reply record Info diff --git a/src/main/riddl/Product/product.riddl b/src/main/riddl/Product/product.riddl index 900cf3c1..941bd22d 100644 --- a/src/main/riddl/Product/product.riddl +++ b/src/main/riddl/Product/product.riddl @@ -96,26 +96,9 @@ context ProductContext is { } on command DeleteProduct{ set field DraftProductState.meta to "ProductContext.ProductMetaInfo" -// ( -// createdOn = @DraftProductState.meta.createdOn, -// createdBy = @DraftProductState.meta.createdBy, -// lastUpdated = now(), -// lastUpdatedBy = @DeleteProduct.onBehalfOf, -// currentState = @ProductStates.Deleted -// ) send event ProductDeleted -// ( -// sku = @DraftProductState.sku, -// info = @DraftProductState.info, -// meta = @DraftProductState.meta -// ) to outlet ProductEvents.Events morph entity Product to state DeletedProductState with record DeletedProduct -// ( -// sku = @DraftProductState.sku, -// name = @DraftProductState.info.name, -// lastMeta = @DraftProductState.meta -// ) } on command ActivateProduct{ if "not all required fields are filled in" then { @@ -123,39 +106,9 @@ context ProductContext is { } else { // "all required fields are present" set field DraftProductState.meta to "ProductContext.ProductMetaInfo" -// ( -// createdOn = @DraftProductState.meta.createdOn, -// createdBy = @DraftProductState.meta.createdBy, -// lastUpdated = now(), -// lastUpdatedBy = @ActivateProduct.onBehalfOf, -// currentState = @ProductStates.Active -// ) send event ProductActivated -// ( -// sku = @DraftProductState.sku, -// info = @DraftProductState.info, -// meta = @DraftProductState.meta -// ) to outlet ProductEvents.Events morph entity Product to state DefinedProductState with record DefinedProduct -// ( -// info = !ProductInfo( -// name = @DraftProductState.info.name, -// description = @DraftProductState.info.description, -// products = @DraftProductState.info.products, -// event = @DraftProductState.info.event, -// venue = @DraftProductState.info.venue, -// location = @DraftProductState.info.location, -// sponsoringOrg = @DraftProductState.info.sponsoringOrg -// ), -// meta = !ProductContext.MetaInfo( -// createdOn = @DraftProductState.meta.createdOn, -// createdBy = @DraftProductState.meta.createdBy, -// lastUpdatedOn = now(), -// lastUpdatedBy = @ActivateProduct.updatingMember, -// currentState = @ProductStates.Active -// ) -// ) } } on command InactivateProduct{ @@ -183,48 +136,16 @@ context ProductContext is { "yield ProductInfoUpdated event with new info" } on command DeleteProduct{ - set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" -// ( -// createdOn = @DefinedProductState.meta.createdOn, -// createdBy = @DefinedProductState.meta.createdBy, -// lastUpdated = now(), -// lastUpdatedBy = @DeleteProduct.onBehalfOf, -// currentState = @ProductStates.Deleted -// ) - send event ProductDeleted -// ( -// sku = @DefinedProductState.sku, -// info = @DefinedProductState.info, -// meta = @DefinedProductState.meta -// ) - to outlet ProductEvents.Events + set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" to outlet ProductEvents.Events morph entity Product to state DeletedProductState with record DeletedProduct -// ( -// sku = @DefinedProductState.sku, -// name = @DefinedProductState.info.name, -// lastMeta = @DefinedProductState.meta -// ) } on command ActivateProduct{ error "Product is already active" } on command InactivateProduct { set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" -// ( -// createdOn = @DefinedProductState.meta.createdOn, -// createdBy = @DefinedProductState.meta.createdBy, -// lastUpdated = now(), -// lastUpdatedBy = @InactivateProduct.onBehalfOf, -// currentState = @ProductStates.Inactive -// ) - send event ProductInactivated -// ( -// sku = @DefinedProductState.sku, -// info = @DefinedProductState.info, -// meta = @DefinedProductState.meta -// ) - to outlet ProductEvents.Events - become entity Product to handler InactiveProductHandler + send event ProductInactivated to outlet ProductEvents.Events + become entity Product to handler InactiveProductHandler } on query GetProductInfo{ "yield ProductInfoResult message" @@ -241,43 +162,12 @@ context ProductContext is { } on command DeleteProduct{ set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" -// ( -// createdOn = @DefinedProductState.meta.createdOn, -// createdBy = @DefinedProductState.meta.createdBy, -// lastUpdated = now(), -// lastUpdatedBy = @DeleteProduct.onBehalfOf, -// currentState = @ProductStates.Deleted -// ) - send event ProductDeleted -// ( -// sku = @DefinedProductState.sku, -// info = @DefinedProductState.info, -// meta = @DefinedProductState.meta -// ) - to outlet ProductEvents.Events + send event ProductDeleted to outlet ProductEvents.Events morph entity Product to state DeletedProductState with record DeletedProduct -// ( -// sku = @DefinedProductState.sku, -// name = @DefinedProductState.info.name, -// lastMeta = @DefinedProductState.meta -// ) } on command ActivateProduct{ set field DefinedProductState.meta to "ProductContext.ProductMetaInfo" -// ( -// createdOn = @DefinedProductState.meta.createdOn, -// createdBy = @DefinedProductState.meta.createdBy, -// lastUpdated = now(), -// lastUpdatedBy = @ActivateProduct.onBehalfOf, -// currentState = @ProductStates.Active -// ) - send event ProductActivated -// ( -// sku = @DefinedProductState.sku, -// info = @DefinedProductState.info, -// meta = @DefinedProductState.meta -// ) - to outlet ProductEvents.Events + send event ProductActivated to outlet ProductEvents.Events become entity Product to handler ActiveProductHandler } on command InactivateProduct{