Skip to content

Instantly share code, notes, and snippets.

@2garryn
Created December 12, 2011 19:15
Show Gist options
  • Save 2garryn/1468643 to your computer and use it in GitHub Desktop.
Save 2garryn/1468643 to your computer and use it in GitHub Desktop.
Test code to create tree
fill_elem_tree(C, AppIntId, ElemId) ->
case db:get(C, AppIntId, ElemId) of
{error, not_found} ->
{error, {?MODULE, no_value}};
Value ->
ResultRec = wac_lib:from_binary(term, Value),
ChildsRec = [fill_elem_tree(C, AppIntId, ChildElId) ||
ChildElId <- ResultRec#elem.childs],
#elem_info{id = ResultRec#elem.id,
name = ResultRec#elem.name,
element_type = ResultRec#elem.element_type,
description = ResultRec#elem.description,
var_type = ResultRec#elem.var_type,
permissions = ResultRec#elem.permissions,
timeout = ResultRec#elem.timeout,
childs = ChildsRec,
name_tree = ResultRec#elem.tree}
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment