Commit 2a1539ac authored by Bas Lijnse's avatar Bas Lijnse

Refactored the schedule meeting example

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@696 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 1fa29e01
......@@ -2,66 +2,37 @@ implementation module ScheduleMeeting
import iTasks
import CommonDomain
import StdMisc
// (c) MJP 2007
// findDate will settle a date and time between two persons that want to meet
// first a person is chosen by the person taken the initiative, person 0
// then a date is settled by the two persons by repeatedly asking each other for a convenient date
// if such a date is found both have to confirm the date and the task is finished
npersons = 5
scheduleMeetingExample :: [Workflow]
scheduleMeetingExample
= [ { name = "Examples/Business/Schedule meeting"
, label = "Schedule meeting"
, roles = []
, mainTask = findDate >>| return Void
}
]
findDate :: Task (Date,Time)
findDate
= chooseUser "Choose person you want to schedule a meeting with:"
>>= \whom -> findDate` whom.User.userId ({Date|year = 2007, mon = 1, day = 1},{Time|hour = 9, min = 0, sec = 0})
>>= \datetime -> (confirm 0 whom.User.userId datetime -&&- confirm whom.User.userId 0 datetime)
scheduleMeetingExample = [workflow "Examples/Business/Schedule meeting" scheduleMeeting]
scheduleMeeting :: Task (Date,Time)
scheduleMeeting
= getCurrentUser -&&- chooseUser "Who do yo want to schedule a meeting with?"
>>= \(me,you) -> enterInformation "When do you want to schedule the meeting?"
>>= \datetime -> findDate you datetime
>>= \datetime -> (confirm you me datetime -&&- confirm me you datetime)
>>| return datetime
where
findDate` :: Int (Date,Time) -> Task (Date,Time)
findDate` whom daytime
= proposeDateTime daytime
>>= \daytime -> whom @: ("Meeting Request",determineDateTime daytime)
>>= \(ok,daytime) -> if ok
(return daytime)
( isOkDateTime daytime
>>= \ok -> if ok
(return daytime)
(findDate` whom daytime)
)
where
proposeDateTime :: (Date,Time) -> Task (Date,Time)
proposeDateTime (date,time)
= updateInformation [Text "Propose a new date and time for meeting:",BrTag [],BrTag []] input
>>= \(_,date,_,time) -> return (date,time)
where
input = (toString (Text "date: "), date, toString (Text "time: "), time)
determineDateTime :: (Date,Time) -> Task (Bool,(Date,Time))
determineDateTime daytime
= isOkDateTime daytime
>>= \ok -> if ok
(return (ok,daytime))
( proposeDateTime daytime
>>= \daytime -> return (ok,daytime)
)
isOkDateTime :: (Date,Time) -> Task Bool
isOkDateTime (date,time)
= requestConfirmation ("Can we meet on the " <+++ date <+++ " at " <+++ time <+++ "?")
confirm :: Int Int (Date,Time) -> Task Void
confirm me you (date,time)
= me @: ("Meeting confirmation", showMessage ("User " <+++ me <+++ " and " <+++ you <+++ " have a meeting on " <+++ date <+++ " at " <+++ time))
findDate :: User (Date,Time) -> Task (Date, Time)
findDate user datetime
= user.userId @: ("Meeting request", proposeMeeting datetime)
>>= \(ok,alternative) -> if ok
(return datetime)
(requestConfirmationAbout ("Your proposed date (" <+++ datetime <+++ ") was not possible, is this alternative ok?") alternative
>>= \ok -> if ok
(return alternative)
(updateInformation "Please suggest an alternative date" datetime >>= \datetime -> findDate user datetime)
)
proposeMeeting :: (Date,Time) -> Task (Bool,(Date,Time))
proposeMeeting datetime
= requestConfirmationAbout "Can we meet on the following date?" datetime
>>= \ok -> if ok
(return (True,datetime))
(updateInformation "Please suggest an alternative date" datetime >>= \alternative -> return (False,alternative))
confirm :: User User (Date,Time) -> Task Void
confirm you me (date,time)
= you.userId @:
("Meeting confirmation", showMessage ("You have a meeting with " <+++ me.displayName <+++ " on " <+++ date <+++ " at " <+++ time))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment