view_table_manager.anubis 2.72 KB
/*
 * Created by PyramIDE.
 * User: Totoro
 * Date: 16/11/2011
 * Time: 23:53
 */
 
read tools/basis.anubis
transmit hayamiki_lib/view/types/hk_form.anubis
transmit hayamiki_lib/view/view_table_manager_types.anubis

public define Maybe(VTM_view)
  _vtm_get_view
  (
    String          _table_name,
    List(VTM_view)  list
  ) = 
  if list is
  {
    []        then  println("_vtm_get_view "+_table_name+" not found"); failure,
    [ h . t ] then
      if h.table_name = _table_name then
        success(h)
      else
        _vtm_get_view(_table_name, t)
  }.
  
public define Maybe(VTM_view)
  vtm_get_view
  (
    String        table_name,
    VTM_view_list vtm_vlist
  ) = 
  _vtm_get_view(table_name, vtm_vlist.list).

  
public define Maybe(VTM_edit)
  _vtm_get_edit
  (
    String          table_name,
    List(VTM_edit)  list
  ) = 
  if list is
  {
    []        then  failure,
    [ h . t ] then
      if h is vtm_edit(tb_name, get_edit) then
        if tb_name = table_name then
          success(h)
        else
          _vtm_get_edit(table_name, t)
  }.
  
public define Maybe(VTM_edit)
  vtm_get_edit
  (
    String        table_name,
    VTM_edit_list vtm_vlist
  ) = 
  _vtm_get_edit(table_name, vtm_vlist.list).

//public define Maybe(TM_writer)
//  _tm_get_writer
//  (
//    String          table_name,
//    List(TM_writer) list
//  ) = 
//  if list is
//  {
//    []        then  failure,
//    [ h . t ] then
//      if h is tm_writer(tb_name, get_writer_from_type, get_writer_from_fields) then
//        if tb_name = table_name then
//          success(h)
//        else
//          _tm_get_writer(table_name, t)
//  }.
  
//public define Maybe(TM_writer)
//  tm_get_writer
//  (
//    String          table_name,
//    TM_writer_list  tm_wlist
//  ) = 
//  _tm_get_writer(table_name, tm_wlist.list).

public define Maybe((SQLite3DataBase db, List(Int) l_int) -> Maybe(One))
  _tm_get_delete
  (
    String          table_name,
    List(TM_delete) list
  ) = 
  if list is
  {
    []        then  failure,
    [ h . t ] then
      since h is tm_delete(tb_name, delete_func),
        if tb_name = table_name then
          success(delete_func)
        else
          _tm_get_delete(table_name, t)
  }.
  
public define Maybe((SQLite3DataBase db, List(Int) l_int) -> Maybe(One))
  tm_get_delete
  (
    String          table_name,
    TM_delete_list  tm_dlist
  ) = 
  _tm_get_delete(table_name, tm_dlist.list).

public define Maybe(HK_Table_controller)
  get_hk_controller
  (
    String                      _table_name,
    List(HK_Table_controller)   controllers
  )=
  if controllers is
  {
    []        then  failure,
    [h . t ]  then
      if h.table_name = _table_name then
        success(h)
      else
        get_hk_controller(_table_name, t)
  }
.