definition: |
manyToManyAddOrRemove :: String -> Entity -> [(String,String)] -> [Entity] -> [CFuncDecl] manyToManyAddOrRemove erdname (Entity entityName _) entityrels allEntities = map (addOrRemoveFunction "add" "new" entityName) entityrels ++ map (addOrRemoveFunction "remove" "delete" entityName) entityrels where addOrRemoveFunction :: String -> String -> String -> (String,String) -> CFuncDecl addOrRemoveFunction funcPrefix dbFuncPrefix e1 (e2,mmrel) = stCmtFunc ((if funcPrefix == "add" then "Associates given entities with the " ++ entityName ++ " entity" else "Removes association to the given entities with the " ++ entityName ++ " entity") ++ "\nwith respect to the `" ++ mmrel ++ "` relation.") (controllerModuleName e1, funcPrefix ++ mmrel) 2 Private (listType (ctvar e2) ~> ctvar e1 ~> applyTC (dbconn "DBAction") [tupleType []]) [simpleRule [CPVar (0, lowerFirst e2 ++ "s"), CPVar (1, lowerFirst e1)] (applyF (pre "mapM_") [CLambda [CPVar(2, "t")] (applyF (model erdname, dbFuncPrefix ++ mmrel) [applyF (model erdname, lowerFirst e1 ++ "Key") [cvar (lowerFirst e1)], applyF (model erdname, lowerFirst e2 ++ "Key") [cvar "t"]]), cvar (lowerFirst e2 ++ "s")])] |
demand: |
arguments 2 3 |
deterministic: |
deterministic operation |
failfree: |
<FAILING> |
indeterministic: |
referentially transparent operation |
infix: |
no fixity defined |
iotype: |
{(_,{Entity},_,_) |-> _} |
name: |
manyToManyAddOrRemove |
precedence: |
no precedence defined |
result-values: |
_ |
signature: |
String -> Database.ERD.Entity -> [(String, String)] -> [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 |