Commit 0c87588c authored by Bas Lijnse's avatar Bas Lijnse
Browse files

Removed dependency on MySQL from IWorld by using extensible ADT

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@2637 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 53c31ac2
......@@ -5,8 +5,10 @@ import iTasks.Framework.IWorld, iTasks.Framework.Shared
from Data.SharedDataSource import class reportSDSChange(..)
import qualified Data.Map
derive class iTask SQLValue, SQLDate, SQLTime
//Extend Resource type for mysql resources
:: *Resource | MySQLResource *(!*MySQLCursor, !*MySQLConnection, !*MySQLContext)
derive class iTask SQLValue, SQLDate, SQLTime
sqlShare :: SQLDatabase String (A.*cur: *cur -> *(MaybeErrorString r,*cur) | SQLCursor cur)
(A.*cur: w *cur -> *(MaybeErrorString Void, *cur) | SQLCursor cur) -> ReadWriteShared r w
......@@ -90,10 +92,10 @@ where
write Void iworld = (Ok Void,iworld)
openMySQLDb :: !SQLDatabase !*IWorld -> (MaybeErrorString (!*MySQLCursor, !*MySQLConnection, !*MySQLContext), !*IWorld)
openMySQLDb db iworld=:{IWorld|mysqlConnection=Just con}
= (Ok con, {IWorld|iworld & mysqlConnection=Nothing})
openMySQLDb db iworld=:{IWorld|mysqlConnection=Nothing}
# iworld=:{IWorld|world} = {IWorld|iworld & mysqlConnection = Nothing}
openMySQLDb db iworld=:{IWorld|resources=Just (MySQLResource con)}
= (Ok con, {IWorld|iworld & resources=Nothing})
openMySQLDb db iworld=:{IWorld|resources=Nothing}
# iworld=:{IWorld|world} = {IWorld|iworld & resources = Nothing}
# (err,mbContext,world) = openContext world
| isJust err = (Error (toString (fromJust err)),{IWorld|iworld & world = world})
# (err,mbConn,context) = openConnection db (fromJust mbContext)
......@@ -103,8 +105,8 @@ openMySQLDb db iworld=:{IWorld|mysqlConnection=Nothing}
= (Ok (fromJust mbCursor,connection, context),{IWorld|iworld & world = world})
closeMySQLDb :: !*MySQLCursor !*MySQLConnection !*MySQLContext !*IWorld -> *IWorld
closeMySQLDb cursor connection context iworld=:{IWorld|mysqlConnection=Nothing}
= {IWorld|iworld & mysqlConnection=Just (cursor,connection,context)}
closeMySQLDb cursor connection context iworld=:{IWorld|resources=Nothing}
= {IWorld|iworld & resources=Just (MySQLResource (cursor,connection,context))}
closeMySQLDb cursor connection context iworld=:{IWorld|world}
# (err,connection) = closeCursor cursor connection
# (err,context) = closeConnection connection context
......
......@@ -195,7 +195,7 @@ initIWorld sdkPath world
,uiMessages = newMap
,shutdown = False
,world = world
,mysqlConnection = Nothing
,resources = Nothing
}
where
defaultConfig :: Config
......
......@@ -13,7 +13,6 @@ from Text.JSON import :: JSONNode
from StdFile import class FileSystem
from Data.SharedDataSource import class registerSDSDependency, class registerSDSChangeDetection, class reportSDSChange, :: CheckRes(..), :: BasicShareId, :: Hash
from iTasks.Framework.TaskServer import class HttpServerEnv
import Database.SQL.MySQL
:: *IWorld = { application :: !String // The name of the application
, build :: !String // The date/time identifier of the application's build
......@@ -44,9 +43,11 @@ import Database.SQL.MySQL
, world :: !*World // The outside world
//Experimental database connection cache
, mysqlConnection :: !*(Maybe *(!*MySQLCursor, !*MySQLConnection, !*MySQLContext))
, resources :: !*(Maybe *Resource)
}
:: *Resource = Resource | .. //Extensible resource type for caching database connections etc...
updateCurrentDateTime :: !*IWorld -> *IWorld
queueWork :: !(!Work, !Maybe Timestamp) !*IWorld -> *IWorld
......
......@@ -6,14 +6,13 @@ import Data.Maybe, Data.Map, Data.Functor
import System.File, System.Directory, System.OSError, System.FilePath
import Text, Text.JSON
import Data.SharedDataSource
from iTasks.Framework.IWorld import :: IWorld(..), :: Work, :: UIMessage
from iTasks.Framework.IWorld import :: IWorld(..), :: Work, :: UIMessage, :: Resource
from iTasks.Framework.UIDefinition import :: UIDef, :: UIControl
from iTasks.Framework.UIDiff import :: UIUpdate, :: UIDiffers
from iTasks.Framework.TaskState import :: TaskListEntry
from iTasks.API.Core.SystemTypes import :: DateTime, :: User, :: Config, :: TaskId, :: TaskNo, :: InstanceNo, :: TaskListItem, :: TaskTime, :: SessionId
from iTasks import serialize, deserialize, defaultStoreFormat, functionFree
from System.Time import :: Timestamp(..), instance < Timestamp, instance toInt Timestamp
import Database.SQL.MySQL
:: StoreItem =
{ format :: !StoreFormat
......
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