anchor.diff:  -author('Bikram Chatterjee <bikram.chatterjee@k2informatics.ch>').
   
   -include("dderl.hrl").
  +-include_lib("erlimem/src/gres.hrl").
   
   -export([ init/0
           , process_cmd/3
  
positive.code:     Statement = binary_to_term(base64:decode(proplists:get_value(<<"statement">>, BodyJson, <<>>))),
      SrtSpc = proplists:get_value(<<"spec">>, BodyJson, []),
      SortSpec = sort_json_to_term(SrtSpc),
      GuiResp = Statement:gui_req(sort, SortSpec),
      GuiRespJson = gen_adapter:gui_resp(GuiResp, Statement:get_columns()),
      ?Debug("sort ~p ~p", [SortSpec, GuiResp]),
      From ! {reply, jsx:encode([{<<"sort">>,GuiRespJson}])},
      Priv;
  process_cmd({[<<"filter">>], ReqBody}, From, Priv) ->
      [{<<"filter">>,BodyJson}] = ReqBody,
      Statement = binary_to_term(base64:decode(proplists:get_value(<<"statement">>, BodyJson, <<>>))),
      FltrSpec = proplists:get_value(<<"spec">>, BodyJson, []),
      FilterSpec = filter_json_to_term(FltrSpec),
      GuiResp = Statement:gui_req(filter, FilterSpec),
      GuiRespJson = gen_adapter:gui_resp(GuiResp, Statement:get_columns()),
      ?Debug("filter ~p ~p", [FilterSpec, GuiResp]),
      From ! {reply, jsx:encode([{<<"filter">>,GuiRespJson}])},
      Priv;
  
  % gui button events
  
negative.code:     Priv.
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%
  gui_resp_cb_fun(Cmd, Statement, From) ->
      fun(#gres{} = GuiResp) ->
          GuiRespJson = gen_adapter:gui_resp(GuiResp, Statement:get_columns()),
          ?Debug("resp ~p ~p", [Cmd, GuiResp]),
          From ! {reply, jsx:encode([{Cmd,GuiRespJson}])}
      end.
  
  sort_json_to_term([]) -> [];
  sort_json_to_term([[{C,T}|_]|Sorts]) ->
  