Skip to content

Commit

Permalink
Adjust state definitions to meet new syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
reid-spencer committed Aug 9, 2024
1 parent b227005 commit 4d986b8
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 95 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ lazy val examples = Root(
)
).configure(With.typical)
.configure(With.noPublishing)
.configure(With.scala3)
.settings(
scalaVersion := "3.4.1",
libraryDependencies ++= Dep.testing ++ Dep.riddl
// riddlcMinVersion := "0.43.0",
// riddlcOptions := Seq("--show-times"),
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.ossuminc" % "sbt-ossuminc" % "0.9.5")
addSbtPlugin("com.ossuminc" % "sbt-ossuminc" % "0.12.0")
2 changes: 1 addition & 1 deletion src/riddl/ReactiveBBQ/restaurant/Customer.riddl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context Customer is {
entity Customer is {
type mainType is Nothing
state main of mainType is { ??? }
state main of mainType
handler input is { ??? }
} explained as {
| An entity for customers that tracks the state changes of the entity.
Expand Down
5 changes: 2 additions & 3 deletions src/riddl/ReactiveBBQ/restaurant/Kitchen.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ context Kitchen is {
entity OrderViewer is {
option is kind("device")
type OrderViewData is { viewType: OrderViewType }
state OrderViewerState of OrderViewData is {
handler input is { ??? }
}
state OrderViewerState of OrderViewData
handler input is { ??? }
} explained as {
|## Brief
|This is an OrderViewer
Expand Down
5 changes: 2 additions & 3 deletions src/riddl/ReactiveBBQ/restaurant/Location.riddl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
context Location is {
entity Location is {
record LocationData is { name: String }
state LocationState of Location.LocationData is {
handler LocationHandler is { ??? }
}
state LocationState of Location.LocationData
handler LocationHandler is { ??? }
} explained as {
"This is a retail store Location"
}
Expand Down
17 changes: 8 additions & 9 deletions src/riddl/ReactiveBBQ/restaurant/Loyalty.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,24 @@ context Loyalty is {

entity LoyaltyAccount is {
type InitialStateData is { id is LoyaltyId }
state InitialState of LoyaltyAccount.InitialStateData is {
handler foo is { ??? }
} explained as {
|This state type contains the state values associated with the loyalty
|account when it is first created. It only contains the `LoyaltyId` value
|that uniquely identifies the account.
state InitialState of LoyaltyAccount.InitialStateData
explained as {
|This state type contains the state values associated with the loyalty
|account when it is first created. It only contains the `LoyaltyId` value
|that uniquely identifies the account.
}
handler foo is { ??? }
record ActiveStateData is {
id is LoyaltyId,
customer is CustomerId,
points is Number,
accrualRate is Real,
redemptionRate is Real
}
state ActiveState of LoyaltyAccount.ActiveStateData is {
handler foo { ??? }
} explained as {
state ActiveState of LoyaltyAccount.ActiveStateData explained as {
|This state type used when a loyalty account is active
}
handler foo { ??? }
handler Inputs is {
???
}
Expand Down
10 changes: 4 additions & 6 deletions src/riddl/ReactiveBBQ/restaurant/Menu.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ context Menu is {
description: String,
price: Amount
}
state MenuItemState of MenuItem.MenuItemStateData = {
handler MenuItemHandler is { ??? }
}
state MenuItemState of MenuItem.MenuItemStateData
handler MenuItemHandler is { ??? }
}

type AddItem = command { item: MenuItemRef }
Expand All @@ -21,8 +20,7 @@ context Menu is {
type CorporateItemId = Pattern("")

record MenuStateData is { items: many MenuItemRef }
state MenuState of Menu.MenuStateData is {
handler MenuHandler is { ??? }
}
state MenuState of Menu.MenuStateData
handler MenuHandler is { ??? }
}
}
5 changes: 2 additions & 3 deletions src/riddl/ReactiveBBQ/restaurant/Order.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ context Order is {
orderId is OrderId,
customerId is CustomerId
}
state OrderState of record Order.OrderStateData is {
handler foo is { ??? }
}
state OrderState of record Order.OrderStateData
handler foo is { ??? }
}
} explained as {
| This bounded context defines the handling of restaurant orders.
Expand Down
5 changes: 2 additions & 3 deletions src/riddl/ReactiveBBQ/restaurant/Payment.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ context Payment is {
cardToken is String?,
customerId is CustomerId?
}
state PaymentState of type Payment.PaymentStateValue is {
handler foo is { ??? }
}
state PaymentState of type Payment.PaymentStateValue
handler foo is { ??? }
}
} explained as {
| The Payment bounded context deals with receiving payments from customers for their orders.
Expand Down
5 changes: 2 additions & 3 deletions src/riddl/ReactiveBBQ/restaurant/Reservation.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ context Reservation is {
time is Time,
date is Date
}
state reservation of record Restaurant.Reservation.Reservation.ReservationValue is {
handler ofInputs is {}
}
state reservation of record Restaurant.Reservation.Reservation.ReservationValue
handler ofInputs is {}
}
}
// #Reservation
2 changes: 1 addition & 1 deletion src/riddl/ReactiveBBQ/restaurant/Server.riddl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context Server {
entity Server {
type ServerStateData is Nothing
state ServerState of type Server.ServerStateData is { ??? }
state ServerState of type Server.ServerStateData
handler ServerHandler is { ??? }
}
}
2 changes: 1 addition & 1 deletion src/riddl/ReactiveBBQ/restaurant/Table.riddl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context Table {
entity Table {
record TableStateData is { ??? }
state TableState of Table.TableStateData is { ??? }
state TableState of Table.TableStateData
handler TableHandler is { ??? }
}
}
29 changes: 14 additions & 15 deletions src/riddl/ReactiveSummit/entities.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@ context ToDoList is {
event ItemCompleted is {id: Id(ToDoItem) }

entity ToDoItem is {
state Active is {
fields are {
content: ReactiveSummit.ToDoContent
createdAt: TimeStamp
}
handler is {
on command ToDoList.AddItem {
example add_item is {
when "id of content does not exist"
then "create new ToDoItem from content"
else ""
}
record ActiveState is {
content: ReactiveSummit.ToDoContent
createdAt: TimeStamp
}
state Active is record ActiveState
handler is {
on command ToDoList.AddItem {
example add_item is {
when "id of content does not exist"
then "create new ToDoItem from content"
else ""
}

}
state Completed is {

record CompletedState is {
content: ReactiveSummit.ToDoContent
createdAt: TimeStamp
completedAt: TimeStamp
}

state Completed is record CompletedState
}

projection ToDoItems is {
Expand Down
85 changes: 40 additions & 45 deletions src/riddl/dokn/dokn.riddl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ domain dokn is {
primaryContactPhone: MobileNumber,
primaryContactEmail: EmailAddress
}
state CompanyBase of Company.fields is {
handler CompanyBaseHandler is {
on command AddCompany {
send event CompanyAdded to outlet CompanyEvents_out
}
}
state CompanyBase of Company.fields
handler CompanyBaseHandler is {
on command AddCompany {
send event CompanyAdded to outlet CompanyEvents_out
}
}
}
}
Expand Down Expand Up @@ -80,15 +79,14 @@ domain dokn is {
onDutyTime: TimeStamp,
companyId: CompanyId
}
state DriverBase of Driver.fields is {
handler DriverBaseHandler is {
on command AddDriverToCompany {
send event DriverAddedToCompany to inlet Driver_out
}
on command RemoveDriverFromCompany {
send event DriverRemovedFromCompany to inlet Driver_out
}
}
state DriverBase of Driver.fields
handler DriverBaseHandler is {
on command AddDriverToCompany {
send event DriverAddedToCompany to inlet Driver_out
}
on command RemoveDriverFromCompany {
send event DriverRemovedFromCompany to inlet Driver_out
}
}
}
}
Expand All @@ -105,9 +103,8 @@ domain dokn is {
downvoteCount: Integer,
approved: Boolean
}
state NoteBase of Note.fields is {
handler NoteBaseHandler is { ??? }
}
state NoteBase of Note.fields
handler NoteBaseHandler is { ??? }
}
}

Expand All @@ -119,9 +116,8 @@ domain dokn is {
path: String,
companyId: CompanyId
}
state MediaBase of Media.fields is {
handler MediaBaseHandler is { ??? }
}
state MediaBase of Media.fields
handler MediaBaseHandler is { ??? }
}
}

Expand Down Expand Up @@ -160,30 +156,29 @@ domain dokn is {
ticketCount: Integer,
loadingMethod: LoadingMethod
}
state LocationBase of Location.fields is {
handler Base is {
on command Location.AddDeliveryLocation {
send event Location.DeliveryLocationAdded to inlet CompanyEvents_in
}
on command ChangeLocationName {
send event Location.LocationNameChanged to inlet CompanyEvents_in
}
on command ReportTicketReceived {
send event Location.TicketReportedAtLocation to inlet CompanyEvents_in
}
on command ModifyNotesAtLocation {
send event Location.NotesForLocationModified to inlet CompanyEvents_in
}
on event Location.LocationAddressReceived {
set field LocationBase.address to "field Location.LocationAddressReceived.newAddress"
}
on query Location.getLocationDetails {
send result Location.LocationDetails to inlet Driver_in
}
on query Location.getLocationNotes {
send result Location.LocationNotes to outlet Driver_out
}
}
state LocationBase of Location.fields
handler Base is {
on command Location.AddDeliveryLocation {
send event Location.DeliveryLocationAdded to inlet CompanyEvents_in
}
on command ChangeLocationName {
send event Location.LocationNameChanged to inlet CompanyEvents_in
}
on command ReportTicketReceived {
send event Location.TicketReportedAtLocation to inlet CompanyEvents_in
}
on command ModifyNotesAtLocation {
send event Location.NotesForLocationModified to inlet CompanyEvents_in
}
on event Location.LocationAddressReceived {
set field LocationBase.address to "field Location.LocationAddressReceived.newAddress"
}
on query Location.getLocationDetails {
send result Location.LocationDetails to inlet Driver_in
}
on query Location.getLocationNotes {
send result Location.LocationNotes to outlet Driver_out
}
}
}
}
Expand Down

0 comments on commit 4d986b8

Please sign in to comment.