CurryInfo: spicey-4.2.0 / Spicey.ControllerGeneration.editController

definition:
editController :: ControllerGenerator
editController erdname (Entity entityName attrList) relationships allEntities =
  controllerFunction
    ("Shows a form to edit the given " ++ entityName ++ " entity.")
    entityName "edit" 1
    (baseType (model erdname,entityName) ~> controllerType)
    [simpleRule [CPVar pvar] -- parameterlist for controller
      (applyF (pre "$")
        [applyF checkAuthorizationFunc
          [applyF (enauthModName,lowerFirst entityName ++ "OperationAllowed")
            [applyF (authorizationModule,"UpdateEntity") [CVar pvar]]],
         CLambda [CPVar infovar] $
           doExpr (
            map (\ ((ename,erel), num) ->
                  CSPat (CPVar (num,"all" ++ erel ++ ename ++ "s")) 
                        (applyF (model erdname,"runQ")
                           [constF (model erdname,"queryAll" ++ ename ++ "s")]))
               (zip (map (\n -> (n,"")) manyToOneEntities ++ manyToManyEntities)
                    [1..]) ++
            map 
              (\ (ename, num) -> CSPat (CPVar (num,(lowerFirst (fst $ relationshipName entityName ename relationships))++ename)) 
                              (
                                applyF (model erdname,"runJustT") [
                                  applyF (controllerModuleName entityName,"get"++(fst $ relationshipName entityName ename relationships)++ename) [CVar pvar]
                                ]
                              )
              )
              (zip manyToOneEntities [1..]) ++
            map 
              (\ ((ename,erel), num) ->
                   CSPat (CPVar (num, lowerFirst erel ++ ename ++ "s")) 
                         (applyF (model erdname,"runJustT")
                           [applyF (controllerModuleName entityName,
                                    "get" ++ erel ++ entityName ++ ename ++ "s")
                                   [CVar pvar]])
              )
              (zip manyToManyEntities [1..]) ++
            [CSExpr setParCall,
             CSExpr $ applyF (pre "return")
               [list2ac [applyF (html "formElem")
                           [constF (controllerFormName entityName "edit")]]]
            ])])]
 where
  manyToManyEntities = manyToMany allEntities (Entity entityName attrList)
  manyToOneEntities  = manyToOne (Entity entityName attrList) relationships
  pvar               = (0, lowerFirst entityName ++ "ToEdit")
  infovar            = (1, "sinfo")

  setParCall =
    applyF (wuiModule "setParWuiStore")
      [constF (controllerStoreName entityName "edit"),
       tupleExpr
        ([CVar infovar, CVar pvar] ++ 
         map (\ (ename, num) ->
               CVar (num,lowerFirst (fst $ relationshipName
                            entityName ename relationships)
                         ++ ename))
             (zip manyToOneEntities [1..]) ++
         map (\ ((ename,erel), num) -> CVar (num, "all" ++ erel ++ ename ++ "s"))
             (zip (map (\n -> (n,"")) manyToOneEntities ++ manyToManyEntities)
                  [1..])),
       tupleExpr
        ([CVar pvar] ++ 
          (map (\ ((ename,erel), num) ->
                 CVar (num,lowerFirst erel ++ ename ++ "s"))
               (zip manyToManyEntities [1..])))]
demand:
argument 2
deterministic:
deterministic operation
documentation:
------------------------------------------------------------------------------
--- Generates a controller to edit an entity.
failfree:
<FAILING>
indeterministic:
referentially transparent operation
infix:
no fixity defined
iotype:
{(_,{Entity},_,_) |-> _}
name:
editController
precedence:
no precedence defined
result-values:
_
signature:
String -> Database.ERD.Entity -> [Database.ERD.Relationship]
-> [Database.ERD.Entity] -> AbstractCurry.Types.CFuncDecl
solution-complete:
operation might suspend on free variables
terminating:
possibly non-terminating
totally-defined:
possibly non-reducible on same data term