Commit c3b82fda authored by Bas Lijnse's avatar Bas Lijnse

Changed events fetching and removal for loops. This breaks groups for now!

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1120 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 364c43c7
......@@ -15,7 +15,7 @@ import Text
//Standard monadic operations:
(>>=) infixl 1 :: !(Task a) !(a -> Task b) -> Task b | iTask a & iTask b
(>>=) taska taskb = mkSequenceTask ">>=" tbind
(>>=) taska taskb = mkSequenceTask (dotdot (taskLabel taska)) tbind
where
tbind tst
# (result,tst) = applyTask taska tst
......@@ -27,7 +27,9 @@ where
= applyTask (taskb a) tst
TaskException e
= (TaskException e,tst)
dotdot s = if (endsWith s "...") s (s +++ "...")
(>>|) infixl 1 :: !(Task a) (Task b) -> Task b | iTask a & iTask b
(>>|) taska taskb = taska >>= \_ -> taskb
......@@ -122,7 +124,7 @@ group label description procFun parseFun initState initTasks groupActions = mkGr
where
execInGroup tst=:{taskNr,request}
# grTaskNr = drop 1 taskNr // get taskNr of group-task
# (events,tst) = getEventsFor (taskNrToString grTaskNr) True tst
# (events,tst) = getGroupEvents (taskNrToString grTaskNr) tst
# (pst,tst) = loadPSt grTaskNr tst
# gAction = case parseString (http_getValue "group" events "") of
Nothing = parseString (http_getValue "menuAndGroup" events "")
......
......@@ -388,23 +388,26 @@ setFocusCommand :: !String !*TSt -> *TSt //Only for group tasks
//EVENTS
/**
* Get the events (name/value pairs) for the current task
* These events are removed from the task state
*
* @param Include group events
* @param The task state
*
* @return The matched events
* @return The modified task state
*/
getEvents :: !Bool !*TSt -> ([(!String,!String)],!*TSt)
/**
* Get the events for a specific tasks
* Get the group events for a group of tasks
* These events are removed from the task state
*
* @param The task id to get events for
* @param Include events of subtasks?
* @param The task id of the group
* @param The task state
*
* @return The matched group events
* @return The modified task state
*/
getEventsFor :: !TaskId !Bool !*TSt -> ([(!String,!String)],!*TSt)
getGroupEvents :: !TaskId !*TSt -> ([(!String,!String)],!*TSt)
/**
* Test if there are events for any task during this run.
*
......
......@@ -751,9 +751,7 @@ applyTask (Task initProperties groupedProperties mbInitTaskNr taskfun) tst=:{tas
(Nothing, Just initTaskNr) = copyTaskStates initTaskNr taskNr tst
_ = tst
// Execute task function
# (result, tst) = taskfun tst
// Remove user updates (needed for looping. a new task may get the same tasknr again, but should not get the events)
# tst=:{tree=node,iworld=iworld=:{IWorld|store}} = {TSt|tst & events = []}
# (result, tst=:{tree=node,iworld=iworld=:{IWorld|store}}) = taskfun tst
// Update task state
= case result of
(TaskFinished a)
......@@ -773,6 +771,7 @@ applyTask (Task initProperties groupedProperties mbInitTaskNr taskfun) tst=:{tas
= (TaskFinished a, tst)
(TaskBusy)
// Store intermediate value
# procId = taskNrToString (tl taskNr)
# store = storeValue taskId result store
# tst = addTaskNode (finalizeTaskNode node)
{tst & taskNr = incTaskNr taskNr, tree = tree, iworld = {IWorld|iworld & store = store}}
......@@ -894,13 +893,30 @@ where
getEvents :: !Bool !*TSt -> ([(!String,!String)],!*TSt)
getEvents includeGroupEvents tst=:{taskNr,events}
= ([(name,value) \\ (task,name,value) <- events | task == taskId && (includeGroupEvents || name <> "group")], tst)
# (matched, rest) = getEvents` events
= (matched, {TSt|tst & events = rest})
where
taskId = taskNrToString taskNr
getEventsFor :: !TaskId !Bool !*TSt -> ([(!String,!String)],!*TSt)
getEventsFor taskId includeSub tst=:{TSt|events}
= ([(name,value) \\ (task,name,value) <- events | if includeSub (startsWith taskId task) (taskId == task)], tst)
getEvents` [] = ([],[])
getEvents` [event=:(task,name,value):events]
# (matched,rest) = getEvents` events
| task == taskId && (includeGroupEvents || name <> "group") = ([(name,value):matched], rest)
| otherwise = (matched, [event:rest])
getGroupEvents :: !TaskId !*TSt -> ([(!String,!String)],!*TSt)
getGroupEvents taskId tst=:{TSt|events}
# (matched, rest) = getGroupEvents` events
= (matched, {TSt|tst & events = rest})
where
getGroupEvents` []
= ([],[])
getGroupEvents` [event=:(task,name,value):events]
# (matched,rest) = getGroupEvents` events
| (task == taskId) && (name == "group" || name == "menuAndGroup")
= ([(name,value):matched], rest)
| otherwise
= (matched, [event:rest])
anyEvents :: !*TSt -> (!Bool,!*TSt)
anyEvents tst=:{TSt|events} = (not (isEmpty events),tst)
......
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