|
definition: |
controllerInstDecl :: String -> Entity -> CInstanceDecl
controllerInstDecl erdname (Entity entityName _) =
simpleInstanceDecl (spiceyModule,"EntityController")
entityType
[stFunc (spiceyModule,"controllerOnKey") 1 Private
(stringType ~> (entityType ~> controllerType) ~> controllerType)
[simpleRule [CPVar (2,"s")]
(applyF (spiceyModule,"applyControllerOn")
[readKey, getEntityOp])],
stFunc (spiceyModule,"entityRoute") 2 Private
(stringType ~> entityType ~> stringType)
[simpleRule [CPVar rvar, CPVar entvar]
(applyF (pre "concat")
[list2ac
[string2ac $ '?' : entityName ++ "/",
CVar rvar,
string2ac "/",
applyF (model erdname, "show" ++ entityName ++ "Key")
[CVar entvar]]])]]
where
entityType = baseType (model erdname, entityName)
rvar = (1,"r")
entvar = (2,"ent")
readKey = applyF (model erdname, "read" ++ entityName ++ "Key")
[CVar (2,"s")]
getEntityOp = applyF (pre ".")
[constF (model erdname, "runJustT"),
constF (model erdname, "get" ++ entityName)]
|
|
demand: |
argument 2 |
|
deterministic: |
deterministic operation |
|
documentation: |
Generates the instance declaration for a controller. |
|
failfree: |
(_, _) |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,{Entity}) |-> {CInstance}}
|
|
name: |
controllerInstDecl |
|
precedence: |
no precedence defined |
|
result-values: |
{CInstance}
|
|
signature: |
String -> Database.ERD.Entity -> AbstractCurry.Types.CInstanceDecl |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
yes |
|
totally-defined: |
reducible on all ground data terms |