Ejemplo n.º 1
0
 public void Cmd_bgn(Xob_bldr bldr) {
   Db_conn conn = Xob_db_file.new__file_make(wiki.Fsys_mgr().Root_dir()).Conn();
   Xob_xfer_temp_tbl.Create_table(conn);
   Db_stmt trg_stmt = Xob_xfer_temp_tbl.Insert_stmt(conn);
   conn.Txn_bgn();
   DataRdr rdr = conn.Exec_sql_as_rdr(Sql_select);
   Xob_xfer_temp_itm temp_itm = new Xob_xfer_temp_itm();
   Xof_img_size img_size = new Xof_img_size();
   byte[] cur_ttl = Bry_.Empty;
   byte cur_repo = Byte_.Max_value_127;
   while (rdr.MoveNextPeer()) {
     temp_itm.Clear();
     temp_itm.Load(rdr);
     if (Bry_.Eq(cur_ttl, temp_itm.Orig_file_ttl())) { // same ttl; DATE:2015-03-22
       if (temp_itm.Orig_repo()
           != cur_repo) // if repo is different, ignore 2nd; handles images in both repos; take 1st
         // only (which should be local)
         continue;
     } else { // new ttl; update ttl, repo
       cur_ttl = temp_itm.Orig_file_ttl();
       cur_repo = temp_itm.Orig_repo();
     }
     if (temp_itm.Chk(img_size)) temp_itm.Insert(trg_stmt, img_size);
   }
   conn.Txn_end();
 }
Ejemplo n.º 2
0
 public void Test_category_v2(String ctg_name_str, int... expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   byte[] ctg_name_bry = Bry_.new_a7(ctg_name_str);
   Xoctg_data_ctg ctg = new Xoctg_data_ctg(ctg_name_bry);
   wiki.Db_mgr_as_sql().Load_mgr().Load_ctg_v2(ctg, ctg_name_bry);
   Tfds.Eq_ary(expd, Xto_int_ary(ctg));
 }
Ejemplo n.º 3
0
 public void Test_search(String search_word_str, int... expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   List_adp rv = List_adp_.new_();
   byte[] search_word_bry = Bry_.new_a7(search_word_str);
   wiki.Db_mgr_as_sql().Load_mgr().Load_search(Cancelable_.Never, rv, search_word_bry, 100);
   Tfds.Eq_ary(expd, Xto_int_ary(rv));
 }
Ejemplo n.º 4
0
 public void Test_load_ttl(int ns_id, String ttl_str, Xowd_page_itm expd) {
   Xowe_wiki wiki = bldr_fxt.Wiki();
   Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
   byte[] ttl_bry = Bry_.new_a7(ttl_str);
   wiki.Db_mgr_as_sql().Load_mgr().Load_by_ttl(actl, ns, ttl_bry);
   Tfds.Eq(expd.Id(), actl.Id());
   Tfds.Eq_date(expd.Modified_on(), actl.Modified_on());
   Tfds.Eq(expd.Redirected(), actl.Redirected());
   Tfds.Eq(expd.Text_len(), actl.Text_len());
 }
Ejemplo n.º 5
0
 public void Init_page_insert(Int_obj_ref page_id_next, int ns_id, String[] ttls) {
   Xowe_wiki wiki = this.Wiki();
   int len = ttls.length;
   DateAdp modified_on = Tfds.Now_time0_add_min(0);
   Xowd_page_tbl tbl_page = wiki.Db_mgr_as_sql().Core_data_mgr().Tbl__page();
   tbl_page.Insert_bgn();
   for (int i = 0; i < len; i++) {
     String ttl = ttls[i];
     int page_id = page_id_next.Val();
     tbl_page.Insert_cmd_by_batch(
         page_id, ns_id, Bry_.new_u8(ttl), false, modified_on, 0, page_id, 0, 0);
     page_id_next.Val_add(1);
   }
   tbl_page.Insert_end();
 }
Ejemplo n.º 6
0
 private void Init(Db_engine engine) {
   init = false;
   tbl_mgr.Clear();
   idx_mgr.Clear();
   Dbmeta_parser__tbl tbl_parser = new Dbmeta_parser__tbl();
   Dbmeta_parser__idx idx_parser = new Dbmeta_parser__idx();
   Db_qry__select_in_tbl qry =
       Db_qry__select_in_tbl.new_(
           "sqlite_master",
           String_.Ary_empty,
           String_.Ary("type", "name", "sql"),
           Db_qry__select_in_tbl.Order_by_null);
   Db_rdr rdr = engine.Stmt_by_qry(qry).Exec_select__rls_auto();
   try {
     Gfo_usr_dlg_.Instance.Log_many(
         "", "", "db.schema.load.bgn: conn=~{0}", engine.Conn_info().Db_api());
     while (rdr.Move_next()) {
       String type_str = rdr.Read_str("type");
       String name = rdr.Read_str("name");
       String sql = rdr.Read_str("sql");
       try {
         int type_int = Dbmeta_itm_tid.Xto_int(type_str);
         switch (type_int) {
           case Dbmeta_itm_tid.Tid_table:
             if (String_.Has_at_bgn(name, "sqlite_"))
               continue; // ignore b/c of non-orthodox syntax; EX: "CREATE TABLE
                         // sqlite_sequence(name, seq)"; also "CREATE TABLE
                         // sqlite_stat(tbl,idx,stat)";
             tbl_mgr.Add(tbl_parser.Parse(Bry_.new_u8(sql)));
             break;
           case Dbmeta_itm_tid.Tid_index:
             if (sql == null)
               continue; // ignore "autoindex"; EX: sqlite_autoindex_temp_page_len_avg_1
             idx_mgr.Add(idx_parser.Parse(Bry_.new_u8(sql)));
             break;
           default:
             Gfo_usr_dlg_.Instance.Log_many(
                 "",
                 "",
                 "db.schema.unknown type: conn=~{0} type=~{1} name=~{2} sql=~{3}",
                 engine.Conn_info().Db_api(),
                 type_str,
                 name,
                 sql);
             break;
         }
       } catch (
           Exception
               e) { // tables / indexes may be unparseable; skip them; EX: CREATE TABLE unparseable
                    // (col_1 /*comment*/ int); DATE:2016-06-08
         Gfo_usr_dlg_.Instance.Log_many(
             "",
             "",
             "db.schema.unparseable: conn=~{0} type=~{1} name=~{2} sql=~{3} err=~{4}",
             engine.Conn_info().Db_api(),
             type_str,
             name,
             sql,
             Err_.Message_gplx_log(e));
       }
     }
   } finally {
     rdr.Rls();
   }
 }