Commit d4bc38ba authored by Bas Lijnse's avatar Bas Lijnse
Browse files

Simplified task numbers and more refactoring in task state storage.

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@1974 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 27b9ed2f
......@@ -32,8 +32,8 @@ Ext.define('itasks.container.TabContainer',{
this.callParent(arguments);
},
onTab: function(cnt,tab) {
if(cnt.taskId) {
this.fireEvent('edit',cnt.taskId,'top',cnt.items.indexOf(tab));
if(cnt.taskId && tab.taskId) {
this.fireEvent('edit',cnt.taskId,'top',tab.taskId);
}
},
insert: function(idx,tab) {
......
......@@ -70,7 +70,7 @@ where
= //updateManagerProperties pid (\m -> {ManagerProperties | m & status = Active})
/*>>| */ viewInformation ("Task activated","workflow is activated") [] False
delete (WorkflowProcess pid)
delete pid
= removeTask pid topLevelTasks
>>| viewInformation ("Task deleted","workflow is deleted") [] True
......
......@@ -413,6 +413,6 @@ optionalToMaybe 'general'.No = Nothing
createDocumentTask :: !String !String !String -> Task Document
createDocumentTask name mime content = mkInstantTask create
where
create taskNr iworld
create taskId iworld
# (res,iworld) = createDocument name mime content iworld
= (TaskStable res NoRep TCEmpty,iworld)
\ No newline at end of file
= (TaskStable res NoRep (TCEmpty taskId),iworld)
\ No newline at end of file
......@@ -312,7 +312,7 @@ whileUnchanged :: (ReadWriteShared r w) (r -> Task b) -> Task b | iTask r & iTas
* Append a task to the set of top level tasks
*
*/
appendTopLevelTask :: !ManagementMeta !(Task a) -> Task ProcessId | iTask a
appendTopLevelTask :: !ManagementMeta !(Task a) -> Task TaskId | iTask a
// Additional tuning shortcuts
instance tune BeforeLayout
......
......@@ -5,8 +5,8 @@ implementation module CommonCombinators
import StdBool, StdList,StdOrdList, StdTuple, StdGeneric, StdMisc, StdInt, StdClass, GenRecord, Text, Time, Tuple, List
import Util, Either, GenVisualize, GenUpdate
from StdFunc import id, const, o
from SystemTypes import :: ProcessId, :: User(..), :: Note(..)
from TaskContext import :: TaskContextTree(..), :: SubTaskId, :: SubTaskOrder, :: SubTaskContext, :: ParallelMeta
from SystemTypes import :: User(..), :: Note(..)
from TaskContext import :: TaskState(..), :: ParallelMeta, :: ParallelContext, :: ParallelItem
from SharedCombinators import mapShared, :: Shared, :: ReadWriteShared
from SystemData import randomInt, topLevelTasks
......@@ -233,8 +233,8 @@ whileUnchanged share task
)
<! isJust) >>= \(Just r) -> return r
appendTopLevelTask :: !ManagementMeta !(Task a) -> Task ProcessId | iTask a
appendTopLevelTask props task = appendTask (Detached props, \_ -> task @ const Remove) topLevelTasks @ WorkflowProcess
appendTopLevelTask :: !ManagementMeta !(Task a) -> Task TaskId | iTask a
appendTopLevelTask props task = appendTask (Detached props, \_ -> task @ const Remove) topLevelTasks @ \topNo -> (TaskId topNo 0)
instance tune BeforeLayout
where tune (BeforeLayout f) task = tune (ModifyLayout (\l pa0 ac0 at0 -> let (pa1,ac1,at1) = f (pa0,ac0,at0) in l pa1 ac1 at1)) task
......
......@@ -5,29 +5,29 @@ import StdBool, FilePath, CSV, File, Map, IWorld, Task, TaskContext, DocumentSto
exportDocument :: !FilePath !Document -> Task Document
exportDocument filename document = mkInstantTask eval
where
eval taskNr iworld = writeDocument filename document iworld
eval taskId iworld = writeDocument taskId filename document iworld
exportTextFile :: !FilePath !String -> Task String
exportTextFile filename content = mkInstantTask eval
where
eval taskNr iworld = fileTask filename content writeAll iworld
eval taskId iworld = fileTask taskId filename content writeAll iworld
createCSVFile :: !String ![[String]] -> Task Document
createCSVFile filename content = mkInstantTask eval
where
eval taskNr iworld
eval taskId iworld
# (doc,iworld) = createDocumentWith filename "text/csv" (writeCSVFile content) iworld
= (TaskStable doc NoRep TCEmpty, iworld)
= (TaskStable doc NoRep (TCEmpty taskId), iworld)
exportCSVFile :: !FilePath ![[String]] -> Task [[String]]
exportCSVFile filename content = mkInstantTask eval
where
eval taskNr iworld = fileTask filename content writeCSVFile iworld
eval taskId iworld = fileTask taskId filename content writeCSVFile iworld
exportCSVFileWith :: !Char !Char !Char !FilePath ![[String]] -> Task [[String]]
exportCSVFileWith delimitChar quoteChar escapeChar filename content = mkInstantTask eval
where
eval taskNr iworld = fileTask filename content (writeCSVFileWith delimitChar quoteChar escapeChar) iworld
eval taskId iworld = fileTask taskId filename content (writeCSVFileWith delimitChar quoteChar escapeChar) iworld
exportJSONFile :: !FilePath a -> Task a | iTask a
exportJSONFile filename content = exportJSONFileWith toJSON filename content
......@@ -35,15 +35,15 @@ exportJSONFile filename content = exportJSONFileWith toJSON filename content
exportJSONFileWith :: !(a -> JSONNode) !FilePath a -> Task a | iTask a
exportJSONFileWith encoder filename content = mkInstantTask eval
where
eval taskNr iworld = fileTask filename content (writeJSON encoder) iworld
eval taskId iworld = fileTask taskId filename content (writeJSON encoder) iworld
fileTask filename content f iworld=:{IWorld|world}
fileTask taskId filename content f iworld=:{IWorld|world}
# (ok,file,world) = fopen filename FWriteData world
| not ok = (openException filename,{IWorld|iworld & world = world})
# file = f content file
# (ok,world) = fclose file world
| not ok = (closeException filename,{IWorld|iworld & world = world})
= (TaskStable content NoRep TCEmpty, {IWorld|iworld & world = world})
= (TaskStable content NoRep (TCEmpty taskId), {IWorld|iworld & world = world})
writeAll content file
= fwrites content file
......@@ -51,7 +51,7 @@ writeAll content file
writeJSON encoder content file
= fwrites (toString (encoder content)) file
writeDocument filename document iworld
writeDocument taskId filename document iworld
# (mbContent,iworld=:{IWorld|world})
= getDocumentContent document.Document.documentId iworld
| isNothing mbContent = (ioException filename, {IWorld|iworld & world = world})
......@@ -60,7 +60,7 @@ writeDocument filename document iworld
# file = fwrites (fromJust mbContent) file
# (ok,world) = fclose file world
| not ok = (closeException filename,{IWorld|iworld & world = world})
= (TaskStable document NoRep TCEmpty, {IWorld|iworld & world = world})
= (TaskStable document NoRep (TCEmpty taskId), {IWorld|iworld & world = world})
ioException s = taskException (FileException s IOError)
openException s = taskException (FileException s CannotOpen)
......
......@@ -8,40 +8,40 @@ CHUNK_SIZE :== 1024
importDocument :: !FilePath -> Task Document
importDocument filename = mkInstantTask eval
where
eval taskNr iworld = readDocument filename iworld
eval taskId iworld = readDocument taskId filename iworld
importTextFile :: !FilePath -> Task String
importTextFile filename = mkInstantTask eval
where
eval taskNr iworld = fileTask filename readAll iworld
eval taskId iworld = fileTask taskId filename readAll iworld
importCSVFile :: !FilePath -> Task [[String]]
importCSVFile filename = mkInstantTask eval
where
eval taskNr iworld = fileTask filename readCSVFile iworld
eval taskId iworld = fileTask taskId filename readCSVFile iworld
importCSVFileWith :: !Char !Char !Char !FilePath -> Task [[String]]
importCSVFileWith delimitChar quoteChar escapeChar filename = mkInstantTask eval
where
eval taskNr iworld = fileTask filename (readCSVFileWith delimitChar quoteChar escapeChar) iworld
eval taskId iworld = fileTask taskId filename (readCSVFileWith delimitChar quoteChar escapeChar) iworld
importJSONFile :: !FilePath -> Task a | iTask a
importJSONFile filename = mkInstantTask eval
where
eval taskNr iworld = readJSON filename fromJSON iworld
eval taskId iworld = readJSON taskId filename fromJSON iworld
importJSONFileWith :: !(JSONNode -> Maybe a) !FilePath -> Task a | iTask a
importJSONFileWith parsefun filename = mkInstantTask eval
where
eval taskNr iworld = readJSON filename parsefun iworld
eval taskId iworld = readJSON taskId filename parsefun iworld
fileTask filename f iworld=:{IWorld|world}
fileTask taskId filename f iworld=:{IWorld|world}
# (ok,file,world) = fopen filename FReadData world
| not ok = (openException filename,{IWorld|iworld & world = world})
# (res,file) = f file
# (ok,world) = fclose file world
| not ok = (closeException filename,{IWorld|iworld & world = world})
= (TaskStable res NoRep TCEmpty, {IWorld|iworld & world = world})
= (TaskStable res NoRep (TCEmpty taskId), {IWorld|iworld & world = world})
readAll file
# (chunk,file) = freads file CHUNK_SIZE
......@@ -51,17 +51,17 @@ readAll file
# (rest,file) = readAll file
= (chunk +++ rest,file)
readJSON filename parsefun iworld=:{IWorld|world}
readJSON taskId filename parsefun iworld=:{IWorld|world}
# (ok,file,world) = fopen filename FReadData world
| not ok = (openException filename,{IWorld|iworld & world = world})
# (content,file) = readAll file
# (ok,world) = fclose file world
| not ok = (closeException filename,{IWorld|iworld & world = world})
= case (parsefun (fromString content)) of
Just a = (TaskStable a NoRep TCEmpty, {IWorld|iworld & world = world})
Just a = (TaskStable a NoRep (TCEmpty taskId), {IWorld|iworld & world = world})
Nothing = (parseException filename, {IWorld|iworld & world = world})
readDocument filename iworld=:{IWorld|world}
readDocument taskId filename iworld=:{IWorld|world}
# (ok,file,world) = fopen filename FReadData world
| not ok = (openException filename,{IWorld|iworld & world = world})
# (content,file) = readAll file
......@@ -70,7 +70,7 @@ readDocument filename iworld=:{IWorld|world}
# name = dropDirectory filename
# mime = extensionToMimeType (takeExtension name)
# (document,iworld) = createDocument name mime content {IWorld|iworld & world = world}
= (TaskStable document NoRep TCEmpty, iworld)
= (TaskStable document NoRep (TCEmpty taskId), iworld)
openException s = taskException (FileException s CannotOpen)
closeException s = taskException (FileException s CannotClose)
......
......@@ -100,17 +100,7 @@ parallel :: !d !a ![TaskContainer a] -> Task a | descr d & iTask a
= Keep
| Remove
| Stop
/**
* Information about a task in a parallel set.
*/
:: ParallelTaskMeta =
{ index :: !Int //* The task's index
, taskId :: !TaskId
, taskMeta :: !TaskMeta
, progressMeta :: !Maybe ProgressMeta
, managementMeta :: !Maybe ManagementMeta
}
/**
* Get the shared state of a task list
*/
......@@ -131,7 +121,7 @@ appendTask :: !(TaskContainer s) !(TaskList s) -> Task Int | TC s
/**
* Removes (and stops) a task from a task list
*/
removeTask :: !Int !(TaskList s) -> Task Void | TC s
removeTask :: !TaskId !(TaskList s) -> Task Void | TC s
/**
* Execute a task with the identity of the given user
......
This diff is collapsed.
......@@ -122,7 +122,7 @@ interact :: !d !((Maybe l) r -> l) ![InteractionPart l r] !(Maybe l) !(ReadOnlyS
* @return The state of the process to work on
* @throws WorkOnException
*/
workOn :: !ProcessId -> Task WorkOnProcessState
workOn :: !TaskId -> Task WorkOnProcessState
/**
* Evaluate a "World" function that does not yield any result once.
......
......@@ -17,49 +17,49 @@ derive JSONEncode UpdateMask
derive JSONDecode UpdateMask
return :: !a -> (Task a) | iTask a
return a = mkInstantTask (\_ iworld -> (TaskStable a NoRep TCEmpty, iworld))
return a = mkInstantTask (\taskId iworld -> (TaskStable a NoRep (TCEmpty taskId), iworld))
throw :: !e -> Task a | iTask a & iTask, toString e
throw e = mkInstantTask (\_ iworld -> (TaskException (dynamic e) (toString e), iworld))
throw e = mkInstantTask (\taskId iworld -> (TaskException (dynamic e) (toString e), iworld))
get :: !(ReadWriteShared a w) -> Task a | iTask a
get shared = mkInstantTask eval
where
eval taskNr iworld
eval taskId iworld
# (val,iworld) = 'Shared'.readShared shared iworld
# res = case val of
Ok val = TaskStable val NoRep TCEmpty
Ok val = TaskStable val NoRep (TCEmpty taskId)
Error e = taskException (SharedException e)
= (res, iworld)
set :: !a !(ReadWriteShared r a) -> Task a | iTask a
set val shared = mkInstantTask eval
where
eval taskNr iworld
eval taskId iworld
# (res,iworld) ='Shared'.writeShared shared val iworld
# res = case res of
Ok _ = TaskStable val NoRep TCEmpty
Ok _ = TaskStable val NoRep (TCEmpty taskId)
Error e = taskException (SharedException e)
= (res, iworld)
update :: !(r -> w) !(ReadWriteShared r w) -> Task w | iTask r & iTask w
update fun shared = mkInstantTask eval
where
eval taskNr iworld
eval taskId iworld
# (val,iworld) = 'Shared'.updateShared shared fun iworld
| isError val = (taskException (SharedException (fromError val)), iworld)
= (TaskStable (fromOk val) NoRep TCEmpty, iworld)
= (TaskStable (fromOk val) NoRep (TCEmpty taskId), iworld)
interact :: !d !((Maybe l) r -> l) ![InteractionPart l r] !(Maybe l) !(ReadOnlyShared r) -> Task (l,r) | descr d & iTask l & iTask r
interact desc initFun parts initLocal shared = mkTask init edit eval
where
init taskNr iworld //Create the initial views
init taskId iworld //Create the initial views
# (mbrvalue,iworld) = 'Shared'.readShared shared iworld
| isError mbrvalue = (TCEmpty, iworld)
| isError mbrvalue = (TCEmpty taskId, iworld)
# rvalue = fromOk mbrvalue
# (version,iworld) = getSharedVersion shared iworld
# lvalue = initFun initLocal rvalue
= (TCInteract (toJSON lvalue) (initParts lvalue rvalue parts) version, iworld)
= (TCInteract taskId (toJSON lvalue) (initParts lvalue rvalue parts) version, iworld)
initParts l r parts = map (initPart l r) parts
......@@ -80,9 +80,12 @@ where
= (fromOk mbv,iworld)
//Rewrite lucky events to events that target this task
edit taskNo (LuckyEvent e) context iworld = (edit taskNo (TaskEvent [] e) context iworld)
edit (LuckyEvent e) context=:(TCInteract taskId _ _ _) iworld
= (edit (TaskEvent taskId e) context iworld)
//There is an edit event for this task (because the location part of the event is the empty list)
edit taskNo (TaskEvent [] (dps,editv)) context=:(TCInteract encl views version) iworld=:{IWorld|timestamp,latestEvent}
edit (TaskEvent targetId (dps,editv)) context=:(TCInteract taskId encl views version) iworld=:{IWorld|timestamp,latestEvent}
| targetId <> taskId
= (context,iworld)
//Read latest versions of states
# (mbrval,iworld) = 'Shared'.readShared shared iworld
| isError mbrval = (context, iworld)
......@@ -93,9 +96,9 @@ where
| idx >= length parts = (context, iworld)
//Apply the event to the view
# (l,view,iworld) = updateView l r dp editv (parts !! idx) (views !! idx) iworld
= (TCInteract (toJSON l) (updateAt idx view views) version, iworld)
= (TCInteract taskId (toJSON l) (updateAt idx view views) version, iworld)
edit _ _ context iworld = (context,iworld)
edit _ context iworld = (context,iworld)
splitDataPath dp
= (hd dplist, dataPathFromList (reverse (tl dplist)))
......@@ -121,7 +124,7 @@ where
# (v,maskv,iworld) = updateValueAndMask dp editv v maskv iworld
= (v,toJSON v,maskv,iworld)
eval taskNo eEvent cEvent tuiTaskNo repAs context=:(TCInteract encl views rversion) iworld=:{IWorld|timestamp}
eval eEvent cEvent repAs context=:(TCInteract taskId encl views rversion) iworld=:{IWorld|timestamp}
# (mbrvalue,iworld) = 'Shared'.readShared shared iworld
| isError mbrvalue = (sharedException mbrvalue, iworld)
# rvalue = fromOk mbrvalue
......@@ -131,35 +134,40 @@ where
# (rversion,iworld) = if changed (getSharedVersion shared iworld) (rversion,iworld)
# lvalue = fromJust (fromJSON encl)
# mbEdit = case eEvent of
Just (TaskEvent [] e) = Just e
Just (TaskEvent t e)
| t == taskId = Just e
_ = Nothing
# (lvalue,reps,views,valid,iworld) = evalParts 0 taskNo repAs (fmap (appFst s2dp) mbEdit) changed lvalue rvalue parts views iworld
# (lvalue,reps,views,valid,iworld) = evalParts 0 taskId repAs (fmap (appFst s2dp) mbEdit) changed lvalue rvalue parts views iworld
# rep = case repAs of
(RepAsTUI layout)
# layoutfun = fromMaybe DEFAULT_LAYOUT layout
= TUIRep (layoutfun [gui \\ (TUIRep gui) <- reps] [] (initAttributes desc))
(RepAsTUI Nothing layout)
= TUIRep ((fromMaybe DEFAULT_LAYOUT layout) [gui \\ (TUIRep gui) <- reps] [] (initAttributes desc))
(RepAsTUI (Just target) layout) //If there is a target set, we only produce a representation only if this task is the target
| target == taskId
= TUIRep ((fromMaybe DEFAULT_LAYOUT layout) [gui \\ (TUIRep gui) <- reps] [] (initAttributes desc))
| otherwise
= NoRep
_
# (parts,actions) = unzip [(part,actions) \\ (ServiceRep (part,actions)) <- reps]
= ServiceRep (flatten parts,flatten actions)
# result = if valid (Just (lvalue,rvalue)) Nothing
= (TaskInstable result rep (TCInteract (toJSON lvalue) views rversion), iworld)
eval taskNo eEvent cEvent tuiTaskNo repAs TCEmpty iworld
= (TaskInstable result rep (TCInteract taskId (toJSON lvalue) views rversion), iworld)
eval eEvent cEvent repAs (TCEmpty _) iworld
= (taskException "Failed to initialize interact",iworld)
eval taskNo eEvent cEvent tuiTaskNo repAs context iworld
eval eEvent cEvent repAs context iworld
= (taskException "Corrupt context in interact",iworld)
evalParts idx taskNo repAs mbEvent changed l r [] [] iworld
evalParts idx taskId repAs mbEvent changed l r [] [] iworld
= (l,[],[],True,iworld)
evalParts idx taskNo repAs mbEvent changed l r [p:ps] [v:vs] iworld
# (nl,rep,view,pvalid,iworld) = evalPart idx taskNo repAs mbEvent changed l r p v iworld
# (nnl,reps,views,valid,iworld) = evalParts (idx + 1) taskNo repAs mbEvent changed nl r ps vs iworld
evalParts idx taskId repAs mbEvent changed l r [p:ps] [v:vs] iworld
# (nl,rep,view,pvalid,iworld) = evalPart idx taskId repAs mbEvent changed l r p v iworld
# (nnl,reps,views,valid,iworld) = evalParts (idx + 1) taskId repAs mbEvent changed nl r ps vs iworld
= (nnl,[rep:reps],[view:views],pvalid && valid,iworld) //All parts have to be valid
evalPart idx taskNo repAs mbEvent changed l r part view=:(encv,maskv,dirty) iworld = case part of
evalPart idx taskId repAs mbEvent changed l r part view=:(encv,maskv,dirty) iworld = case part of
DisplayPart f
//Simply visualize the view
# (rep,iworld) = displayRep idx taskNo repAs f l r encv iworld
# (rep,iworld) = displayRep idx taskId repAs f l r encv iworld
= (l,rep,view,True,iworld)
FormPart initf sharef viewf
......@@ -169,20 +177,20 @@ where
# (l,v,encv,maskv,vermask,dirty)
= if changed (refreshForm sharef l r v encv maskv vermask dirty) (l,v,encv,maskv,vermask,dirty)
//Create an editor for the view
# (rep,iworld) = editorRep idx taskNo repAs initf v encv maskv vermask mbEvent iworld
# (rep,iworld) = editorRep idx taskId repAs initf v encv maskv vermask mbEvent iworld
= (l,rep,(encv,maskv,dirty),isValidValue vermask,iworld)
displayRep idx taskNo (RepAsTUI _) f l r encv iworld
displayRep idx taskId (RepAsTUI _ _) f l r encv iworld
# (editor,iworld) = visualizeAsDisplay (f l r) iworld
= (TUIRep (editor,[],[]),iworld)
displayRep idx taskNo _ f l r encv iworld
= (ServiceRep ([(taskNrToString taskNo,idx,encv)],[]),iworld)
displayRep idx taskId _ f l r encv iworld
= (ServiceRep ([(toString taskId,idx,encv)],[]),iworld)
editorRep idx taskNo (RepAsTUI _) f v encv maskv vermask mbEvent iworld
# (editor,iworld) = visualizeAsEditor v (taskNrToString taskNo) idx vermask mbEvent iworld
editorRep idx taskId (RepAsTUI _ _) f v encv maskv vermask mbEvent iworld
# (editor,iworld) = visualizeAsEditor v taskId idx vermask mbEvent iworld
= (TUIRep (editor,[],[]),iworld)
editorRep idx taskNo _ f v encv maskv vermask mbEvent iworld
= (ServiceRep ([(taskNrToString taskNo,idx,encv)],[]),iworld)
editorRep idx taskId _ f v encv maskv vermask mbEvent iworld
= (ServiceRep ([(toString taskId,idx,encv)],[]),iworld)
refreshForm f l r v encv maskv vermask dirty
= case f l r (if (isValidValue vermask) (Just v) Nothing) dirty of
......@@ -195,45 +203,42 @@ where
sharedException :: !(MaybeErrorString a) -> (TaskResult b)
sharedException err = taskException (SharedException (fromError err))
workOn :: !ProcessId -> Task WorkOnProcessState
workOn (SessionProcess sessionId)
= abort "workOn applied to session process"
workOn processId
workOn :: !TaskId -> Task WorkOnProcessState
workOn target=:(TaskId topNo taskNo)
= mkTask init edit eval
where
init taskNr iworld = (TCEmpty, iworld)
init taskId iworld
= (TCEmpty taskId, iworld)
edit taskNr event _ iworld
edit event context iworld
//Load instance
# (mbContext,iworld) = loadTaskInstance processId iworld
| isError mbContext = (TCEmpty, iworld)
# (mbContext,iworld) = loadTaskInstance (Right topNo) iworld
| isError mbContext = (context, iworld)
//Apply event to instance
# (mbContext,iworld) = editInstance (Just event) (fromOk mbContext) iworld
//Store instance
| isError mbContext = (TCEmpty, iworld)
| isError mbContext = (context, iworld)
# iworld = storeTaskInstance (fromOk mbContext) iworld
= (TCEmpty, iworld)
= (context, iworld)
eval taskNr eEvent cEvent tuiTaskNr (RepAsTUI layout) _ iworld=:{evalStack}
eval eEvent cEvent (RepAsTUI target layout) (TCEmpty taskId) iworld=:{evalStack}
//Check for cycles
| isMember processId evalStack
| isMember taskId evalStack
=(taskException WorkOnDependencyCycle, iworld)
//Load instance
# (mbContext,iworld) = loadTaskInstance processId iworld
# (mbContext,iworld) = loadTaskInstance (Right topNo) iworld
| isError mbContext
//If the instance can not be found, check if it was only just added by an
//appendTask in the same session. If so, create a temporary result and trigger
//reevaluation.
# (found,iworld) = checkIfAddedGlobally processId iworld
# (found,iworld) = checkIfAddedGlobally topNo iworld
| found
= (TaskInstable Nothing (TUIRep (Just (stringDisplay "Task finished"),[],[])) TCEmpty, {iworld & readShares = Nothing})
= (TaskInstable Nothing (TUIRep (Just (stringDisplay "Task finished"),[],[])) (TCEmpty taskId), {iworld & readShares = Nothing})
| otherwise
= (taskException WorkOnNotFound ,iworld)
//Eval instance
# target = case processId of
(WorkflowProcess procNo) = [procNo]
(EmbeddedProcess _ taskId) = reverse (taskNrFromString taskId)
# (mbResult,context,iworld) = evalInstance target eEvent cEvent True (fromOk mbContext) iworld
# subTarget = if (taskNo == 0) Nothing (Just (TaskId topNo taskNo))
# (mbResult,context,iworld) = evalInstance eEvent cEvent subTarget True (fromOk mbContext) iworld
= case mbResult of
Error e = (taskException WorkOnEvalError, iworld)
Ok result
......@@ -244,13 +249,13 @@ where
(TaskStable _ rep _) = (WOFinished, rep, iworld)
(TaskException _ err) = (WOExcepted, TUIRep (Just (stringDisplay ("Task excepted: " +++ err)), [], []), iworld)
= case result of
WOFinished = (TaskStable WOFinished rep TCEmpty, iworld)
_ = (TaskInstable (Just result) rep TCEmpty, iworld)
WOFinished = (TaskStable WOFinished rep (TCEmpty taskId), iworld)
_ = (TaskInstable (Just result) rep (TCEmpty taskId), iworld)
checkIfAddedGlobally (WorkflowProcess procNo) iworld=:{parallelControls,currentUser}
= case 'Map'.get (toString topLevelTasks) parallelControls of
checkIfAddedGlobally topNo iworld=:{parallelControls,currentUser}
= case 'Map'.get (TaskId 0 0) parallelControls of
Just (_,controls)
= (isMember procNo [i \\ AppendTask i currentUser _ <- controls], iworld)
= (isMember topNo [i \\ AppendTask i currentUser _ <- controls], iworld)
_
= (False,iworld)
checkIfAddedGlobally _ iworld = (False,iworld)
......@@ -258,24 +263,24 @@ where
appWorld :: !(*World -> *World) -> Task Void
appWorld fun = mkInstantTask eval
where
eval taskNr iworld=:{IWorld|world}
= (TaskStable Void NoRep TCEmpty, {IWorld|iworld & world = fun world})
eval taskId iworld=:{IWorld|world}
= (TaskStable Void NoRep (TCEmpty taskId), {IWorld|iworld & world = fun world})