UserDBTasks.icl 2.17 KB
Newer Older
Bas Lijnse's avatar
Bas Lijnse committed
1
implementation module UserDBTasks
2

Bas Lijnse's avatar
Bas Lijnse committed
3
from TSt import :: Task, :: TSt
Bas Lijnse's avatar
Bas Lijnse committed
4
from TSt import mkInstantTask
Bas Lijnse's avatar
Bas Lijnse committed
5 6 7 8
import StdList, StdMaybe

from UserDB import :: User
from UserDB import qualified getUser
Bas Lijnse's avatar
Bas Lijnse committed
9
from UserDB import qualified getUserByName
Bas Lijnse's avatar
Bas Lijnse committed
10 11 12 13 14 15
from UserDB import qualified getUsers
from UserDB import qualified getUsersWithRole
from UserDB import qualified getDisplayNames
from UserDB import qualified getUserNames
from UserDB import qualified getRoles
from UserDB import qualified authenticateUser
16
from UserDB	import qualified createUser
17 18
from UserDB import qualified updateUser
from UserDB import qualified deleteUser
19

Bas Lijnse's avatar
Bas Lijnse committed
20
import InteractionTasks, CoreCombinators
21

Bas Lijnse's avatar
Bas Lijnse committed
22
getUser :: !UserId -> Task User
Bas Lijnse's avatar
Bas Lijnse committed
23
getUser uid = mkInstantTask "getUser" (UserDB@getUser uid)
Bas Lijnse's avatar
Bas Lijnse committed
24

Bas Lijnse's avatar
Bas Lijnse committed
25 26 27
getUserByName :: !String -> Task User
getUserByName name = mkInstantTask "getUserByName" (UserDB@getUserByName name)

Bas Lijnse's avatar
Bas Lijnse committed
28
getUsers :: Task [User]
Bas Lijnse's avatar
Bas Lijnse committed
29
getUsers = mkInstantTask "getUsers" UserDB@getUsers
Bas Lijnse's avatar
Bas Lijnse committed
30

Bas Lijnse's avatar
Bas Lijnse committed
31
getUsersWithRole :: !String	-> Task [User]
Bas Lijnse's avatar
Bas Lijnse committed
32
getUsersWithRole role = mkInstantTask "getUsersWithRole" (UserDB@getUsersWithRole role)
33
	
Bas Lijnse's avatar
Bas Lijnse committed
34
getDisplayNames :: ![UserId] -> Task [String]
Bas Lijnse's avatar
Bas Lijnse committed
35
getDisplayNames uids = mkInstantTask "getDisplayNames" (UserDB@getDisplayNames uids)
36

Bas Lijnse's avatar
Bas Lijnse committed
37
getUserNames :: ![UserId] -> Task [String]
Bas Lijnse's avatar
Bas Lijnse committed
38
getUserNames uids = mkInstantTask "getUserNames" (UserDB@getUserNames uids)
Bas Lijnse's avatar
Bas Lijnse committed
39 40

getRoles :: ![UserId]	-> Task [[String]]
Bas Lijnse's avatar
Bas Lijnse committed
41
getRoles uids = mkInstantTask "getRoles" (UserDB@getRoles uids)
Bas Lijnse's avatar
Bas Lijnse committed
42 43 44 45

authenticateUser :: !String !String	-> Task (Maybe User)
authenticateUser username password = mkInstantTask "authenticateUser" (UserDB@authenticateUser username password)

46 47 48 49 50 51 52 53
createUser :: !User -> Task User
createUser user = mkInstantTask "createUser" (UserDB@createUser user)

updateUser :: !User -> Task User
updateUser user = mkInstantTask "updateUser" (UserDB@updateUser user)

deleteUser :: !User -> Task User
deleteUser user = mkInstantTask "deleteUser" (UserDB@deleteUser user)
54

Bas Lijnse's avatar
Bas Lijnse committed
55
chooseUser :: !question -> Task User | html question
56
chooseUser question
Bas Lijnse's avatar
Bas Lijnse committed
57
	= 				getUsers
58
	>>= \users ->	enterChoice question users
Bas Lijnse's avatar
Bas Lijnse committed
59

60
	
Bas Lijnse's avatar
Bas Lijnse committed
61
chooseUserWithRole :: !question !String -> Task User | html question
62
chooseUserWithRole question role
Bas Lijnse's avatar
Bas Lijnse committed
63
	= 				getUsersWithRole role
64
	>>= \users ->	enterChoice question users