diff --git a/AlgebraicDataflowArchitectureModel/models/Citrus.model b/AlgebraicDataflowArchitectureModel/models/Citrus.model index a4cd25b..356405a 100644 --- a/AlgebraicDataflowArchitectureModel/models/Citrus.model +++ b/AlgebraicDataflowArchitectureModel/models/Citrus.model @@ -19,18 +19,24 @@ } channel DeleteBook(aid:Str) { - out accounts.{aid}.books(bookList:List, deleteBook(bid:int)) = if(bid < length(bookList), remove(bookList, bid), bookList) + out accounts.{aid}.books(bookList:List, deleteBook(bid:Int)) = if(bid < length(bookList), remove(bookList, bid), bookList) } channel CreateToDo(aid:Str, bid:Int) { - out accounts.{aid}.books.{bid}.todos(toDoDB:Map, createtodo(year:Str, month:Str, day:Str, title:Str)) = insert(toDoDB, - year, - insert(lookup(toDoDB, year), - month, - insert(lookup(lookup(toDoDB, year), month), - day, - append(lookup(lookup(lookup(toDoDB, year), month), day), - {"title": title, "check": false})))) + out accounts.{aid}.books.{bid}.todos(toDoDB:Map, createtodo(year:Str, month:Str, day:Str, title:Str)) = + if( + contains(toDoDB,year), + if( + contains(lookup(toDoDB,year),month), + if( + contains(lookup(lookup(toDoDB,year),month),day), + insert(toDoDB,year,insert(lookup(toDoDB,year),month,insert(lookup(lookup(toDoDB,year),month),day,append(lookup(lookup(lookup(toDoDB,year),month),day),{"title":title,"check":false})))), + insert(toDoDB,year,insert(lookup(toDoDB,year),month,insert(lookup(lookup(toDoDB,year),month),day,append(nil,{"title":title,"check":false})))) + ), + insert(toDoDB,year,insert(lookup(toDoDB,year),month,insert(nil,day,append(nil,{"title":title,"check":false})))) + ), + insert(toDoDB,year,insert(nil,month,insert(nil,day,append(nil,{"title":title,"check":false})))) + ) } channel ChangeToDoName(aid:Str, bid:Int, year:Str, month:Str, day:Str, tid:Int) { @@ -42,7 +48,7 @@ } channel DeleteToDo(aid:Str, bid:Int) { - out accounts.{aid}.books.{bid}.todos(toDoDB:Map, deleteToDo(year:Str, month:Str, day:Str, tid:int)) = insert(toDoDB, + out accounts.{aid}.books.{bid}.todos(toDoDB:Map, deleteToDo(year:Str, month:Str, day:Str, tid:Int)) = insert(toDoDB, year, insert(lookup(toDoDB, year), month,