mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
'v3.3.4.1'
This commit is contained in:
@@ -22,14 +22,14 @@ import gplx.xowa.apps.*;
|
||||
import gplx.xowa.guis.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.langs.cases.*;
|
||||
import gplx.xowa.files.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.files.bins.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.specials.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.site_stats.*; import gplx.xowa.wikis.data.*; import gplx.xowa.files.repos.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.wikis.xwikis.*; import gplx.xowa.wikis.ttls.*; import gplx.xowa.wikis.specials.*; import gplx.xowa.addons.*;
|
||||
import gplx.xowa.htmls.*; import gplx.xowa.htmls.core.htmls.utls.*; import gplx.xowa.htmls.core.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.css.*; import gplx.xowa.htmls.bridges.dbuis.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.parsers.*;
|
||||
import gplx.xowa.apps.urls.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
private final Xof_fsdb_mgr__sql fsdb_mgr; private Fsdb_db_mgr db_core_mgr;
|
||||
private final Xof_fsdb_mgr__sql fsdb_mgr; private Fsdb_db_mgr db_core_mgr;
|
||||
private boolean init_needed = true;
|
||||
public Xowv_wiki(Xoav_app app, byte[] domain_bry, Io_url wiki_root_dir) {
|
||||
this.app = app;
|
||||
@@ -42,37 +42,40 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
this.special_mgr = new Xosp_special_mgr(this);
|
||||
this.fsys_mgr = new Xow_fsys_mgr(wiki_root_dir, app.Fsys_mgr().File_dir().GenSubDir(domain_str));
|
||||
this.fsdb_mgr = new Xof_fsdb_mgr__sql();
|
||||
this.url__parser = new Xoa_url_parser(this);
|
||||
this.url__parser = new Xow_url_parser(this);
|
||||
this.xwiki_mgr = new Xow_xwiki_mgr(this);
|
||||
this.stats = new Xow_site_stats_mgr(this);
|
||||
}
|
||||
public Xoa_app App() {return app;}
|
||||
public boolean Type_is_edit() {return Bool_.N;}
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public Xow_domain_itm Domain_itm() {return domain_itm;} private final Xow_domain_itm domain_itm;
|
||||
public int Domain_tid() {return domain_tid;} private final int domain_tid;
|
||||
public byte[] Domain_abrv() {return domain_abrv;} private final byte[] domain_abrv;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry;
|
||||
public String Domain_str() {return domain_str;} private final String domain_str;
|
||||
public Xow_domain_itm Domain_itm() {return domain_itm;} private final Xow_domain_itm domain_itm;
|
||||
public int Domain_tid() {return domain_tid;} private final int domain_tid;
|
||||
public byte[] Domain_abrv() {return domain_abrv;} private final byte[] domain_abrv;
|
||||
public Xow_ns_mgr Ns_mgr() {return ns_mgr;} private final Xow_ns_mgr ns_mgr;
|
||||
public Xow_fsys_mgr Fsys_mgr() {return fsys_mgr;} private Xow_fsys_mgr fsys_mgr;
|
||||
public Xowd_db_mgr Data__core_mgr() {return data_mgr__core_mgr;} private Xowd_db_mgr data_mgr__core_mgr;
|
||||
public Xow_repo_mgr File__repo_mgr() {return file_mgr__repo_mgr;} private Xowv_repo_mgr file_mgr__repo_mgr = new Xowv_repo_mgr();
|
||||
public Xof_fsdb_mode File__fsdb_mode() {return file_mgr__fsdb_mode;} private final Xof_fsdb_mode file_mgr__fsdb_mode = Xof_fsdb_mode.new_v2_gui();
|
||||
public Xof_fsdb_mode File__fsdb_mode() {return file_mgr__fsdb_mode;} private final Xof_fsdb_mode file_mgr__fsdb_mode = Xof_fsdb_mode.new_v2_gui();
|
||||
public Fsdb_db_mgr File__fsdb_core() {return db_core_mgr;}
|
||||
public Xof_orig_mgr File__orig_mgr() {return orig_mgr;} private final Xof_orig_mgr orig_mgr = new Xof_orig_mgr();
|
||||
public Xof_orig_mgr File__orig_mgr() {return orig_mgr;} private final Xof_orig_mgr orig_mgr = new Xof_orig_mgr();
|
||||
public Xof_bin_mgr File__bin_mgr() {return fsdb_mgr.Bin_mgr();}
|
||||
public Fsm_mnt_mgr File__mnt_mgr() {return fsdb_mgr.Mnt_mgr();}
|
||||
public boolean Html__hdump_enabled() {return Bool_.Y;}
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public Xow_hdump_mgr Html__hdump_mgr() {return html__hdump_mgr;} private final Xow_hdump_mgr html__hdump_mgr;
|
||||
public boolean Html__css_installing() {return html__css_installing;} public void Html__css_installing_(boolean v) {html__css_installing = v;} private boolean html__css_installing;
|
||||
public Xoh_page_wtr_mgr Html__wtr_mgr() {return html__wtr_mgr;} private final Xoh_page_wtr_mgr html__wtr_mgr = new Xoh_page_wtr_mgr(Bool_.Y);
|
||||
public Xow_mw_parser_mgr Mw_parser_mgr() {return mw_parser_mgr;} private final Xow_mw_parser_mgr mw_parser_mgr = new Xow_mw_parser_mgr();
|
||||
public Xow_wiki_props Props() {return props;} private final Xow_wiki_props props = new Xow_wiki_props();
|
||||
public Xoh_page_wtr_mgr Html__wtr_mgr() {return html__wtr_mgr;} private final Xoh_page_wtr_mgr html__wtr_mgr = new Xoh_page_wtr_mgr(Bool_.Y);
|
||||
public Xow_mw_parser_mgr Mw_parser_mgr() {return mw_parser_mgr;} private final Xow_mw_parser_mgr mw_parser_mgr = new Xow_mw_parser_mgr();
|
||||
public Xow_wiki_props Props() {return props;} private final Xow_wiki_props props = new Xow_wiki_props();
|
||||
public Xol_lang_itm Lang() {throw Err_.new_unimplemented();}
|
||||
public Xoa_url_parser Utl__url_parser() {return url__parser;} private final Xoa_url_parser url__parser;
|
||||
|
||||
public Xol_case_mgr Case_mgr() {if (case_mgr == null) case_mgr = Xol_case_mgr_.U8(); return case_mgr;} private Xol_case_mgr case_mgr;
|
||||
public Xow_site_stats_mgr Stats() {return stats;} private final Xow_site_stats_mgr stats;
|
||||
public Xow_url_parser Utl__url_parser() {return url__parser;} private final Xow_url_parser url__parser;
|
||||
public Xoax_addon_mgr Addon_mgr() {return addon_mgr;} private final Xoax_addon_mgr addon_mgr = new Xoax_addon_mgr();
|
||||
public Xosp_special_mgr Special_mgr() {return special_mgr;} private Xosp_special_mgr special_mgr;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private final Xow_xwiki_mgr xwiki_mgr;
|
||||
public Xoav_app Appv() {return app;} private final Xoav_app app;
|
||||
public Xow_xwiki_mgr Xwiki_mgr() {return xwiki_mgr;} private final Xow_xwiki_mgr xwiki_mgr;
|
||||
public Xoav_app Appv() {return app;} private final Xoav_app app;
|
||||
public void Init_by_wiki() {
|
||||
if (!init_needed) return;
|
||||
init_needed = false;
|
||||
@@ -89,6 +92,7 @@ public class Xowv_wiki implements Xow_wiki, Xow_ttl_parser, GfoInvkAble {
|
||||
orig_mgr.Init_by_wiki(this, file_mgr__fsdb_mode, db_core_mgr.File__orig_tbl_ary(), Xof_url_bldr.new_v2());
|
||||
fsdb_mgr.Init_by_wiki(this);
|
||||
data_mgr__core_mgr.Db__core().Tbl__ns().Select_all(ns_mgr);
|
||||
data_mgr__core_mgr.Db__core().Tbl__site_stats().Select(stats);
|
||||
html__hdump_mgr.Init_by_db(this);
|
||||
}
|
||||
public void Init_by_make(Xowd_core_db_props props, gplx.xowa.bldrs.infos.Xob_info_session info_session) {
|
||||
|
||||
@@ -29,17 +29,17 @@ public class Xow_cache_mgr {
|
||||
public Xow_page_cache Page_cache() {return page_cache;} private Xow_page_cache page_cache;
|
||||
public Xow_defn_cache Defn_cache() {return defn_cache;} private Xow_defn_cache defn_cache;
|
||||
public Xow_defn_cache Lst_cache() {return lst_cache;} private Xow_defn_cache lst_cache;
|
||||
public KeyVal[] Scrib_lang_names() {
|
||||
public Keyval[] Scrib_lang_names() {
|
||||
if (scrib_lang_names == null) {
|
||||
List_adp list = List_adp_.new_();
|
||||
Xoa_sitelink_itm_mgr itm_mgr = wiki.App().Xwiki_mgr__sitelink_mgr().Itm_mgr();
|
||||
int len = itm_mgr.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xoa_sitelink_itm itm = itm_mgr.Get_at(i);
|
||||
KeyVal kv = KeyVal_.new_(String_.new_u8(itm.Key()), String_.new_u8(itm.Name()));
|
||||
Keyval kv = Keyval_.new_(String_.new_u8(itm.Key()), String_.new_u8(itm.Name()));
|
||||
list.Add(kv);
|
||||
}
|
||||
scrib_lang_names = (KeyVal[])list.To_ary(KeyVal.class);
|
||||
scrib_lang_names = (Keyval[])list.To_ary(Keyval.class);
|
||||
}
|
||||
return scrib_lang_names;
|
||||
}
|
||||
@@ -50,5 +50,5 @@ public class Xow_cache_mgr {
|
||||
lst_cache.Free_mem_all();
|
||||
scrib_lang_names = null;
|
||||
}
|
||||
private static KeyVal[] scrib_lang_names;
|
||||
private static Keyval[] scrib_lang_names;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class Xoa_ctg_mgr implements GfoInvkAble {
|
||||
private static final byte Missing_ctg_cls_normal_tid = 0, Missing_ctg_cls_hide_tid = 1, Missing_ctg_cls_red_tid = 2;
|
||||
private static final String Missing_ctg_cls_normal_str = "normal", Missing_ctg_cls_hide_str = "hide", Missing_ctg_cls_red_str = "red_link";
|
||||
private static final byte[] Missing_ctg_cls_normal_css = Bry_.new_a7(".xowa-missing-category-entry {}"), Missing_ctg_cls_hide_css = Bry_.new_a7(".xowa-missing-category-entry {display: none;}"), Missing_ctg_cls_red_css = Bry_.new_a7(".xowa-missing-category-entry {color: red;}");
|
||||
private static KeyVal[] Options_missing_ctg_cls_list = KeyVal_.Ary(KeyVal_.new_(Missing_ctg_cls_normal_str), KeyVal_.new_(Missing_ctg_cls_hide_str), KeyVal_.new_(Missing_ctg_cls_red_str));
|
||||
private static Keyval[] Options_missing_ctg_cls_list = Keyval_.Ary(Keyval_.new_(Missing_ctg_cls_normal_str), Keyval_.new_(Missing_ctg_cls_hide_str), Keyval_.new_(Missing_ctg_cls_red_str));
|
||||
private static byte Missing_ctg_cls_tid_parse(String v) {
|
||||
if (String_.Eq(v, Missing_ctg_cls_normal_str)) return Missing_ctg_cls_normal_tid;
|
||||
else if (String_.Eq(v, Missing_ctg_cls_hide_str)) return Missing_ctg_cls_hide_tid;
|
||||
|
||||
@@ -62,14 +62,14 @@ abstract class Xoctg_fmtr_itm_base implements gplx.core.brys.Bfr_arg, Xoctg_fmtr
|
||||
}
|
||||
@gplx.Virtual public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
byte[] itm_href = wiki.App().Html__href_wtr().Build_to_bry(wiki, ttl);
|
||||
byte[] itm_full_ttl = gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(ttl.Full_txt());// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
|
||||
byte[] itm_full_ttl = gplx.langs.htmls.Gfh_utl.Escape_html_as_bry(ttl.Full_txt_w_ttl_case());// NOTE: ttl.Full_txt() to get full ns; EX: Template:A instead of just "A"
|
||||
byte[] itm_atr_cls = hctx.Mode_is_hdump() ? Bry_.Empty : Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
Bry_fmtr fmtr = itm.Missing() ? html_itm_missing : html_itm;
|
||||
fmtr.Bld_bfr_many(bfr, itm_href, itm_full_ttl, itm_full_ttl, itm.Page_id(), itm_atr_cls);
|
||||
}
|
||||
}
|
||||
class Xoctg_fmtr_itm_page extends Xoctg_fmtr_itm_base {
|
||||
public static final Xoctg_fmtr_itm_page Instance = new Xoctg_fmtr_itm_page(); Xoctg_fmtr_itm_page() {}
|
||||
public static final Xoctg_fmtr_itm_page Instance = new Xoctg_fmtr_itm_page(); Xoctg_fmtr_itm_page() {}
|
||||
}
|
||||
class Xoctg_fmtr_itm_file extends Xoctg_fmtr_itm_base {
|
||||
// public void Bfr_arg__add(Bry_bfr bfr) {
|
||||
@@ -93,7 +93,7 @@ class Xoctg_fmtr_itm_file extends Xoctg_fmtr_itm_base {
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
public static final Xoctg_fmtr_itm_file Instance = new Xoctg_fmtr_itm_file(); Xoctg_fmtr_itm_file() {}
|
||||
public static final Xoctg_fmtr_itm_file Instance = new Xoctg_fmtr_itm_file(); Xoctg_fmtr_itm_file() {}
|
||||
}
|
||||
class Xoctg_fmtr_itm_subc extends Xoctg_fmtr_itm_base {
|
||||
@Override public void Bld_html(Bry_bfr bfr, Xowe_wiki wiki, Xoh_wtr_ctx hctx, Xoctg_view_itm itm, Xoa_ttl ttl, byte[] ttl_page, Xoh_href_parser href_parser, Bry_fmtr html_itm) {
|
||||
@@ -119,6 +119,6 @@ class Xoctg_fmtr_itm_subc extends Xoctg_fmtr_itm_base {
|
||||
if (val == 0) return;
|
||||
if (bfr.Len() > 1) bfr.Add(Bld_contains_text_itm_dlm); // NOTE: 1 b/c Paren_bgn is always added
|
||||
bfr.Add(msg_mgr.Val_by_id_args(msg_id, val));
|
||||
} static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
|
||||
public static final Xoctg_fmtr_itm_subc Instance = new Xoctg_fmtr_itm_subc(); Xoctg_fmtr_itm_subc() {}
|
||||
} static final byte[] Bld_contains_text_itm_dlm = Bry_.new_a7(", ");
|
||||
public static final Xoctg_fmtr_itm_subc Instance = new Xoctg_fmtr_itm_subc(); Xoctg_fmtr_itm_subc() {}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import gplx.xowa.langs.*; import gplx.xowa.langs.msgs.*; import gplx.xowa.htmls.
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
@gplx.Internal protected Xoctg_fmtr_grp Fmtr_grp() {return fmtr_grp;} private Xoctg_fmtr_grp fmtr_grp = new Xoctg_fmtr_grp();
|
||||
private final Xoctg_fmtr_all mgr_subcs = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_subc);
|
||||
private final Xoctg_fmtr_all mgr_pages = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_page);
|
||||
private final Xoctg_fmtr_all mgr_files = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_file);
|
||||
private final Xoctg_fmtr_all mgr_subcs = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_subc);
|
||||
private final Xoctg_fmtr_all mgr_pages = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_page);
|
||||
private final Xoctg_fmtr_all mgr_files = new Xoctg_fmtr_all(Xoa_ctg_mgr.Tid_file);
|
||||
public Xoctg_data_cache Data_cache() {return data_cache;} private Xoctg_data_cache data_cache = new Xoctg_data_cache();
|
||||
public void Bld_html(Xowe_wiki wiki, Xoae_page page, Xoh_wtr_ctx hctx, Bry_bfr bfr) {
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_m001();
|
||||
@@ -36,7 +36,7 @@ public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
}
|
||||
catch (Exception e) { // ctg error should never cause page to fail
|
||||
tmp_bfr.Mkr_rls();
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to generate category: title=~{0} err=~{1}", String_.new_u8(page.Ttl().Full_txt()), Err_.Message_gplx_full(e));
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to generate category: title=~{0} err=~{1}", String_.new_u8(page.Ttl().Full_txt_w_ttl_case()), Err_.Message_gplx_full(e));
|
||||
}
|
||||
} private Xoctg_url url_ctg = new Xoctg_url();
|
||||
private void Bld_html_v2(Xowe_wiki wiki, Xoae_page page, Xoh_wtr_ctx hctx, Bry_bfr bfr) {
|
||||
@@ -72,7 +72,7 @@ public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
}
|
||||
itm.Set__ttl__sortkey(itm_ttl, itm.Sort_key());
|
||||
}
|
||||
} List_adp title_list = List_adp_.new_(); static final byte[] Bry_missing = Bry_.new_a7("missing");
|
||||
} List_adp title_list = List_adp_.new_(); static final byte[] Bry_missing = Bry_.new_a7("missing");
|
||||
private void Add_titles(List_adp title_list, Xoctg_view_grp grp) {
|
||||
int len = grp.Itms().length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
@@ -124,7 +124,7 @@ class Xoctg_view_itm_sorter_id implements gplx.core.lists.ComparerAble {
|
||||
Xoctg_view_itm rhs = (Xoctg_view_itm)rhsObj;
|
||||
return Int_.Compare(lhs.Page_id(), rhs.Page_id());
|
||||
}
|
||||
public static final Xoctg_view_itm_sorter_id Instance = new Xoctg_view_itm_sorter_id();
|
||||
public static final Xoctg_view_itm_sorter_id Instance = new Xoctg_view_itm_sorter_id();
|
||||
}
|
||||
class Xoctg_view_itm_sorter_sortkey implements gplx.core.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
@@ -132,5 +132,5 @@ class Xoctg_view_itm_sorter_sortkey implements gplx.core.lists.ComparerAble {
|
||||
Xoctg_view_itm rhs = (Xoctg_view_itm)rhsObj;
|
||||
return Bry_.Compare(lhs.Sort_key(), rhs.Sort_key());
|
||||
}
|
||||
public static final Xoctg_view_itm_sorter_sortkey Instance = new Xoctg_view_itm_sorter_sortkey();
|
||||
public static final Xoctg_view_itm_sorter_sortkey Instance = new Xoctg_view_itm_sorter_sortkey();
|
||||
}
|
||||
|
||||
@@ -243,8 +243,8 @@ public class Xoctg_html_mgr_tst {
|
||||
class Xoh_ctg_page_fxt {
|
||||
public Xoh_ctg_page_fxt Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
ctg_html = wiki.Html_mgr().Ns_ctg();
|
||||
ctg = new Xoctg_view_ctg();
|
||||
}
|
||||
|
||||
@@ -69,8 +69,8 @@ public class Xoctg_idx_mgr_tst {
|
||||
class Xoctg_idx_mgr_fxt {
|
||||
public Xoctg_idx_mgr_fxt Clear() {
|
||||
if (app == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
idx_mgr = new Xoctg_idx_mgr();
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Xoctg_pagelist_itms implements gplx.core.brys.Bfr_arg {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse(wiki, Xow_ns_.Tid__category, page.Ttl_page_db());
|
||||
byte[] lnki_cls = hctx.Mode_is_hdump() ? Bry_.Empty : Xoh_lnki_wtr.Lnki_cls_visited(history_mgr, wiki.Domain_bry(), ttl.Page_txt()); // NOTE: must be ttl.Page_txt() in order to match Xou_history_mgr.Add
|
||||
byte[] lnki_href = href_wtr.Build_to_bry(wiki, ttl);
|
||||
byte[] lnki_ttl = ttl.Full_txt();
|
||||
byte[] lnki_ttl = ttl.Full_txt_w_ttl_case();
|
||||
byte[] lnki_text = ttl.Page_txt();
|
||||
fmtr_itm.Bld_bfr_many(bfr, lnki_cls, lnki_href, lnki_ttl, lnki_text);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ class Xoctg_url_fxt {
|
||||
public Xoctg_url_chkr url() {return expd.Clear();} private Xoctg_url_chkr expd;
|
||||
public void Clear() {
|
||||
if (parser == null) {
|
||||
Xoa_app app = Xoa_app_fxt.app_();
|
||||
Xoa_app app = Xoa_app_fxt.Make__app__edit();
|
||||
parser = app.User().Wikii().Utl__url_parser();
|
||||
page_url = Xoa_url.blank();
|
||||
ctg_url = new Xoctg_url();
|
||||
expd = new Xoctg_url_chkr();
|
||||
}
|
||||
} private Xoa_url_parser parser; Xoa_url page_url; Xoctg_url ctg_url;
|
||||
} private Xow_url_parser parser; Xoa_url page_url; Xoctg_url ctg_url;
|
||||
public void Test_parse(String url_str, Xoctg_url_chkr expd) {
|
||||
page_url = parser.Parse(Bry_.new_u8(url_str));
|
||||
ctg_url.Parse(Gfo_usr_dlg_.Test(), page_url);
|
||||
|
||||
@@ -25,7 +25,6 @@ public class Xoctg_view_itm implements gplx.CompareAble {
|
||||
public byte[] Sort_key() {return sort_key;} private byte[] sort_key;
|
||||
public int Sort_idx() {return sort_idx;} private int sort_idx;
|
||||
public boolean Missing() {return missing;} private boolean missing; public void Missing_y_() {missing = true;}
|
||||
|
||||
public Xoctg_view_itm Set__page(byte tid, int page_id) {this.tid = tid; this.page_id = page_id; return this;}
|
||||
public Xoctg_view_itm Set__ttl__sortkey(Xoa_ttl ttl, byte[] sort_key) {
|
||||
this.ttl = ttl;
|
||||
|
||||
@@ -127,8 +127,8 @@ class Xow_data_mgr_fxt {
|
||||
Xoae_app app;
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
wiki.Db_mgr().Save_mgr().Page_id_next_(0);
|
||||
}
|
||||
public Xow_data_mgr_fxt Create(String ttl_str, String data) {
|
||||
|
||||
@@ -17,17 +17,18 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.bldrs.infos.*;
|
||||
import gplx.xowa.htmls.core.dbs.*;
|
||||
import gplx.xowa.wikis.data.site_stats.*;
|
||||
import gplx.xowa.htmls.core.dbs.*; import gplx.xowa.addons.searchs.dbs.*;
|
||||
public class Xowd_db_file {
|
||||
Xowd_db_file(Db_cfg_tbl cfg_tbl, Xob_info_session info_session, Xob_info_file info_file, Xowd_core_db_props props, Xowd_db_file_schema_props schema_props, int id, byte tid, Io_url url, String ns_ids, int part_id, Guid_adp guid, Db_conn conn, byte cmd_mode) {
|
||||
this.id = id; this.tid = tid; this.url = url; this.ns_ids = ns_ids; this.part_id = part_id; this.guid = guid;
|
||||
this.id = id; this.tid = tid; this.url = url; this.ns_ids = ns_ids; this.part_id = part_id; this.guid = guid; this.db_props = props; this.schema_props = schema_props;
|
||||
this.conn = conn; this.cmd_mode = cmd_mode;
|
||||
this.url_rel = url.NameAndExt();
|
||||
boolean schema_is_1 = props.Schema_is_1();
|
||||
this.tbl__cfg = cfg_tbl;
|
||||
this.tbl__db = new Xowd_xowa_db_tbl(conn, schema_is_1);
|
||||
this.tbl__ns = new Xowd_site_ns_tbl(conn, schema_is_1);
|
||||
this.tbl__site_stats = new Xowd_site_stats_tbl(conn, schema_is_1);
|
||||
this.tbl__site_stats = new Xow_site_stats_tbl(conn, schema_is_1);
|
||||
this.tbl__page = new Xowd_page_tbl(conn, schema_is_1);
|
||||
this.tbl__text = new Xowd_text_tbl(conn, schema_is_1, props.Zip_tid_text());
|
||||
this.tbl__html = new Xoh_page_tbl(conn);
|
||||
@@ -37,40 +38,39 @@ public class Xowd_db_file {
|
||||
this.tbl__cat_link = new Xowd_cat_link_tbl(conn, schema_is_1);
|
||||
this.tbl__wbase_qid = new Xowd_wbase_qid_tbl(conn, schema_is_1, schema_props.Wbase__qid__src_ttl_has_spaces());
|
||||
this.tbl__wbase_pid = new Xowd_wbase_pid_tbl(conn, schema_is_1);
|
||||
this.tbl__search_word = new Xowd_search_word_tbl(conn, schema_is_1, schema_props.Search__word__page_count_exists());
|
||||
this.tbl__search_link = new Xowd_search_link_tbl(conn, schema_is_1);
|
||||
this.info_session = info_session;
|
||||
this.info_file = info_file;
|
||||
}
|
||||
public int Id() {return id;} private final int id; // unique id in xowa_db
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public String Ns_ids() {return ns_ids;} private final String ns_ids;
|
||||
public int Part_id() {return part_id;} private final int part_id;
|
||||
public Guid_adp Guid() {return guid;} private final Guid_adp guid;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xowd_db_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public long File_len() {return file_len;} public Xowd_db_file File_len_add(int v) {file_len += v; return this;} private long file_len;
|
||||
public long File_max() {return file_max;} public Xowd_db_file File_max_(long v) {file_max = v; return this;} private long file_max;
|
||||
public Xob_info_session Info_session() {return info_session;} private final Xob_info_session info_session;
|
||||
public Xob_info_file Info_file() {return info_file;} private final Xob_info_file info_file;
|
||||
public Db_cfg_tbl Tbl__cfg() {return tbl__cfg;} private final Db_cfg_tbl tbl__cfg;
|
||||
public Xowd_xowa_db_tbl Tbl__db() {return tbl__db;} private final Xowd_xowa_db_tbl tbl__db;
|
||||
public Xowd_site_ns_tbl Tbl__ns() {return tbl__ns;} private final Xowd_site_ns_tbl tbl__ns;
|
||||
public Xowd_page_tbl Tbl__page() {return tbl__page;} private final Xowd_page_tbl tbl__page;
|
||||
public Xowd_text_tbl Tbl__text() {return tbl__text;} private final Xowd_text_tbl tbl__text;
|
||||
public Xoh_page_tbl Tbl__html() {return tbl__html;} private final Xoh_page_tbl tbl__html;
|
||||
public Xowd_css_core_tbl Tbl__css_core() {return tbl__css_core;} private final Xowd_css_core_tbl tbl__css_core;
|
||||
public Xowd_css_file_tbl Tbl__css_file() {return tbl__css_file;} private final Xowd_css_file_tbl tbl__css_file;
|
||||
public Xowd_cat_core_tbl Tbl__cat_core() {return tbl__cat_core;} private final Xowd_cat_core_tbl tbl__cat_core;
|
||||
public Xowd_cat_link_tbl Tbl__cat_link() {return tbl__cat_link;} private final Xowd_cat_link_tbl tbl__cat_link;
|
||||
public Xowd_search_word_tbl Tbl__search_word() {return tbl__search_word;} private final Xowd_search_word_tbl tbl__search_word;
|
||||
public Xowd_search_link_tbl Tbl__search_link() {return tbl__search_link;} private final Xowd_search_link_tbl tbl__search_link;
|
||||
public Xowd_site_stats_tbl Tbl__site_stats() {return tbl__site_stats;} private final Xowd_site_stats_tbl tbl__site_stats;
|
||||
public Xowd_wbase_qid_tbl Tbl__wbase_qid() {return tbl__wbase_qid;} private final Xowd_wbase_qid_tbl tbl__wbase_qid;
|
||||
public Xowd_wbase_pid_tbl Tbl__wbase_pid() {return tbl__wbase_pid;} private final Xowd_wbase_pid_tbl tbl__wbase_pid;
|
||||
public void Rls() {conn.Rls_conn();}
|
||||
public int Id() {return id;} private final int id; // unique id in xowa_db
|
||||
public byte Tid() {return tid;} private final byte tid;
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
public String Url_rel() {return url_rel;} private final String url_rel;
|
||||
public Xowd_core_db_props Db_props() {return db_props;} private final Xowd_core_db_props db_props;
|
||||
public Xowd_db_file_schema_props Schema_props() {return schema_props;} private final Xowd_db_file_schema_props schema_props;
|
||||
public String Ns_ids() {return ns_ids;} private final String ns_ids;
|
||||
public int Part_id() {return part_id;} private final int part_id;
|
||||
public Guid_adp Guid() {return guid;} private final Guid_adp guid;
|
||||
public byte Cmd_mode() {return cmd_mode;} public Xowd_db_file Cmd_mode_(byte v) {cmd_mode = v; return this;} private byte cmd_mode;
|
||||
public long File_len() {return file_len;} public Xowd_db_file File_len_add(int v) {file_len += v; return this;} private long file_len;
|
||||
public long File_max() {return file_max;} public Xowd_db_file File_max_(long v) {file_max = v; return this;} private long file_max;
|
||||
public Xob_info_session Info_session() {return info_session;} private final Xob_info_session info_session;
|
||||
public Xob_info_file Info_file() {return info_file;} private final Xob_info_file info_file;
|
||||
public Db_cfg_tbl Tbl__cfg() {return tbl__cfg;} private final Db_cfg_tbl tbl__cfg;
|
||||
public Xowd_xowa_db_tbl Tbl__db() {return tbl__db;} private final Xowd_xowa_db_tbl tbl__db;
|
||||
public Xowd_site_ns_tbl Tbl__ns() {return tbl__ns;} private final Xowd_site_ns_tbl tbl__ns;
|
||||
public Xowd_page_tbl Tbl__page() {return tbl__page;} private Xowd_page_tbl tbl__page;
|
||||
public Xowd_text_tbl Tbl__text() {return tbl__text;} private final Xowd_text_tbl tbl__text;
|
||||
public Xoh_page_tbl Tbl__html() {return tbl__html;} private final Xoh_page_tbl tbl__html;
|
||||
public Xowd_css_core_tbl Tbl__css_core() {return tbl__css_core;} private final Xowd_css_core_tbl tbl__css_core;
|
||||
public Xowd_css_file_tbl Tbl__css_file() {return tbl__css_file;} private final Xowd_css_file_tbl tbl__css_file;
|
||||
public Xowd_cat_core_tbl Tbl__cat_core() {return tbl__cat_core;} private final Xowd_cat_core_tbl tbl__cat_core;
|
||||
public Xowd_cat_link_tbl Tbl__cat_link() {return tbl__cat_link;} private final Xowd_cat_link_tbl tbl__cat_link;
|
||||
public Xow_site_stats_tbl Tbl__site_stats() {return tbl__site_stats;} private final Xow_site_stats_tbl tbl__site_stats;
|
||||
public Xowd_wbase_qid_tbl Tbl__wbase_qid() {return tbl__wbase_qid;} private final Xowd_wbase_qid_tbl tbl__wbase_qid;
|
||||
public Xowd_wbase_pid_tbl Tbl__wbase_pid() {return tbl__wbase_pid;} private final Xowd_wbase_pid_tbl tbl__wbase_pid;
|
||||
public void Rls() {conn.Rls_conn();}
|
||||
public Xowd_page_tbl Tbl__page__rebind() {this.tbl__page = new Xowd_page_tbl(tbl__page.conn, tbl__page.schema_is_1); return tbl__page;}
|
||||
|
||||
public static final Xowd_db_file Null = null;
|
||||
public static Xowd_db_file make_(Xob_info_session info_session, Xowd_core_db_props props, int id, byte tid, Io_url url, String ns_ids, int part_id, String core_file_name, Db_conn conn) {
|
||||
|
||||
@@ -24,6 +24,7 @@ public class Xowd_db_file_ {
|
||||
, Tid_wiki_solo = 8, Tid_text_solo = 9
|
||||
, Tid_html_solo = 10, Tid_html_data = 11
|
||||
, Tid_file_solo = 12, Tid_file_core = 13, Tid_file_data = 14, Tid_file_user = 15
|
||||
, Tid_search_link = 16
|
||||
;
|
||||
private static final String
|
||||
Key_core = "core", Key_text = "text", Key_cat = "xtn.category", Key_search_core = "xtn.search.core", Key_wbase = "core.wbase"
|
||||
@@ -31,6 +32,7 @@ public class Xowd_db_file_ {
|
||||
, Key_text_solo = "text.solo", Key_wiki_solo = "wiki.solo"
|
||||
, Key_html_solo = "html.solo", Key_html_data = "html"
|
||||
, Key_file_solo = "file.solo", Key_file_core = "file.core", Key_file_data = "file.data", Key_file_user = "file.user"
|
||||
, Key_search_link = "xtn.search.link"
|
||||
;
|
||||
public static String To_key(byte v) {
|
||||
switch (v) {
|
||||
@@ -49,6 +51,7 @@ public class Xowd_db_file_ {
|
||||
case Tid_file_core: return Key_file_core;
|
||||
case Tid_file_data: return Key_file_data;
|
||||
case Tid_file_user: return Key_file_user;
|
||||
case Tid_search_link: return Key_search_link;
|
||||
default: throw Err_.new_unhandled(v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class Xowd_db_file_hash {
|
||||
tids.Del(file.Id());
|
||||
--count_total;
|
||||
}
|
||||
public Ordered_hash Get_by_tid_or_null(byte tid) {return (Ordered_hash)hash.Get_by(tid);}
|
||||
public void Add_or_new(Xowd_db_file file) {
|
||||
byte tid = file.Tid();
|
||||
Ordered_hash tids = (Ordered_hash)hash.Get_by(tid);
|
||||
|
||||
@@ -21,6 +21,7 @@ import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.domains.*; import gplx.xowa.bldrs.infos.*;
|
||||
public class Xowd_db_mgr {
|
||||
private Xowd_db_file[] dbs__ary = new Xowd_db_file[0]; private int dbs__ary_len = 0; private final Xowd_db_file_hash db_file_hash = new Xowd_db_file_hash();
|
||||
private final Hash_adp id_hash = Hash_adp_.new_(); private final gplx.core.primitives.Int_obj_ref id_hash_ref = gplx.core.primitives.Int_obj_ref.neg1_();
|
||||
private final Xow_wiki wiki; private final Io_url wiki_root_dir; private final Xow_domain_itm domain_itm;
|
||||
public Xowd_db_mgr(Xow_wiki wiki, Io_url wiki_root_dir, Xow_domain_itm domain_itm) {this.wiki = wiki; this.wiki_root_dir = wiki_root_dir; this.domain_itm = domain_itm;}
|
||||
public Xowd_core_db_props Props() {return props;} private Xowd_core_db_props props = Xowd_core_db_props.Test;
|
||||
@@ -30,18 +31,31 @@ public class Xowd_db_mgr {
|
||||
public Xowd_db_file Db__text() {return db__text;} private Xowd_db_file db__text;
|
||||
public Xowd_db_file Db__html() {return db__html;} private Xowd_db_file db__html;
|
||||
public Xowd_db_file Db__cat_core() {return db__cat_core;} private Xowd_db_file db__cat_core;
|
||||
public Xowd_db_file Db__search() {return db__search;} private Xowd_db_file db__search;
|
||||
public Xowd_db_file Db__wbase() {return db__wbase;} private Xowd_db_file db__wbase;
|
||||
public int Dbs__len() {return dbs__ary.length;}
|
||||
public void Db__wbase_(Xowd_db_file v) {db__wbase = v;}
|
||||
public Ordered_hash Dbs__get_hash_by_tid(int tid) {return db_file_hash.Get_by_tid_or_null((byte)tid);}
|
||||
public Xowd_db_file Dbs__get_at(int i) {return dbs__ary[i];}
|
||||
public Xowd_db_file Dbs__get_by_id(int id) {return (Xowd_db_file)id_hash.Get_by_or_fail(id_hash_ref.Val_(id));}
|
||||
public Xowd_db_file Dbs__get_by_tid_or_core(byte... tids_ary) {Xowd_db_file rv = Dbs__get_by_tid_or_null(tids_ary); return rv == null ? db__core : rv;}
|
||||
public Xowd_db_file Dbs__get_by_tid_or_null(byte... tids_ary) {
|
||||
int tids_len = tids_ary.length;
|
||||
for (int i = 0; i < tids_len; ++i) {
|
||||
byte tid = tids_ary[i];
|
||||
Ordered_hash tid_dbs = db_file_hash.Get_by_tid_or_null(tid); if (tid_dbs == null) continue;
|
||||
if (tid_dbs.Len() != 1) throw Err_.new_("xowa.dbs", "expecting only 1 db for tid; tid=~{0} len=~{1} db_api=~{2}", tid, tid_dbs.Len(), db__core.Conn().Conn_info().Db_api());
|
||||
return (Xowd_db_file)tid_dbs.Get_at(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public Xowd_db_file Dbs__make_by_tid(byte tid) {
|
||||
int tid_idx = Get_tid_idx(db_file_hash, tid);
|
||||
return Dbs__make_by_tid(tid, Xob_info_file.Ns_ids_empty, tid_idx, Get_tid_name(db_file_hash, tid_idx, tid));
|
||||
}
|
||||
public Xowd_db_file Dbs__make_by_tid(byte tid, String ns_ids, int part_id, String file_name_suffix) {
|
||||
Io_url url = wiki_root_dir.GenSubFil(domain_itm.Domain_str() + file_name_suffix);
|
||||
Xowd_db_file rv = Xowd_db_file.make_(db__core.Info_session(), props, dbs__ary_len, tid, url, ns_ids, part_id, db__core.Url().NameAndExt(), Db_conn_bldr.Instance.New(url));
|
||||
int next_id = Dbs__get_at(dbs__ary_len - 1).Id() + 1;
|
||||
Xowd_db_file rv = Xowd_db_file.make_(db__core.Info_session(), props, next_id, tid, url, ns_ids, part_id, db__core.Url().NameAndExt(), Db_conn_bldr.Instance.New(url));
|
||||
Dbs__add_and_save(rv);
|
||||
Dbs__set_by_tid(rv);
|
||||
return rv;
|
||||
@@ -60,6 +74,7 @@ public class Xowd_db_mgr {
|
||||
}
|
||||
public void Init_by_load(Io_url core_url) {
|
||||
db_file_hash.Clear();
|
||||
id_hash.Clear();
|
||||
Db_conn core_conn = Db_conn_bldr.Instance.Get(core_url);
|
||||
props = Xowd_core_db_props.Cfg_load(core_url, core_conn);
|
||||
Dbs__set_by_tid(Xowd_db_file.load_(props, Xowd_db_file_.Id_core, Core_db_tid(props.Layout_text()), core_url, Xob_info_file.Ns_ids_empty, Xob_info_file.Part_id_1st, Guid_adp_.Empty));
|
||||
@@ -69,6 +84,7 @@ public class Xowd_db_mgr {
|
||||
Xowd_db_file db = dbs__ary[i];
|
||||
Dbs__set_by_tid(db);
|
||||
db_file_hash.Add_or_new(db);
|
||||
id_hash.Add(gplx.core.primitives.Int_obj_ref.new_(db.Id()), db);
|
||||
}
|
||||
wiki.Props().Init_by_load(wiki.App(), Tbl__cfg());
|
||||
}
|
||||
@@ -100,10 +116,9 @@ public class Xowd_db_mgr {
|
||||
switch (db.Tid()) {
|
||||
case Xowd_db_file_.Tid_wiki_solo:
|
||||
case Xowd_db_file_.Tid_text_solo:
|
||||
case Xowd_db_file_.Tid_core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__search = db__text = db; break;}
|
||||
case Xowd_db_file_.Tid_core : {db__core = db; if (props.Layout_text().Tid_is_all_or_few()) db__cat_core = db__text = db; break;}
|
||||
case Xowd_db_file_.Tid_text : {db__text = db; break;}
|
||||
case Xowd_db_file_.Tid_html_data : {db__html = db; break;}
|
||||
case Xowd_db_file_.Tid_search_core : {if (db__search == null) db__search = db; break;}
|
||||
case Xowd_db_file_.Tid_wbase : {if (db__wbase == null) db__wbase = db; break;}
|
||||
case Xowd_db_file_.Tid_cat_core :
|
||||
case Xowd_db_file_.Tid_cat : {if (db__cat_core == null) db__cat_core = db; break;}
|
||||
@@ -116,6 +131,7 @@ public class Xowd_db_mgr {
|
||||
rv.Info_file().Save(rv.Tbl__cfg());
|
||||
rv.Info_session().Save(rv.Tbl__cfg());
|
||||
db_file_hash.Add_or_new(rv);
|
||||
id_hash.Add(gplx.core.primitives.Int_obj_ref.new_(rv.Id()), rv);
|
||||
}
|
||||
public void Rls() {
|
||||
for (int i = 0; i < dbs__ary_len; i++)
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.site_stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_site_stats_mgr implements GfoInvkAble { // REF.MW:https://www.mediawiki.org/wiki/Manual:Site_stats_table
|
||||
private final Xow_wiki wiki;
|
||||
public Xow_site_stats_mgr(Xow_wiki wiki) {this.wiki = wiki;}
|
||||
public long Num_pages() {return num_pages;} private long num_pages; // ss_total_pages; pages in entire wiki: 16,299,475
|
||||
public long Num_articles() {return num_articles;} private long num_articles; // ss_good_articles; pages in main ns w/o redirect: 5,072,469
|
||||
public long Num_views() {return num_views;} private long num_views; // ss_total_views
|
||||
public long Num_edits() {return num_edits;} private long num_edits; // ss_total_edits
|
||||
public long Num_users() {return num_users;} private long num_users; // ss_users
|
||||
public long Num_active() {return num_active;} private long num_active; // ss_active_users
|
||||
public int Num_admins() {return num_admins;} private int num_admins; // ss_admins
|
||||
public int Num_files() {return num_files;} private int num_files; // ss_images
|
||||
public void Load_by_db(long num_pages, long num_articles, int num_files, long num_edits, long num_views, long num_users, long num_active, int num_admins) {
|
||||
this.num_pages = num_pages;
|
||||
this.num_articles = num_articles;
|
||||
this.num_files = num_files;
|
||||
this.num_edits = num_edits;
|
||||
this.num_views = num_views;
|
||||
this.num_users = num_users;
|
||||
this.num_active = num_active;
|
||||
this.num_admins = num_admins;
|
||||
}
|
||||
private Object Number_of_articles_in_ns_(GfoMsg m) {
|
||||
int ns_id = m.ReadInt("ns_id");
|
||||
int count = m.ReadInt("count");
|
||||
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
|
||||
if (ns != null) ns.Count_(count);
|
||||
return this;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_number_of_pages_)) num_pages = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_articles_)) num_articles = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_files_)) num_files = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_articles_in_ns_)) return Number_of_articles_in_ns_(m);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_number_of_pages_ = "number_of_pages_", Invk_number_of_articles_ = "number_of_articles_", Invk_number_of_files_ = "number_of_files_", Invk_number_of_articles_in_ns_ = "number_of_articles_in_ns_";
|
||||
}
|
||||
@@ -15,13 +15,13 @@ GNU Affero General Public License for more details.
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.metas.*;
|
||||
public class Xowd_site_stats_tbl {
|
||||
package gplx.xowa.wikis.data.site_stats; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.site_stats.*;
|
||||
public class Xow_site_stats_tbl {
|
||||
private final String tbl_name = "site_stats";
|
||||
private final String fld_row_id, fld_good_articles, fld_total_pages, fld_images;
|
||||
private final Db_conn conn; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
public Xowd_site_stats_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
public Xow_site_stats_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
fld_row_id = flds.Add_int_pkey("ss_row_id");
|
||||
fld_good_articles = flds.Add_long("ss_good_articles");
|
||||
@@ -29,7 +29,7 @@ public class Xowd_site_stats_tbl {
|
||||
fld_images = flds.Add_int("ss_images");
|
||||
}
|
||||
public void Create_tbl() {
|
||||
conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));
|
||||
conn.Stmt_insert(tbl_name, flds).Val_int(fld_row_id, Site_stats_row_id).Val_long(fld_good_articles, 0).Val_long(fld_total_pages, 0).Val_int(fld_images, 0).Exec_insert();
|
||||
}
|
||||
public void Update(int num_articles, int num_pages, int num_files) {
|
||||
@@ -38,13 +38,15 @@ public class Xowd_site_stats_tbl {
|
||||
.Crt_int(fld_row_id, Site_stats_row_id)
|
||||
.Exec_update();
|
||||
}
|
||||
public void Select(Xow_wiki_stats stats) {
|
||||
public void Select(Xow_site_stats_mgr stats) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_row_id).Crt_int(fld_row_id, Site_stats_row_id).Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
stats.NumArticles_ ((int)rdr.Read_long(fld_good_articles)); // #<>(int)rdr.Read_long~rdr.Read_int
|
||||
stats.NumPages_ ((int)rdr.Read_long(fld_total_pages)); // #<>(int)rdr.Read_long~rdr.Read_int
|
||||
stats.NumFiles_ (rdr.Read_int(fld_images));
|
||||
stats.Load_by_db
|
||||
( rdr.Read_long(fld_good_articles)
|
||||
, rdr.Read_long(fld_total_pages)
|
||||
, rdr.Read_int(fld_images)
|
||||
, 0, 0, 0, 0, 0);
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class Xowd_cat_core_tbl implements Rls_able {
|
||||
in_wkr.Ctor(this, tbl_name, flds, fld_id);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Xowd_cat_core_tbl Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds)); return this;}
|
||||
public Xowd_cat_core_tbl Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds)); return this;}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__cat_core__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int id, int pages, int subcats, int files, byte hidden, int link_db_id) {
|
||||
|
||||
@@ -32,9 +32,9 @@ public class Xowd_cat_link_tbl implements Rls_able {
|
||||
fld_timestamp = flds.Add_str ("cl_timestamp", 14);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Xowd_cat_link_tbl Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds)); return this;}
|
||||
public Xowd_cat_link_tbl Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds)); return this;}
|
||||
public void Create_idx() {
|
||||
conn.Ddl_create_idx(Xoa_app_.Usr_dlg()
|
||||
conn.Meta_idx_create(Xoa_app_.Usr_dlg()
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "main", fld_to_id, fld_type_id, fld_sortkey, fld_from)
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "from", fld_from)
|
||||
);
|
||||
|
||||
@@ -29,7 +29,7 @@ public class Xowd_css_core_tbl implements Rls_able {
|
||||
}
|
||||
public Db_conn Conn() {return conn;} private final Db_conn conn;
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_key)));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_key)));}
|
||||
public void Rls() {}
|
||||
public int Insert(String key, DateAdp updated_on) {
|
||||
Db_stmt stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xowd_css_file_tbl implements Rls_able {
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert(int css_id, String path, byte[] data) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_int(fld_css_id, css_id).Val_str(fld_path, path).Val_bry(fld_data, data).Exec_insert();
|
||||
|
||||
@@ -33,16 +33,18 @@ public class Xowd_page_itm {
|
||||
public int Redirect_id() {return redirect_id;} private int redirect_id;
|
||||
public DateAdp Modified_on() {return modified_on;} public Xowd_page_itm Modified_on_(DateAdp v) {modified_on = v; return this;} private DateAdp modified_on;
|
||||
public boolean Exists() {return exists;} public Xowd_page_itm Exists_(boolean v) {exists = v; return this;} private boolean exists;
|
||||
public int Page_score;
|
||||
public Xow_ns Ns() {return ns;} private Xow_ns ns;
|
||||
public Object Xtn() {return xtn;} public Xowd_page_itm Xtn_(Object v) {this.xtn = v; return this;} private Object xtn;
|
||||
public int Tdb_row_idx() {return tdb_row_idx;} public void Tdb_row_idx_(int v) {tdb_row_idx = v;} private int tdb_row_idx;
|
||||
public int Rank() {return text_len;}
|
||||
public Xowd_page_itm Init(int id, byte[] ttl_page_db, boolean redirected, int text_len, int text_db_id, int tdb_row_idx) {
|
||||
this.id = id; this.ttl_page_db = ttl_page_db; this.redirected = redirected;
|
||||
this.text_len = text_len; this.text_db_id = text_db_id; this.tdb_row_idx = tdb_row_idx;
|
||||
id_val = null;
|
||||
return this;
|
||||
}
|
||||
public void Init_by_sql(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int text_db_id, int html_db_id, int redirect_id) {
|
||||
public void Init_by_sql(int id, int ns_id, byte[] ttl_page_db, DateAdp modified_on, boolean redirected, int text_len, int text_db_id, int html_db_id, int redirect_id, int page_score) {
|
||||
this.id = id;
|
||||
this.ns_id = ns_id;
|
||||
this.ttl_page_db = ttl_page_db;
|
||||
@@ -52,6 +54,7 @@ public class Xowd_page_itm {
|
||||
this.text_db_id = text_db_id;
|
||||
this.html_db_id = html_db_id;
|
||||
this.redirect_id = redirect_id;
|
||||
this.Page_score = page_score;
|
||||
}
|
||||
public void Init_by_tdb(int id, int text_db_id, int tdb_row_idx, boolean redirected, int text_len, int ns_id, byte[] ttl_page_db) {
|
||||
this.id = id;
|
||||
@@ -70,7 +73,7 @@ public class Xowd_page_itm {
|
||||
return this;
|
||||
}
|
||||
public Xowd_page_itm Ttl_(Xoa_ttl ttl) {
|
||||
ttl_full_db = ttl.Full_txt();
|
||||
ttl_full_db = ttl.Full_txt_w_ttl_case();
|
||||
ttl_page_db = ttl.Page_db();
|
||||
ns = ttl.Ns();
|
||||
ns_id = ns.Id();
|
||||
@@ -120,9 +123,9 @@ public class Xowd_page_itm {
|
||||
this.html_db_id = orig.html_db_id;
|
||||
}
|
||||
public void Srl_save(Bry_bfr bfr) {gplx.xowa.wikis.tdbs.Xotdb_page_itm_.Txt_id_save(bfr, this);}
|
||||
public static final int Id_null = -1, Modified_on_null_int = 0;
|
||||
public static final Xowd_page_itm[] Ary_empty = new Xowd_page_itm[0];
|
||||
public static final Xowd_page_itm Null = null;
|
||||
public static final int Id_null = -1, Modified_on_null_int = 0, Redirect_id_null = -1;
|
||||
public static final Xowd_page_itm[] Ary_empty = new Xowd_page_itm[0];
|
||||
public static final Xowd_page_itm Null = null;
|
||||
public static Xowd_page_itm new_tmp() {return new Xowd_page_itm();}
|
||||
public static Xowd_page_itm new_srch(int id, int text_len) {return new Xowd_page_itm().Id_(id).Text_len_(text_len);}
|
||||
}
|
||||
|
||||
@@ -20,24 +20,26 @@ import gplx.core.primitives.*; import gplx.core.criterias.*;
|
||||
import gplx.dbs.*; import gplx.xowa.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.qrys.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xowd_page_tbl implements Rls_able {
|
||||
private final String tbl_name = "page";
|
||||
private String fld_id, fld_ns, fld_title, fld_is_redirect, fld_touched, fld_len, fld_random_int, fld_text_db_id, fld_html_db_id, fld_redirect_id;
|
||||
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final Db_conn conn; private Db_stmt stmt_select_all_by_ttl, stmt_select_all_by_id, stmt_select_id_by_ttl, stmt_insert; private boolean hdump_enabled;
|
||||
private final String[] flds_select_all, flds_select_idx;
|
||||
private final String tbl_name = "page";
|
||||
private String fld_id, fld_ns, fld_title, fld_is_redirect, fld_touched, fld_len, fld_random_int, fld_score, fld_text_db_id, fld_html_db_id, fld_redirect_id;
|
||||
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private Db_stmt stmt_select_all_by_ttl, stmt_select_all_by_id, stmt_select_id_by_ttl, stmt_insert; private boolean hdump_enabled;
|
||||
private final String[] flds_select_all, flds_select_idx;
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public Dbmeta_fld_list Flds__all() {return flds;}
|
||||
public String Fld_page_id() {return fld_id;}
|
||||
public String Fld_page_ns() {return fld_ns;}
|
||||
public String Fld_page_title() {return fld_title;}
|
||||
public String Fld_page_len() {return fld_len;}
|
||||
public String Fld_page_score() {return fld_score;} public static final String Fld__page_score__key = "page_score";
|
||||
public String Fld_html_db_id() {return fld_html_db_id;}
|
||||
public String Fld_is_redirect() {return fld_is_redirect;}
|
||||
public String Fld_redirect_id() {return fld_redirect_id;}
|
||||
public String[] Flds_select_idx() {return flds_select_idx;}
|
||||
public String[] Flds_select_all() {return flds_select_all;}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public final Db_conn conn; public final boolean schema_is_1;
|
||||
public Xowd_page_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
this.conn = conn; this.schema_is_1 = schema_is_1;
|
||||
String fld_text_db_id_name = "";
|
||||
if (schema_is_1) {fld_text_db_id_name = "page_file_idx";}
|
||||
else {fld_text_db_id_name = "page_text_db_id";}
|
||||
@@ -50,11 +52,12 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
fld_random_int = flds.Add_int("page_random_int"); // MW:XOWA
|
||||
fld_text_db_id = flds.Add_int(fld_text_db_id_name); // MW:XOWA
|
||||
Hdump_enabled_(!schema_is_1);
|
||||
flds_select_all = String_.Ary_wo_null(fld_id, fld_ns, fld_title, fld_touched, fld_is_redirect, fld_len, fld_text_db_id, fld_html_db_id, fld_redirect_id);
|
||||
flds_select_idx = String_.Ary(fld_ns, fld_title, fld_id, fld_len);
|
||||
fld_score = Dbmeta_fld_itm.Make_or_null(conn, flds, tbl_name, Dbmeta_fld_tid.Tid__int, -1, Fld__page_score__key);
|
||||
flds_select_all = String_.Ary_wo_null(fld_id, fld_ns, fld_title, fld_touched, fld_is_redirect, fld_len, fld_text_db_id, fld_html_db_id, fld_redirect_id, fld_score);
|
||||
flds_select_idx = String_.Ary_wo_null(fld_ns, fld_title, fld_id, fld_len, fld_score);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds.To_fld_ary()));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds.To_fld_ary()));}
|
||||
public void Insert(int page_id, int ns_id, byte[] ttl_wo_ns, boolean page_is_redirect, DateAdp modified_on, int page_len, int random_int, int text_db_id, int html_db_id) {
|
||||
this.Insert_bgn();
|
||||
this.Insert_cmd_by_batch(page_id, ns_id, ttl_wo_ns, page_is_redirect, modified_on, page_len, random_int, text_db_id, html_db_id);
|
||||
@@ -74,6 +77,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
.Val_int(fld_text_db_id, text_db_id)
|
||||
.Val_int(fld_html_db_id, html_db_id)
|
||||
.Val_int(fld_redirect_id, -1)
|
||||
.Val_int(fld_score, -1)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Hdump_enabled_(boolean v) {
|
||||
@@ -111,7 +115,7 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
finally {rdr.Rls();}
|
||||
return false;
|
||||
}
|
||||
public Db_rdr Select_all() {
|
||||
public Db_rdr Select_all__id__ttl() {
|
||||
Db_qry__select_cmd qry = new Db_qry__select_cmd().From_(tbl_name).Cols_(fld_id, fld_title).Order_asc_(fld_id);
|
||||
return conn.Stmt_new(qry).Exec_select__rls_auto();
|
||||
}
|
||||
@@ -159,12 +163,11 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
}
|
||||
public byte[] Select_random(Xow_ns ns) {// ns should be ns_main
|
||||
int random_int = RandomAdp_.new_().Next(ns.Count());
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, String_.Ary(fld_title), fld_ns, fld_random_int)
|
||||
.Crt_int(fld_ns, ns.Id()).Crt_int(fld_random_int, random_int)
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, String_.Ary(fld_title), fld_random_int, fld_ns)
|
||||
.Crt_int(fld_random_int, random_int).Crt_int(fld_ns, ns.Id())
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
return rdr.Move_next() ? rdr.Read_bry_by_str(fld_title) : null;
|
||||
} finally {rdr.Rls();}
|
||||
try {return rdr.Move_next() ? rdr.Read_bry_by_str(fld_title) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public void Select_by_search(Cancelable cancelable, List_adp rv, byte[] search, int results_max) {
|
||||
if (Bry_.Len_eq_0(search)) return; // do not allow empty search
|
||||
@@ -275,16 +278,21 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
html_db_id = rdr.Read_int(fld_html_db_id);
|
||||
redirected_id = rdr.Read_int(fld_redirect_id);
|
||||
}
|
||||
int page_len = rdr.Read_int(fld_len);
|
||||
int page_score = page_len;
|
||||
if (fld_score != Dbmeta_fld_itm.Key_null)
|
||||
page_score = rdr.Read_int(fld_score);
|
||||
page.Init_by_sql
|
||||
( rdr.Read_int(fld_id)
|
||||
, rdr.Read_int(fld_ns)
|
||||
, rdr.Read_bry_by_str(fld_title)
|
||||
, DateAdp_.parse_fmt(rdr.Read_str(fld_touched), Page_touched_fmt)
|
||||
, rdr.Read_bool_by_byte(fld_is_redirect)
|
||||
, rdr.Read_int(fld_len)
|
||||
, page_len
|
||||
, rdr.Read_int(fld_text_db_id)
|
||||
, html_db_id
|
||||
, redirected_id
|
||||
, page_score
|
||||
);
|
||||
}
|
||||
public void Update__html_db_id(int page_id, int html_db_id) {
|
||||
@@ -315,24 +323,25 @@ public class Xowd_page_tbl implements Rls_able {
|
||||
;
|
||||
}
|
||||
public void Create_index() {
|
||||
conn.Ddl_create_idx(Xoa_app_.Usr_dlg()
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "title" , fld_ns, fld_title, fld_id, fld_len, fld_is_redirect)
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "random" , fld_ns, fld_random_int)
|
||||
conn.Meta_idx_create(Xoa_app_.Usr_dlg()
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "title" , fld_title, fld_ns)
|
||||
, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "random" , fld_random_int)
|
||||
);
|
||||
}
|
||||
public int Fld_page_score_eval(Db_rdr rdr, int page_len) {
|
||||
return fld_score == Dbmeta_fld_itm.Key_null ? page_len : rdr.Read_int(fld_score);
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_select_all_by_ttl = Db_stmt_.Rls(stmt_select_all_by_ttl);
|
||||
stmt_select_all_by_id = Db_stmt_.Rls(stmt_select_all_by_id);
|
||||
stmt_select_id_by_ttl = Db_stmt_.Rls(stmt_select_id_by_ttl);
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
private static final String Page_touched_fmt = "yyyyMMddHHmmss";
|
||||
private static final String Page_touched_fmt = "yyyyMMddHHmmss";
|
||||
public static void Assert_col__page_html_db_id(Xowd_db_mgr db_mgr) {
|
||||
Xowd_page_tbl page_tbl = db_mgr.Tbl__page(); Db_conn page_conn = page_tbl.Conn();
|
||||
boolean html_flds_exists = page_conn.Meta_fld_exists(page_tbl.Tbl_name(), page_tbl.Fld_html_db_id());
|
||||
if (html_flds_exists) return;
|
||||
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Dbmeta_fld_itm.new_int(page_tbl.Fld_html_db_id()).Default_(-1));
|
||||
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Dbmeta_fld_itm.new_int(page_tbl.Fld_redirect_id()).Default_(-1));
|
||||
Xowd_page_tbl page_tbl = db_mgr.Tbl__page(); Db_conn page_conn = page_tbl.conn;
|
||||
page_conn.Meta_fld_assert(page_tbl.Tbl_name(), page_tbl.Fld_html_db_id() , Dbmeta_fld_tid.Itm__int, -1);
|
||||
page_conn.Meta_fld_assert(page_tbl.Tbl_name(), page_tbl.Fld_redirect_id() , Dbmeta_fld_tid.Itm__int, -1);
|
||||
page_tbl.Hdump_enabled_(Bool_.Y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_pagelinks_tbl implements Rls_able {
|
||||
private final String tbl_name = "pagelink"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_src_id, fld_trg_id;
|
||||
private final Db_conn conn;
|
||||
public Xowd_pagelinks_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
fld_src_id = flds.Add_int("src_id");
|
||||
fld_trg_id = flds.Add_int("trg_id");
|
||||
flds.Add_int("trg_count");
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx__src_trg() {conn.Ddl_create_idx(Gfo_usr_dlg_.Instance, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "src_trg", fld_src_id, fld_trg_id));}
|
||||
public void Create_idx__trg_src() {conn.Ddl_create_idx(Gfo_usr_dlg_.Instance, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "trg_src", fld_trg_id, fld_src_id));}
|
||||
public void Rls() {}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xowd_pagelinks_temp_tbl implements Rls_able {
|
||||
private final String tbl_name = "pagelinks_temp"; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_src_id, fld_trg_ns, fld_trg_ttl;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Xowd_pagelinks_temp_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
flds.Add_int_pkey_autonum("uid");
|
||||
fld_src_id = flds.Add_int("src_id");
|
||||
fld_trg_ns = flds.Add_int("trg_ns");
|
||||
fld_trg_ttl = flds.Add_str("trg_ttl", 255);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Ddl_create_idx(Gfo_usr_dlg_.Instance, Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "main", fld_src_id, fld_trg_ns, fld_trg_ttl));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__pagelinks__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert(int src_id, int trg_ns, byte[] trg_ttl) {
|
||||
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
stmt_insert.Clear().Val_int(fld_src_id, src_id).Val_int(fld_trg_ns, trg_ns).Val_bry_as_str(fld_trg_ttl, trg_ttl).Exec_insert();
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.dbs.*; import gplx.dbs.utls.*;
|
||||
public class Xowd_search_link_tbl {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_word_id, fld_page_id;
|
||||
public final Db_conn conn; private Db_stmt stmt_insert; private final Xowd_search_page_tbl__in_wkr in_wkr = new Xowd_search_page_tbl__in_wkr();
|
||||
public Xowd_search_link_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
String fld_prefix = "";
|
||||
if (schema_is_1) {tbl_name = "search_title_page"; fld_prefix = "stp_";}
|
||||
else {tbl_name = "search_link";}
|
||||
fld_word_id = flds.Add_int(fld_prefix + "word_id");
|
||||
fld_page_id = flds.Add_int(fld_prefix + "page_id");
|
||||
in_wkr.Ctor(tbl_name, flds, fld_page_id, fld_word_id);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public String Fld_word_id() {return fld_word_id;}
|
||||
public String Fld_page_id() {return fld_page_id;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx_unique() {conn.Ddl_create_idx(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_word_id, fld_page_id));}
|
||||
public void Create_idx_normal() {conn.Ddl_create_idx(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "main", fld_word_id, fld_page_id));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__search_link__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int word_id, int page_id) {
|
||||
stmt_insert.Clear().Val_int(fld_word_id, word_id).Val_int(fld_page_id, page_id).Exec_insert();
|
||||
}
|
||||
public void Select_in(Cancelable cancelable, List_adp rv, List_adp words) {
|
||||
in_wkr.Init(words, rv);
|
||||
in_wkr.Select_in(cancelable, conn, 0, words.Count());
|
||||
}
|
||||
}
|
||||
class Xowd_search_page_tbl__in_wkr extends Db_in_wkr__base {
|
||||
private String tbl_name; private Dbmeta_fld_list flds; private String fld_page_id, fld_word_id;
|
||||
private List_adp words, pages;
|
||||
public void Ctor(String tbl_name, Dbmeta_fld_list flds, String fld_page_id, String fld_word_id) {
|
||||
this.tbl_name = tbl_name; this.flds = flds; this.fld_page_id = fld_page_id; this.fld_word_id = fld_word_id;
|
||||
}
|
||||
public void Init(List_adp words, List_adp pages) {this.words = words; this.pages = pages;}
|
||||
@Override protected Db_qry Make_qry(int bgn, int end) {
|
||||
Object[] part_ary = In_ary(end - bgn);
|
||||
return Db_qry_.select_cols_(tbl_name, Db_crt_.New_in(fld_word_id, part_ary), flds.To_str_ary());
|
||||
}
|
||||
@Override protected void Fill_stmt(Db_stmt stmt, int bgn, int end) {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
Int_obj_val word_id = (Int_obj_val)words.Get_at(i);
|
||||
stmt.Crt_int(fld_word_id, word_id.Val());
|
||||
}
|
||||
}
|
||||
@Override protected void Read_data(Cancelable cancelable, Db_rdr rdr) {
|
||||
while (rdr.Move_next()) {
|
||||
if (cancelable.Canceled()) return;
|
||||
int page_id = rdr.Read_int(fld_page_id);
|
||||
Xowd_page_itm page = new Xowd_page_itm().Id_(page_id);
|
||||
pages.Add(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.dbs.*; import gplx.dbs.engines.sqlite.*;
|
||||
public class Xowd_search_temp_tbl {
|
||||
private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_page_id, fld_word_text;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final String sql_create_word, sql_create_link;
|
||||
public Xowd_search_temp_tbl(Db_conn conn, boolean schema_is_1) {
|
||||
this.conn = conn;
|
||||
if (schema_is_1) {sql_create_word = Sql_create_word_v1; sql_create_link = Sql_create_link_v1;}
|
||||
else {sql_create_word = Sql_create_word_v2; sql_create_link = Sql_create_link_v2;}
|
||||
// flds.Add_int_dflt("word_id", -1);
|
||||
flds.Add_int_pkey_autonum("word_id");
|
||||
fld_page_id = flds.Add_int("page_id");
|
||||
fld_word_text = flds.Add_str("word_text", 255);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;} private final String tbl_name = "search_temp";
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__search_temp__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int page_id, byte[] word) {
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_page_id, page_id).Val_bry_as_str(fld_word_text, word)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Make_data(Gfo_usr_dlg usr_dlg, Xowd_search_link_tbl search_link_tbl, Xowd_search_word_tbl search_word_tbl) {
|
||||
conn.Ddl_create_idx(usr_dlg, Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_word_text, fld_page_id));
|
||||
conn.Exec_delete_all(search_word_tbl.Tbl_name());
|
||||
conn.Exec_sql_plog_txn("search_temp.create_word", sql_create_word);
|
||||
conn.Exec_delete_all(search_link_tbl.Tbl_name());
|
||||
conn.Exec_sql_plog_txn("search_temp.create_link", sql_create_link);
|
||||
Create_idx(usr_dlg, search_link_tbl, search_word_tbl);
|
||||
conn.Env_vacuum();
|
||||
}
|
||||
public void Create_idx(Gfo_usr_dlg usr_dlg, Xowd_search_link_tbl search_link_tbl, Xowd_search_word_tbl search_word_tbl) {
|
||||
conn.Ddl_delete_tbl(tbl_name);
|
||||
try {search_word_tbl.Create_idx();}
|
||||
catch (Exception e) {usr_dlg.Warn_many("", "", "bldr.search_word.unique_search_failed: err=~{0}", Err_.Message_gplx_full(e));}
|
||||
try {search_link_tbl.Create_idx_unique();}
|
||||
catch (Exception e) {
|
||||
usr_dlg.Warn_many("", "", "bldr.search_page.unique_search_failed: err=~{0}", Err_.Message_gplx_full(e));
|
||||
search_link_tbl.Create_idx_normal();;
|
||||
}
|
||||
}
|
||||
public void Update_word_id(Db_conn cur_conn, Io_url prv_url) {
|
||||
String sql = String_.Concat_lines_nl_skip_last
|
||||
( "REPLACE INTO search_temp (word_id, page_id, word_text)"
|
||||
, "SELECT Coalesce(prv.word_id, cur.word_id), cur.page_id, cur.word_text"
|
||||
, "FROM search_temp cur"
|
||||
, " LEFT JOIN <attach_db>search_word prv ON cur.word_text = prv.word_text"
|
||||
);
|
||||
Db_attach_cmd.new_(cur_conn, "prv_db", prv_url).Add_fmt("updating_word_ids", sql).Exec();
|
||||
Db_stmt update_stmt = cur_conn.Stmt_update(tbl_name, String_.Ary(fld_word_text), fld_page_id);
|
||||
Db_rdr rdr = cur_conn.Stmt_select(tbl_name, flds, String_.Ary(fld_page_id)).Crt_int(fld_page_id, -1).Exec_select__rls_auto();
|
||||
int nxt_page_id = 1000;
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
update_stmt.Crt_int(fld_page_id, ++nxt_page_id).Exec_update();
|
||||
}
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
private static final String Sql_create_word_v1 = String_.Concat_lines_nl
|
||||
( "INSERT INTO search_title_word (stw_word_id, stw_word)"
|
||||
, "SELECT word_id"
|
||||
, ", word_text"
|
||||
, "FROM search_temp"
|
||||
, "GROUP BY "
|
||||
, " word_text"
|
||||
, ";"
|
||||
);
|
||||
private static final String Sql_create_link_v1 = String_.Concat_lines_nl
|
||||
( "INSERT INTO search_title_page (stp_word_id, stp_page_id)"
|
||||
, "SELECT w.stw_word_id"
|
||||
, ", t.page_id"
|
||||
, "FROM search_temp t"
|
||||
, " JOIN search_title_word w ON t.word_text = w.stw_word"
|
||||
, ";"
|
||||
);
|
||||
private static final String Sql_create_word_v2 = String_.Concat_lines_nl
|
||||
( "INSERT INTO search_word (word_id, word_text, word_page_count)"
|
||||
, "SELECT word_id"
|
||||
, ", word_text"
|
||||
, ", Count(DISTINCT page_id)"
|
||||
, "FROM search_temp"
|
||||
, "GROUP BY "
|
||||
, " word_text"
|
||||
, ";"
|
||||
);
|
||||
private static final String Sql_create_link_v2 = String_.Concat_lines_nl
|
||||
( "INSERT INTO search_link (word_id, page_id)"
|
||||
, "SELECT w.word_id"
|
||||
, ", t.page_id"
|
||||
, "FROM search_temp t"
|
||||
, " JOIN search_word w ON t.word_text = w.word_text"
|
||||
, ";"
|
||||
);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
public class Xowd_search_word_row {
|
||||
public Xowd_search_word_row(int id, byte[] text, int page_count) {this.id = id; this.text = text; this.page_count = page_count;}
|
||||
public int Id() {return id;} private final int id;
|
||||
public byte[] Text() {return text;} private final byte[] text;
|
||||
public int Page_count() {return page_count;} private final int page_count;
|
||||
public static final Xowd_search_word_row Null = null;
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.data.tbls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.*; import gplx.dbs.cfgs.*; import gplx.dbs.qrys.*;
|
||||
public class Xowd_search_word_tbl implements Rls_able {
|
||||
private final String tbl_name; private final Dbmeta_fld_list flds = Dbmeta_fld_list.new_();
|
||||
private final String fld_id, fld_text; private String fld_page_count; private boolean page_count_exists;
|
||||
public final Db_conn conn; private Db_stmt stmt_insert, stmt_select_by, stmt_select_in;
|
||||
public Xowd_search_word_tbl(Db_conn conn, boolean schema_is_1, boolean page_count_exists) {
|
||||
this.conn = conn; this.page_count_exists = page_count_exists;
|
||||
String fld_prefix = "", fld_text_name = "word_text";
|
||||
if (schema_is_1) {tbl_name = "search_title_word"; fld_prefix = "stw_"; fld_text_name = "stw_word";}
|
||||
else {tbl_name = "search_word";}
|
||||
this.fld_id = flds.Add_int_pkey(fld_prefix + "word_id");
|
||||
this.fld_text = flds.Add_str(fld_text_name, 255);
|
||||
this.fld_page_count = page_count_exists ? flds.Add_int_dflt("word_page_count", 0) : Dbmeta_fld_itm.Key_null;
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public String Fld_id() {return fld_id;}
|
||||
public String Fld_text() {return fld_text;}
|
||||
public String Fld_page_count() {return fld_page_count;}
|
||||
public String Fld_page_score_max() {return Dbmeta_fld_itm.Key_null;}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Ddl_create_idx(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "main", fld_text, fld_id, fld_page_count));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__search_word__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int id, byte[] word, int page_count) {
|
||||
stmt_insert.Clear().Val_int(fld_id, id).Val_bry_as_str(fld_text, word).Val_int(fld_page_count, page_count).Exec_insert();
|
||||
}
|
||||
public Xowd_search_word_row Select_by_or_null(byte[] word) {
|
||||
if (stmt_select_by == null) stmt_select_by = conn.Stmt_select(tbl_name, flds, fld_text);
|
||||
Db_rdr rdr = stmt_select_by.Clear().Crt_bry_as_str(fld_text, word).Exec_select__rls_manual();
|
||||
try {
|
||||
return rdr.Move_next() ? new_row(rdr) : Xowd_search_word_row.Null;
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xowd_search_word_row new_row(Db_rdr rdr) {
|
||||
int page_count = fld_page_count == Dbmeta_fld_itm.Key_null ? 0 : rdr.Read_int(fld_page_count);
|
||||
return new Xowd_search_word_row(rdr.Read_int(fld_id), rdr.Read_bry_by_str(fld_text), page_count);
|
||||
}
|
||||
public Xowd_search_word_row[] Select_in(Cancelable cxl, byte[] word) {
|
||||
if (stmt_select_in == null) {
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_(tbl_name).Order_(fld_page_count, Bool_.N).Where_(Db_crt_.New_like(fld_text, "")); // order by highest page count to look at most common words
|
||||
stmt_select_in = conn.Stmt_new(qry);
|
||||
}
|
||||
List_adp list = List_adp_.new_();
|
||||
Db_rdr rdr = stmt_select_in.Clear().Crt_bry_as_str(fld_text, Bry_.Replace(word, Byte_ascii.Star, Byte_ascii.Percent)).Exec_select__rls_manual();
|
||||
try {
|
||||
int row_count = 0;
|
||||
while (rdr.Move_next()) {
|
||||
if (cxl.Canceled()) break;
|
||||
Xowd_search_word_row word_row = new_row(rdr);
|
||||
if (++row_count % 10 == 0)
|
||||
Xoa_app_.Usr_dlg().Prog_many("", "", "search; reading pages for word: word=~{0} pages=~{1}", word_row.Text(), word_row.Page_count());
|
||||
list.Add(word_row);
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
return (Xowd_search_word_row[])list.To_ary_and_clear(Xowd_search_word_row.class);
|
||||
}
|
||||
public void Select_by_word(Cancelable cancelable, Xowd_search_link_tbl search_page_tbl, List_adp rv, byte[] search, int results_max) {
|
||||
gplx.core.criterias.Criteria crt = null;
|
||||
if (Bry_.Has(search, Byte_ascii.Star)) {
|
||||
search = Bry_.Replace(search, Byte_ascii.Star, Byte_ascii.Percent);
|
||||
crt = Db_crt_.New_like (fld_text, String_.new_u8(search));
|
||||
}
|
||||
else
|
||||
crt = Db_crt_.New_eq (fld_text, String_.new_u8(search));
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().Cols_(fld_id).From_(tbl_name).Where_(crt);
|
||||
|
||||
List_adp words = List_adp_.new_();
|
||||
Db_rdr rdr = conn.Stmt_new(qry).Crt_bry_as_str(fld_text, search).Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next())
|
||||
words.Add(Int_obj_val.new_(rdr.Read_int(fld_id)));
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
|
||||
search_page_tbl.Select_in(cancelable, rv, words);
|
||||
}
|
||||
public boolean Ddl__page_count() {return page_count_exists;}
|
||||
public void Ddl__page_count_y_() { // needed for search_cmd;
|
||||
page_count_exists = true;
|
||||
if (!flds.Has("word_page_count"))
|
||||
flds.Add_int_dflt("word_page_count", 0);
|
||||
}
|
||||
public void Ddl__page_count__add(Xowd_search_link_tbl link_tbl, Db_cfg_tbl cfg_tbl) {
|
||||
Dbmeta_fld_itm page_count_fld = Dbmeta_fld_itm.new_int("word_page_count").Default_(0);
|
||||
conn.Txn_bgn("schema__search_word__upgrade");
|
||||
conn.Ddl_append_fld(tbl_name, page_count_fld); // SQL: ALTER TABLE search_word ADD word_page_count integer NOT NULL DEFAULT 0;
|
||||
String sql = String_.Format(String_.Concat_lines_nl_skip_last
|
||||
( "REPLACE INTO {0} ({1}, {2}, word_page_count)"
|
||||
, "SELECT w.{1}"
|
||||
, ", w.{2}"
|
||||
, ", Count(l.{4})"
|
||||
, "FROM {0} w"
|
||||
, " JOIN {3} l ON w.{1} = l.{4}"
|
||||
, "GROUP BY w.{1}"
|
||||
, ", w.{2};"
|
||||
), tbl_name, fld_id, fld_text
|
||||
, link_tbl.Tbl_name(), link_tbl.Fld_word_id()
|
||||
);
|
||||
conn.Exec_sql_plog_ntx("calculating page count per word (please wait)", sql);
|
||||
Ddl__page_count__cfg(cfg_tbl);
|
||||
fld_page_count = page_count_fld.Name(); flds.Add(page_count_fld); this.Rls();
|
||||
conn.Txn_end();
|
||||
}
|
||||
public void Ddl__page_count__cfg(Db_cfg_tbl cfg_tbl) {
|
||||
cfg_tbl.Insert_yn(Xowd_db_file_schema_props.Grp, Xowd_db_file_schema_props.Key__col_search_word_page_count, Bool_.Y);
|
||||
}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
stmt_select_by = Db_stmt_.Rls(stmt_select_by);
|
||||
stmt_select_in = Db_stmt_.Rls(stmt_select_in);
|
||||
}
|
||||
public static final int Id_null = -1;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class Xowd_site_ns_tbl {
|
||||
fld_is_alias = flds.Add_bool ("ns_is_alias");
|
||||
fld_count = flds.Add_int ("ns_count");
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert(Xow_ns_mgr ns_mgr) {
|
||||
Db_stmt stmt = conn.Stmt_insert(tbl_name, flds);
|
||||
int len = ns_mgr.Ids_len();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xowd_text_tbl implements Rls_able {
|
||||
fld_text_data = flds.Add_bry(fld_text_data_name);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__text__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(int page_id, byte[] text_data) {
|
||||
|
||||
@@ -31,8 +31,8 @@ public class Xowd_wbase_pid_tbl implements Rls_able {
|
||||
fld_trg_ttl = flds.Add_str(fld_prefix + "trg_ttl", 512);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Ddl_create_idx(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "src", fld_src_lang, fld_src_ttl));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Meta_idx_create(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "src", fld_src_lang, fld_src_ttl));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__wbase_pid__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(byte[] src_lang, byte[] src_ttl, byte[] trg_ttl) {
|
||||
|
||||
@@ -33,8 +33,8 @@ public class Xowd_wbase_qid_tbl implements Rls_able {
|
||||
fld_trg_ttl = flds.Add_str(fld_prefix + "trg_ttl", 512);
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Ddl_create_idx(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "src", fld_src_wiki, fld_src_ns, fld_src_ttl));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_idx() {conn.Meta_idx_create(Xoa_app_.Usr_dlg(), Dbmeta_idx_itm.new_normal_by_tbl(tbl_name, "src", fld_src_wiki, fld_src_ns, fld_src_ttl));}
|
||||
public void Insert_bgn() {conn.Txn_bgn("schema__wbase_qid__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
|
||||
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
|
||||
public void Insert_cmd_by_batch(byte[] src_wiki, int src_ns, byte[] src_ttl, byte[] trg_ttl) {
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Xowd_xowa_db_tbl {
|
||||
}
|
||||
stmt_bldr.Conn_(conn, tbl_name, flds, fld_id);
|
||||
}
|
||||
public void Create_tbl() {conn.Ddl_create_tbl(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public Xowd_db_file[] Select_all(Xowd_core_db_props props, Io_url wiki_root_dir) {
|
||||
List_adp list = List_adp_.new_();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds).Exec_select__rls_auto();
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.specials.search.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
public interface Xodb_load_mgr {
|
||||
void Load_init (Xowe_wiki wiki);
|
||||
void Load_page (Xowd_page_itm rv, Xow_ns ns, boolean timestamp_enabled);
|
||||
@@ -31,7 +31,6 @@ public interface Xodb_load_mgr {
|
||||
boolean Load_ctg_v2 (Xoctg_data_ctg rv, byte[] ttl);
|
||||
void Load_ctg_v2a (Xoctg_view_ctg rv, Xoctg_url url_ctg, byte[] ttl_bry, int limit);
|
||||
Xowd_page_itm[] Load_ctg_list (byte[][] ctg_ttls);
|
||||
void Load_search (Cancelable cancelable, List_adp rv, byte[] search, int results_max);
|
||||
void Load_ttls_for_all_pages (Cancelable cancelable, List_adp rslt_list, Xowd_page_itm rslt_nxt, Xowd_page_itm rslt_prv, Int_obj_ref rslt_count, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item);
|
||||
void Load_ttls_for_search_suggest(Cancelable cancelable, List_adp rslt_list, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item);
|
||||
byte[] Find_random_ttl (Xow_ns ns);
|
||||
|
||||
@@ -17,19 +17,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.specials.search.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.apps.gfs.*; import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.wikis.data.*;
|
||||
import gplx.xowa.addons.searchs.*;
|
||||
public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
public Xodb_load_mgr_sql(Xodb_mgr_sql db_mgr, Xowd_db_mgr fsys_mgr) {this.db_mgr = db_mgr; this.fsys_mgr = fsys_mgr;} private Xodb_mgr_sql db_mgr; Xowd_db_mgr fsys_mgr;
|
||||
public byte Search_version() {
|
||||
if (search_version_init_needed) Search_version_init();
|
||||
return search_version;
|
||||
} private byte search_version = gplx.xowa.specials.search.Xows_page__search.Version_null;
|
||||
public void Search_version_refresh() {
|
||||
search_version_init_needed = true;
|
||||
Search_version_init();
|
||||
}
|
||||
private Xodb_mgr_sql db_mgr; Xowd_db_mgr fsys_mgr;
|
||||
public Xodb_load_mgr_sql(Xow_wiki wiki, Xodb_mgr_sql db_mgr, Xowd_db_mgr fsys_mgr) {this.db_mgr = db_mgr; this.fsys_mgr = fsys_mgr;}
|
||||
public void Load_init(Xowe_wiki wiki) {
|
||||
Load_init_cfg(wiki);
|
||||
Xowd_db_file db_core = wiki.Data__core_mgr().Db__core();
|
||||
@@ -57,7 +51,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_in__ns_ttl(cancelable, rv, db_mgr.Wiki().Ns_mgr(), fill_idx_fields_only, bgn, end);
|
||||
}
|
||||
public void Load_page(Xowd_page_itm rv, Xow_ns ns, boolean timestamp_enabled) {
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_at(rv.Text_db_id()).Tbl__text();
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id(rv.Text_db_id()).Tbl__text();
|
||||
byte[] text_bry = text_tbl.Select(rv.Id());
|
||||
rv.Text_(text_bry);
|
||||
}
|
||||
@@ -81,7 +75,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
for (byte i = Xoa_ctg_mgr.Tid_subc; i < len; i++) {
|
||||
boolean arg_is_from = ctg_url.Grp_fwds()[i] == Bool_.N_byte;
|
||||
byte[] arg_sortkey = ctg_url.Grp_idxs()[i];
|
||||
Xowd_cat_link_tbl cat_link_tbl = db_mgr.Core_data_mgr().Dbs__get_at(cat_link_db_idx).Tbl__cat_link();
|
||||
Xowd_cat_link_tbl cat_link_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id(cat_link_db_idx).Tbl__cat_link();
|
||||
int found = cat_link_tbl.Select_by_type(list, cat_page_id, i, arg_sortkey, arg_is_from, load_max);
|
||||
if (found > 0 && found == load_max + 1) {
|
||||
Xowd_page_itm last_page = (Xowd_page_itm)List_adp_.Pop(list);
|
||||
@@ -118,24 +112,6 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
view_grp.Total_(ctg.Count_by_tid(i));
|
||||
}
|
||||
}
|
||||
private boolean search_version_init_needed = true;
|
||||
private void Search_version_init() {
|
||||
if (search_version_init_needed) {
|
||||
search_version_init_needed = false;
|
||||
Xowd_db_file search_db = db_mgr.Core_data_mgr().Db__search();
|
||||
search_version = search_db == Xowd_db_file.Null ? Xows_page__search.Version_1 : Xows_page__search.Version_2;
|
||||
}
|
||||
}
|
||||
public void Load_search(Cancelable cancelable, List_adp rv, byte[] search, int results_max) {
|
||||
if (search_version_init_needed) Search_version_init();
|
||||
if (search_version == gplx.xowa.specials.search.Xows_page__search.Version_1)
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_by_search(cancelable, rv, search, results_max);
|
||||
else {
|
||||
Xowd_db_mgr core_data_mgr = db_mgr.Core_data_mgr();
|
||||
core_data_mgr.Db__search().Tbl__search_word().Select_by_word(cancelable, core_data_mgr.Db__search().Tbl__search_link(), rv, search, results_max);
|
||||
core_data_mgr.Tbl__page().Select_in__id(cancelable, true, rv);
|
||||
}
|
||||
}
|
||||
public void Load_ttls_for_all_pages(Cancelable cancelable, List_adp rslt_list, Xowd_page_itm rslt_nxt, Xowd_page_itm rslt_prv, Int_obj_ref rslt_count, Xow_ns ns, byte[] key, int max_results, int min_page_len, int browse_len, boolean include_redirects, boolean fetch_prv_item) {
|
||||
db_mgr.Core_data_mgr().Tbl__page().Select_for_special_all_pages(cancelable, rslt_list, rslt_nxt, rslt_prv, rslt_count, ns, key, max_results, min_page_len, browse_len, include_redirects, fetch_prv_item);
|
||||
}
|
||||
@@ -178,7 +154,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
}
|
||||
private static boolean Ctg_select_v1(Xowe_wiki wiki, Xowd_db_mgr core_data_mgr, Xoctg_view_ctg view_ctg, int link_db_id, Xowd_category_itm ctg) {
|
||||
List_adp link_list = List_adp_.new_();
|
||||
core_data_mgr.Dbs__get_at(link_db_id).Tbl__cat_link().Select_in(link_list, ctg.Id());
|
||||
core_data_mgr.Dbs__get_by_id(link_db_id).Tbl__cat_link().Select_in(link_list, ctg.Id());
|
||||
int link_list_len = link_list.Count();
|
||||
link_list.Sort_by(Xowd_page_itm_sorter.IdAsc);
|
||||
core_data_mgr.Tbl__page().Select_in__id(Cancelable_.Never, false, link_list, 0, link_list_len);
|
||||
|
||||
@@ -96,7 +96,6 @@ class Xodb_load_mgr_sql_fxt {
|
||||
}
|
||||
return bfr.To_str_and_clear();
|
||||
}
|
||||
|
||||
public Xoctg_url_mok ctg_url_() {return new Xoctg_url_mok();}
|
||||
public Xodb_load_mgr_sql_fxt Init_limit_(int v) {limit = v; return this;} private int limit = 3;
|
||||
public void Test_select(Xoctg_url ctg_url, Xoctg_mok_ctg expd) {
|
||||
|
||||
@@ -17,10 +17,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.primitives.*; import gplx.core.brys.*; import gplx.core.flds.*; import gplx.core.envs.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.xowa.specials.search.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.bldrs.cmds.ctgs.*; import gplx.xowa.wikis.ctgs.*; import gplx.core.encoders.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*;
|
||||
import gplx.xowa.wikis.tdbs.*; import gplx.xowa.wikis.tdbs.hives.*; import gplx.xowa.wikis.tdbs.xdats.*;
|
||||
import gplx.xowa.addons.searchs.specials.*;
|
||||
import gplx.xowa.guis.views.*;
|
||||
public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
private final Xob_xdat_file tmp_xdat_file = new Xob_xdat_file(); private final Xob_xdat_itm tmp_xdat_itm = new Xob_xdat_itm();
|
||||
@@ -75,14 +76,14 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
public void Load_search(Cancelable cancelable, List_adp rv, byte[] search, int results_max) {
|
||||
Xow_ns ns = wiki.Ns_mgr().Ns_main();
|
||||
int search_len = search.length;
|
||||
byte match_tid = Xows_page__search.Match_tid_all;
|
||||
byte match_tid = Srch_special_page.Match_tid_all;
|
||||
if (search_len > 0 && search[search_len - 1] == Byte_ascii.Star) {
|
||||
search = Bry_.Mid(search, 0, search_len - 1);
|
||||
match_tid = Xows_page__search.Match_tid_bgn;
|
||||
match_tid = Srch_special_page.Match_tid_bgn;
|
||||
}
|
||||
int bgn_idx = this.Find_file_idx_by_ns(Xotdb_dir_info_.Tid_search_ttl, ns, search);
|
||||
if (bgn_idx == Xow_data_mgr.File_idx_unknown) return;
|
||||
if (match_tid == Xows_page__search.Match_tid_all) {
|
||||
if (match_tid == Srch_special_page.Match_tid_all) {
|
||||
if (!this.Load_xdat_file(cancelable, tmp_xdat_file, Xotdb_dir_info_.Tid_search_ttl, ns, bgn_idx)) return;
|
||||
tmp_xdat_file.Find(tmp_xdat_itm, search, 0, Byte_ascii.Pipe, true);
|
||||
if (tmp_xdat_itm.Missing()) return;
|
||||
|
||||
@@ -21,7 +21,6 @@ public interface Xodb_mgr extends GfoInvkAble {
|
||||
byte Tid();
|
||||
String Tid_name();
|
||||
byte Category_version();
|
||||
byte Search_version(); void Search_version_refresh();
|
||||
Xodb_load_mgr Load_mgr();
|
||||
Xodb_save_mgr Save_mgr();
|
||||
DateAdp Dump_date_query(); // used by maint_mgr
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
public Xodb_mgr_sql(Xowe_wiki wiki) {
|
||||
this.wiki = wiki;
|
||||
this.core_data_mgr = new Xowd_db_mgr(wiki, wiki.Fsys_mgr().Root_dir(), wiki.Domain_itm());
|
||||
this.load_mgr = new Xodb_load_mgr_sql(this, core_data_mgr);
|
||||
this.load_mgr = new Xodb_load_mgr_sql(wiki, this, core_data_mgr);
|
||||
this.save_mgr = new Xodb_save_mgr_sql(this);
|
||||
}
|
||||
public byte Tid() {return Tid_sql;} public String Tid_name() {return "sqlite3";} public static final byte Tid_sql = 1;
|
||||
@@ -32,7 +32,6 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
public Xodb_load_mgr Load_mgr() {return load_mgr;} private final Xodb_load_mgr_sql load_mgr;
|
||||
public Xodb_save_mgr Save_mgr() {return save_mgr;} private final Xodb_save_mgr_sql save_mgr;
|
||||
public byte Category_version() {return category_version;} private byte category_version = Xoa_ctg_mgr.Version_null;
|
||||
public byte Search_version() {return load_mgr.Search_version();} public void Search_version_refresh() {load_mgr.Search_version_refresh();}
|
||||
public DateAdp Dump_date_query() {
|
||||
DateAdp rv = wiki.Props().Modified_latest(); if (rv != null) return rv;
|
||||
Io_url url = core_data_mgr.Db__core().Url();
|
||||
@@ -50,7 +49,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
else if (ctx.Match(k, Invk_data_storage_format_)) {} // SERIALIZED:000.sqlite3|xowa_cfg; ignore; read from Xow_db_props
|
||||
else if (ctx.Match(k, Invk_category_version)) return category_version;
|
||||
else if (ctx.Match(k, Invk_category_version_)) category_version = m.ReadByte("v");
|
||||
else if (ctx.Match(k, Invk_search_version)) return this.Search_version();
|
||||
else if (ctx.Match(k, Invk_search_version)) {return 1;} // return this.Search_version(); // REMOVED: DATE:2016-02-26
|
||||
else if (ctx.Match(k, Invk_tid_name)) return this.Tid_name();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Xodb_mgr_txt implements Xodb_mgr {
|
||||
}
|
||||
return category_version;
|
||||
} byte category_version = Xoa_ctg_mgr.Version_null;
|
||||
public byte Search_version() {return gplx.xowa.specials.search.Xows_page__search.Version_2;}
|
||||
public byte Search_version() {return gplx.xowa.addons.searchs.specials.Srch_special_page.Version_2;}
|
||||
public void Search_version_refresh() {throw Err_.new_unimplemented();}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_data_storage_format)) return Io_stream_.Obsolete_to_str(data_storage_format);
|
||||
|
||||
@@ -24,12 +24,12 @@ class Xodb_page_rdr__sql implements Xodb_page_rdr {
|
||||
public Xodb_page_rdr__sql(Xowe_wiki wiki) {
|
||||
this.db_mgr = wiki.Data__core_mgr();
|
||||
this.page_tbl = db_mgr.Tbl__page();
|
||||
this.rdr = page_tbl.Select_all();
|
||||
this.rdr = page_tbl.Select_all__id__ttl();
|
||||
}
|
||||
public boolean Move_next() {return rdr.Move_next();}
|
||||
public boolean Read(Xowd_page_itm page) {
|
||||
page_tbl.Read_page__all(page, rdr);
|
||||
Xowd_text_tbl text_tbl = db_mgr.Dbs__get_at(page.Text_db_id()).Tbl__text();
|
||||
Xowd_text_tbl text_tbl = db_mgr.Dbs__get_by_id(page.Text_db_id()).Tbl__text();
|
||||
page.Text_(text_tbl.Select(page.Id()));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public interface Xodb_save_mgr {
|
||||
boolean Create_enabled(); void Create_enabled_(boolean v);
|
||||
boolean Update_modified_on_enabled(); void Update_modified_on_enabled_(boolean v);
|
||||
int Page_id_next(); void Page_id_next_(int v);
|
||||
void Data_create(Xoa_ttl ttl, byte[] text);
|
||||
int Data_create(Xoa_ttl ttl, byte[] text);
|
||||
void Data_update(Xoae_page page, byte[] text);
|
||||
void Data_rename(Xoae_page page, int trg_ns, byte[] trg_ttl);
|
||||
void Clear();
|
||||
|
||||
@@ -19,19 +19,18 @@ package gplx.xowa.wikis.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa
|
||||
import gplx.core.ios.*; import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.dbs.qrys.*;
|
||||
import gplx.xowa.wikis.*;
|
||||
public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
private final Xodb_mgr_sql db_mgr;
|
||||
private final Xodb_mgr_sql db_mgr;
|
||||
public Xodb_save_mgr_sql(Xodb_mgr_sql db_mgr) {this.db_mgr = db_mgr;}
|
||||
public boolean Create_enabled() {return create_enabled;} public void Create_enabled_(boolean v) {create_enabled = v;} private boolean create_enabled;
|
||||
public boolean Update_modified_on_enabled() {return update_modified_on_enabled;} public void Update_modified_on_enabled_(boolean v) {update_modified_on_enabled = v;} private boolean update_modified_on_enabled;
|
||||
public int Page_id_next() {return page_id_next;} public void Page_id_next_(int v) {page_id_next = v;} private int page_id_next;
|
||||
public void Data_create(Xoa_ttl ttl, byte[] text_raw) {
|
||||
public int Data_create(Xoa_ttl ttl, byte[] text_raw) {
|
||||
int ns_id = ttl.Ns().Id();
|
||||
Xowd_db_file db_file = db_mgr.Core_data_mgr().Db__core();
|
||||
int ns_count = db_file.Tbl__ns().Select_ns_count(ns_id) + 1;
|
||||
int page_id = db_file.Tbl__cfg().Select_int_or("db", "page.id_next", -1);
|
||||
if (page_id == -1) { // HACK: changed for tests; was dbs.qrys.Db_qry_sql.rdr_("SELECT (Max(page_id) + 1) AS max_page_id FROM page;")
|
||||
// Db_rdr rdr = db_mgr.Core_data_mgr().Tbl__page().Conn().Stmt_new(Db_qry_sql.rdr_("SELECT (Max(page_id) + 1) AS max_page_id FROM page;")).Exec_select__rls_manual();
|
||||
Db_rdr rdr = db_mgr.Core_data_mgr().Tbl__page().Conn().Stmt_select(db_file.Tbl__page().Tbl_name(), String_.Ary(db_file.Tbl__page().Fld_page_id()), Dbmeta_fld_itm.Str_ary_empty).Exec_select__rls_auto();
|
||||
Db_rdr rdr = db_mgr.Core_data_mgr().Tbl__page().conn.Stmt_select(db_file.Tbl__page().Tbl_name(), String_.Ary(db_file.Tbl__page().Fld_page_id()), Dbmeta_fld_itm.Str_ary_empty).Exec_select__rls_auto();
|
||||
try {
|
||||
int max_page_id = -1;
|
||||
while (rdr.Move_next()) {
|
||||
@@ -42,7 +41,6 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
db_mgr.Core_data_mgr().Tbl__cfg().Upsert_int("db", "page.id_next", page_id + 1);
|
||||
} finally {rdr.Rls();}
|
||||
}
|
||||
|
||||
Xowd_db_mgr fsys_mgr = db_mgr.Core_data_mgr();
|
||||
Xowd_db_file page_text_db = fsys_mgr.Db__text();
|
||||
Xowd_text_tbl page_text_tbl = page_text_db.Tbl__text();
|
||||
@@ -59,6 +57,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
page_core_tbl.Insert_end();
|
||||
page_text_tbl.Insert_end();
|
||||
}
|
||||
return page_id;
|
||||
}
|
||||
public void Data_update(Xoae_page page, byte[] text_raw) {
|
||||
boolean redirect = db_mgr.Wiki().Redirect_mgr().Is_redirect(text_raw, text_raw.length);
|
||||
@@ -67,7 +66,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
db_mgr.Core_data_mgr().Tbl__page().Update__redirect__modified(page_id, redirect, modified);
|
||||
Xowd_page_itm db_page = new Xowd_page_itm();
|
||||
db_mgr.Load_mgr().Load_by_id(db_page, page.Revision_data().Id());
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_at(db_page.Text_db_id()).Tbl__text();
|
||||
Xowd_text_tbl text_tbl = db_mgr.Core_data_mgr().Dbs__get_by_id(db_page.Text_db_id()).Tbl__text();
|
||||
text_tbl.Update(page.Revision_data().Id(), text_raw);
|
||||
// int html_db_id = db_page.Html_db_id();
|
||||
// if (html_db_id != -1)
|
||||
|
||||
@@ -31,7 +31,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
public boolean Update_modified_on_enabled() {return update_modified_on_enabled;} public void Update_modified_on_enabled_(boolean v) {update_modified_on_enabled = v;} private boolean update_modified_on_enabled;
|
||||
public int Page_id_next() {return page_id_next;} public void Page_id_next_(int v) {page_id_next = v;} private int page_id_next = 0;
|
||||
public void Clear() {page_id_next = 0;} // TEST: needed for ctg_test
|
||||
public void Data_create(Xoa_ttl ttl, byte[] text) {
|
||||
public int Data_create(Xoa_ttl ttl, byte[] text) {
|
||||
Xow_ns ns_itm = ttl.Ns(); byte[] ttl_bry = ttl.Page_db();
|
||||
Xowd_page_itm db_page = Xowd_page_itm.new_tmp();
|
||||
boolean found = load_mgr.Load_by_ttl(db_page, ns_itm, ttl_bry);
|
||||
@@ -59,6 +59,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
Xowd_hive_mgr ttl_hive = new Xowd_hive_mgr(wiki, Xotdb_dir_info_.Tid_ttl);
|
||||
ttl_hive.Create(ttl.Ns(), ttl.Page_db(), ttl_row_bry, Bry_comparer_fld_last.Instance);
|
||||
wiki.Db_mgr().Load_mgr().Clear(); // NOTE: need to clear cached regy_ary in load_mgr
|
||||
return page_id;
|
||||
}
|
||||
public void Data_update(Xoae_page page, byte[] text) {Data_update_under(page, text, null);}
|
||||
public void Data_rename(Xoae_page page, int trg_ns, byte[] trg_ttl) {
|
||||
@@ -118,5 +119,5 @@ class Bry_comparer_fld_last implements gplx.core.lists.ComparerAble {
|
||||
int rhs_bgn = Bry_find_.Find_bwd(rhs, Byte_ascii.Pipe); if (rhs_bgn == Bry_find_.Not_found) rhs_bgn = -1;
|
||||
return Bry_.Compare(lhs, lhs_bgn + 1, lhs.length, rhs, rhs_bgn + 1, rhs.length);
|
||||
}
|
||||
public static final Bry_comparer_fld_last Instance = new Bry_comparer_fld_last();
|
||||
public static final Bry_comparer_fld_last Instance = new Bry_comparer_fld_last();
|
||||
}
|
||||
|
||||
@@ -30,16 +30,16 @@ class Xodb_upgrade_mgr {
|
||||
}
|
||||
}
|
||||
// class Xodb_upgrade_mgr_v0_6_2_0 {
|
||||
// public static void Upgrade(Xodb_mgr_sql db_mgr, KeyVal[] kv_ary) {
|
||||
// public static void Upgrade(Xodb_mgr_sql db_mgr, Keyval[] kv_ary) {
|
||||
// Db_conn p = db_mgr.Fsys_mgr().Core_provider();
|
||||
// Fix_storage_format(p, db_mgr, kv_ary);
|
||||
// Fix_category_version(p, db_mgr);
|
||||
// }
|
||||
// private static void Fix_storage_format(Db_conn p, Xodb_mgr_sql db_mgr, KeyVal[] kv_ary) { // storage_format saved incorrectly as int
|
||||
// private static void Fix_storage_format(Db_conn p, Xodb_mgr_sql db_mgr, Keyval[] kv_ary) { // storage_format saved incorrectly as int
|
||||
// int len = kv_ary.length;
|
||||
// String gfs_data_storage_format = Xoa_gfs_mgr.Build_code(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format);
|
||||
// for (int i = 0; i < len; i++) {
|
||||
// KeyVal kv = kv_ary[i];
|
||||
// Keyval kv = kv_ary[i];
|
||||
// String kv_key = kv.Key();
|
||||
// if (String_.Eq(kv_key, gfs_data_storage_format)) {
|
||||
// byte data_storage_format_byte = Byte_.parse(kv.Val_to_str_or_empty());
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Xow_domain_itm {
|
||||
public int Domain_type_id() {return domain_type.Tid();}
|
||||
public byte[] Abrv_wm() {return abrv_wm;} private final byte[] abrv_wm; // EX: enwiki
|
||||
public byte[] Abrv_xo() {return abrv_xo;} private final byte[] abrv_xo; // EX: en.w
|
||||
public Xol_lang_stub Lang_actl_itm() {return lang_actl_itm;} private final Xol_lang_stub lang_actl_itm; // EX: zh
|
||||
public Xol_lang_stub Lang_actl_itm() {return lang_actl_itm;} private final Xol_lang_stub lang_actl_itm; // EX: zh
|
||||
public int Lang_actl_uid() {return lang_actl_itm.Id();}
|
||||
public byte[] Lang_actl_key() {return lang_actl_itm.Key();}
|
||||
public byte[] Lang_orig_key() {return lang_orig_key;} private final byte[] lang_orig_key; // EX: lzh
|
||||
|
||||
@@ -19,6 +19,7 @@ package gplx.xowa.wikis.domains; import gplx.*; import gplx.xowa.*; import gplx.
|
||||
import gplx.core.primitives.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xow_domain_itm_ {
|
||||
public static final Xow_domain_itm[] Ary_empty = new Xow_domain_itm[0];
|
||||
public static Xow_domain_itm parse(byte[] raw) {
|
||||
/*
|
||||
~{type}.org EX: wikimediafoundation
|
||||
|
||||
@@ -843,6 +843,7 @@ public class Xow_domain_regy {
|
||||
, "gom.wikipedia.org"
|
||||
, "lrc.wikipedia.org"
|
||||
, "azb.wikipedia.org"
|
||||
, "ady.wikipedia.org"
|
||||
};
|
||||
//, "als.wikisource.org"
|
||||
//, "als.wikinews.org"
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Xow_wiki_props implements GfoInvkAble {
|
||||
if (app.Bldr__running()) return; // never load main_page during bldr; note that Init_by_load is called by bldr cmds like css; DATE:2015-07-24
|
||||
this.main_page = cfg_tbl.Select_bry_or(Xow_cfg_consts.Grp__wiki_init, Xow_cfg_consts.Key__init__main_page, null);
|
||||
if (main_page == null) { // main_page not found
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "mw_props.load; main_page not found; conn=~{0}", cfg_tbl.Conn().Conn_info().Xto_api());
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "mw_props.load; main_page not found; conn=~{0}", cfg_tbl.Conn().Conn_info().Db_api());
|
||||
this.main_page = Xoa_page_.Main_page_bry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012 gnosygnu@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.wikis.metas; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
public class Xow_wiki_stats implements GfoInvkAble {
|
||||
public Xow_wiki_stats(Xowe_wiki wiki) {this.wiki = wiki;} private Xowe_wiki wiki;
|
||||
public int NumPages() {return num_pages;} public Xow_wiki_stats NumPages_(int v) {num_pages = v; return this;} private int num_pages; // in entire wiki: 28,433,596
|
||||
public int NumArticles() {return num_articles;} public Xow_wiki_stats NumArticles_(int v) {num_articles = v; return this;} private int num_articles; // in main ns: 4,074,996
|
||||
public int NumFiles() {return num_files;} public Xow_wiki_stats NumFiles_(int v) {num_files = v; return this;} private int num_files;
|
||||
public int NumEdits() {return num_edits;} public Xow_wiki_stats NumEdits_(int v) {num_edits = v; return this;} private int num_edits;
|
||||
public int NumViews() {return num_views;} public Xow_wiki_stats NumViews_(int v) {num_views = v; return this;} private int num_views;
|
||||
public int NumUsers() {return num_users;} public Xow_wiki_stats NumUsers_(int v) {num_users = v; return this;} private int num_users;
|
||||
public int NumUsersActive() {return num_users_active;} public Xow_wiki_stats NumUsersActive_(int v) {num_users_active = v; return this;} private int num_users_active;
|
||||
public int NumAdmins() {return num_admins;} public Xow_wiki_stats NumAdmins_(int v) {num_admins = v; return this;} private int num_admins;
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_number_of_pages_)) num_pages = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_articles_)) num_articles = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_files_)) num_files = m.ReadInt("v");
|
||||
else if (ctx.Match(k, Invk_number_of_articles_in_ns_)) return Number_of_articles_in_ns_(m);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
return this;
|
||||
} public static final String Invk_number_of_pages_ = "number_of_pages_", Invk_number_of_articles_ = "number_of_articles_", Invk_number_of_files_ = "number_of_files_", Invk_number_of_articles_in_ns_ = "number_of_articles_in_ns_";
|
||||
Object Number_of_articles_in_ns_(GfoMsg m) {
|
||||
int ns_id = m.ReadInt("ns_id");
|
||||
int count = m.ReadInt("count");
|
||||
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
|
||||
if (ns != null) ns.Count_(count);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class Xow_module_mgr implements GfoInvkAble {
|
||||
public Xow_module_base Itm__top_icon() {return itm__top_icon;} private Xow_module_base itm__top_icon = new Xow_module_base();
|
||||
public Xow_module_base Itm__navframe() {return itm__navframe;} private Xow_module_base itm__navframe = new Xow_module_base();
|
||||
public Xow_module_base Itm__title_rewrite() {return itm__title_rewrite;} private Xow_module_base itm__title_rewrite = new Xow_module_base();
|
||||
public Xow_popup_mgr Popup_mgr() {return popup_mgr;} private Xow_popup_mgr popup_mgr;
|
||||
public Xow_popup_mgr Popup_mgr() {return popup_mgr;} private Xow_popup_mgr popup_mgr;
|
||||
public Xow_module_base Get(byte[] key) {return (Xow_module_base)regy.Get_by_bry(key);}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_get)) return Get(m.ReadBry("v"));
|
||||
|
||||
@@ -83,13 +83,13 @@ public class Xow_ns implements GfoInvkAble {
|
||||
if (aliases == null) aliases = Ordered_hash_.New();
|
||||
aliases.Add_if_dupe_use_1st(alias, alias);
|
||||
} private Ordered_hash aliases;
|
||||
public KeyVal[] Aliases_as_scrib_ary() { // NOTE: intended for Scrib_lib_site; DATE:2014-02-15
|
||||
if (aliases == null) return KeyVal_.Ary_empty;
|
||||
public Keyval[] Aliases_as_scrib_ary() { // NOTE: intended for Scrib_lib_site; DATE:2014-02-15
|
||||
if (aliases == null) return Keyval_.Ary_empty;
|
||||
int len = aliases.Count();
|
||||
KeyVal[] rv = new KeyVal[len];
|
||||
Keyval[] rv = new Keyval[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
String alias = (String)aliases.Get_at(i);
|
||||
rv[i] = KeyVal_.int_(i + List_adp_.Base1, alias);
|
||||
rv[i] = Keyval_.int_(i + List_adp_.Base1, alias);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
}
|
||||
public void Aliases_clear() {aliases.Clear();}
|
||||
public Xow_ns_mgr Aliases_add(int ns_id, String name) {
|
||||
KeyVal kv = KeyVal_.new_(name, Int_obj_val.new_(ns_id));
|
||||
Keyval kv = Keyval_.new_(name, Int_obj_val.new_(ns_id));
|
||||
aliases.Add_if_dupe_use_nth(name, kv);
|
||||
return this;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class Xow_ns_mgr implements GfoInvkAble, gplx.core.lists.ComparerAble {
|
||||
}
|
||||
int aliases_len = aliases.Count();
|
||||
for (int i = 0; i < aliases_len; i++) {
|
||||
KeyVal kv = (KeyVal)aliases.Get_at(i);
|
||||
Keyval kv = (Keyval)aliases.Get_at(i);
|
||||
int ns_id = ((Int_obj_val)kv.Val()).Val();
|
||||
Xow_ns ns = Ids_get_or_null(ns_id); if (ns == null) continue; // happens when alias exists, but not ns; EX: test has Image alias, but not File alias; should not happen "live" but don't want to fail
|
||||
ns.Aliases_add(kv.Key()); // register alias with official ns; EX: "Image" will be placed in "File"'s .Aliases
|
||||
|
||||
@@ -31,7 +31,6 @@ public class Xotdb_dir_info {
|
||||
ext_str = String_.new_a7(ext_bry);
|
||||
return this;
|
||||
} byte ext_tid = gplx.core.ios.Io_stream_.Tid_raw;
|
||||
|
||||
public static final String Wtr_xdat_str = ".xdat", Wtr_zip_str = ".zip", Wtr_gz_str = ".gz", Wtr_bz2_str = ".bz2";
|
||||
public static final byte[] Wtr_xdat_bry = Bry_.new_a7(Wtr_xdat_str), Wtr_zip_bry = Bry_.new_a7(Wtr_zip_str), Wtr_gz_bry = Bry_.new_a7(Wtr_gz_str), Wtr_bz2_bry = Bry_.new_a7(Wtr_bz2_str);
|
||||
public static String Wtr_dir(byte v) {
|
||||
|
||||
@@ -85,9 +85,9 @@ public class Xotdb_fsys_mgr {
|
||||
return url;
|
||||
}
|
||||
public static Io_url Find_file_or_null(Io_url dir, String file_name, String file_ext_0, String file_ext_1) {
|
||||
Io_url url = Xobd_rdr.Find_fil_by(dir, file_name + file_ext_0);
|
||||
Io_url url = Xob_page_wkr_cmd.Find_fil_by(dir, file_name + file_ext_0);
|
||||
if (url == null) {
|
||||
url = Xobd_rdr.Find_fil_by(dir, file_name + file_ext_1);
|
||||
url = Xob_page_wkr_cmd.Find_fil_by(dir, file_name + file_ext_1);
|
||||
if (url == null) return null;
|
||||
}
|
||||
return url;
|
||||
|
||||
@@ -27,8 +27,8 @@ public class Xotdb_fsys_mgr_tst {
|
||||
}
|
||||
class Xow_fsys_mgr_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
}
|
||||
Xoae_app app; Xowe_wiki wiki;
|
||||
public Xow_fsys_mgr_fxt Zip_(byte tid, boolean v) {wiki.Tdb_fsys_mgr().Tdb_dir_regy()[tid].Ext_tid_(v ? gplx.core.ios.Io_stream_.Tid_zip : gplx.core.ios.Io_stream_.Tid_raw); return this;}
|
||||
|
||||
@@ -21,8 +21,8 @@ import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xo
|
||||
public class Xow_hive_mgr_fxt {
|
||||
public void Clear() {
|
||||
if (hive_mgr == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
hive_mgr = new Xob_hive_mgr(wiki);
|
||||
}
|
||||
hive_mgr.Clear();
|
||||
|
||||
@@ -65,8 +65,8 @@ public class Xowd_hive_mgr_tst {
|
||||
class Xowd_hive_mgr_fxt {
|
||||
Xoae_app app; Xowe_wiki wiki; Xowd_hive_mgr mgr;
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
mgr = new Xowd_hive_mgr(wiki, Xotdb_dir_info_.Tid_page);
|
||||
}
|
||||
public Xowd_hive_mgr_fxt Tst_reg(String expd) {
|
||||
|
||||
@@ -63,8 +63,8 @@ class Xof_file_regy_fxt {
|
||||
byte[] md5_(byte[] name) {return Xof_file_wkr_.Md5(name);}
|
||||
public void Ini() {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
Xoae_app app = Xoa_app_fxt.app_();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
Xoae_app app = Xoa_app_fxt.Make__app__edit();
|
||||
Xowe_wiki wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
regy_mgr = new Xof_meta_mgr(wiki);
|
||||
regy_mgr.Clear();
|
||||
regy_mgr.Depth_(2);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Xow_ttl__xwik_tst {
|
||||
fxt.Init_ttl(":fr:Test").Expd_xwik_txt("fr").Expd_page_txt("Test").Expd_force_literal_link(1).Test();
|
||||
fxt.Init_ttl(":::fr:Test").Expd_xwik_txt("").Expd_page_txt(":fr:Test").Expd_force_literal_link(1).Test();
|
||||
}
|
||||
@Test public void Ns_should_precede_xwiki() {// PURPOSE: the "Wikipedia" in "Wikipedia:Main page" should be interpreted as namespace, not an alias
|
||||
@Test public void Ns_should_precede_xwiki() {// PURPOSE: the "Wikipedia" in "Wikipedia:Main page" should be interpreted as Srch_rslt_cbk, not an alias
|
||||
fxt.Wiki().Xwiki_mgr().Add_by_atrs(Bry_.new_a7("Wikipedia"), Bry_.new_a7("en.wikipedia.org"));
|
||||
fxt.Init_ttl("Wikipedia:Test").Expd_xwik_txt("").Expd_full_txt("Wikipedia:Test").Test();
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.wikis.ttls; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
|
||||
import gplx.core.log_msgs.*;
|
||||
class Xow_ttl_fxt {
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
private final Xop_fxt fxt = new Xop_fxt();
|
||||
public Xow_ttl_fxt Init_ttl(String raw) {test_raw = raw; return this;} private String test_raw = "";
|
||||
public Xow_ttl_fxt Expd_ns_id(int v) {expd_ns_id = v; return this;} private int expd_ns_id = Int_.Min_value;
|
||||
public Xow_ttl_fxt Expd_page_txt(String v) {expd_page_txt = v; return this;} private String expd_page_txt;
|
||||
@@ -64,7 +64,7 @@ class Xow_ttl_fxt {
|
||||
if (expd_page_txt != null) Tfds.Eq(expd_page_txt, String_.new_u8(actl.Page_txt()), "Page_txt");
|
||||
if (expd_page_url != null) Tfds.Eq(expd_page_url, String_.new_u8(actl.Page_url()), "Page_url");
|
||||
if (expd_page_db != null) Tfds.Eq(expd_page_db , String_.new_u8(actl.Page_db()) , "Page_db");
|
||||
if (expd_full_txt != null) Tfds.Eq(expd_full_txt, String_.new_u8(actl.Full_txt()), "Full_txt");
|
||||
if (expd_full_txt != null) Tfds.Eq(expd_full_txt, String_.new_u8(actl.Full_txt_w_ttl_case()), "Full_txt");
|
||||
if (expd_full_url != null) Tfds.Eq(expd_full_url, String_.new_u8(actl.Full_url()), "Full_url");
|
||||
if (expd_leaf_txt != null) Tfds.Eq(expd_leaf_txt, String_.new_u8(actl.Leaf_txt()), "Leaf_txt");
|
||||
if (expd_leaf_url != null) Tfds.Eq(expd_leaf_url, String_.new_u8(actl.Leaf_url()), "Leaf_url");
|
||||
|
||||
@@ -19,7 +19,7 @@ package gplx.xowa.wikis.xwikis; import gplx.*; import gplx.xowa.*; import gplx.x
|
||||
import gplx.core.net.*; import gplx.core.brys.fmtrs.*;
|
||||
import gplx.xowa.langs.*; import gplx.xowa.wikis.domains.*;
|
||||
public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
private final boolean show_in_sitelangs_base;
|
||||
private final boolean show_in_sitelangs_base;
|
||||
public Xow_xwiki_itm(byte[] key_bry, byte[] url_fmt, int lang_id, int domain_tid, byte[] domain_bry, byte[] domain_name, byte[] abrv_wm) {
|
||||
this.key_bry = key_bry; this.key_str = String_.new_u8(key_bry);
|
||||
this.url_fmt = url_fmt; this.lang_id = lang_id;
|
||||
@@ -27,15 +27,15 @@ public class Xow_xwiki_itm implements gplx.CompareAble {
|
||||
this.domain_tid = domain_tid; this.domain_bry = domain_bry; this.domain_name = domain_name; this.abrv_wm = abrv_wm;
|
||||
this.show_in_sitelangs_base = Calc_show_in_sitelangs(key_bry, url_fmt, lang_id, domain_tid, domain_bry);
|
||||
}
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: commons
|
||||
public String Key_str() {return key_str;} private final String key_str;
|
||||
public byte[] Url_fmt() {return url_fmt;} private final byte[] url_fmt; // EX: //commons.wikimedia.org/wiki/Category:$1
|
||||
public Bry_fmtr Url_fmtr(){return url_fmtr;} private final Bry_fmtr url_fmtr;
|
||||
public int Lang_id() {return lang_id;} private final int lang_id; // EX: Id__unknown
|
||||
public int Domain_tid() {return domain_tid;} private final int domain_tid; // EX: Tid_int_commons
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry; // EX: commons.wikimedia.org
|
||||
public byte[] Domain_name() {return domain_name;} private final byte[] domain_name; // EX: Wikimedia Commons
|
||||
public byte[] Abrv_wm() {return abrv_wm;} private final byte[] abrv_wm; // EX: enwiki; needed for sitelinks
|
||||
public byte[] Key_bry() {return key_bry;} private final byte[] key_bry; // EX: commons
|
||||
public String Key_str() {return key_str;} private final String key_str;
|
||||
public byte[] Url_fmt() {return url_fmt;} private final byte[] url_fmt; // EX: //commons.wikimedia.org/wiki/Category:$1
|
||||
public Bry_fmtr Url_fmtr(){return url_fmtr;} private final Bry_fmtr url_fmtr;
|
||||
public int Lang_id() {return lang_id;} private final int lang_id; // EX: Id__unknown
|
||||
public int Domain_tid() {return domain_tid;} private final int domain_tid; // EX: Tid_int_commons
|
||||
public byte[] Domain_bry() {return domain_bry;} private final byte[] domain_bry; // EX: commons.wikimedia.org
|
||||
public byte[] Domain_name() {return domain_name;} private final byte[] domain_name; // EX: Wikimedia Commons
|
||||
public byte[] Abrv_wm() {return abrv_wm;} private final byte[] abrv_wm; // EX: enwiki; needed for sitelinks
|
||||
public boolean Offline() {return offline;} public Xow_xwiki_itm Offline_(boolean v) {offline = v; return this;} private boolean offline;
|
||||
public int compareTo(Object obj) {Xow_xwiki_itm comp = (Xow_xwiki_itm)obj; return Bry_.Compare(key_bry, comp.key_bry);}
|
||||
public boolean Show_in_sitelangs(byte[] cur_lang_key) {
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Xow_xwiki_mgr {
|
||||
}
|
||||
public void Add_itm(Xow_xwiki_itm itm) {
|
||||
byte[] key_bry = itm.Key_bry();
|
||||
if (wiki.Ns_mgr().Names_get_or_null(key_bry) != null) return;// NOTE: do not add xwiki if key matches namespace; EX: en.wiktionary.org has ns of "Wiktionary"; do not add key of "wiktionary"; note that wikipedia does have an key to wiktionary
|
||||
if (wiki.Ns_mgr().Names_get_or_null(key_bry) != null) return;// NOTE: do not add xwiki if key matches Srch_rslt_cbk; EX: en.wiktionary.org has ns of "Wiktionary"; do not add key of "wiktionary"; note that wikipedia does have an key to wiktionary
|
||||
list.Add_if_dupe_use_nth(key_bry, itm); // NOTE: some wikis like commons will be added multiple times under different aliases (commons, c, commons.wikimedia.org); need to check domain and add only once DATE:2014-11-07
|
||||
hash.Add_if_dupe_use_nth(key_bry, itm);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.xwikis.bldrs.*;
|
||||
public class Xow_xwiki_itm_parser extends Dsv_wkr_base {
|
||||
private Xow_domain_itm owner_domain_itm;
|
||||
private int cur_tid = -1; private byte[] cur_fld1, cur_fld2, cur_fld3;
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser(); private final Gfo_url url = new Gfo_url();
|
||||
public Ordered_hash Xwiki_list() {return xwiki_list;} private final Ordered_hash xwiki_list = Ordered_hash_.New();
|
||||
private final Gfo_url_parser url_parser = new Gfo_url_parser(); private final Gfo_url url = new Gfo_url();
|
||||
public Ordered_hash Xwiki_list() {return xwiki_list;} private final Ordered_hash xwiki_list = Ordered_hash_.New();
|
||||
@Override public Dsv_fld_parser[] Fld_parsers() {return new Dsv_fld_parser[] {Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser, Dsv_fld_parser_.Bry_parser};}
|
||||
@Override public boolean Write_bry(Dsv_tbl_parser parser, int fld_idx, byte[] src, int bgn, int end) {
|
||||
switch (fld_idx) {
|
||||
@@ -52,10 +52,10 @@ public class Xow_xwiki_itm_parser extends Dsv_wkr_base {
|
||||
domain_bry = cur_fld2;
|
||||
break;
|
||||
case Tid__wm_peer: // EX: "2|wikt|wikipedia"
|
||||
domain_bry = Bry_.Add(owner_domain_itm.Lang_actl_key(), Byte_ascii.Dot_bry, cur_fld2, gplx.xowa.apps.urls.Xoa_url_parser.Bry_dot_org);
|
||||
domain_bry = Bry_.Add(owner_domain_itm.Lang_actl_key(), Byte_ascii.Dot_bry, cur_fld2, gplx.xowa.apps.urls.Xow_url_parser.Bry_dot_org);
|
||||
break;
|
||||
case Tid__wm_lang: // EX: "3|en;english|en|English"
|
||||
domain_bry = Bry_.Add(cur_fld2, Byte_ascii.Dot_bry, owner_domain_itm.Domain_type().Key_bry(), gplx.xowa.apps.urls.Xoa_url_parser.Bry_dot_org);
|
||||
domain_bry = Bry_.Add(cur_fld2, Byte_ascii.Dot_bry, owner_domain_itm.Domain_type().Key_bry(), gplx.xowa.apps.urls.Xow_url_parser.Bry_dot_org);
|
||||
break;
|
||||
default: throw Err_.new_unhandled(cur_tid);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class Xow_xwiki_mgr_tst {
|
||||
, "https://en.wiktionary.org/wiki/~{0}")
|
||||
, fxt.xwiki_("s", "en.wikisource.org", "https://en.wikisource.org/wiki/~{0}"));
|
||||
}
|
||||
@Test public void Add_bulk_peers_skip_self() { // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is namespace; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
@Test public void Add_bulk_peers_skip_self() { // PURPOSE: skip "wikipedia" as alias since "Wikipedia" is Srch_rslt_cbk; needed for titles of "Wikipedia:Main page" (which would otherwise try to go to page "Main Page" in the main names of xwiki "Wikipedia"
|
||||
fxt.Init_peers();
|
||||
fxt.Test_add_bulk_peers
|
||||
( fxt.xwiki_null_("wikipedia")
|
||||
@@ -66,8 +66,8 @@ class Xow_xwiki_mgr_fxt {
|
||||
Xow_xwiki_mgr xwiki_mgr; Xoa_lang_mgr lang_mgr; String_bldr sb = String_bldr_.new_(); Xoae_app app; Xowe_wiki wiki;
|
||||
public void Clear() {
|
||||
if (xwiki_mgr == null) {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
xwiki_mgr = wiki.Xwiki_mgr();
|
||||
lang_mgr = app.Lang_mgr();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ public class Xoa_sitelink_div_wtr {
|
||||
private final Xoa_sitelink_grp_wtr grp_wtr = new Xoa_sitelink_grp_wtr();
|
||||
public void Write(Bry_bfr bfr, Xowe_wiki wiki, Xoa_sitelink_mgr mgr, List_adp slink_list, byte[] qid) {
|
||||
Xoa_sitelink_grp_mgr grp_mgr = mgr.Grp_mgr(); Xoa_sitelink_itm_mgr itm_mgr = mgr.Itm_mgr();
|
||||
|
||||
// reset grps
|
||||
grp_wtr.Init_by_app(wiki.App());
|
||||
int grp_len = grp_mgr.Len();
|
||||
@@ -32,7 +31,6 @@ public class Xoa_sitelink_div_wtr {
|
||||
Xoa_sitelink_grp grp = grp_mgr.Get_at(i);
|
||||
grp.Reset();
|
||||
}
|
||||
|
||||
// add itms to each grp
|
||||
int slink_len = slink_list.Count();
|
||||
for (int i = 0; i < slink_len; i++) {
|
||||
@@ -51,7 +49,6 @@ public class Xoa_sitelink_div_wtr {
|
||||
}
|
||||
itm.Init_by_page(slink.Domain_info(), ttl_bry, ttl_is_empty, slink.Badges());
|
||||
}
|
||||
|
||||
// write html
|
||||
Xoapi_toggle_itm toggle_itm = wiki.Appe().Api_root().Html().Page().Toggle_mgr().Get_or_new("wikidata-langs");
|
||||
toggle_itm.Init(wiki.Msg_mgr().Val_by_id(Xol_msg_itm_.Id_page_lang_header));
|
||||
|
||||
@@ -19,8 +19,8 @@ package gplx.xowa.wikis.xwikis.sitelinks.htmls; import gplx.*; import gplx.xowa.
|
||||
import gplx.xowa.langs.*; import gplx.xowa.parsers.*;
|
||||
class Xoa_sitelink_div_wtr_fxt {
|
||||
public void Clear() {
|
||||
app = Xoa_app_fxt.app_();
|
||||
wiki = Xoa_app_fxt.wiki_tst_(app);
|
||||
app = Xoa_app_fxt.Make__app__edit();
|
||||
wiki = Xoa_app_fxt.Make__wiki__edit(app);
|
||||
Init_langs(wiki);
|
||||
}
|
||||
public static void Init_langs(Xowe_wiki wiki) {
|
||||
|
||||
Reference in New Issue
Block a user