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

Generation of ER model slightly improved

parent 67ddf019
......@@ -28,7 +28,11 @@ To generate an application, follow the steps below.
file is "<ERD>.db" where <ERD> is the name of the specified ER model.
Since this file name will be used in the _generated_ cgi programs,
a relative file name will be relative to the place where
the cgi programs are stored.
the cgi programs are stored. In order to avoid confusion due to
relative file names, it might be better to specify
an absolute path name for the database file.
This path could also be set in the definition of the constant
`sqliteDBFile` in the generated Curry program `Model/<ERD>.curry`.
4. Change into the generated directory containing all sources as a
Curry package, e.g., by `cd Blog`.
......
......@@ -79,6 +79,9 @@ a relative database file name will be relative to the place where
the web programs are stored.
In order to avoid such confusion, it might be better to specify
an absolute path name for the database file.
This path could also be set in the definition of the constant
\code{sqliteDBFile} in the generated Curry program
\code{Model/$ERD$.curry}.
Spicey generates the web application as a Curry package in a new
directory. Thus, change into this directory (e.g., \code{cd $ERD$})
......
......@@ -28,9 +28,8 @@ src/Model/
it contains the Curry module <MODEL>.curry implementing the access
to the database which are generated from the ER description.
In addition to the Curry program, this directory also contains
the term files of the original and transformed ER description
(files `<MODEL>_ERD.term` and `<MODEL>_ERDT.term`),
Curry file of the original ER description (file `<MODEL>_ERD.curry`),
the Curry file of the original ER description (file `<MODEL>_ERD.curry`),
the term files of the transformed ER description (`<MODEL>_ERDT.term`),
and the info file `<MODEL>_SQLCode.info` which is used by
the Curry preprocessor when SQL queries are embedded in the source
code.
......
......@@ -8,6 +8,7 @@ import AbstractCurry.Types
import AbstractCurry.Build
import AbstractCurry.Pretty hiding(showCProg)
import Database.ERD
import Directory
import FilePath ( (</>) )
import IO
import System(system)
......@@ -83,20 +84,17 @@ createHtmlHelpers _ (ERD name entities relationship) path _ =
hPutStr fileh (showCProg (generateToHtml erdname allEntities relationships))
hClose fileh
-- uses Curry's ertools for ERD to Curry transformation
-- Uses Curry's `ertools` for ERD to Curry transformation
createModels :: String -> ERD -> String -> String -> IO ()
createModels term_path erd path db_path = do
let erdname = erdName erd
dbfile = if null db_path then erdname ++ ".db"
else db_path
aterm_path <- getAbsolutePath term_path
curdir <- getCurrentDirectory
setCurrentDirectory path
erd2cdbiWithDBandERD dbfile term_path
let orgerdfile = erdname ++ "_ERD.term"
transerdfile = erdname ++ "_ERDT.term"
curryfile = erdname ++ ".curry"
infofile = erdname ++ "_SQLCode.info"
system $ unwords ["mv", transerdfile, curryfile, infofile, path]
system $ unwords ["cp", term_path, path </> orgerdfile]
done
setCurrentDirectory curdir
createRoutes :: String -> ERD -> String -> String -> IO ()
createRoutes _ erd path _ = do
......
......@@ -16,7 +16,7 @@ import Spicey.Scaffolding
systemBanner :: String
systemBanner =
let bannerText = "Spicey Web Framework (Version " ++ packageVersion ++
" of 05/01/18)"
" of 08/01/18)"
bannerLine = take (length bannerText) (repeat '-')
in bannerLine ++ "\n" ++ bannerText ++ "\n" ++ bannerLine
......
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