Commit 44a292c8 authored by Bas Lijnse's avatar Bas Lijnse

Added internal shares for access to task state, not used yet

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2375 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 6eaf46e1
implementation module SystemData
import SystemTypes, TaskStore, Time, Shared, Util, Text, Task, Tuple, StdFile
import SystemTypes, Store, TaskStore, Time, Shared, Util, Text, Task, Tuple, StdFile
import Random
import StdList, StdBool
from StdFunc import o, seq
......@@ -9,6 +9,9 @@ from Util import qualified currentDate, currentTime, currentDateTime, currentT
SYSTEM_DATA_NS :== "SystemData"
sharedStore :: !String !a -> Shared a | JSONEncode{|*|}, JSONDecode{|*|}, TC a
sharedStore storeId defaultV = storeAccess NS_APPLICATION_SHARES storeId defaultV
/*
sharedStore :: !String !a -> Shared a | JSONEncode{|*|}, JSONDecode{|*|}, TC a
sharedStore storeId defaultV = createChangeOnWriteSDS
"sharedStore" storeId
......@@ -23,6 +26,7 @@ where
= (res,iworld)
write v iworld = (Ok Void,storeValue NS_APPLICATION_SHARES storeId v iworld)
*/
currentDateTime :: ReadOnlyShared DateTime
currentDateTime = createReadOnlySDSPredictable SYSTEM_DATA_NS "currentDateTime" read
......@@ -142,4 +146,4 @@ where
# file = fwrites content file
# (ok,world) = fclose file world
| not ok = (Error (toString CannotClose) ,{IWorld|iworld & world = world})
= (Ok Void, {IWorld|iworld & world = world})
\ No newline at end of file
= (Ok Void, {IWorld|iworld & world = world})
......@@ -13,6 +13,7 @@ import JSON_NG
from Time import :: Timestamp
from IWorld import :: IWorld
from FilePath import :: FilePath
from SharedDataSource import :: RWShared
// Storage formats
:: StoreFormat = SFPlain | SFDynamic
......@@ -26,6 +27,11 @@ NS_TASK_INSTANCES :== "task-instances"
NS_DOCUMENT_CONTENT :== "document-data"
NS_APPLICATION_SHARES :== "application-data"
/**
* Create a shared data source for a piece of data in the store
*/
storeAccess :: !String !String a -> RWShared a a IWorld | JSONEncode{|*|}, JSONDecode{|*|}, TC a
/**
* Determine the location of the store from data directory and build
*/
......
......@@ -2,6 +2,7 @@ implementation module Store
import StdString, StdArray, StdChar, StdClass, StdInt, StdBool, StdFile, StdList, StdTuple, StdOrdList, StdMisc, Void
import File, Directory, OSError, Maybe, Map, Text, JSON_NG, Functor, FilePath
import SharedDataSource
from IWorld import :: IWorld(..), :: Work
from SystemTypes import :: DateTime, :: User, :: Config, :: TaskId, :: TaskNo, :: InstanceNo, :: TaskListItem, :: TaskTime, :: SessionId
from UIDefinition import :: UIDef, :: UIControl
......@@ -15,7 +16,16 @@ from iTasks import serialize, deserialize, defaultStoreFormat, functionFree
}
:: StoreFormat = SFPlain | SFDynamic
storeAccess :: !String !String a -> RWShared a a IWorld | JSONEncode{|*|}, JSONDecode{|*|}, TC a
storeAccess namespace storeId defaultV = createChangeOnWriteSDS namespace storeId read write
where
read iworld
# (mbV,iworld) = loadValue namespace storeId iworld
= (maybe (Ok defaultV) Ok mbV, iworld)
write v iworld
= (Ok Void,storeValue namespace storeId v iworld)
storePath :: !FilePath !String -> FilePath
storePath dataDir build = dataDir </> "store-" +++ build
......@@ -188,4 +198,4 @@ where
# (err,world) = deleteFile (dir </> f) world
= unlink dir fs world
| otherwise
= unlink dir fs world
\ No newline at end of file
= unlink dir fs world
......@@ -8,7 +8,7 @@ definition module TaskStore
import Maybe, Error, SystemTypes, Task, TaskState, UIDefinition
from Time import :: Timestamp
from SharedDataSource import :: BasicShareId
from SharedDataSource import :: BasicShareId, :: RWShared
newSessionId :: !*IWorld -> (!SessionId, !*IWorld)
newInstanceId :: !*IWorld -> (!InstanceNo, !*IWorld)
......@@ -60,10 +60,16 @@ addShareRegistration :: !BasicShareId !InstanceNo !*IWorld -> *IWorld
clearShareRegistrations :: !InstanceNo !*IWorld -> *IWorld
addOutdatedOnShareChange :: !BasicShareId !(InstanceNo -> Bool) !*IWorld -> *IWorld
//Task state accessible as shared data sources
taskInstanceMeta :: !InstanceNo -> RWShared TIMeta TIMeta IWorld
taskInstanceReduct :: !InstanceNo -> RWShared TIReduct TIReduct IWorld
taskInstanceResult :: !InstanceNo -> RWShared TIResult TIResult IWorld
taskInstanceRep :: !InstanceNo -> RWShared TIRep TIRep IWorld
//Keep last version of session user interfaces around, to be able to send differences to client
storeCurUI :: !SessionId !Int !UIDef !*IWorld -> *IWorld
loadPrevUI :: !SessionId !Int !*IWorld -> (!Maybe UIDef, !*IWorld)
//Sync previous user interfaces to disk (Only used with CGI wrapper)
saveUICache :: !*IWorld -> *IWorld
restoreUICache :: !*IWorld -> *IWorld
\ No newline at end of file
restoreUICache :: !*IWorld -> *IWorld
......@@ -21,6 +21,8 @@ derive JSONDecode UIControlSequence, UIActionSet, UIControlGroup, UIAbstractCont
derive JSONDecode UIMenuButtonOpts, UIButtonOpts, UIContainerOpts, UIPanelOpts, UIFieldSetOpts, UIWindowOpts, UIViewportOpts
derive JSONDecode UISize, UIMinSize, UIDirection, UIHAlign, UIVAlign, UISideSizes, UIMenuItem
derive gDefault TIMeta//, TIReduct, TIResult, TaskListEntry, TaskTree//, TaskRep, DeferredJSON, InteractionMask
INCREMENT :== "increment"
PERSISTENT_INDEX :== "persistent-index"
SHARE_REGISTRATIONS :== "share-registrations"
......@@ -227,6 +229,18 @@ addOutdatedOnShareChange shareId filterFun iworld
# regs = put shareId (filter (not o filterFun) outdated) regs
= storeValue NS_TASK_INSTANCES SHARE_REGISTRATIONS regs iworld
_ = iworld
taskInstanceMeta :: !InstanceNo -> RWShared TIMeta TIMeta IWorld
taskInstanceMeta instanceNo = storeAccess NS_TASK_INSTANCES (meta_store instanceNo) (abort "Read task instance meta too early")
taskInstanceReduct :: !InstanceNo -> RWShared TIReduct TIReduct IWorld
taskInstanceReduct instanceNo = storeAccess NS_TASK_INSTANCES (reduct_store instanceNo) (abort "Read task instance reduct too early")
taskInstanceResult :: !InstanceNo -> RWShared TIResult TIResult IWorld
taskInstanceResult instanceNo = storeAccess NS_TASK_INSTANCES (result_store instanceNo) (abort "Read task instance result too early")
taskInstanceRep :: !InstanceNo -> RWShared TIRep TIRep IWorld
taskInstanceRep instanceNo = storeAccess NS_TASK_INSTANCES (rep_store instanceNo) (abort "Read task representation result too early")
storeCurUI :: !SessionId !Int !UIDef !*IWorld -> *IWorld
storeCurUI sid version def iworld=:{IWorld|uis} = {IWorld|iworld & uis = put sid (version,def) uis}
......
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