Commit db6a3e07 authored by Bas Lijnse's avatar Bas Lijnse

A set ofo small improvements

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/branches/fancyTasks@626 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 68ed72b8
......@@ -14,13 +14,14 @@ import MovingTask
import DeadlineTask
import DelegateTask
import ReviewTask
import ExceptionHandling
//Miscellaneous examples
import SmallExamples
import GUIDemo
import BugReport
import Coffeemachine
import Newsgroups
import ExceptionHandling
import ChangeHandling
import WebShop
......@@ -40,6 +41,7 @@ where
, delegateTaskExample
, reviewTaskExample
, smallExamples
, guiDemoExample
, bugReportExample
, coffeemachineExample
, newsgroupsExample
......
......@@ -54,10 +54,24 @@ instance DB Bug where
bugReportExample :: [Workflow]
bugReportExample
= [workflow "Examples/Miscellaneous/Bug report" reportBug]
= [ workflow "Examples/Miscellaneous/Bug report (simple)" reportBug1
, workflow "Examples/Miscellaneous/Bug report (intermediate)" reportBug2
, workflow "Examples/Miscellaneous/Bug report (advanced)" reportBug3
]
reportBug1 :: Task BugReport
reportBug1
= enterInformation "Please describe the bug you have found"
>>= \report ->
assignByName "bas" "Bug fix" NormalPriority Nothing
(showMessageAbout "The following bug has been reported" report)
>>| return report
reportBug :: Task Void
reportBug
reportBug2 :: Task Void
reportBug2 = return Void
reportBug3 :: Task Void
reportBug3
= enterInitialReport
>>= \report ->
fileBugReport report
......
......@@ -14,7 +14,7 @@ derive gParse NegativeValueException, TooLargeValueException
exceptionHandlingExample :: [Workflow]
exceptionHandlingExample
= [{ name = "Examples/Miscellaneous/Exception handling"
= [{ name = "Examples/Higher order/Exception handling"
, label = "Exception example"
, roles = []
, mainTask = exceptionTask
......
definition module GUIDemo
/**
* Two step workflow that demonstrates the possibilities
* of the generic user interfaces.
*/
import iTasks
guiDemoExample :: [Workflow]
\ No newline at end of file
implementation module GUIDemo
import iTasks
import CommonDomain
guiDemoExample :: [Workflow]
guiDemoExample
= [ workflow "Examples/Miscellaneous/GUI Demo" guiDemo]
:: Address =
{ street :: String
, number :: Int
, postalCode :: String
}
:: Person =
{ name :: String
, cool :: Bool
, dob :: Date
, tob :: Time
, age :: Maybe Int
, address :: Address
, grades :: [Int]
, note :: Maybe Note
}
derive gPrint Person, Address
derive gParse Person, Address
derive gVisualize Person, Address
derive gUpdate Person, Address
address = {Address | street = "Heyendaalseweg", number = 135, postalCode = "6525 AJ"}
person = {Person | name = "John Doe"
, cool = True
, dob = {year = 1978, mon = 4, day = 1}
, tob = {hour = 13, min = 42, sec = 0}
, age = Just 23
, address = address
, grades = []
, note = Nothing
}
guiDemo :: Task Void
guiDemo
= updateInformation "You may change this information" person
>>= showMessageAbout "This is the information you entered"
\ No newline at end of file
......@@ -3,7 +3,7 @@ implementation module SmallExamples
import iTasks
smallExamples :: [Workflow]
smallExamples = [workflow "Examples/Miscellaneous/calculateSum" calculateSum]
smallExamples = [workflow "Examples/Miscellaneous/Calculate sum" calculateSum]
calculateSum :: Task Int
calculateSum
......@@ -13,4 +13,4 @@ calculateSum
>>= \num2 ->
let sum = (num1 + num2) in
showMessageAbout "The sum of those numbers is:" sum
>>| return sum
>>| return sum
\ No newline at end of file
......@@ -17,6 +17,10 @@ from InteractionTasks import class html
*/
getUser :: !UserId -> Task User
/**
* Finds a specific user by username
*/
getUserByName :: !String -> Task User
/**
* Finds all users
*/
getUsers :: Task [User]
......
......@@ -7,6 +7,7 @@ import StdList, StdMaybe
from UserDB import :: User
from UserDB import qualified getCurrentUser
from UserDB import qualified getUser
from UserDB import qualified getUserByName
from UserDB import qualified getUsers
from UserDB import qualified getUsersWithRole
from UserDB import qualified getDisplayNames
......@@ -19,6 +20,9 @@ import InteractionTasks, CoreCombinators
getUser :: !UserId -> Task User
getUser uid = mkInstantTask "getUser" (UserDB@getUser uid)
getUserByName :: !String -> Task User
getUserByName name = mkInstantTask "getUserByName" (UserDB@getUserByName name)
getUsers :: Task [User]
getUsers = mkInstantTask "getUsers" UserDB@getUsers
......
......@@ -16,6 +16,15 @@ import TSt
*/
getUser :: !Int !*TSt -> (!User , !*TSt)
/**
* Fetches the id and display name from the user database for a given user id.
*
* @param A username
* @param A unique user database handle
* @return The user
* @return The database handle
*/
getUserByName :: !String !*TSt -> (!User , !*TSt)
/**
* Fetches the id and display name of all users from the from the user database.
*
* @param A unique user database handle
......
......@@ -9,7 +9,17 @@ unknownUser = {User | userId = -1, userName = "", displayName = "Unknown user",
rootUser :: User
rootUser = {User | userId = 0, userName = "root", displayName = "Root", password = "", roles = []}
//TEMPORARY ALTERNATIVE HARDCODED USER SET
testUsers :: [User]
testUsers = [ {User | userId = 1, userName = "bas", displayName = "Bas", password = "", roles = []}
, {User | userId = 2, userName = "rinus", displayName = "Rinus", password = "", roles = []}
, {User | userId = 3, userName = "thomas", displayName = "Thomas", password = "", roles = []}
, {User | userId = 4, userName = "peter", displayName = "Peter", password = "", roles = []}
, {User | userId = 5, userName = "pieter", displayName = "Pieter", password = "", roles = []}
, {User | userId = 6, userName = "janmartin", displayName = "Jan Martin", password = "", roles = []}
]
/*
testUsers :: [User]
testUsers = [ {User | userId = 1, userName = "president", displayName = "President", password = "", roles = ["president"]}
, {User | userId = 2, userName = "manager", displayName = "Middle manager", password = "", roles = ["manager"]}
......@@ -45,7 +55,9 @@ testUsers = [ {User | userId = 1, userName = "president", displayName = "Preside
, {User | userId = 47, userName = "expert7", displayName = "Expert 7", password = "", roles = ["experts"]}
, {User | userId = 48, userName = "expert8", displayName = "Expert 8", password = "", roles = ["experts"]}
, {User | userId = 49, userName = "expert9", displayName = "Expert 9", password = "", roles = ["experts"]}
]
]
*/
getUser :: !Int !*TSt -> (!User,!*TSt)
getUser 0 tst
= (rootUser,tst)
......@@ -55,6 +67,15 @@ getUser uid tst
[x] = (x,tst)
_ = (unknownUser,tst)
getUserByName :: !String !*TSt -> (!User, !*TSt)
getUserByName "root" tst
= (rootUser,tst)
getUserByName name tst
# (users, tst) = userStore id tst
= case filter (\u -> u.User.userName == name) users of
[x] = (x,tst)
_ = (unknownUser,tst)
getUsers :: !*TSt -> (![User], !*TSt)
getUsers tst
# (users, tst) = userStore id tst
......
......@@ -27,6 +27,9 @@ eitherTask :: !(Task a) !(Task b) -> Task (Either a b) | iTask a & iTask
//Task delegation
(@:) infix 3 :: !UserId !(LabeledTask a) -> Task a | iTask a
assignByName :: !String !String !TaskPriority !(Maybe Timestamp) (Task a)
-> Task a | iTask a
/* Handling recursion and loops:
repeatTask :: repeat Task until predicate is valid
(<|) :: repeat task (recursively) as long as predicate does not hold, and give error message otherwise
......
......@@ -8,12 +8,12 @@ import StdBool, StdList, StdTuple, StdGeneric, StdMisc, GenBimap
from StdFunc import id, const
from TSt import :: Task(..), :: TSt{..}, :: TaskInfo{..}, :: StaticInfo{..}, :: Workflow, :: ChangeLifeTime, :: Options, :: HTTPRequest, :: Config
from TSt import applyTask, mkSequenceTask, mkParallelTask
from Types import :: ProcessId, :: DynamicId, :: TaskId, :: TaskPriority(..)
from Types import :: ProcessId, :: DynamicId, :: TaskId, :: TaskPriority(..), :: User(..)
from Store import :: Store
from SessionDB import :: Session
from TaskTree import :: TaskTree, :: TaskCombination(..)
import SystemTasks, InteractionTasks, CoreCombinators, TuningCombinators, LiftingCombinators
import SystemTasks, InteractionTasks, UserDBTasks, CoreCombinators, TuningCombinators, LiftingCombinators
import Util, Either
import GenVisualize, GenUpdate
......@@ -106,4 +106,9 @@ repeatTask task pred a =
(@:) infix 3 :: !UserId !(LabeledTask a) -> Task a | iTask a
(@:) nuserId (label,task) = assign nuserId NormalPriority Nothing (task <<@ label)
assignByName :: !String !String !TaskPriority !(Maybe Timestamp) (Task a) -> Task a | iTask a
assignByName name subject priority deadline task
= getUserByName name
>>= \user ->
assign user.User.userId priority deadline (task <<@ subject)
// ******************************************************************************************************
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