Commit 780a06de authored by Bas Lijnse's avatar Bas Lijnse

Migrated movingTask and deadline examples

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/branches/fancyTasks@503 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 1a0edc7e
......@@ -7,6 +7,10 @@ import Vote
import Purchase
import TravelBooking
//Higher order examples
import MovingTask
import DeadlineTask
//Miscellaneous examples
import Coffeemachine
import Newsgroups
......@@ -19,6 +23,8 @@ where
workflows = flatten [ voteExample
, purchaseExample
, travelBookingExample
, movingTaskExample
, deadlineTaskExample
, coffeemachineExample
, newsgroupsExample
, exceptionHandlingExample
......
definition module DeadlineTask
import iTasks
deadlineTaskExample :: [Workflow]
\ No newline at end of file
module deadline
implementation module DeadlineTask
import iTasks, iDataTrivial
import StdClass, StdEnum, StdList
......@@ -10,18 +10,19 @@ import StdClass, StdEnum, StdList
// If the task is not finished on time, the task will be shipped back to the original user who has to do it instead
// It is also possible that the user becomes impatient and he can cancel the delegated task even though the deadline is not reached
npersons = 6
Start world = startEngine [delegateWorkflow] world
delegateWorkflow = { name = "deadline"
, label = "deadline work"
, roles = []
, mainTask = deadline mytask #>> return_V Void
}
deadlineTaskExample :: [Workflow]
deadlineTaskExample
= [ { name = "Examples/Higher order tasks/Deadline task"
, label = "Do task before deadline"
, roles = []
, mainTask = deadline trivialTask >>| return Void
}
]
mytask = editTask "OK" 0 <| (\n -> if (n <= 42) (False,[Text ("Error " <+++ n <+++ " should be larger than 42")]) (True,[]))
trivialTask :: Task Int
trivialTask = editTask "OK" 0 <| (\n -> if (n <= 42) (False,[Text ("Error " <+++ n <+++ " should be larger than 42")]) (True,[]))
deadline :: (Task a) -> Task a | iData a
deadline task
......@@ -32,12 +33,12 @@ deadline task
=>> \time -> [Text "Cancel delegated work if you are getting impatient:",BrTag [],BrTag []]
?>> (delegateTask (toInt whom) time task
-||-
buttonTask "Cancel" (return_V Nothing))
buttonTask "Cancel" (return Nothing))
=>> CheckDone
where
CheckDone (Just value)
= [Text ("Result of task: " +++ printToString value),BrTag [],BrTag []]
?>> buttonTask "OK" (return_V value)
?>> buttonTask "OK" (return value)
CheckDone nothing
= [Text "Task expired or canceled, you have to do it yourself!",BrTag [],BrTag []]
?>> buttonTask "OK" task
......@@ -47,8 +48,8 @@ where
where
mytask
= ( waitForTimerTask time
#>> return_V Nothing) // return nothing
>>| return Nothing) // return nothing
-||-
( [Text ("You have to complete the task in " <+++ time <+++ " time"),BrTag [],BrTag []] // tell deadline
?>> task
=>> \v -> return_V (Just v)) // do task and return its result
>>= \v -> return (Just v)) // do task and return its result
definition module MovingTask
import iTasks
movingTaskExample :: [Workflow]
\ No newline at end of file
module movingTask
implementation module MovingTask
import StdEnv, iTasks, iDataTrivial
from ProcessDB import :: ProcessStatus, Suspended, Active, Deleted, Finished
// (c) MJP 2007
// Just a scratch file to test the different combinators in the iTasks library
import iTasks, iDataTrivial
from ProcessDB import :: ProcessStatus(..)
derive gForm QForm, Person, Gender
derive gUpd QForm, Person, Gender
......@@ -26,27 +22,29 @@ derive gPrint QForm, Person, Gender
}
:: Gender = Male | Female
Start world = startEngine [myWorkflow] world
myWorkflow
= { name = "movingTask"
movingTaskExample :: [Workflow]
movingTaskExample
= [ { name = "Examples/Higher order tasks/Moving task"
, label = "movingTask"
, roles = []
, mainTask = movingTask ("Task which can be moved", [Text "Please fill in quotation:"] ?>> fillInForm createDefault)
, mainTask = movingTask ("Task which can be moved", trivialTask )
}
]
fillInForm :: QForm -> (Task QForm)
trivialTask :: Task QForm
trivialTask = [Text "Please fill in quotation:"] ?>> fillInForm createDefault
fillInForm :: QForm -> Task QForm
fillInForm form
= editTask "commit" form
=>> \form -> chooseTask [Text "Is everything filled in correctly?", toHtml form]
[("Yes, commit", return_V form)
[("Yes, commit", return form)
,("No", fillInForm form)
]
OK = button "OK" True
NOK = button "OK" False
movingTask labeltask
= newmove
where
......@@ -64,12 +62,12 @@ where
,("delete it", delete wid)
,("wait for it",waitForIt wid)
]
=>> \finished -> if finished (return_V Void) (inspect wid)
=>> \finished -> if finished (return Void) (inspect wid)
getStatus wid
= getProcessStatus wid
=>> \st -> getProcessOwner wid
=>> \mbOwner -> if (isNothing mbOwner) (return_V ["???"]) (getUserNamesTask [(fromJust mbOwner)])
=>> \mbOwner -> if (isNothing mbOwner) (return ["???"]) (getUserNamesTask [(fromJust mbOwner)])
=>> \names -> case st of
Finished -> [Text "It is finished"] ?>> OK
Deleted -> [Text "It is deleted"] ?>> OK
......@@ -88,12 +86,12 @@ where
delete wid
= deleteProcess wid
#>> return_V True
#>> return True
reassign wid
= selectUser "Who is next?"
=>> \who -> setProcessOwner who wid
#>> return_V False
#>> return False
waitForIt wid
= [Text "Waiting for the result..."]
......@@ -107,5 +105,5 @@ selectUser prompt
= getUsersIds
=>> \userIds -> getUserNamesTask userIds
=>> \names -> chooseTask_pdm [Text prompt] 0
[(name, return_V userId) \\ userId <- userIds & name <- names]
[(name, return userId) \\ userId <- userIds & name <- names]
This source diff could not be displayed because it is too large. You can view the blob instead.
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