Commit e91c7ea9 authored by Michael Hanus 's avatar Michael Hanus
Browse files

ertools are now downloaded by CPM

parent 9fc4ebc5
......@@ -24,7 +24,6 @@ currycheck/CurryCheck
currydoc/CurryDoc
currytest/CurryTest
cusage/CheckUsage
ertools/ERD2CDBI
ertools/ERD2Curry
importcalls/ImportCalls
optimize/BindingOpt
......
-- ERD specification for university lectures.
import Database.ERD
uniERD :: ERD
uniERD =
ERD "Uni"
[Entity "Student"
[Attribute "Name" (StringDom Nothing) NoKey False,
Attribute "Firstname" (StringDom Nothing) NoKey False,
Attribute "MatNum" (IntDom Nothing) Unique False,
Attribute "Email" (StringDom Nothing) Unique False,
Attribute "Age" (IntDom Nothing) NoKey True],
Entity "Lecture"
[Attribute "Title" (StringDom Nothing) NoKey False,
Attribute "Topic" (StringDom Nothing) NoKey True],
Entity "Lecturer"
[Attribute "Name" (StringDom Nothing) NoKey False,
Attribute "Firstname" (StringDom Nothing) NoKey False],
Entity "Place"
[Attribute "Street" (StringDom Nothing) NoKey False,
Attribute "StrNr" (IntDom Nothing) NoKey False,
Attribute "RoomNr" (IntDom Nothing) NoKey False],
Entity "Time"
[Attribute "Time" (DateDom Nothing) Unique False],
Entity "Exam"
[Attribute "GradeAverage" (FloatDom Nothing) NoKey True],
Entity "Result"
[Attribute "Attempt" (IntDom Nothing) NoKey False,
Attribute "Grade" (FloatDom Nothing) NoKey True,
Attribute "Points" (IntDom Nothing) NoKey True]]
[Relationship "Teaching"
[REnd "Lecturer" "taught_by" (Exactly 1),
REnd "Lecture" "teaches" (Between 0 Infinite)],
Relationship "Participation"
[REnd "Student" "participated_by" (Between 0 Infinite),
REnd "Lecture" "participates" (Between 0 Infinite)],
Relationship "Taking"
[REnd "Result" "has_a" (Between 0 Infinite),
REnd "Student" "belongs_to" (Exactly 1)],
Relationship "Resulting"
[REnd "Exam" "result_of" (Exactly 1),
REnd "Result" "results_in" (Between 0 Infinite)],
Relationship "Belonging"
[REnd "Exam" "has_a" (Between 0 Infinite),
REnd "Lecture" "belongs_to" (Exactly 1)],
Relationship "ExamDate"
[REnd "Exam" "taking_place" (Between 0 Infinite),
REnd "Time" "at" (Exactly 1)],
Relationship "ExamPlace"
[REnd "Exam" "taking_place" (Between 0 Infinite),
REnd "Place" "in" (Exactly 1)]]
\ No newline at end of file
......@@ -17,7 +17,7 @@ export PATH
cleandir () {
$CURRYBIN/cleancurry
/bin/rm -f $LOGFILE *_PUBLIC.curry TEST*.curry
/bin/rm -f Uni_ERDT.term Uni_SQLCode.info Uni_CDBI.curry Uni.db
/bin/rm -f Uni.erdterm Uni_ERDT.term Uni_SQLCode.info Uni_CDBI.curry Uni.db
$CURRYBIN/cleancurry
}
......@@ -25,7 +25,7 @@ cleandir () {
exectests() {
cleandir
# compile model:
$CURRYBIN/curry erd2cdbi Uni_ERD.term `pwd`/Uni.db
$CURRYBIN/curry erd2curry --db `pwd`/Uni.db --cdbi UniERD.curry
# fill database:
$CURRYBIN/curry $REPL_OPTS :l CreateData :eval createTestData :q
# run query tests:
......
......@@ -4,6 +4,25 @@
#
# Note that the execution of this script requires an already installed 'cpm'!
echo "Updating 'ertools'..."
mv ertools/Makefile Makefile.ertools # keep old Makefile
rm -rf ertools
cpm checkout ertools
cd ertools
rm -rf .cpm .git*
# Generate package configuration file:
ERTCONFIG=src/ERToolsPackageConfig.curry
echo "module ERToolsPackageConfig where" > $ERTCONFIG
echo "import Distribution(installDir)" >> $ERTCONFIG
echo "import FilePath(combine)" >> $ERTCONFIG
echo "packageVersion :: String" >> $ERTCONFIG
echo "packageVersion = \"1.0.0\"" >> $ERTCONFIG
echo "packagePath :: String" >> $ERTCONFIG
echo "packagePath = installDir ++ combine \"currytools\" \"ertools\"" >> $ERTCONFIG
cd ..
mv Makefile.ertools ertools/Makefile
echo "'ertools' updated from package repository."
echo "Updating 'optimize'..."
mv optimize/Makefile Makefile.optimize # keep old Makefile
rm -rf optimize
......
This diff is collapsed.
#****************************************************************************
# The ERD2CDBI tool transforms an ERD term into datatypes for CDBI.
# The ERD2Curry tool transforms an ERD term into datatypes for CDBI.
# It also creates an information file for the currypp SQL-Parser.
# If the tool is invoked with the option -db, it creates a
# If the tool is invoked with the option --db, it creates a
# corresponding sqlite database.
#
#****************************************************************************
# installation binaries
ERD2CURRY = $(BINDIR)/$(CURRYSYSTEM)-erd2curry
ERD2CDBI = $(BINDIR)/$(CURRYSYSTEM)-erd2cdbi
# The tool name of the application:
TOOL = $(BINDIR)/$(CURRYSYSTEM)-erd2curry
# Some modules required by the erd2curry tool:
DEPSERD2CURRY = ERD2Curry.curry CodeGeneration.curry Transformation.curry \
XML2ERD.curry ERD2Graph.curry \
$(ROOT)/lib/Database/ERD*.curry $(LIBDIR)/AbstractCurry/*.curry
# The load path of the application:
LOADPATH = src
# Some modules required by the erd2cdbi tool:
DEPSERD2CDBI = ERD2CDBI.curry $(ROOT)/lib/Database/ERD*.curry \
$(ROOT)/lib/Database/CDBI/*.curry
# Some modules required by the erd2curry tool:
DEP = src/*.curry \
$(ROOT)/lib/Database/ERD*.curry $(ROOT)/lib/Database/CDBI/*.curry \
$(LIBDIR)/AbstractCurry/*.curry
.PHONY: all compile install clean uninstall
all: install
compile:
$(MAKE) ERD2Curry
$(MAKE) ERD2CDBI
compile: ERD2Curry
install: compile
rm -f $(ERD2CURRY) $(ERD2CDBI) $(BINDIR)/erd2curry $(BINDIR)/erd2cdbi
cd $(BINDIR) && ln -s ../currytools/ertools/ERD2Curry $(notdir $(ERD2CURRY))
cd $(BINDIR) && ln -s ../currytools/ertools/ERD2CDBI $(notdir $(ERD2CDBI))
rm -f $(TOOL)
cd $(BINDIR) && ln -s ../currytools/ertools/ERD2Curry $(notdir $(TOOL))
clean:
$(CLEANCURRY)
rm -f erd2curry ERD2CDBI
cd src && $(CLEANCURRY)
uninstall: clean
rm -f $(ERD2CURRY) $(ERD2CDBI)
ERD2Curry: $(DEPSERD2CURRY)
$(REPL) $(REPL_OPTS) :load ERD2Curry :save :quit
rm -f ERD2Curry $(TOOL)
ERD2CDBI: $(DEPSERD2CDBI)
$(REPL) $(REPL_OPTS) :load ERD2CDBI :save :quit
ERD2Curry: $(DEPS)
$(REPL) $(REPL_OPTS) :set path $(LOADPATH) :load ERD2Curry :save :quit
......@@ -11,9 +11,9 @@ ERD2CDBI compiler
This tool transforms an ERD term into datatypes used in the
Database.CDBI. libraries. It also creates an information file
for the currypp SQL-Parser.
If the tool is invoked with the option -db, it creates a
corresponding sqlite database.
for the currypp SQL-Parser. This compiler is invoked by
erd2curry --db <sqlite3 db file> --cdbi <Curry program with ERD>
----------------------------------------------------------------------
......@@ -70,11 +70,12 @@ erd2curry -v mymodel.erdterm
Examples:
---------
This directory contains two examples for ERD term files:
The directory `examples` contains two examples for the specification
of ERD models:
* `Blog.erdterm`: a simple ERD model for a blog with entries, comments,
* `BlogERD.curry`: a simple ERD model for a blog with entries, comments,
and tags.
* `Uni.erdterm`: an ERD model for university lectures as
* `UniERD.curry`: an ERD model for university lectures as
presented in the original paper cited above.
---
......
......@@ -5,7 +5,7 @@
module ERDGeneric where
import KeyDatabase
import KeyDatabaseSQLite
import List
import ReadShowTerm
import Read
......
{
"name": "ertools",
"version": "1.0.0",
"author": "Michael Hanus <mh@informatik.uni-kiel.de>",
"synopsis": "Tools for dealing with database applications specified by entity-relationship diagrams",
"category": [ "Database" ],
"dependencies": {
},
"configModule": "ERToolsPackageConfig",
"executable": {
"name": "erd2curry",
"main": "ERD2Curry"
},
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/ertools.git",
"tag": "$version"
}
}
......@@ -6,6 +6,8 @@
--- @version February 2015
------------------------------------------------------------------------------
{-# OPTIONS_CYMAKE -Wno-incomplete-patterns #-}
module CodeGeneration(Option,Storage(..),ConsistencyTest(..),
isSQLite,erd2code) where
......@@ -31,7 +33,7 @@ isSQLite (storage,_) =
-- The name of the KeyDatabase module:
keyDatabaseMod :: String
keyDatabaseMod = "KeyDatabase"
keyDatabaseMod = "KeyDatabaseSQLite"
erd2code :: Option -> ERD -> CurryProg
erd2code opt@(_, consistencyTest) (ERD n es rs) =
......@@ -71,8 +73,8 @@ generateStorageDefinition (storage, _) n = case storage of
where
dbFileDef path =
cfunc (n,"dbFile") 0 Private stringType
[simpleRule [] (string2ac (path ++ "/" ++ n ++ ".db"))]
[simpleRule [] (string2ac path)]
generatedEntity2DBcode :: Option -> String -> [Relationship] -> Entity
-> [CFuncDecl]
generatedEntity2DBcode (storage, _) name allrels
......@@ -254,7 +256,6 @@ entity2datatype _ ername (Entity name attrs) =
[CType (ername,name) Public [] [CCons (ername,name) Private argTypes],
CTypeSyn (ername,name++"Tuple") Private [] (tupleType (tail argTypes))]
where
arity = length attrs
argTypes = map attrType attrs
-- Create transformation between entity type and tuple representation:
......@@ -599,7 +600,7 @@ entitySpec (s,eName) attrs v =
-- Generate persistent dynamic predicate for an entity using SQLite3 DB
-- of Sebastian Fischer's KeyDatabase module.
predEntrySQLite :: QName -> [Attribute] -> CVisibility -> String -> CFuncDecl
predEntrySQLite (s,eName) attrs v dbpath =
predEntrySQLite (s,eName) attrs v _ =
cmtfunc
("Database predicate representing the relation between keys and "++eName++
" tuple entities.")
......@@ -856,9 +857,6 @@ newEntity (str,eName) attrs ens rels v esAll rsAll =
case c of (Between i (Max j)) -> i>0 && j>i
_ -> False
getExactB (Relationship _ [REnd _ _ _, REnd _ _ (Exactly i)]) = i
getMinB (Relationship _ [REnd _ _ _, REnd _ _ (Between i _)]) = i
duplicate [] [] = []
duplicate (Relationship _ [REnd _ _ _, REnd _ _ (Exactly i)]:exactRs) (p:ps) =
(map ((p++) . show) [1..i]) ++ (duplicate exactRs ps)
......@@ -1312,6 +1310,7 @@ rel2code option name es r =
then rolesR option name r es
else roles name r
isGeneratedR :: Relationship -> Bool
isGeneratedR (Relationship n _) = n == ""
--generierte Beziehung als Teil der Umsetzung einer n:m Beziehung
......@@ -1592,6 +1591,7 @@ hasDefault (DateDom d) = isJust d
hasDefault (UserDefined _ d) = isJust d
-- Get the default value of the attribute domain:
getDefault :: Domain -> CExpr
getDefault (IntDom (Just d)) = CLit (CIntc d)
getDefault (FloatDom (Just d)) = CLit (CFloatc d)
getDefault (StringDom (Just d)) = string2ac d
......
......@@ -7,7 +7,7 @@
--- `x_SQLCODE.info` that is used when embedded SQL statements are
--- translated by the Curry preprocessor `currypp`.
---
--- @author Mike Tallarek, extensions by Julia Krone
--- @author Mike Tallarek, extensions by Julia Krone and Michael Hanus
--- @version 0.2
--- ----------------------------------------------------------------------------
......@@ -20,7 +20,7 @@ import AbstractCurry.Build
import Char ( toLower, toUpper )
import Database.ERD
import Database.ERDGoodies
import Directory ( doesFileExist )
import Directory ( doesFileExist, getAbsolutePath )
import Distribution ( installDir )
import qualified FilePath as FP ( (</>), combine, splitFileName)
import IO
......@@ -32,45 +32,13 @@ import SetFunctions ( selectValue, set2 )
import System
import Time
-- Takes a x_ERD.term or x_ERDT.term (an ER-Model translated by erd2curry)
-- and the absolute path to the database.
-- Creates a SQLite database (if it does not exist,
-- a .curry program with all datatypes
-- and an .info-file for the CurryPP-SQLParser
main :: IO ()
main = do
args <- getArgs
case args of
[erdfname, dbPath] -> do erdterm <- translateERD2ERDT erdfname
writeCDBI erdfname erdterm dbPath
_ -> showUsageString
showUsageString :: IO ()
showUsageString = do
putStrLn $ unlines
["Usage: curry erd2cdbi <ERD file> <DB path>",
"",
"<ERD file>: name of file containing ERD specification",
"<DB path> : absolute path to database (including name of database)>"]
exitWith 1
-- Translate the ERD file, if it is not a ERDT file, into ERDT format
-- by the use of erd2curry tools, and read ERDT file:
translateERD2ERDT :: String -> IO ERD
translateERD2ERDT erdfname = do
erdterm <- readERDTermFile erdfname
let (dir,file) = FP.splitFileName erdfname
erdtfile = erdName erdterm ++ "_ERDT.term"
if file == erdtfile
then return erdterm
else do system (unwords [installDir FP.</> "bin" FP.</> "curry", "erd2curry",
"-t ",erdfname])
readERDTermFile (FP.combine dir erdtfile)
-- Write all the data so CDBI can be used, create a database
-- when option is set and a .info file
-- Write all the data so CDBI can be used, create a database (if it does
-- not exist) and a .info file/
-- The parameters are the name of the file containing the ERD term,
-- the ER model, and the name of the SQLite3 database.
writeCDBI :: String -> ERD -> String -> IO ()
writeCDBI erdfname (ERD name ents rels) dbPath = do
writeCDBI erdfname (ERD name ents rels) dbname = do
dbPath <- getAbsolutePath dbname
let cdbiMod = name++"_CDBI"
cdbiFile = cdbiMod++".curry"
imports = [ "Time"
......
module ERD2Curry where
module ERD2Curry( main, erd2curryWithDBandERD )
where
import AbstractCurry.Files (readCurry)
import AbstractCurry.Select (imports)
......@@ -13,109 +14,142 @@ import System (exitWith, getArgs, system)
import Time
import XML
import XML2ERD
import Transformation
import CodeGeneration
import ERD2CDBI (writeCDBI)
import ERD2Graph
import ERToolsPackageConfig(packagePath, packageVersion)
import Transformation
import XML2ERD
systemBanner :: String
systemBanner =
let bannerText = "ERD->Curry Compiler (Version of 12/01/17)"
let bannerText = "ERD->Curry Compiler (Version " ++ packageVersion ++
" of 09/03/17)"
bannerLine = take (length bannerText) (repeat '-')
in bannerLine ++ "\n" ++ bannerText ++ "\n" ++ bannerLine
data EROptions = EROptions
{ optERProg :: String -- Curry program containing ERD
, optFromXml :: Bool -- read ERD from XML file?
, optVisualize :: Bool -- visualize ERD?
, optStorage :: Storage -- storage of data
, optToERDT :: Bool -- only transform into ERDT term file
, optCDBI :: Bool -- generate Curry for Database.CDBI libraries
}
defaultEROptions :: EROptions
defaultEROptions = EROptions
{ optERProg = ""
, optFromXml = False
, optVisualize = False
, optStorage = SQLite ""
, optToERDT = False
, optCDBI = False
}
--- Main function for saved state. The argument is the directory containing
--- these sources.
main :: IO ()
main = do
putStrLn systemBanner
args <- getArgs
configs <- parseArgs ("",False,SQLite ".",False,False) args
-- the directory containing the sources of this tool:
let erd2currydir = installDir </> "currytools" </> "ertools"
callStart erd2currydir configs
configs <- parseArgs defaultEROptions args
startERD2Curry configs
parseArgs :: (String,Bool,Storage,Bool,Bool) -> [String]
-> IO (Maybe (String,Bool,Storage,Bool,Bool))
parseArgs :: EROptions -> [String] -> IO (Maybe EROptions)
parseArgs _ [] = return Nothing
parseArgs (file,fromxml,storage,vis,trerdt) (arg:args) = case arg of
parseArgs opts (arg:args) = case arg of
"-h" -> putStrLn helpText >> exitWith 0
"-?" -> putStrLn helpText >> exitWith 0
"--help" -> putStrLn helpText >> exitWith 0
"-x" -> parseArgs (file,True,storage,vis,trerdt) args
"-l" -> parseArgs (file,fromxml,setSQLite storage,vis,trerdt) args
"-f" -> if curryCompiler == "pakcs"
then parseArgs (file,fromxml,setFileDB storage,vis,trerdt) args
else error "Wrong parameter -f: file-based database only available in PAKCS!"
"-d" -> parseArgs (file,fromxml,DB,vis,trerdt) args
"-p" -> if null args then return Nothing else
parseArgs (file,fromxml,setFilePath (head args) storage,vis,trerdt)
(tail args)
"--dbpath" ->
if null args then return Nothing else
parseArgs (file,fromxml,setFilePath (head args) storage,vis,trerdt)
(tail args)
"-t" -> parseArgs (file,fromxml,storage,vis,True) args
"-v" -> parseArgs (file,fromxml,storage,True,trerdt) args
f -> return $ if null args then Just (f,fromxml,storage,vis,trerdt)
"-x" -> parseArgs opts { optFromXml = True } args
"-l" -> parseArgs (setSQLite (optStorage opts)) args
"-d" -> parseArgs opts { optStorage = DB } args
"--db" -> if null args
then return Nothing
else parseArgs (setFilePath (head args) (optStorage opts))
(tail args)
"-t" -> parseArgs opts { optToERDT = True } args
"-v" -> parseArgs opts { optVisualize = True } args
"--cdbi" -> parseArgs opts { optCDBI = True } args
f -> return $ if null args then Just opts { optERProg = f }
else Nothing
where
setFilePath path (Files _) = Files path
setFilePath path (SQLite _) = SQLite path
setFilePath _ DB = DB
setFilePath path (Files _) = opts { optStorage = Files path }
setFilePath path (SQLite _) = opts { optStorage = SQLite path }
setFilePath _ DB = opts { optStorage = DB }
setSQLite (Files p) = SQLite p
setSQLite (SQLite p) = SQLite p
setSQLite DB = SQLite "."
setSQLite (Files p) = opts { optStorage = SQLite p }
setSQLite (SQLite p) = opts { optStorage = SQLite p }
setSQLite DB = opts { optStorage = SQLite "" }
setFileDB (Files p) = Files p
setFileDB (SQLite p) = Files p
setFileDB DB = Files "."
storagePath :: Storage -> String
storagePath (Files p) = p
storagePath (SQLite p) = p
storagePath DB = ""
helpText :: String
helpText = unlines
[ "Usage:"
, ""
, " curry erd2curry [-l] [-f] [-d] [-t] [-x] [-v] [--dbpath <dir>] <prog>"
, " erd2curry [-l] [-d] [-t] [-x] [-v] [--db <dbfile>] [--cdbi] <prog>"
, ""
, "Parameters:"
, "-l: generate interface to SQLite3 database (default)"
, "-f: generate interface to file-based database implementation (only in PAKCS)"
, "-d: generate interface to SQL database (experimental)"
, "-x: generate from ERD xmi document instead of ERD Curry program"
, "-t: only transform ERD into ERDT term file"
, "-v: only show visualization of ERD with dotty"
, "--dbpath <dir>: name of the directory where DB files are stored"
, "<prog> : name of Curry program file containing ERD definition"
, "--db <dbfile>: file of the SQLite3 database"
, "--cdbi : generate Curry module for Database.CDBI modules"
, "<prog> : name of Curry program file containing ERD definition"
]
callStart :: String -> Maybe (String,Bool,Storage,Bool,Bool) -> IO ()
callStart _ Nothing = do
--- Runs ERD2Curry with a given database and ERD term file or program.
erd2curryWithDBandERD :: String -> String -> IO ()
erd2curryWithDBandERD dbname erfile =
startERD2Curry
(Just defaultEROptions
{ optStorage = SQLite dbname, optERProg = erfile })
startERD2Curry :: Maybe EROptions -> IO ()
startERD2Curry Nothing = do
putStrLn $ "ERROR: Illegal arguments\n\n" ++ helpText
exitWith 1
callStart erd2currydir (Just (orgfile,fromxml,storage,vis,trerdt)) = do
file <- if ".curry" `isSuffixOf` orgfile
then storeERDFromProgram orgfile
else return orgfile
if vis
then readERDTermFile file >>= viewERD
else start erd2currydir (storage,WithConsistencyTest) fromxml trerdt file "."
startERD2Curry (Just opts) = do
-- the directory containing the sources of this tool:
let erd2currysrcdir = packagePath </> "src"
orgfile = optERProg opts
erdfile <- if ".curry" `isSuffixOf` orgfile ||
".lcurry" `isSuffixOf` orgfile
then storeERDFromProgram orgfile
else return orgfile
if optVisualize opts
then readERDTermFile erdfile >>= viewERD
else start erd2currysrcdir opts erdfile "."
--- Main function to invoke the ERD->Curry translator.
start :: String -> Option -> Bool -> Bool -> String -> String -> IO ()
start erd2currydir opt fromxml trerdt srcfile path = do
(erdfile,erd) <- if fromxml
start :: String -> EROptions -> String -> String -> IO ()
start erd2currysrcdir opts srcfile path = do
(erdfile,erd) <- if optFromXml opts
then transformXmlFile srcfile path
else readERDTermFile srcfile >>= \e -> return (srcfile,e)
let transerdfile = addPath path (erdName erd ++ "_ERDT.term")
curryfile = addPath path (erdName erd ++ ".curry")
let erdname = erdName erd
transerdfile = addPath path (erdname ++ "_ERDT.term")
curryfile = addPath path (erdname ++ ".curry")
transerd = transform erd
opt = ( if optStorage opts == SQLite ""
then SQLite (erdname ++ ".db")
else optStorage opts
, WithConsistencyTest )
erdprog = erd2code opt (transform erd)
writeFile transerdfile
("{- ERD specification transformed from "++erdfile++" -}\n\n " ++
showERD 2 transerd ++ "\n")
putStrLn $ "Transformed ERD term written into file '"++transerdfile++"'."
unless trerdt $ do
when (optCDBI opts) $
writeCDBI srcfile transerd (storagePath (fst opt))
unless (optToERDT opts || optCDBI opts) $ do
copyAuxiliaryFiles
moveOldVersion curryfile
curdir <- getCurrentDirectory
......@@ -126,27 +160,23 @@ start erd2currydir opt fromxml trerdt srcfile path = do
prettyCurryProg
(setOnDemandQualification (erdprog:impprogs) defaultOptions)
erdprog
putStrLn $ "Database operations generated into file '"++curryfile++"'\n"++
"with " ++ showOption (erdName erd) opt ++ ".\n"
putStrLn $ "Database operations generated into file '" ++ curryfile ++
"'\nwith " ++ showOption opt ++ ".\n"
where
-- Copy auxiliary files ERDGeneric.curry and KeyDatabase.curry to target dir
copyAuxiliaryFiles = do
if isSQLite opt
then copyFile (erd2currydir </> "KeyDatabase.curry.sqlite")
(addPath path "KeyDatabase.curry")
else done
copyFile (erd2currydir </> "ERDGeneric.curry")
copyFile (erd2currysrcdir </> "ERDGeneric.curry")
(addPath path "ERDGeneric.curry")
showOption _ (Files f,_) = "database files stored in directory '"++f++"'"
showOption ername (SQLite p,_) =
"SQLite3 database stored in file '"++p++"/"++ername++".db'"
showOption _ (DB,_) = "SQL database interface"
showOption (Files f,_) = "database files stored in directory '"++f++"'"
showOption (SQLite f,_) =
"SQLite3 database stored in file '" ++ f ++ "'"
showOption (DB,_) = "SQL database interface"
--- Adds a path to a file name.
addPath :: String -> String -> String
addPath path fname | path=="." = fname
| otherwise = path++"/"++fname
| otherwise = path </> fname
--- Moves a file (if it exists) to one with extension ".versYYMMDDhhmmss".
moveOldVersion :: String -> IO ()
......
......@@ -2,6 +2,8 @@
--- This module defines an operation to visualize an ERD term with dot.
---------------------------------------------------------------------
{-# OPTIONS_CYMAKE -Wno-incomplete-patterns #-}
module ERD2Graph(viewERD) where
import IO
......@@ -15,6 +17,7 @@ import Distribution(getRcVar)
-- If not, it will be represented as an arc with a label.
-- However, some graph drawing tools have problems to write the
-- labels in a good manner to the arcs.
relationAsNode :: Bool
relationAsNode = True
-- Visualize an ERD term with dot.
......
------------------------------------------------------------------------------
--- Generic operations and integrity tests
--- to support the database code generated from ERDs
------------------------------------------------------------------------------
module ERDGeneric where
import KeyDatabaseSQLite
import List
import ReadShowTerm
import Read
import Char(isDigit)