definition:
|
generateControllersForEntity :: String -> [Entity] -> Entity -> [Relationship]
-> CurryProg
generateControllersForEntity erdname allEntities
entity@(Entity ename attrlist) relationships =
let noKeyAttrs = filter (\a -> notKey a && notPKey a) attrlist
in
CurryProg
(controllerModuleName ename)
-- imports:
[ timeModule
, "HTML.Base", "HTML.Session", "HTML.WUI"
, model erdname
, "Config.EntityRoutes", "Config.UserProcesses"
, sessionInfoModule, authorizationModule, enauthModName, spiceyModule
, "System.PreludeHelpers"
, entitiesToHtmlModule erdname
, viewModuleName ename
]
Nothing -- defaultdecl
[] -- classdecls
[] -- instdecls
[newEntityType erdname entity relationships allEntities] -- typedecls
-- functions
(
[
-- controller for dispatching to various controllers:
mainController erdname entity relationships allEntities,
-- controller for providing a page to enter new entity data:
--newController erdname entity relationships allEntities,
newController erdname (Entity ename noKeyAttrs) relationships allEntities,
newForm erdname (Entity ename noKeyAttrs) relationships allEntities,
newStore erdname (Entity ename noKeyAttrs) relationships allEntities,
-- transaction for saving data in new entity:
createTransaction erdname entity relationships allEntities,
-- controller to show an existing record in a form to edit
editController erdname entity relationships allEntities,
editForm erdname (Entity ename noKeyAttrs) relationships allEntities,
editStore erdname (Entity ename noKeyAttrs) relationships allEntities,
-- transaction to update a record with the given data
updateTransaction erdname entity relationships allEntities,
-- controller to delete an entity with the given data
deleteController erdname entity relationships allEntities,
-- controller to destroy an entity with the given data
destroyController erdname entity relationships allEntities,
-- transaction to delete an entity with the given data
deleteTransaction erdname entity relationships allEntities,
-- controller to list all entities:
listController erdname entity relationships allEntities,
-- controller to show entites:
showController erdname entity relationships allEntities
] ++
manyToManyAddOrRemove erdname entity (manyToMany allEntities entity)
allEntities ++
--(getAll erdname entity (manyToOne entity relationships) allEntities) ++
--(getAll erdname entity (manyToMany allEntities entity) allEntities) ++
--(manyToManyGetRelated erdname entity (manyToMany allEntities entity) allEntities) ++
manyToOneGetRelated erdname entity (manyToOne entity relationships)
allEntities relationships
)
[] -- opdecls
|