mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Edit: Save compiled HTML when editing pages [#699]
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@@ -13,74 +13,106 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.core; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.wkrs.*; import gplx.xowa.htmls.core.hzips.*; import gplx.xowa.htmls.heads.*; import gplx.xowa.htmls.core.dbs.*;
|
||||
import gplx.core.ios.*; import gplx.core.primitives.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.pages.*;
|
||||
import gplx.xowa.addons.wikis.pages.syncs.core.parsers.*;
|
||||
public class Xow_hdump_mgr__save {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Xoh_hzip_bfr tmp_bfr = Xoh_hzip_bfr.New_txt(32); private Bool_obj_ref html_db_is_new = Bool_obj_ref.n_();
|
||||
private int dflt_zip_tid, dflt_hzip_tid;
|
||||
public Xow_hdump_mgr__save(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg;
|
||||
}
|
||||
public void Init_by_db(int dflt_zip_tid, int dflt_hzip_tid, boolean mode_is_b256) {
|
||||
this.dflt_zip_tid = dflt_zip_tid; this.dflt_hzip_tid = dflt_hzip_tid; tmp_bfr.Mode_is_b256_(mode_is_b256);
|
||||
}
|
||||
public byte[] Src_as_hzip() {return src_as_hzip;} private byte[] src_as_hzip;
|
||||
public int Save(Xoae_page page) {
|
||||
synchronized (tmp_hpg) {
|
||||
Bld_hdump(page);
|
||||
tmp_hpg.Ctor_by_hdiff(tmp_bfr, page, page.Wikie().Msg_mgr().Val_by_id(gplx.xowa.langs.msgs.Xol_msg_itm_.Id_toc));
|
||||
Xow_db_file html_db = Get_html_db(wiki, page, html_db_is_new.Val_n_());
|
||||
return Save(page, tmp_hpg, html_db.Tbl__html(), html_db_is_new.Val(), true);
|
||||
}
|
||||
}
|
||||
public int Save(Xoae_page page, Xoh_page hpg, Xowd_html_tbl html_tbl, boolean insert, boolean use_hzip_dflt) {
|
||||
int hzip_tid = use_hzip_dflt ? dflt_hzip_tid : Xoh_hzip_dict_.Hdb__htxt;
|
||||
byte[] db_body = Write(tmp_bfr, wiki, page, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, hzip_tid, hpg.Db().Html().Html_bry());
|
||||
if (insert) html_tbl.Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_tbl.Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
return db_body.length;
|
||||
}
|
||||
public void Bld_hdump(Xoae_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will keep incrementing upwards
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump_by_hzip_tid(dflt_hzip_tid);
|
||||
wiki.Html__wtr_mgr().Wkr(Xopg_view_mode_.Tid__read).Write_body(tmp_bfr, page.Wikie().Parser_mgr().Ctx(), hctx, page); // save as hdump_fmt
|
||||
page.Db().Html().Html_bry_(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
private byte[] Write(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoae_page page, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
switch (hzip_tid) {
|
||||
case Xoh_hzip_dict_.Hdb__htxt:
|
||||
break;
|
||||
case Xoh_hzip_dict_.Hdb__hzip:
|
||||
src = hzip_mgr.Encode_as_bry((Xoh_hzip_bfr)bfr.Clear(), wiki, hpg, src);
|
||||
break;
|
||||
// TOMBSTONE: not used; Xosync_update_mgr calls save directly; unsure if this should be restored for parallelism
|
||||
// case Xoh_hzip_dict_.Hdb__page_sync:
|
||||
// src = plain_parser.Parse_hdoc(wiki.Domain_itm(), page.Url_bry_safe(), hpg.Hdump_mgr().Imgs(), src);
|
||||
// break;
|
||||
}
|
||||
src_as_hzip = src;
|
||||
if (zip_tid > gplx.core.ios.streams.Io_stream_tid_.Tid__raw)
|
||||
src = zip_mgr.Zip((byte)zip_tid, src);
|
||||
return src;
|
||||
}
|
||||
private static Xow_db_file Get_html_db(Xow_wiki wiki, Xoae_page page, Bool_obj_ref html_db_is_new) {
|
||||
Xow_db_file rv = Xow_db_file.Null;
|
||||
Xow_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int html_db_id = page.Db().Page().Html_db_id();
|
||||
if (html_db_id == -1) {
|
||||
html_db_is_new.Val_y_();
|
||||
rv = core_data_mgr.Db__html();
|
||||
if (rv == null) rv = core_data_mgr.Dbs__make_by_tid(Xow_db_file_.Tid__html_data);
|
||||
html_db_id = rv.Id();
|
||||
page.Db().Page().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Db().Page().Id(), html_db_id);
|
||||
}
|
||||
else {
|
||||
rv = core_data_mgr.Dbs__get_by_id_or_fail(html_db_id);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
package gplx.xowa.htmls.core;
|
||||
|
||||
import gplx.core.ios.Io_stream_zip_mgr;
|
||||
import gplx.core.primitives.Bool_obj_ref;
|
||||
import gplx.xowa.Xoae_page;
|
||||
import gplx.xowa.Xow_wiki;
|
||||
import gplx.xowa.htmls.Xoh_page;
|
||||
import gplx.xowa.htmls.core.dbs.Xowd_html_tbl;
|
||||
import gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx;
|
||||
import gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_;
|
||||
import gplx.xowa.htmls.core.hzips.Xoh_hzip_mgr;
|
||||
import gplx.xowa.htmls.core.wkrs.Xoh_hzip_bfr;
|
||||
import gplx.xowa.wikis.data.Xow_db_file;
|
||||
import gplx.xowa.wikis.data.Xow_db_file_;
|
||||
import gplx.xowa.wikis.data.Xow_db_mgr;
|
||||
import gplx.xowa.wikis.pages.Xopg_view_mode_;
|
||||
import gplx.xowa.wikis.pages.dbs.Xopg_db_page;
|
||||
|
||||
public class Xow_hdump_mgr__save {
|
||||
private final Xow_wiki wiki; private final Xoh_hzip_mgr hzip_mgr; private final Io_stream_zip_mgr zip_mgr;
|
||||
private final Xoh_page tmp_hpg; private final Xoh_hzip_bfr tmp_bfr = Xoh_hzip_bfr.New_txt(32); private Bool_obj_ref html_db_is_new = Bool_obj_ref.n_();
|
||||
private int dflt_zip_tid, dflt_hzip_tid;
|
||||
public Xow_hdump_mgr__save(Xow_wiki wiki, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, Xoh_page tmp_hpg) {
|
||||
this.wiki = wiki; this.hzip_mgr = hzip_mgr; this.zip_mgr = zip_mgr; this.tmp_hpg = tmp_hpg;
|
||||
}
|
||||
public void Init_by_db(int dflt_zip_tid, int dflt_hzip_tid, boolean mode_is_b256) {
|
||||
this.dflt_zip_tid = dflt_zip_tid; this.dflt_hzip_tid = dflt_hzip_tid; tmp_bfr.Mode_is_b256_(mode_is_b256);
|
||||
}
|
||||
public byte[] Src_as_hzip() {return src_as_hzip;} private byte[] src_as_hzip;
|
||||
public int Save(Xoae_page page) {return Save(page, false);}
|
||||
public int Save(Xoae_page page, boolean isEdit) {
|
||||
synchronized (tmp_hpg) {
|
||||
Bld_hdump(page);
|
||||
tmp_hpg.Ctor_by_hdiff(tmp_bfr, page, page.Wikie().Msg_mgr().Val_by_id(gplx.xowa.langs.msgs.Xol_msg_itm_.Id_toc));
|
||||
Xow_db_file html_db = Get_html_db(wiki, page, html_db_is_new.Val_n_(), isEdit);
|
||||
return Save(page, tmp_hpg, html_db.Tbl__html(), html_db_is_new.Val(), true);
|
||||
}
|
||||
}
|
||||
public int Save(Xoae_page page, Xoh_page hpg, Xowd_html_tbl html_tbl, boolean insert, boolean use_hzip_dflt) {
|
||||
int hzip_tid = use_hzip_dflt ? dflt_hzip_tid : Xoh_hzip_dict_.Hdb__htxt;
|
||||
byte[] db_body = Write(tmp_bfr, wiki, page, hpg, hzip_mgr, zip_mgr, dflt_zip_tid, hzip_tid, hpg.Db().Html().Html_bry());
|
||||
if (insert) html_tbl.Insert(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
else html_tbl.Update(hpg, dflt_zip_tid, dflt_hzip_tid, db_body);
|
||||
return db_body.length;
|
||||
}
|
||||
public void Bld_hdump(Xoae_page page) {
|
||||
page.File_queue().Clear(); // need to reset uid to 0, else xowa_file_# will keep incrementing upwards
|
||||
Xoh_wtr_ctx hctx = Xoh_wtr_ctx.Hdump_by_hzip_tid(dflt_hzip_tid);
|
||||
wiki.Html__wtr_mgr().Wkr(Xopg_view_mode_.Tid__read).Write_body(tmp_bfr, page.Wikie().Parser_mgr().Ctx(), hctx, page); // save as hdump_fmt
|
||||
page.Db().Html().Html_bry_(tmp_bfr.To_bry_and_clear());
|
||||
}
|
||||
private byte[] Write(Xoh_hzip_bfr bfr, Xow_wiki wiki, Xoae_page page, Xoh_page hpg, Xoh_hzip_mgr hzip_mgr, Io_stream_zip_mgr zip_mgr, int zip_tid, int hzip_tid, byte[] src) {
|
||||
switch (hzip_tid) {
|
||||
case Xoh_hzip_dict_.Hdb__htxt:
|
||||
break;
|
||||
case Xoh_hzip_dict_.Hdb__hzip:
|
||||
src = hzip_mgr.Encode_as_bry((Xoh_hzip_bfr)bfr.Clear(), wiki, hpg, src);
|
||||
break;
|
||||
// TOMBSTONE: not used; Xosync_update_mgr calls save directly; unsure if this should be restored for parallelism
|
||||
// case Xoh_hzip_dict_.Hdb__page_sync:
|
||||
// src = plain_parser.Parse_hdoc(wiki.Domain_itm(), page.Url_bry_safe(), hpg.Hdump_mgr().Imgs(), src);
|
||||
// break;
|
||||
}
|
||||
src_as_hzip = src;
|
||||
if (zip_tid > gplx.core.ios.streams.Io_stream_tid_.Tid__raw)
|
||||
src = zip_mgr.Zip((byte)zip_tid, src);
|
||||
return src;
|
||||
}
|
||||
private static Xow_db_file Get_html_db(Xow_wiki wiki, Xoae_page page, Bool_obj_ref html_db_is_new, boolean isEdit) {
|
||||
Xow_db_file rv = Xow_db_file.Null;
|
||||
Xow_db_mgr core_data_mgr = wiki.Data__core_mgr();
|
||||
int html_db_id = page.Db().Page().Html_db_id();
|
||||
if (html_db_id == Xopg_db_page.HTML_DB_ID_NULL) {
|
||||
html_db_is_new.Val_y_();
|
||||
|
||||
// get htmlDbTid; NOTE: probably do not need Tid__html_data b/c xomp_wkr and sync_mgr should be building the databases; ISSUE#:699; DATE:2020-08-06
|
||||
byte htmlDbTid = isEdit ? Xow_db_file_.Tid__html_user : Xow_db_file_.Tid__html_data;
|
||||
|
||||
// get htmlDb
|
||||
if (isEdit) {
|
||||
rv = core_data_mgr.Dbs__get_by_tid_or_null(htmlDbTid);
|
||||
}
|
||||
else {
|
||||
rv = core_data_mgr.Db__html();
|
||||
}
|
||||
|
||||
// make htmlDb if not available
|
||||
if (rv == null) {
|
||||
rv = core_data_mgr.Dbs__make_by_tid(htmlDbTid);
|
||||
Xowd_html_tbl html_tbl = new Xowd_html_tbl(rv.Conn());
|
||||
html_tbl.Create_tbl();
|
||||
}
|
||||
|
||||
html_db_id = rv.Id();
|
||||
page.Db().Page().Html_db_id_(html_db_id);
|
||||
core_data_mgr.Tbl__page().Update__html_db_id(page.Db().Page().Id(), html_db_id);
|
||||
}
|
||||
else {
|
||||
rv = core_data_mgr.Dbs__get_by_id_or_fail(html_db_id);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@@ -13,85 +13,111 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.hxtns.blobs; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.core.ios.*;
|
||||
public class Hxtn_blob_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_blob"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private static final String
|
||||
fld_blob_tid = flds.Add_int("blob_tid"), fld_wiki_id = flds.Add_int("wiki_id"), fld_blob_id = flds.Add_int("blob_id")
|
||||
, fld_zip_tid = flds.Add_byte("zip_tid"), fld_blob_data = flds.Add_bry("blob_data");
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final byte zip_tid_default;
|
||||
private final Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||
public Hxtn_blob_tbl(Db_conn conn, byte zip_tid_default) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
this.zip_tid_default = zip_tid_default;
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Stmt_bgn() {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
}
|
||||
public void Stmt_end() {
|
||||
this.Rls();
|
||||
if (!conn.Meta_idx_exists(tbl_name, "pkey"))
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_blob_id, fld_wiki_id, fld_blob_tid));
|
||||
}
|
||||
public void Insert_by_rdr(Db_rdr rdr) {
|
||||
Db_stmt_.Insert_by_rdr(flds, rdr, stmt_insert);
|
||||
}
|
||||
public void Insert_exec(int blob_tid, int wiki_id, int blob_id, byte[] blob_data) {
|
||||
blob_data = zip_mgr.Zip(zip_tid_default, blob_data);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_blob_tid , blob_tid)
|
||||
.Val_int(fld_wiki_id , wiki_id)
|
||||
.Val_int(fld_blob_id , blob_id)
|
||||
.Val_byte(fld_zip_tid , zip_tid_default)
|
||||
.Val_bry(fld_blob_data , blob_data)
|
||||
.Exec_insert();
|
||||
}
|
||||
public void Select_to_regy(Bry_bfr temp_bfr, Hash_adp_bry blob_data_hash) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, String_.Ary(fld_wiki_id, fld_blob_id, fld_blob_tid))
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
byte[] key = Make_key(temp_bfr, rdr.Read_int(fld_wiki_id), rdr.Read_int(fld_blob_id), rdr.Read_int(fld_blob_tid));
|
||||
blob_data_hash.Add_as_key_and_val(key);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
public byte[] Select_text(int blob_tid, int wiki_id, int blob_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_blob_id, fld_wiki_id, fld_blob_tid)
|
||||
.Crt_int(fld_blob_id, blob_id)
|
||||
.Crt_int(fld_wiki_id, wiki_id)
|
||||
.Crt_int(fld_blob_tid, blob_tid)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
byte[] rv = rdr.Read_bry(fld_blob_data);
|
||||
byte zip_type = rdr.Read_byte(fld_zip_tid);
|
||||
rv = zip_mgr.Unzip(zip_type, rv);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Make_key(Bry_bfr temp_bfr, int blob_id, int wiki_id, int blob_tid) {
|
||||
return temp_bfr.Add_int_variable(blob_id).Add_byte_pipe().Add_int_variable(wiki_id).Add_byte_pipe().Add_int_variable(blob_tid).To_bry_and_clear();
|
||||
}
|
||||
|
||||
public static final int Blob_tid__wtxt = 0, Blob_tid__html = 1;
|
||||
package gplx.xowa.htmls.hxtns.blobs;
|
||||
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Hash_adp_bry;
|
||||
import gplx.Rls_able;
|
||||
import gplx.String_;
|
||||
import gplx.core.ios.Io_stream_zip_mgr;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_rdr_;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Db_stmt_;
|
||||
import gplx.dbs.Dbmeta_fld_list;
|
||||
import gplx.dbs.Dbmeta_idx_itm;
|
||||
import gplx.dbs.Dbmeta_tbl_itm;
|
||||
|
||||
public class Hxtn_blob_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_blob"; private static final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private static final String
|
||||
fld_blob_tid = flds.Add_int("blob_tid"), fld_wiki_id = flds.Add_int("wiki_id"), fld_blob_id = flds.Add_int("blob_id")
|
||||
, fld_zip_tid = flds.Add_byte("zip_tid"), fld_blob_data = flds.Add_bry("blob_data");
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
private final byte zip_tid_default;
|
||||
private final Io_stream_zip_mgr zip_mgr = new Io_stream_zip_mgr();
|
||||
public Hxtn_blob_tbl(Db_conn conn, byte zip_tid_default) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
this.zip_tid_default = zip_tid_default;
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Stmt_bgn() {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
}
|
||||
public void Stmt_end() {
|
||||
this.Rls();
|
||||
if (!conn.Meta_idx_exists(tbl_name, "pkey"))
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_blob_id, fld_wiki_id, fld_blob_tid));
|
||||
}
|
||||
public void Insert_by_rdr(Db_rdr rdr) {
|
||||
Db_stmt_.Insert_by_rdr(flds, rdr, stmt_insert);
|
||||
}
|
||||
public void Insert_exec(int blob_tid, int wiki_id, int blob_id, byte[] blob_data) {
|
||||
blob_data = zip_mgr.Zip(zip_tid_default, blob_data);
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_blob_tid , blob_tid)
|
||||
.Val_int(fld_wiki_id , wiki_id)
|
||||
.Val_int(fld_blob_id , blob_id)
|
||||
.Val_byte(fld_zip_tid , zip_tid_default)
|
||||
.Val_bry(fld_blob_data , blob_data)
|
||||
.Exec_insert();
|
||||
}
|
||||
public boolean Exists(int blob_tid, int wiki_id, int blob_id) {
|
||||
Db_rdr rdr = Db_rdr_.Empty;
|
||||
try {
|
||||
rdr = conn.Stmt_select(tbl_name, flds, fld_blob_tid, fld_wiki_id, fld_blob_id)
|
||||
.Crt_int(fld_blob_tid, blob_tid)
|
||||
.Crt_int(fld_wiki_id, wiki_id)
|
||||
.Crt_int(fld_blob_id, blob_id)
|
||||
.Exec_select__rls_auto();
|
||||
return rdr.Move_next();
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
public void Select_to_regy(Bry_bfr temp_bfr, Hash_adp_bry blob_data_hash) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, String_.Ary(fld_wiki_id, fld_blob_id, fld_blob_tid))
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
byte[] key = Make_key(temp_bfr, rdr.Read_int(fld_wiki_id), rdr.Read_int(fld_blob_id), rdr.Read_int(fld_blob_tid));
|
||||
blob_data_hash.Add_as_key_and_val(key);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
public byte[] Select_text(int blob_tid, int wiki_id, int blob_id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_blob_id, fld_wiki_id, fld_blob_tid)
|
||||
.Crt_int(fld_blob_id, blob_id)
|
||||
.Crt_int(fld_wiki_id, wiki_id)
|
||||
.Crt_int(fld_blob_tid, blob_tid)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
if (rdr.Move_next()) {
|
||||
byte[] rv = rdr.Read_bry(fld_blob_data);
|
||||
byte zip_type = rdr.Read_byte(fld_zip_tid);
|
||||
rv = zip_mgr.Unzip(zip_type, rv);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] Make_key(Bry_bfr temp_bfr, int blob_id, int wiki_id, int blob_tid) {
|
||||
return temp_bfr.Add_int_variable(blob_id).Add_byte_pipe().Add_int_variable(wiki_id).Add_byte_pipe().Add_int_variable(blob_tid).To_bry_and_clear();
|
||||
}
|
||||
|
||||
public static final int Blob_tid__wtxt = 0, Blob_tid__html = 1;
|
||||
}
|
||||
@@ -1,122 +1,124 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.hxtns.pages;
|
||||
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.Hash_adp_bry;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.List_adp;
|
||||
import gplx.core.lists.hashs.Hash_adp__int;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_conn_bldr;
|
||||
import gplx.xowa.Xoa_ttl;
|
||||
import gplx.xowa.Xow_wiki;
|
||||
import gplx.xowa.htmls.Xoh_page;
|
||||
import gplx.xowa.htmls.hxtns.blobs.Hxtn_blob_tbl;
|
||||
import gplx.xowa.htmls.hxtns.wikis.Hxtn_wiki_mgr;
|
||||
import gplx.xowa.htmls.hxtns.wkrs.Hxtn_wkr_mgr;
|
||||
public class Hxtn_page_mgr {
|
||||
private Hxtn_page_tbl page_tbl;
|
||||
private Hxtn_blob_tbl blob_tbl;
|
||||
private Hash_adp_bry blob_hash;
|
||||
private final Hash_adp__int wkrs = new Hash_adp__int();
|
||||
private boolean dbs_missing = true;
|
||||
private Bry_bfr temp_bfr;
|
||||
public Hxtn_page_tbl Page_tbl() {return page_tbl;}
|
||||
public Hxtn_blob_tbl Blob_tbl() {return blob_tbl;}
|
||||
|
||||
public void Init_by_xomp_wkr(Db_conn wkr_db_conn, byte zip_tid) {
|
||||
// init tbls and other members
|
||||
this.page_tbl = new Hxtn_page_tbl(wkr_db_conn);
|
||||
this.blob_tbl = new Hxtn_blob_tbl(wkr_db_conn, zip_tid);
|
||||
this.blob_hash = Hash_adp_bry.cs();
|
||||
this.temp_bfr = Bry_bfr_.New();
|
||||
|
||||
// if tbl exists, xomp_resume has run; load known blobs to prevent dupes
|
||||
if (wkr_db_conn.Meta_tbl_exists(page_tbl.Tbl_name())) {
|
||||
blob_tbl.Select_to_regy(temp_bfr, blob_hash);
|
||||
}
|
||||
// else tbl doesn't exist, so create them
|
||||
else {
|
||||
page_tbl.Create_tbl();
|
||||
blob_tbl.Create_tbl();
|
||||
}
|
||||
}
|
||||
public void Init_by_wiki(Xow_wiki wiki, boolean is_merge) {
|
||||
Io_url core_db_url = Make_url(wiki, "-html.hxtn-core.xowa");
|
||||
if (!is_merge && !Io_mgr.Instance.ExistsFil(core_db_url)) return;
|
||||
dbs_missing = false;
|
||||
Db_conn page_conn = Db_conn_bldr.Instance.Get_or_new(core_db_url).Conn();
|
||||
this.page_tbl = new Hxtn_page_tbl(page_conn);
|
||||
|
||||
Io_url blob_db_url = Make_url(wiki, "-html.hxtn-blob.xowa");
|
||||
this.blob_tbl = new Hxtn_blob_tbl(Db_conn_bldr.Instance.Get_or_new(blob_db_url).Conn(), gplx.core.ios.streams.Io_stream_tid_.Tid__raw);
|
||||
|
||||
if (is_merge) {
|
||||
page_tbl.Create_tbl();
|
||||
blob_tbl.Create_tbl();
|
||||
|
||||
Hxtn_wkr_mgr wkr_mgr = new Hxtn_wkr_mgr();
|
||||
wkr_mgr.Init_by_xomp_merge(page_conn);
|
||||
|
||||
Hxtn_wiki_mgr wiki_mgr = new Hxtn_wiki_mgr();
|
||||
wiki_mgr.Init_by_xomp_merge(page_conn, wiki.Domain_str());
|
||||
}
|
||||
}
|
||||
public void Insert_bgn(boolean is_merge) {
|
||||
page_tbl.Stmt_bgn();
|
||||
blob_tbl.Stmt_bgn();
|
||||
}
|
||||
public void Insert_end(boolean is_merge) {
|
||||
page_tbl.Stmt_end();
|
||||
blob_tbl.Stmt_end();
|
||||
}
|
||||
public void Page_tbl__insert(int page_id, int wkr_id, int data_id) {
|
||||
page_tbl.Insert_exec(page_id, wkr_id, data_id);
|
||||
}
|
||||
public void Blob_tbl__insert(int blob_tid, int wiki_id, int blob_id, byte[] blob_text) {
|
||||
byte[] key = Hxtn_blob_tbl.Make_key(temp_bfr, blob_tid, wiki_id, blob_id);
|
||||
if (!blob_hash.Has(key)) {// multiple pages can refer to same template; only insert if not seen
|
||||
blob_hash.Add_as_key_and_val(key);
|
||||
blob_tbl.Insert_exec(blob_tid, wiki_id, blob_id, blob_text);
|
||||
}
|
||||
}
|
||||
public void Reg_wkr(Hxtn_page_wkr wkr) {
|
||||
wkrs.Add(wkr.Id(), wkr);
|
||||
}
|
||||
public void Load_by_page(Xoh_page hpg, Xoa_ttl ttl) {
|
||||
if (dbs_missing) return; // PERF:do not call SELECT if dbs don't exist
|
||||
List_adp list = page_tbl.Select_by_page(hpg.Page_id());
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Hxtn_page_itm itm = (Hxtn_page_itm)list.Get_at(i);
|
||||
Hxtn_page_wkr wkr = (Hxtn_page_wkr)wkrs.Get_by_or_null(itm.Wkr_id());
|
||||
if (wkr == null) { // ignore unknown wkrs so other devs can add new xtns; ISSUE#:634; DATE:2020-03-08
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "hxtn.unknown wkr: page_id=~{0} wkr_id=~{1}", itm.Page_id(), itm.Wkr_id());
|
||||
continue;
|
||||
}
|
||||
wkr.Load_by_page(hpg, ttl, itm.Data_id());
|
||||
}
|
||||
}
|
||||
private static Io_url Make_url(Xow_wiki wiki, String file_name) {return wiki.Fsys_mgr().Root_dir().GenSubFil(wiki.Domain_str() + file_name);}
|
||||
public static final int
|
||||
Id__template_styles = 0
|
||||
, Id__indicators = 2
|
||||
;
|
||||
}
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
|
||||
You may use XOWA according to either of these licenses as is most appropriate
|
||||
for your project on a case-by-case basis.
|
||||
|
||||
The terms of each license can be found in the source code repository:
|
||||
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.hxtns.pages;
|
||||
|
||||
import gplx.Bry_bfr;
|
||||
import gplx.Bry_bfr_;
|
||||
import gplx.Gfo_usr_dlg_;
|
||||
import gplx.Hash_adp_bry;
|
||||
import gplx.Io_mgr;
|
||||
import gplx.Io_url;
|
||||
import gplx.List_adp;
|
||||
import gplx.core.lists.hashs.Hash_adp__int;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_conn_bldr;
|
||||
import gplx.xowa.Xoa_ttl;
|
||||
import gplx.xowa.Xow_wiki;
|
||||
import gplx.xowa.htmls.Xoh_page;
|
||||
import gplx.xowa.htmls.hxtns.blobs.Hxtn_blob_tbl;
|
||||
import gplx.xowa.htmls.hxtns.wikis.Hxtn_wiki_mgr;
|
||||
import gplx.xowa.htmls.hxtns.wkrs.Hxtn_wkr_mgr;
|
||||
|
||||
public class Hxtn_page_mgr {
|
||||
private Hxtn_page_tbl page_tbl;
|
||||
private Hxtn_blob_tbl blob_tbl;
|
||||
private Hash_adp_bry blob_hash = Hash_adp_bry.cs();
|
||||
private final Hash_adp__int wkrs = new Hash_adp__int();
|
||||
private boolean dbs_missing = true;
|
||||
private Bry_bfr temp_bfr = Bry_bfr_.New();
|
||||
public Hxtn_page_tbl Page_tbl() {return page_tbl;}
|
||||
public Hxtn_blob_tbl Blob_tbl() {return blob_tbl;}
|
||||
|
||||
public void Init_by_xomp_wkr(Db_conn wkr_db_conn, byte zip_tid) {
|
||||
// init tbls and other members
|
||||
this.page_tbl = new Hxtn_page_tbl(wkr_db_conn);
|
||||
this.blob_tbl = new Hxtn_blob_tbl(wkr_db_conn, zip_tid);
|
||||
|
||||
// if tbl exists, xomp_resume has run; load known blobs to prevent dupes
|
||||
if (wkr_db_conn.Meta_tbl_exists(page_tbl.Tbl_name())) {
|
||||
blob_tbl.Select_to_regy(temp_bfr, blob_hash);
|
||||
}
|
||||
// else tbl doesn't exist, so create them
|
||||
else {
|
||||
page_tbl.Create_tbl();
|
||||
blob_tbl.Create_tbl();
|
||||
}
|
||||
}
|
||||
public void Init_by_wiki(Xow_wiki wiki, boolean is_merge) {
|
||||
Io_url core_db_url = Make_url(wiki, "-html.hxtn-core.xowa");
|
||||
if (!is_merge && !Io_mgr.Instance.ExistsFil(core_db_url)) return;
|
||||
dbs_missing = false;
|
||||
Db_conn page_conn = Db_conn_bldr.Instance.Get_or_new(core_db_url).Conn();
|
||||
this.page_tbl = new Hxtn_page_tbl(page_conn);
|
||||
|
||||
Io_url blob_db_url = Make_url(wiki, "-html.hxtn-blob.xowa");
|
||||
this.blob_tbl = new Hxtn_blob_tbl(Db_conn_bldr.Instance.Get_or_new(blob_db_url).Conn(), gplx.core.ios.streams.Io_stream_tid_.Tid__raw);
|
||||
|
||||
if (is_merge) {
|
||||
page_tbl.Create_tbl();
|
||||
blob_tbl.Create_tbl();
|
||||
|
||||
Hxtn_wkr_mgr wkr_mgr = new Hxtn_wkr_mgr();
|
||||
wkr_mgr.Init_by_xomp_merge(page_conn);
|
||||
|
||||
Hxtn_wiki_mgr wiki_mgr = new Hxtn_wiki_mgr();
|
||||
wiki_mgr.Init_by_xomp_merge(page_conn, wiki.Domain_str());
|
||||
}
|
||||
}
|
||||
public void Insert_bgn(boolean is_merge) {
|
||||
page_tbl.Stmt_bgn();
|
||||
blob_tbl.Stmt_bgn();
|
||||
}
|
||||
public void Insert_end(boolean is_merge) {
|
||||
page_tbl.Stmt_end();
|
||||
blob_tbl.Stmt_end();
|
||||
}
|
||||
public void Page_tbl__insert(int page_id, int wkr_id, int data_id) {
|
||||
if (!page_tbl.Exists(page_id, wkr_id, data_id))
|
||||
page_tbl.Insert_exec(page_id, wkr_id, data_id);
|
||||
}
|
||||
public void Blob_tbl__insert(int blob_tid, int wiki_id, int blob_id, byte[] blob_text) {
|
||||
byte[] key = Hxtn_blob_tbl.Make_key(temp_bfr, blob_tid, wiki_id, blob_id);
|
||||
if (!blob_hash.Has(key)) {// multiple pages can refer to same template; only insert if not seen
|
||||
blob_hash.Add_as_key_and_val(key);
|
||||
if (!blob_tbl.Exists(blob_tid, wiki_id, blob_id)) {
|
||||
blob_tbl.Insert_exec(blob_tid, wiki_id, blob_id, blob_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Reg_wkr(Hxtn_page_wkr wkr) {
|
||||
wkrs.Add(wkr.Id(), wkr);
|
||||
}
|
||||
public void Load_by_page(Xoh_page hpg, Xoa_ttl ttl) {
|
||||
if (dbs_missing) return; // PERF:do not call SELECT if dbs don't exist
|
||||
List_adp list = page_tbl.Select_by_page(hpg.Page_id());
|
||||
int len = list.Len();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Hxtn_page_itm itm = (Hxtn_page_itm)list.Get_at(i);
|
||||
Hxtn_page_wkr wkr = (Hxtn_page_wkr)wkrs.Get_by_or_null(itm.Wkr_id());
|
||||
if (wkr == null) { // ignore unknown wkrs so other devs can add new xtns; ISSUE#:634; DATE:2020-03-08
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "hxtn.unknown wkr: page_id=~{0} wkr_id=~{1}", itm.Page_id(), itm.Wkr_id());
|
||||
continue;
|
||||
}
|
||||
wkr.Load_by_page(hpg, ttl, itm.Data_id());
|
||||
}
|
||||
}
|
||||
private static Io_url Make_url(Xow_wiki wiki, String file_name) {return wiki.Fsys_mgr().Root_dir().GenSubFil(wiki.Domain_str() + file_name);}
|
||||
public static final int
|
||||
Id__template_styles = 0
|
||||
, Id__indicators = 2
|
||||
;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
XOWA: the XOWA Offline Wiki Application
|
||||
Copyright (C) 2012-2017 gnosygnu@gmail.com
|
||||
Copyright (C) 2012-2020 gnosygnu@gmail.com
|
||||
|
||||
XOWA is licensed under the terms of the General Public License (GPL) Version 3,
|
||||
or alternatively under the terms of the Apache License Version 2.0.
|
||||
@@ -13,57 +13,82 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.htmls.hxtns.pages; import gplx.*; import gplx.xowa.*; import gplx.xowa.htmls.*; import gplx.xowa.htmls.hxtns.*;
|
||||
import gplx.dbs.*;
|
||||
public class Hxtn_page_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_page"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_page_id, fld_wkr_id, fld_data_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Hxtn_page_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
flds.Add_int_pkey_autonum("id");
|
||||
this.fld_page_id = flds.Add_int("page_id");
|
||||
this.fld_wkr_id = flds.Add_int("wkr_id");
|
||||
this.fld_data_id = flds.Add_int("data_id");
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Stmt_bgn() {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
}
|
||||
public void Stmt_end() {
|
||||
this.Rls();
|
||||
if (!conn.Meta_idx_exists(tbl_name, "pkey"))
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_page_id, fld_wkr_id, fld_data_id));
|
||||
}
|
||||
public void Insert_by_rdr(Db_rdr rdr) {
|
||||
Db_stmt_.Insert_by_rdr(flds, rdr, stmt_insert);
|
||||
}
|
||||
public void Insert_exec(int page_id, int wkr_id, int data_id) {
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_page_id , page_id)
|
||||
.Val_int(fld_wkr_id , wkr_id)
|
||||
.Val_int(fld_data_id , data_id)
|
||||
.Exec_insert();
|
||||
}
|
||||
public List_adp Select_by_page(int page_id) {
|
||||
List_adp rv = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_page_id)
|
||||
.Crt_int(fld_page_id, page_id)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Hxtn_page_itm itm = new Hxtn_page_itm(rdr.Read_int(fld_page_id), rdr.Read_int(fld_wkr_id), rdr.Read_int(fld_data_id));
|
||||
rv.Add(itm);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
package gplx.xowa.htmls.hxtns.pages;
|
||||
|
||||
import gplx.List_adp;
|
||||
import gplx.List_adp_;
|
||||
import gplx.Rls_able;
|
||||
import gplx.dbs.Db_conn;
|
||||
import gplx.dbs.Db_rdr;
|
||||
import gplx.dbs.Db_rdr_;
|
||||
import gplx.dbs.Db_stmt;
|
||||
import gplx.dbs.Db_stmt_;
|
||||
import gplx.dbs.Dbmeta_fld_list;
|
||||
import gplx.dbs.Dbmeta_idx_itm;
|
||||
import gplx.dbs.Dbmeta_tbl_itm;
|
||||
|
||||
public class Hxtn_page_tbl implements Rls_able {
|
||||
private static final String tbl_name = "hxtn_page"; private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
|
||||
private final String fld_page_id, fld_wkr_id, fld_data_id;
|
||||
private final Db_conn conn; private Db_stmt stmt_insert;
|
||||
public Hxtn_page_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
conn.Rls_reg(this);
|
||||
flds.Add_int_pkey_autonum("id");
|
||||
this.fld_page_id = flds.Add_int("page_id");
|
||||
this.fld_wkr_id = flds.Add_int("wkr_id");
|
||||
this.fld_data_id = flds.Add_int("data_id");
|
||||
}
|
||||
public String Tbl_name() {return tbl_name;}
|
||||
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
|
||||
public Db_conn Conn() {return conn;}
|
||||
public void Rls() {
|
||||
stmt_insert = Db_stmt_.Rls(stmt_insert);
|
||||
}
|
||||
public void Stmt_bgn() {
|
||||
stmt_insert = conn.Stmt_insert(tbl_name, flds);
|
||||
}
|
||||
public void Stmt_end() {
|
||||
this.Rls();
|
||||
if (!conn.Meta_idx_exists(tbl_name, "pkey"))
|
||||
conn.Meta_idx_create(Dbmeta_idx_itm.new_unique_by_tbl(tbl_name, "pkey", fld_page_id, fld_wkr_id, fld_data_id));
|
||||
}
|
||||
public void Insert_by_rdr(Db_rdr rdr) {
|
||||
Db_stmt_.Insert_by_rdr(flds, rdr, stmt_insert);
|
||||
}
|
||||
public void Insert_exec(int page_id, int wkr_id, int data_id) {
|
||||
stmt_insert.Clear()
|
||||
.Val_int(fld_page_id , page_id)
|
||||
.Val_int(fld_wkr_id , wkr_id)
|
||||
.Val_int(fld_data_id , data_id)
|
||||
.Exec_insert();
|
||||
}
|
||||
public boolean Exists(int page_id, int wkr_id, int data_id) {
|
||||
Db_rdr rdr = Db_rdr_.Empty;
|
||||
try {
|
||||
rdr = conn.Stmt_select(tbl_name, flds, fld_page_id, fld_wkr_id, fld_data_id)
|
||||
.Crt_int(fld_page_id, page_id)
|
||||
.Crt_int(fld_wkr_id, wkr_id)
|
||||
.Crt_int(fld_data_id, data_id)
|
||||
.Exec_select__rls_auto();
|
||||
return rdr.Move_next();
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
}
|
||||
public List_adp Select_by_page(int page_id) {
|
||||
List_adp rv = List_adp_.New();
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld_page_id)
|
||||
.Crt_int(fld_page_id, page_id)
|
||||
.Exec_select__rls_auto();
|
||||
try {
|
||||
while (rdr.Move_next()) {
|
||||
Hxtn_page_itm itm = new Hxtn_page_itm(rdr.Read_int(fld_page_id), rdr.Read_int(fld_wkr_id), rdr.Read_int(fld_data_id));
|
||||
rv.Add(itm);
|
||||
}
|
||||
} finally {
|
||||
rdr.Rls();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user