1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

v2.11.1.1

This commit is contained in:
gnosygnu
2015-11-01 20:50:05 -05:00
parent 4f43f51b18
commit b990ec409f
858 changed files with 6758 additions and 4187 deletions

View File

@@ -62,7 +62,7 @@ public class Xow_data_mgr_tst {
;
}
@Test public void Update_zip() {
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Id_main].Ext_tid_(gplx.ios.Io_stream_.Tid_zip);
// fxt.Wiki().Fsys_mgr().Dir_regy()[Xow_ns_.Id_main].Ext_tid_(gplx.core.ios.Io_stream_.Tid_zip);
// fxt.Wiki().Data_mgr().Zip_mgr_(new Io_zip_mgr_mok());
// fxt .Create("A1", "A1 data")
// .Create("B12", "B12 data")

View File

@@ -16,13 +16,14 @@ 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; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*;
import gplx.ios.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.cfgs.*;
import gplx.dbs.metas.*; import gplx.xowa.bldrs.cmds.*; import gplx.xowa.wikis.dbs.*;
public class Xowd_core_db_props {
public Xowd_core_db_props(int schema, Xowd_db_layout layout_text, Xowd_db_layout layout_html, Xowd_db_layout layout_file, byte zip_tid_text, byte zip_tid_html) {
public Xowd_core_db_props(int schema, Xowd_db_layout layout_text, Xowd_db_layout layout_html, Xowd_db_layout layout_file, byte zip_tid_text, byte zip_tid_html, boolean hzip_enabled) {
this.schema = schema;
this.layout_text = layout_text; this.layout_html = layout_html; this.layout_file = layout_file;
this.zip_tid_text = zip_tid_text; this.zip_tid_html = zip_tid_html;
this.hzip_enabled = hzip_enabled;
}
public int Schema() {return schema;} private final int schema;
public boolean Schema_is_1() {return schema == 1;}
@@ -31,6 +32,7 @@ public class Xowd_core_db_props {
public Xowd_db_layout Layout_file() {return layout_file;} private final Xowd_db_layout layout_file;
public byte Zip_tid_text() {return zip_tid_text;} private final byte zip_tid_text;
public byte Zip_tid_html() {return zip_tid_html;} private final byte zip_tid_html;
public boolean Hzip_enabled() {return hzip_enabled;} private final boolean hzip_enabled;
public void Cfg_save(Db_cfg_tbl tbl) {
tbl.Conn().Txn_bgn("make__core__cfg__save");
tbl.Insert_int (Cfg_grp, Cfg_key__schema_version , schema);
@@ -39,12 +41,13 @@ public class Xowd_core_db_props {
tbl.Insert_str (Cfg_grp, Cfg_key__layout_file , layout_file.Name());
tbl.Insert_byte (Cfg_grp, Cfg_key__zip_tid_text , zip_tid_text);
tbl.Insert_byte (Cfg_grp, Cfg_key__zip_tid_html , zip_tid_html);
tbl.Insert_yn (Cfg_grp, Cfg_key__hzip_enabled , hzip_enabled);
tbl.Conn().Txn_end();
}
public static Xowd_core_db_props Cfg_load(Io_url url, Db_conn conn) {
Db_cfg_tbl cfg_tbl = new Db_cfg_tbl(conn, "xowa_cfg");
return cfg_tbl.Select_int_or(Cfg_grp, Cfg_key__schema_version, 1) == 1
? new Xowd_core_db_props(1, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, cfg_tbl.Select_byte_or(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format, Io_stream_.Tid_gzip), Io_stream_.Tid_gzip)
? new Xowd_core_db_props(1, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, Xowd_db_layout.Itm_lot, cfg_tbl.Select_byte_or(Xowe_wiki.Invk_db_mgr, Xodb_mgr_sql.Invk_data_storage_format, Io_stream_.Tid_gzip), Io_stream_.Tid_gzip, Bool_.Y)
: Cfg_load(cfg_tbl);
}
private static Xowd_core_db_props Cfg_load(Db_cfg_tbl tbl) {
@@ -56,6 +59,7 @@ public class Xowd_core_db_props {
, Xowd_db_layout.get_(cfg_hash.Get_by(Cfg_key__layout_file).To_str())
, cfg_hash.Get_by(Cfg_key__zip_tid_text).To_byte()
, cfg_hash.Get_by(Cfg_key__zip_tid_html).To_byte()
, cfg_hash.Get_by(Cfg_key__hzip_enabled).To_yn_or(Bool_.N)
);
}
private static final String Cfg_grp = Xow_cfg_consts.Grp__wiki_core
@@ -65,6 +69,7 @@ public class Xowd_core_db_props {
, Cfg_key__layout_file = "layout_file"
, Cfg_key__zip_tid_text = "zip_tid_text"
, Cfg_key__zip_tid_html = "zip_tid_html"
, Cfg_key__hzip_enabled = "hzip_enabled"
;
public static final Xowd_core_db_props Test = new Xowd_core_db_props(2, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Io_stream_.Tid_raw, Io_stream_.Tid_raw);
public static final Xowd_core_db_props Test = new Xowd_core_db_props(2, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Xowd_db_layout.Itm_few, Io_stream_.Tid_raw, Io_stream_.Tid_raw, Bool_.Y);
}

View File

@@ -17,6 +17,7 @@ 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.*;
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;
@@ -29,7 +30,8 @@ public class Xowd_db_file {
this.tbl__site_stats = new Xowd_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 Xowd_html_tbl(conn, props.Zip_tid_html());
this.tbl__html_page = new Xoh_page_tbl(conn);
this.tbl__html_redlink = new Xoh_redlink_tbl(conn);
this.tbl__css_core = new Xowd_css_core_tbl(conn);
this.tbl__css_file = new Xowd_css_file_tbl(conn);
this.tbl__cat_core = new Xowd_cat_core_tbl(conn, schema_is_1);
@@ -59,7 +61,8 @@ public class Xowd_db_file {
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 Xowd_html_tbl Tbl__html() {return tbl__html;} private final Xowd_html_tbl tbl__html;
public Xoh_page_tbl Tbl__html_page() {return tbl__html_page;} private final Xoh_page_tbl tbl__html_page;
public Xoh_redlink_tbl Tbl__html_redlink() {return tbl__html_redlink;} private final Xoh_redlink_tbl tbl__html_redlink;
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;

View File

@@ -22,8 +22,8 @@ public class Xowd_html_row {
public int Tid() {return tid;} private final int tid;
public byte[] Data() {return data;} private final byte[] data;
public static final int // SERIALIZED
Tid_html = 0
, Tid_img = 1
, Tid_redlink = 2
Tid__html = 0
, Tid__img = 1
, Tid__redlink = 2
;
}

View File

@@ -1,71 +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.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
public class Xowd_html_tbl implements RlsAble {
private final String tbl_name = "html"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private final String fld_page_id, fld_html_tid, fld_html_data;
private final Db_conn conn; private Db_stmt stmt_select, stmt_insert, stmt_delete;
private final Io_stream_zip_mgr zip_mgr = Xoa_app_.Utl__zip_mgr(); private final byte zip_tid;
public Xowd_html_tbl(Db_conn conn, byte zip_tid) {
this.conn = conn; this.zip_tid = zip_tid;
fld_page_id = flds.Add_int("page_id");
fld_html_tid = flds.Add_int("html_tid");
fld_html_data = flds.Add_bry("html_data");
conn.Rls_reg(this);
}
public Db_conn Conn() {return conn;}
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.new_(tbl_name, flds));}
public void Create_idx() {conn.Ddl_create_idx(Gfo_usr_dlg_.Instance, Db_meta_idx.new_unique_by_tbl(tbl_name, "main", fld_page_id, fld_html_tid));}
public void Insert_bgn() {conn.Txn_bgn("schema__html__insert"); stmt_insert = conn.Stmt_insert(tbl_name, flds);}
public void Insert_end() {conn.Txn_end(); stmt_insert = Db_stmt_.Rls(stmt_insert);}
public int Insert(int page_id, int tid, byte[] data) {
if (stmt_insert == null) stmt_insert = conn.Stmt_insert(tbl_name, flds);
data = zip_mgr.Zip(zip_tid, data);
stmt_insert.Clear().Val_int(fld_page_id, page_id).Val_int(fld_html_tid, tid).Val_bry(fld_html_data, data).Exec_insert();
return data.length;
}
public void Delete(int page_id) {
if (stmt_delete == null) stmt_delete = conn.Stmt_delete(tbl_name, String_.Ary(fld_page_id));
stmt_delete.Clear().Crt_int(fld_page_id, page_id).Exec_delete();
}
public void Select_by_page(List_adp rv, int page_id) {
if (stmt_select == null) stmt_select = conn.Stmt_select(tbl_name, flds, String_.Ary(fld_page_id));
Db_rdr rdr = stmt_select.Clear().Crt_int(fld_page_id, page_id).Exec_select__rls_manual();
try {
while (rdr.Move_next()) {
Xowd_html_row row = new Xowd_html_row(rdr.Read_int(fld_page_id), rdr.Read_int(fld_html_tid), zip_mgr.Unzip(zip_tid, rdr.Read_bry(fld_html_data)));
rv.Add(row);
}
}
finally {rdr.Rls();}
}
public void Rls() {
stmt_insert = Db_stmt_.Rls(stmt_insert);
stmt_delete = Db_stmt_.Rls(stmt_delete);
stmt_select = Db_stmt_.Rls(stmt_select);
}
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(), Db_meta_fld.new_int(page_tbl.Fld_html_db_id()).Default_(-1));
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Db_meta_fld.new_int(page_tbl.Fld_redirect_id()).Default_(-1));
page_tbl.Hdump_enabled_(Bool_.Y);
}
}

View File

@@ -90,7 +90,7 @@ public class Xowd_page_itm {
ns_id = ns.Id();
return this;
}
public void Clear() {
public Xowd_page_itm Clear() {
id = Id_null; text_len = 0; // text_len should be 0 b/c text defaults to 0;
text_db_id = tdb_row_idx = 0; // default to 0, b/c some tests do not set and will fail at -1
ns_id = Int_.Min_value;
@@ -101,6 +101,7 @@ public class Xowd_page_itm {
id_val = null;
html_db_id = -1;
redirect_id = -1;
return this;
}
public void Copy(Xowd_page_itm orig) {
this.id = orig.id;

View File

@@ -54,6 +54,11 @@ public class Xowd_page_tbl implements RlsAble {
conn.Rls_reg(this);
}
public void Create_tbl() {conn.Ddl_create_tbl(Db_meta_tbl.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);
this.Insert_end();
}
public void Insert_bgn() {conn.Txn_bgn("schema__page__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, 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) {
@@ -321,4 +326,12 @@ public class Xowd_page_tbl implements RlsAble {
stmt_insert = Db_stmt_.Rls(stmt_insert);
}
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(), Db_meta_fld.new_int(page_tbl.Fld_html_db_id()).Default_(-1));
page_conn.Ddl_append_fld(page_tbl.Tbl_name(), Db_meta_fld.new_int(page_tbl.Fld_redirect_id()).Default_(-1));
page_tbl.Hdump_enabled_(Bool_.Y);
}
}

View File

@@ -16,7 +16,7 @@ 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.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
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 RlsAble {
private final String tbl_name = "pagelink"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private final String fld_src_id, fld_trg_id;

View File

@@ -16,7 +16,7 @@ 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.ios.*; import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.wikis.dbs.*; import gplx.dbs.cfgs.*;
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 RlsAble {
private final String tbl_name = "pagelinks_temp"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private final String fld_src_id, fld_trg_ns, fld_trg_ttl;

View File

@@ -16,7 +16,7 @@ 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.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
import gplx.core.ios.*; import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xowd_text_tbl implements RlsAble {
private final String tbl_name = "text"; private final Db_meta_fld_list flds = Db_meta_fld_list.new_();
private final String fld_page_id, fld_text_data;