mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
v2.3.2.1
This commit is contained in:
parent
d279c70606
commit
80b9928b5c
@ -85,24 +85,27 @@ public class IoEngine_system extends IoEngine_base {
|
||||
}
|
||||
@SuppressWarnings("resource")
|
||||
@Override public String LoadFilStr(IoEngine_xrg_loadFilStr args) {
|
||||
Io_url url = args.Url();
|
||||
Io_url url = args.Url(); String url_str = url.Xto_api();
|
||||
boolean file_exists = ExistsFil_api(url); // check if file exists first to avoid throwing exception; note that most callers pass Missing_ignored; DATE:2015-02-24
|
||||
if (!file_exists) {
|
||||
if (args.MissingIgnored()) return "";
|
||||
else throw Err_Fil_NotFound(url);
|
||||
}
|
||||
// get reader for file
|
||||
InputStream stream = null;
|
||||
try {stream = new FileInputStream(url.Xto_api());}
|
||||
InputStream stream = null;
|
||||
try {stream = new FileInputStream(url_str);}
|
||||
catch (FileNotFoundException e) {
|
||||
if (args.MissingIgnored()) return "";
|
||||
throw Err_Fil_NotFound(e, url);
|
||||
}
|
||||
return Load_from_stream_as_str(stream, url_str);
|
||||
}
|
||||
public static String Load_from_stream_as_str(InputStream stream, String url_str) {
|
||||
InputStreamReader reader = null;
|
||||
try {reader = new InputStreamReader(stream, IoEngineArgs._.LoadFilStr_Encoding);}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
Closeable_Close(stream, url, false);
|
||||
throw Err_Text_UnsupportedEncoding(IoEngineArgs._.LoadFilStr_Encoding, "", url, e);
|
||||
Closeable_Close(stream, url_str, false);
|
||||
throw Err_text_unsupported_encoding(IoEngineArgs._.LoadFilStr_Encoding, "", url_str, e);
|
||||
}
|
||||
|
||||
// make other objects
|
||||
@ -114,17 +117,17 @@ public class IoEngine_system extends IoEngine_base {
|
||||
while (true) {
|
||||
try {pos = reader.read(readerBuffer);}
|
||||
catch (IOException e) {
|
||||
Closeable_Close(stream, url, false);
|
||||
Closeable_Close(reader, url, false);
|
||||
throw Err_.err_key_(e, IoEngineArgs._.Err_IoException, "read data from file failed").Add("url", url.Xto_api()).Add("pos", pos);
|
||||
Closeable_Close(stream, url_str, false);
|
||||
Closeable_Close(reader, url_str, false);
|
||||
throw Err_.err_key_(e, IoEngineArgs._.Err_IoException, "read data from file failed").Add("url", url_str).Add("pos", pos);
|
||||
}
|
||||
if (pos == -1) break;
|
||||
sw.write(readerBuffer, 0, pos);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
Closeable_Close(stream, url, false);
|
||||
Closeable_Close(reader, url, false);
|
||||
Closeable_Close(stream, url_str, false);
|
||||
Closeable_Close(reader, url_str, false);
|
||||
return sw.toString();
|
||||
}
|
||||
@Override public boolean ExistsDir(Io_url url) {return new File(url.Xto_api()).exists();}
|
||||
@ -353,12 +356,13 @@ public class IoEngine_system extends IoEngine_base {
|
||||
XferDir(IoEngine_xrg_xferDir.copy_(src, trg));
|
||||
}
|
||||
}
|
||||
protected static void Closeable_Close(Closeable closeable, Io_url url, boolean throwErr) {
|
||||
protected static void Closeable_Close(Closeable closeable, Io_url url, boolean throwErr) {Closeable_Close(closeable, url.Xto_api(), throwErr);}
|
||||
protected static void Closeable_Close(Closeable closeable, String url_str, boolean throwErr) {
|
||||
if (closeable == null) return;
|
||||
try {closeable.close();}
|
||||
catch (IOException e) {
|
||||
if (throwErr)
|
||||
throw Err_.err_key_(e, IoEngineArgs._.Err_IoException, "close object failed").Add("class", ClassAdp_.NameOf_obj(closeable)).Add("url", url.Xto_api());
|
||||
throw Err_.err_key_(e, IoEngineArgs._.Err_IoException, "close object failed").Add("class", ClassAdp_.NameOf_obj(closeable)).Add("url", url_str);
|
||||
// else
|
||||
// UsrDlg_._.Finally("failed to close FileChannel", "url", url, "apiErr", Err_.Message_err_arg(e));
|
||||
}
|
||||
@ -372,11 +376,11 @@ public class IoEngine_system extends IoEngine_base {
|
||||
if (!Op_sys.Cur().Tid_is_drd())
|
||||
IoEngine_system_xtn.SetWritable(fil, true);
|
||||
}
|
||||
Err Err_Text_UnsupportedEncoding(String encodingName, String text, Io_url url, Exception e) {
|
||||
private static Err Err_text_unsupported_encoding(String encodingName, String text, String url_str, Exception e) {
|
||||
return Err_.err_key_(e, "gplx.texts.UnsupportedEncodingException", "text is in unsupported encoding").CallLevel_1_()
|
||||
.Add("encodingName", encodingName)
|
||||
.Add("text", text)
|
||||
.Add("url", url.Xto_api())
|
||||
.Add("url", url_str)
|
||||
;
|
||||
}
|
||||
boolean user_agent_needs_resetting = true;
|
||||
|
22
140_dbs/src/gplx/dbs/Db_batch_wkr.java
Normal file
22
140_dbs/src/gplx/dbs/Db_batch_wkr.java
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
public interface Db_batch_wkr {
|
||||
void Batch_bgn();
|
||||
void Batch_end();
|
||||
}
|
43
140_dbs/src/gplx/dbs/Db_batch_wkr__attach.java
Normal file
43
140_dbs/src/gplx/dbs/Db_batch_wkr__attach.java
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
public class Db_batch_wkr__attach implements Db_batch_wkr {
|
||||
private final Db_conn conn;
|
||||
private final ListAdp list = ListAdp_.new_();
|
||||
public Db_batch_wkr__attach Add(String alias, Io_url url) {list.Add(new Db_batch_wkr__attach_itm(alias, url)); return this;}
|
||||
public Db_batch_wkr__attach(Db_conn conn) {this.conn = conn;}
|
||||
public void Batch_bgn() {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_wkr__attach_itm itm = (Db_batch_wkr__attach_itm)list.FetchAt(i);
|
||||
conn.Exec_env_db_attach(itm.Alias(), itm.Url());
|
||||
}
|
||||
}
|
||||
public void Batch_end() {
|
||||
int len = list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_wkr__attach_itm itm = (Db_batch_wkr__attach_itm)list.FetchAt(i);
|
||||
conn.Exec_env_db_detach(itm.Alias());
|
||||
}
|
||||
}
|
||||
}
|
||||
class Db_batch_wkr__attach_itm {
|
||||
public Db_batch_wkr__attach_itm(String alias, Io_url url) {this.alias = alias; this.url = url;}
|
||||
public String Alias() {return alias;} private final String alias;
|
||||
public Io_url Url() {return url;} private final Io_url url;
|
||||
}
|
26
140_dbs/src/gplx/dbs/Db_batch_wkr__msg.java
Normal file
26
140_dbs/src/gplx/dbs/Db_batch_wkr__msg.java
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
public class Db_batch_wkr__msg implements Db_batch_wkr {
|
||||
private final Gfo_usr_dlg usr_dlg; private final String msg_pre;
|
||||
public Db_batch_wkr__msg(Gfo_usr_dlg usr_dlg, String msg_pre) {this.usr_dlg = usr_dlg; this.msg_pre = msg_pre;}
|
||||
public Gfo_usr_dlg Usr_dlg() {return usr_dlg;}
|
||||
public String Msg() {return msg;} public Db_batch_wkr__msg Msg_(String v) {msg = v; return this;} private String msg;
|
||||
public void Batch_bgn() {usr_dlg.Plog_many("", "", "bgn:" + msg_pre + "." + msg);}
|
||||
public void Batch_end() {usr_dlg.Plog_many("", "", "end:" + msg_pre + "." + msg);}
|
||||
}
|
31
140_dbs/src/gplx/dbs/Db_batch_wkr__sql.java
Normal file
31
140_dbs/src/gplx/dbs/Db_batch_wkr__sql.java
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
public class Db_batch_wkr__sql implements Db_batch_wkr {
|
||||
private final Db_conn conn; private String sql;
|
||||
public Db_batch_wkr__sql(Db_conn conn, String... lines) {this.conn = conn; this.sql = String_.Concat_lines_nl_skip_last(lines);}
|
||||
public String Sql() {return sql;}
|
||||
public Db_batch_wkr__sql Sql_(String... lines) {sql = String_.Concat_lines_nl_skip_last(lines); return this;}
|
||||
public void Batch_bgn() {
|
||||
conn.Txn_bgn();
|
||||
conn.Exec_sql(sql);
|
||||
conn.Txn_end();
|
||||
}
|
||||
public void Batch_end() {
|
||||
}
|
||||
}
|
@ -26,18 +26,24 @@ public class Db_conn {
|
||||
}
|
||||
public Db_url Url() {return engine.Url();}
|
||||
public Db_txn_mgr Txn_mgr() {return txn_mgr;} private final Db_txn_mgr txn_mgr;
|
||||
public void Txn_bgn() {txn_mgr.Txn_bgn();}
|
||||
public void Txn_commit() {txn_mgr.Txn_end(); txn_mgr.Txn_bgn();}
|
||||
public void Txn_end() {txn_mgr.Txn_end();}
|
||||
public Db_stmt Stmt_insert(String tbl, Db_meta_fld_list flds) {return engine.New_stmt_prep(Db_qry_insert.new_(tbl, flds.To_str_ary()));}
|
||||
public Db_stmt Stmt_insert(String tbl, String... cols) {return engine.New_stmt_prep(Db_qry_insert.new_(tbl, cols));}
|
||||
public Db_stmt Stmt_update(String tbl, String[] where, String... cols) {return engine.New_stmt_prep(Db_qry_update.new_(tbl, where, cols));}
|
||||
public Db_stmt Stmt_update_exclude(String tbl, Db_meta_fld_list flds, String... where) {return engine.New_stmt_prep(Db_qry_update.new_(tbl, where, flds.To_str_ary_exclude(where)));}
|
||||
public Db_stmt Stmt_delete(String tbl, String... where) {return engine.New_stmt_prep(Db_qry_delete.new_(tbl, where));}
|
||||
public Db_stmt Stmt_select(String tbl, String[] cols, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, cols));}
|
||||
public Db_stmt Stmt_select(String tbl, Db_meta_fld_list flds, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, flds.To_str_ary()));}
|
||||
public Db_stmt Stmt_select(String tbl, String[] cols, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, cols, null));}
|
||||
public Db_stmt Stmt_select(String tbl, Db_meta_fld_list flds, String... where) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, flds.To_str_ary(), null));}
|
||||
public Db_stmt Stmt_select_order(String tbl, Db_meta_fld_list flds, String[] where, String... orderbys) {return engine.New_stmt_prep(Db_qry__select_in_tbl.new_(tbl, where, flds.To_str_ary(), orderbys));}
|
||||
public void Exec_create_tbl_and_idx(Db_meta_tbl meta) {
|
||||
engine.Exec_ddl_create_tbl(meta);
|
||||
engine.Exec_ddl_create_idx(Gfo_usr_dlg_.Null, meta.Idxs());
|
||||
}
|
||||
public void Exec_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... idxs) {engine.Exec_ddl_create_idx(usr_dlg, idxs);}
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {engine.Exec_env_db_attach(alias, db_url);}
|
||||
public void Exec_env_db_detach(String alias) {engine.Exec_env_db_detach(alias);}
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {engine.Exec_ddl_append_fld(tbl, fld);}
|
||||
public Db_stmt Rls_reg(Db_stmt stmt) {rls_list.Add(stmt); return stmt;}
|
||||
public void Conn_term() {
|
||||
@ -54,4 +60,23 @@ public class Db_conn {
|
||||
public DataRdr Exec_qry_as_rdr(Db_qry qry) {return DataRdr_.cast_(engine.Exec_as_obj(qry));}
|
||||
public int Exec_sql(String sql) {return this.Exec_qry(Db_qry_sql.dml_(sql));}
|
||||
public DataRdr Exec_sql_as_rdr(String sql) {return this.Exec_qry_as_rdr(Db_qry_sql.rdr_(sql));}
|
||||
public void Exec_sql_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... idxs) {engine.Exec_ddl_create_idx(usr_dlg, idxs);}
|
||||
public void Exec_sql(Db_batch_wkr... wkrs) {
|
||||
int len = wkrs.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Db_batch_wkr wkr = wkrs[i];
|
||||
wkr.Batch_bgn();
|
||||
wkr.Batch_end();
|
||||
}
|
||||
}
|
||||
public void Exec_sql__vacuum(Db_batch_wkr__msg msg) {
|
||||
msg.Msg_("vaccuum");
|
||||
Exec_sql(msg, Batch_sql("VACCUUM;"));
|
||||
}
|
||||
public void Exec_sql__idx(Db_batch_wkr__msg msg, Db_meta_idx... idxs) {
|
||||
engine.Exec_ddl_create_idx(msg.Usr_dlg(), idxs);
|
||||
}
|
||||
public Db_batch_wkr__msg Batch_msg(Gfo_usr_dlg usr_dlg, String msg_pre) {return new Db_batch_wkr__msg(usr_dlg, msg_pre);}
|
||||
public Db_batch_wkr__attach Batch_attach(String alias, Io_url url) {return new Db_batch_wkr__attach(this).Add(alias, url);}
|
||||
public Db_batch_wkr__sql Batch_sql(String... lines) {return new Db_batch_wkr__sql(this, lines);}
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.dbs; import gplx.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.qrys.*;
|
||||
public class Db_qry_ {
|
||||
public static Db_qry_select select_cols_(String tbl, Criteria crt, String... cols){return select_().From_(tbl).Where_(crt).Cols_(cols);}
|
||||
public static Db_qry_select select_val_(String tbl, String col, Criteria crt) {return select_().From_(tbl).Where_(crt).Cols_(col);}
|
||||
public static Db_qry_select select_tbl_(String tbl) {return select_().From_(tbl);}
|
||||
public static Db_qry_select select_() {return Db_qry_select.new_();}
|
||||
public static Db_qry__select_cmd select_cols_(String tbl, Criteria crt, String... cols){return select_().From_(tbl).Where_(crt).Cols_(cols);}
|
||||
public static Db_qry__select_cmd select_val_(String tbl, String col, Criteria crt) {return select_().From_(tbl).Where_(crt).Cols_(col);}
|
||||
public static Db_qry__select_cmd select_tbl_(String tbl) {return select_().From_(tbl);}
|
||||
public static Db_qry__select_cmd select_() {return Db_qry__select_cmd.new_();}
|
||||
public static Db_qry_delete delete_(String tbl, Criteria crt) {return Db_qry_delete.new_(tbl, crt);}
|
||||
public static Db_qry_delete delete_tbl_(String tbl) {return Db_qry_delete.new_(tbl);}
|
||||
public static Db_qry_insert insert_(String tbl) {return new Db_qry_insert(tbl);}
|
||||
|
@ -32,11 +32,11 @@ public class Db_stmt_ {
|
||||
return conn.Stmt_new(qry);
|
||||
}
|
||||
public static Db_stmt new_select_(Db_conn conn, String tbl, String[] where, String... flds) {
|
||||
Db_qry_select qry = Db_qry_.select_cols_(tbl, Db_crt_.eq_many_(where), flds);
|
||||
Db_qry__select_cmd qry = Db_qry_.select_cols_(tbl, Db_crt_.eq_many_(where), flds);
|
||||
return conn.Stmt_new(qry);
|
||||
}
|
||||
public static Db_stmt new_select_in_(Db_conn conn, String tbl, String in_fld, Object[] in_vals, String... flds) {
|
||||
Db_qry_select qry = Db_qry_.select_cols_(tbl, Db_crt_.in_(in_fld, in_vals), flds).OrderBy_asc_(in_fld);
|
||||
Db_qry__select_cmd qry = Db_qry_.select_cols_(tbl, Db_crt_.in_(in_fld, in_vals), flds).OrderBy_asc_(in_fld);
|
||||
return conn.Stmt_new(qry);
|
||||
}
|
||||
public static Db_stmt new_select_all_(Db_conn conn, String tbl) {
|
||||
|
@ -32,4 +32,6 @@ public interface Db_engine {
|
||||
void Exec_ddl_create_tbl(Db_meta_tbl meta);
|
||||
void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary);
|
||||
void Exec_ddl_append_fld(String tbl, Db_meta_fld fld);
|
||||
void Exec_env_db_attach(String alias, Io_url db_url);
|
||||
void Exec_env_db_detach(String alias);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
String sql = this.SqlWtr().Xto_str(qry, false); // DBG: Tfds.Write(sql);
|
||||
return qry.Exec_is_rdr() ? (Object)this.Exec_as_rdr(sql) : this.Exec_as_int(sql);
|
||||
}
|
||||
private int Exec_as_int(String sql) {
|
||||
protected int Exec_as_int(String sql) {
|
||||
try {
|
||||
Statement cmd = New_stmt_exec(sql);
|
||||
return cmd.executeUpdate(sql);
|
||||
@ -65,6 +65,8 @@ public abstract class Db_engine_sql_base implements Db_engine {
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {
|
||||
Exec_as_int(Db_sqlbldr__sqlite.I.Bld_alter_tbl_add(tbl, fld));
|
||||
}
|
||||
@gplx.Virtual public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
@gplx.Virtual public void Exec_env_db_detach(String alias) {}
|
||||
@gplx.Virtual public DataRdr New_rdr(ResultSet rdr, String sql) {return gplx.stores.Db_data_rdr_.new_(rdr, sql);}
|
||||
@gplx.Virtual public Sql_qry_wtr SqlWtr() {return Sql_qry_wtr_.new_ansi();}
|
||||
@gplx.Internal protected abstract Connection Conn_new();
|
||||
|
@ -40,5 +40,7 @@ public class Db_engine__mem implements Db_engine {
|
||||
}
|
||||
public void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {} // TODO: implement unique index
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {}
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Exec_env_db_detach(String alias) {}
|
||||
public static final Db_engine__mem _ = new Db_engine__mem(); Db_engine__mem() {}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class Mem_tbl {
|
||||
String[] select = null; Criteria where = null;
|
||||
Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.as_(stmt.Qry());
|
||||
if (qry == null) {
|
||||
Db_qry_select qry2 = (Db_qry_select)stmt.Qry();
|
||||
Db_qry__select_cmd qry2 = (Db_qry__select_cmd)stmt.Qry();
|
||||
select = qry2.Cols_ary();
|
||||
where = qry2.Where();
|
||||
}
|
||||
|
@ -32,5 +32,7 @@ public class Null_engine implements Db_engine {
|
||||
public void Exec_ddl_create_tbl(Db_meta_tbl meta) {}
|
||||
public void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {}
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {}
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Exec_env_db_detach(String alias) {}
|
||||
public static final Null_engine _ = new Null_engine(); Null_engine() {}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ public class Sqlite_engine extends Db_engine_sql_base {
|
||||
}
|
||||
@Override public DataRdr New_rdr(ResultSet rdr, String commandText) {return Sqlite_rdr.new_(rdr, commandText);}
|
||||
@Override public Db_rdr New_rdr_clone() {return new Db_rdr__sqlite();}
|
||||
@Override public void Exec_env_db_attach(String alias, Io_url db_url) {Exec_as_int(String_.Format("ATTACH '{0}' AS {1};", db_url.Raw(), alias));}
|
||||
@Override public void Exec_env_db_detach(String alias) {Exec_as_int(String_.Format("DETACH {0};", alias));}
|
||||
static boolean loaded = false;
|
||||
@gplx.Internal @Override protected Connection Conn_new() {
|
||||
if (!loaded) {
|
||||
|
@ -57,7 +57,8 @@ public class TdbEngine implements Db_engine {
|
||||
public void Exec_ddl_create_tbl(Db_meta_tbl meta) {throw Err_.not_implemented_();}
|
||||
public void Exec_ddl_create_idx(Gfo_usr_dlg usr_dlg, Db_meta_idx... ary) {throw Err_.not_implemented_();}
|
||||
public void Exec_ddl_append_fld(String tbl, Db_meta_fld fld) {throw Err_.not_implemented_();}
|
||||
|
||||
public void Exec_env_db_attach(String alias, Io_url db_url) {}
|
||||
public void Exec_env_db_detach(String alias) {}
|
||||
|
||||
HashAdp wkrs = HashAdp_.new_(); TdbDbLoadMgr loadMgr = TdbDbLoadMgr.new_(); TdbDbSaveMgr saveMgr = TdbDbSaveMgr.new_();
|
||||
public static final TdbEngine _ = new TdbEngine();
|
||||
|
@ -20,11 +20,11 @@ import gplx.core.criterias.*; import gplx.dbs.qrys.*; import gplx.dbs.sqls.*;
|
||||
import gplx.lists.*; /*ComparerAble*/ import gplx.stores.*; /*GfoNdeRdr*/
|
||||
class TdbSelectWkr implements Db_qryWkr {
|
||||
public Object Exec(Db_engine engineObj, Db_qry cmdObj) {
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry_select cmd = (Db_qry_select)cmdObj;
|
||||
TdbEngine engine = TdbEngine.cast_(engineObj); Db_qry__select_cmd cmd = (Db_qry__select_cmd)cmdObj;
|
||||
if (cmd.From().Tbls().Count() > 1) throw Err_.new_key_("gplx.tdbs", "joins not supported for tdbs").Add("sql", cmd.Xto_sql());
|
||||
|
||||
TdbTable tbl = engine.FetchTbl(cmd.From().BaseTable().TblName());
|
||||
GfoNdeList rv = (cmd.Where() == Db_qry_.WhereAll && cmd.Limit() == Db_qry_select.Limit_disabled) ? rv = tbl.Rows() : FilterRecords(tbl, cmd.Where(), cmd.Limit());
|
||||
GfoNdeList rv = (cmd.Where() == Db_qry_.WhereAll && cmd.Limit() == Db_qry__select_cmd.Limit_disabled) ? rv = tbl.Rows() : FilterRecords(tbl, cmd.Where(), cmd.Limit());
|
||||
if (cmd.GroupBy() != null)
|
||||
rv = TdbGroupByWkr.GroupByExec(cmd, rv, tbl);
|
||||
if (cmd.OrderBy() != null) { // don't use null pattern here; if null ORDER BY, then don't call .Sort on GfoNdeList
|
||||
@ -47,7 +47,7 @@ class TdbSelectWkr implements Db_qryWkr {
|
||||
public static final TdbSelectWkr _ = new TdbSelectWkr(); TdbSelectWkr() {}
|
||||
}
|
||||
class TdbGroupByWkr {
|
||||
public static GfoNdeList GroupByExec(Db_qry_select select, GfoNdeList selectRows, TdbTable tbl) {
|
||||
public static GfoNdeList GroupByExec(Db_qry__select_cmd select, GfoNdeList selectRows, TdbTable tbl) {
|
||||
GfoNdeList rv = GfoNdeList_.new_();
|
||||
OrderedHash groupByHash = OrderedHash_.new_();
|
||||
ListAdp groupByFlds = select.GroupBy().Flds();
|
||||
|
@ -17,11 +17,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.core.criterias.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_select implements Db_qry {
|
||||
public class Db_qry__select_cmd implements Db_qry {
|
||||
public int Tid() {return Db_qry_.Tid_select;}
|
||||
public boolean Exec_is_rdr() {return true;}
|
||||
public String Base_table() {return from.BaseTable().TblName();}
|
||||
public String Xto_sql() {return Sql_qry_wtr_.I.Xto_str(this, false);}
|
||||
public String Xto_sql_prepare() {return Sql_qry_wtr_.I.Xto_str(this, true);}
|
||||
public DataRdr Exec_qry_as_rdr(Db_conn conn) {return conn.Exec_qry_as_rdr(this);}
|
||||
public GfoNde ExecRdr_nde(Db_conn conn) {
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
@ -48,13 +49,13 @@ public class Db_qry_select implements Db_qry {
|
||||
}
|
||||
|
||||
public Sql_from From() {return from;} Sql_from from;
|
||||
public Db_qry_select From_(String tblName) {return From_(tblName, null);}
|
||||
public Db_qry_select From_(String tblName, String alias) {
|
||||
public Db_qry__select_cmd From_(String tblName) {return From_(tblName, null);}
|
||||
public Db_qry__select_cmd From_(String tblName, String alias) {
|
||||
if (from != null) throw Err_.new_("super table already defined").Add("from", from.Tbls().Count());
|
||||
from = Sql_from.new_(Sql_tbl_src.new_().JoinType_(Sql_join_itmType.From).TblName_(tblName).Alias_(alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Join_(String name, String alias, Sql_join_itm... ary) {
|
||||
public Db_qry__select_cmd Join_(String name, String alias, Sql_join_itm... ary) {
|
||||
if (from == null) throw Err_.new_("super table is not defined");
|
||||
Sql_tbl_src tbl = Sql_tbl_src.new_().JoinType_(Sql_join_itmType.Inner).TblName_(name).Alias_(alias);
|
||||
for (Sql_join_itm itm : ary)
|
||||
@ -65,50 +66,50 @@ public class Db_qry_select implements Db_qry {
|
||||
|
||||
public Sql_select Cols() {return cols;} Sql_select cols = Sql_select.All;
|
||||
public String[] Cols_ary() {return cols.Flds().To_str_ary();}
|
||||
public Db_qry_select Cols_all_() {return this;}
|
||||
public Db_qry_select Cols_alias_(String expr, String alias) {
|
||||
public Db_qry__select_cmd Cols_all_() {return this;}
|
||||
public Db_qry__select_cmd Cols_alias_(String expr, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(expr, alias);
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_(String... ary) {
|
||||
public Db_qry__select_cmd Cols_(String... ary) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
for (String itm : ary)
|
||||
cols.Add(itm);
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_max(String fld) {return Cols_groupBy_max(fld, fld);}
|
||||
public Db_qry_select Cols_groupBy_max(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_max(String fld) {return Cols_groupBy_max(fld, fld);}
|
||||
public Db_qry__select_cmd Cols_groupBy_max(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_max(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_min(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_min(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_min(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_count(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_count(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_count(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select Cols_groupBy_sum(String fld) {return Cols_groupBy_sum(fld, fld);}
|
||||
public Db_qry_select Cols_groupBy_sum(String fld, String alias) {
|
||||
public Db_qry__select_cmd Cols_groupBy_sum(String fld) {return Cols_groupBy_sum(fld, fld);}
|
||||
public Db_qry__select_cmd Cols_groupBy_sum(String fld, String alias) {
|
||||
if (cols == Sql_select.All) cols = Sql_select.new_();
|
||||
cols.Add(Sql_select_fld_.new_sum(Sql_select_fld_base.Tbl_null, fld, alias));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Criteria Where() {return where;} public Db_qry_select Where_(Criteria crt) {where = crt; return this;} Criteria where;
|
||||
public Criteria Where() {return where;} public Db_qry__select_cmd Where_(Criteria crt) {where = crt; return this;} Criteria where;
|
||||
public Sql_order_by OrderBy() {return orderBy;} Sql_order_by orderBy = null;
|
||||
public Db_qry_select OrderBy_(String fieldName, boolean ascending) {
|
||||
public Db_qry__select_cmd OrderBy_(String fieldName, boolean ascending) {
|
||||
Sql_order_by_itm item = Sql_order_by_itm.new_(fieldName, ascending);
|
||||
orderBy = Sql_order_by.new_(item);
|
||||
return this;
|
||||
}
|
||||
public Db_qry_select OrderBy_asc_(String fieldName) {return OrderBy_(fieldName, true);}
|
||||
public Db_qry_select OrderBy_many_(String... fldNames) {
|
||||
public Db_qry__select_cmd OrderBy_asc_(String fieldName) {return OrderBy_(fieldName, true);}
|
||||
public Db_qry__select_cmd OrderBy_many_(String... fldNames) {
|
||||
Sql_order_by_itm[] ary = new Sql_order_by_itm[fldNames.length];
|
||||
for (int i = 0; i < fldNames.length; i++)
|
||||
ary[i] = Sql_order_by_itm.new_(fldNames[i], true);
|
||||
@ -116,15 +117,15 @@ public class Db_qry_select implements Db_qry {
|
||||
return this;
|
||||
}
|
||||
public Sql_group_by GroupBy() {return groupBy;} Sql_group_by groupBy = null;
|
||||
public Db_qry_select GroupBy_(String... flds) {
|
||||
public Db_qry__select_cmd GroupBy_(String... flds) {
|
||||
if (groupBy != null) throw Err_.new_("group by already defined").Add("group", groupBy);
|
||||
groupBy = Sql_group_by.new_(flds);
|
||||
return this;
|
||||
}
|
||||
public String Indexed_by() {return indexed_by;} public Db_qry_select Indexed_by_(String v) {indexed_by = v; return this;} private String indexed_by;
|
||||
public Db_qry_select Distinct_() {cols.Distinct_set(true); return this;}
|
||||
public String Indexed_by() {return indexed_by;} public Db_qry__select_cmd Indexed_by_(String v) {indexed_by = v; return this;} private String indexed_by;
|
||||
public Db_qry__select_cmd Distinct_() {cols.Distinct_set(true); return this;}
|
||||
public int Limit() {return limit;} int limit = -1; public static final int Limit_disabled = -1;
|
||||
public Db_qry_select Limit_(int v) {this.limit = v; return this;}
|
||||
public Db_qry__select_cmd Limit_(int v) {this.limit = v; return this;}
|
||||
|
||||
public static Db_qry_select new_() {return new Db_qry_select();} Db_qry_select() {}
|
||||
public static Db_qry__select_cmd new_() {return new Db_qry__select_cmd();} Db_qry__select_cmd() {}
|
||||
}
|
@ -59,11 +59,29 @@ public class Db_qry__select_in_tbl implements Db_qry {
|
||||
return sb.XtoStr();
|
||||
}
|
||||
}
|
||||
public static Db_qry__select_in_tbl new_(String base_table, String[] where_flds, String[] select_flds) {
|
||||
Db_qry__select_in_tbl rv = new Db_qry__select_in_tbl(base_table, select_flds, where_flds, null, null, null, null);
|
||||
public static Db_qry__select_in_tbl new_(String base_table, String[] where_flds, String[] select_flds, String[] order_flds) {
|
||||
String order_by_sql = null;
|
||||
if (order_flds != Order_by_null) {
|
||||
int len = order_flds.length;
|
||||
switch (len) {
|
||||
case 0: break;
|
||||
case 1: order_by_sql = order_flds[0]; break;
|
||||
default:
|
||||
Bry_bfr bfr = Bry_bfr.new_();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
String order_fld = order_flds[i];
|
||||
if (i != 0) bfr.Add_byte_comma();
|
||||
bfr.Add_str_ascii(order_fld);
|
||||
}
|
||||
order_by_sql = bfr.Xto_str_and_clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Db_qry__select_in_tbl rv = new Db_qry__select_in_tbl(base_table, select_flds, where_flds, null, null, order_by_sql, null);
|
||||
rv.where = where_flds.length == 0 ? Db_crt_.Wildcard : Db_crt_.eq_many_(where_flds);
|
||||
return rv;
|
||||
}
|
||||
public static Db_qry__select_in_tbl as_(Object obj) {return obj instanceof Db_qry__select_in_tbl ? (Db_qry__select_in_tbl)obj : null;}
|
||||
public static final String[] Where_flds__all = String_.Ary_empty;
|
||||
public static final String[] Order_by_null = null;
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ public class Db_qry_insert implements Db_qry_arg_owner {
|
||||
}
|
||||
public Db_qry_arg_owner Key_arg_(String k, int v) {return Arg_obj_type_(k, v, Db_val_type.Tid_int32);}
|
||||
public Db_qry_arg_owner Key_arg_(String k, String v) {return Arg_obj_type_(k, v, Db_val_type.Tid_varchar);}
|
||||
public Db_qry_select Select() {return select;} Db_qry_select select;
|
||||
public Db_qry_insert Select_(Db_qry_select qry) {this.select = qry; return this;}
|
||||
public Db_qry__select_cmd Select() {return select;} Db_qry__select_cmd select;
|
||||
public Db_qry_insert Select_(Db_qry__select_cmd qry) {this.select = qry; return this;}
|
||||
public Db_qry_insert Cols_(String... ary) {
|
||||
if (cols == null) cols = Sql_select_fld_list.new_();
|
||||
for (String fld : ary)
|
||||
|
@ -19,8 +19,8 @@ package gplx.dbs.qrys; import gplx.*; import gplx.dbs.*;
|
||||
import org.junit.*; import gplx.dbs.sqls.*;
|
||||
public class Db_qry_select_tst {
|
||||
@Before public void setup() {
|
||||
cmd = Db_qry_select.new_();
|
||||
} Db_qry_select cmd; String expd;
|
||||
cmd = Db_qry__select_cmd.new_();
|
||||
} Db_qry__select_cmd cmd; String expd;
|
||||
@Test public void Basic() {
|
||||
cmd.Cols_("fld0", "fld1").From_("tbl0");
|
||||
expd = "SELECT fld0, fld1 FROM tbl0";
|
||||
@ -76,7 +76,7 @@ public class Db_qry_select_tst {
|
||||
// }
|
||||
// @Test public void Union() {
|
||||
// cmd.From_("tbl0").select("fld0").union_(qry2.from("tbl1").select("fld0"));
|
||||
// cmd.From_("tbl0").select("fld0").union_().from("tbl1").select("fld0"); // feasible, but will be bad later when trying to access Db_qry_select props
|
||||
// cmd.From_("tbl0").select("fld0").union_().from("tbl1").select("fld0"); // feasible, but will be bad later when trying to access Db_qry__select_cmd props
|
||||
// expd = "SELECT fld0 FROM tbl0 UNION SELECT fld0 FROM tbl1";
|
||||
// Tfds.Eq(cmd.XtoStr(), expd);
|
||||
// }
|
||||
|
@ -140,7 +140,7 @@ public class Db_stmt_cmd implements Db_stmt {
|
||||
try {return engine.New_rdr_by_obj(stmt.executeQuery(), sql);} catch (Exception e) {throw Err_.err_(e, "select failed: sql={0}", sql);}
|
||||
}
|
||||
public Object Exec_select_val() {
|
||||
try {Object rv = Db_qry_select.Rdr_to_val(engine.New_rdr(stmt.executeQuery(), sql)); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql);}
|
||||
try {Object rv = Db_qry__select_cmd.Rdr_to_val(engine.New_rdr(stmt.executeQuery(), sql)); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql);}
|
||||
}
|
||||
public Db_stmt Clear() {
|
||||
val_idx = 0;
|
||||
|
@ -114,7 +114,7 @@ public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statemen
|
||||
}
|
||||
public Db_rdr Exec_select_as_rdr() {throw Err_.not_implemented_();}
|
||||
public Object Exec_select_val() {
|
||||
try {Object rv = Db_qry_select.Rdr_to_val(this.Exec_select()); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql_orig);}
|
||||
try {Object rv = Db_qry__select_cmd.Rdr_to_val(this.Exec_select()); return rv;} catch (Exception e) {throw Err_.err_(e, "failed to exec prepared statement: sql={0}", sql_orig);}
|
||||
}
|
||||
public Db_stmt Clear() {
|
||||
args.Clear();
|
||||
@ -136,21 +136,41 @@ public class Db_stmt_sql implements Db_stmt {// used for formatting SQL statemen
|
||||
public Db_stmt Parse(Db_qry qry, String sql_str) {
|
||||
this.qry = qry;
|
||||
this.sql_orig = sql_str;
|
||||
int arg_idx = 0;
|
||||
byte[] src = Bry_.new_utf8_(sql_str);
|
||||
int pos_prv = 0;
|
||||
Init_fmtr(tmp_bfr, tmp_fmtr, sql_str);
|
||||
return this;
|
||||
}
|
||||
private static void Init_fmtr(Bry_bfr tmp_bfr, Bry_fmtr tmp_fmtr, String sql_str) {
|
||||
byte[] sql_bry = Bry_.new_utf8_(sql_str);
|
||||
int arg_idx = 0; int pos_prv = 0;
|
||||
tmp_bfr.Clear();
|
||||
while (true) {
|
||||
int pos_cur = Bry_finder.Find_fwd(src, Byte_ascii.Question, pos_prv);
|
||||
if (pos_cur == Bry_.NotFound) break;
|
||||
tmp_bfr.Add_mid(src, pos_prv, pos_cur);
|
||||
int pos_cur = Bry_finder.Find_fwd(sql_bry, Byte_ascii.Question, pos_prv); if (pos_cur == Bry_.NotFound) break;
|
||||
tmp_bfr.Add_mid(sql_bry, pos_prv, pos_cur);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Tilde).Add_byte(Byte_ascii.Curly_bgn);
|
||||
tmp_bfr.Add_int_variable(arg_idx++);
|
||||
tmp_bfr.Add_byte(Byte_ascii.Curly_end);
|
||||
pos_prv = pos_cur + 1;
|
||||
}
|
||||
tmp_bfr.Add_mid(src, pos_prv, src.length);
|
||||
tmp_bfr.Add_mid(sql_bry, pos_prv, sql_bry.length);
|
||||
tmp_fmtr.Fmt_(tmp_bfr.Xto_bry_and_clear());
|
||||
return this;
|
||||
}
|
||||
public static String Xto_str(Bry_bfr tmp_bfr, Bry_fmtr tmp_fmtr, String sql_str, ListAdp args) {
|
||||
Init_fmtr(tmp_bfr, tmp_fmtr, sql_str);
|
||||
Object[] ary = args.Xto_obj_ary();
|
||||
int len = ary.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Object obj = ary[i];
|
||||
String str = "";
|
||||
if (obj == null)
|
||||
str = "NULL";
|
||||
else {
|
||||
str = Object_.Xto_str_strict_or_null(obj);
|
||||
if (ClassAdp_.Eq(obj.getClass(), String_.Cls_ref_type))
|
||||
str = "'" + String_.Replace(str, "'", "''") + "'";
|
||||
}
|
||||
ary[i] = str;
|
||||
}
|
||||
tmp_fmtr.Bld_bfr_many(tmp_bfr, ary);
|
||||
return tmp_bfr.Xto_str_and_clear();
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
case Db_qry_.Tid_delete: return Bld_qry_delete((Db_qry_delete)cmd);
|
||||
case Db_qry_.Tid_update: return Bld_qry_update((Db_qry_update)cmd);
|
||||
case Db_qry_.Tid_select_in_tbl:
|
||||
case Db_qry_.Tid_select: return Bld_qry_select((Db_qry_select)cmd);
|
||||
case Db_qry_.Tid_select: return Bld_qry_select((Db_qry__select_cmd)cmd);
|
||||
case Db_qry_.Tid_sql: return ((Db_qry_sql)cmd).Xto_sql();
|
||||
default: throw Err_.unhandled(cmd.Tid());
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
Bld_where(sb, cmd.Where());
|
||||
return sb.Xto_str_and_clear();
|
||||
}
|
||||
private String Bld_qry_select(Db_qry_select cmd) {
|
||||
private String Bld_qry_select(Db_qry__select_cmd cmd) {
|
||||
sb.Add("SELECT ");
|
||||
if (cmd.Cols().Distinct()) sb.Add("DISTINCT ");
|
||||
Sql_select_fld_list flds = cmd.Cols().Flds();
|
||||
@ -118,7 +118,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
}
|
||||
}
|
||||
private void Bld_select_limit(String_bldr sb, int limit) {
|
||||
if (limit == Db_qry_select.Limit_disabled) return;
|
||||
if (limit == Db_qry__select_cmd.Limit_disabled) return;
|
||||
sb.Add(" LIMIT ").Add(limit);
|
||||
}
|
||||
private void Bld_clause_from(String_bldr sb, Sql_from from) {
|
||||
@ -197,6 +197,7 @@ public class Sql_qry_wtr_ansi implements Sql_qry_wtr {
|
||||
this.Bld_where_val(sb, crt);
|
||||
}
|
||||
public void Bld_where_val(String_bldr sb, Criteria crt) {
|
||||
if (crt == null) return; // handle empty crt; EX: SELECT * FROM tbl;
|
||||
Criteria_bool_base crt_bool = Criteria_bool_base.as_(crt);
|
||||
if (crt_bool != null) {
|
||||
sb.Add("(");
|
||||
|
@ -19,7 +19,7 @@ package gplx.dbs.utls; import gplx.*; import gplx.dbs.*;
|
||||
import gplx.dbs.qrys.*;
|
||||
public class PoolIds {
|
||||
public int FetchNext(Db_conn conn, String url) {
|
||||
Db_qry_select cmd = Db_qry_.select_().From_(Tbl_Name).Where_(Db_crt_.eq_(Fld_id_path, url));
|
||||
Db_qry__select_cmd cmd = Db_qry_.select_().From_(Tbl_Name).Where_(Db_crt_.eq_(Fld_id_path, url));
|
||||
int rv = 0;//boolean isNew = true;
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
try {
|
||||
|
@ -112,7 +112,7 @@ class CrudOpsFxt {
|
||||
this.Init();
|
||||
String val = "Ω";
|
||||
fx.tst_ExecDml(1, Db_qry_.insert_("dbs_crud_ops").Arg_("id", 3).Arg_obj_type_("name", val, Db_val_type.Tid_nvarchar));
|
||||
Db_qry_select select = Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("id", 3));
|
||||
Db_qry__select_cmd select = Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("id", 3));
|
||||
Tfds.Eq(val, ExecRdr_val(select));
|
||||
|
||||
fx.tst_ExecDml(1, Db_qry_.update_("dbs_crud_ops", Db_crt_.Wildcard).Arg_obj_type_("name", val + "a", Db_val_type.Tid_nvarchar));
|
||||
@ -125,5 +125,5 @@ class CrudOpsFxt {
|
||||
Tfds.Eq(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("id", 3))));
|
||||
Tfds.Eq(val, ExecRdr_val(Db_qry_.select_val_("dbs_crud_ops", "name", Db_crt_.eq_("name", "\\"))));
|
||||
}
|
||||
String ExecRdr_val(Db_qry_select select) {return (String)select.ExecRdr_val(fx.Conn());}
|
||||
String ExecRdr_val(Db_qry__select_cmd select) {return (String)select.ExecRdr_val(fx.Conn());}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public abstract class GroupBys_base_tst {
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Arg_("key1", "a").Arg_("val_int", 1));
|
||||
conn.Exec_qry(Db_qry_.insert_("dbs_group_bys").Arg_("key1", "a").Arg_("val_int", 2));
|
||||
|
||||
Db_qry_select qry = Db_qry_.select_().From_("dbs_group_bys")
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_("dbs_group_bys")
|
||||
.Cols_("key1")
|
||||
.GroupBy_("key1");
|
||||
int expd = min ? 1 : 2;
|
||||
|
@ -35,10 +35,10 @@ public abstract class InsertIntos_base_tst {
|
||||
(Db_qry_.insert_("dbs_insert_intos")
|
||||
.Cols_("key1", "val_int")
|
||||
.Select_
|
||||
( Db_qry_select.new_().Cols_("key1", "val_int").From_("dbs_group_bys")
|
||||
( Db_qry__select_cmd.new_().Cols_("key1", "val_int").From_("dbs_group_bys")
|
||||
)
|
||||
);
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry_select.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry__select_cmd.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "key1", "a");
|
||||
}
|
||||
@ -50,10 +50,10 @@ public abstract class InsertIntos_base_tst {
|
||||
(Db_qry_.insert_("dbs_insert_intos")
|
||||
.Cols_("key1", "val_int")
|
||||
.Select_
|
||||
( Db_qry_select.new_().Cols_("key1").Cols_groupBy_sum("val_int", "val_int_func")
|
||||
( Db_qry__select_cmd.new_().Cols_("key1").Cols_groupBy_sum("val_int", "val_int_func")
|
||||
.From_("dbs_group_bys").GroupBy_("key1")
|
||||
));
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry_select.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(Db_qry__select_cmd.new_().Cols_("key1", "val_int").From_("dbs_insert_intos"));
|
||||
GfoNde nde = GfoNde_.rdr_(rdr);
|
||||
GfoNdeTstr.tst_ValsByCol(nde, "val_int", 3);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public abstract class Joins_base_tst {
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_crud_ops").Arg_("id", 1).Arg_("name", "you"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_join1").Arg_("join_id", 0).Arg_("join_data", "data0"));
|
||||
conn.Exec_qry(new Db_qry_insert("dbs_join1").Arg_("join_id", 1).Arg_("join_data", "data1"));
|
||||
Db_qry_select select = Db_qry_select.new_().From_("dbs_crud_ops").Join_("dbs_join1", "j1", Sql_join_itm.new_("join_id", "dbs_crud_ops", "id")).Cols_("id", "name", "join_data");
|
||||
Db_qry__select_cmd select = Db_qry__select_cmd.new_().From_("dbs_crud_ops").Join_("dbs_join1", "j1", Sql_join_itm.new_("join_id", "dbs_crud_ops", "id")).Cols_("id", "name", "join_data");
|
||||
|
||||
DataRdr rdr = conn.Exec_qry_as_rdr(select);
|
||||
GfoNde table = GfoNde_.rdr_(rdr);
|
||||
|
@ -29,11 +29,11 @@ public abstract class OrderBys_base_tst {
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 1).Arg_("name", "you"));
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 0).Arg_("name", "me"));
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 1, "you");
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_RowAry(0, 1, "you");
|
||||
fx.tst_RowAry(1, 0, "me");
|
||||
}
|
||||
@ -41,11 +41,11 @@ public abstract class OrderBys_base_tst {
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 0).Arg_("name", "me"));
|
||||
fx.tst_ExecDml(1, new Db_qry_insert("dbs_crud_ops").Arg_("id", 0).Arg_("name", "you"));
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", true));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 0, "you");
|
||||
|
||||
fx.tst_ExecRdr(2, Db_qry_select.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_ExecRdr(2, Db_qry__select_cmd.new_().From_("dbs_crud_ops").OrderBy_("id", false));
|
||||
fx.tst_RowAry(0, 0, "me");
|
||||
fx.tst_RowAry(1, 0, "you");
|
||||
}
|
||||
|
@ -112,8 +112,8 @@ public class Bit_ {
|
||||
int[] rv = new int[Pow_ary_date_short.length];
|
||||
Xto_date_short_int_ary(rv, v);
|
||||
return DateAdp_.seg_(rv);
|
||||
}
|
||||
private static final int[] Pow_ary_date_short = new int[] {1048576, 65536, 2048, 64, 1};
|
||||
}
|
||||
private static final int[] Pow_ary_date_short = new int[] {1048576, 65536, 2048, 64, 1}; // yndhm -> 12,4,5,5,6
|
||||
private static final int[] Base2_ary = new int[]
|
||||
{ 1, 2, 4, 8, 16, 32, 64, 128
|
||||
, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768
|
||||
|
@ -28,7 +28,7 @@ class Schema_loader_mgr__sqlite implements Schema_loader_mgr {
|
||||
public void Load(Schema_db_mgr db_mgr, Db_conn conn) {
|
||||
Gfo_usr_dlg_._.Log_many("", "", "db.schema.load.bgn: conn=~{0}", conn.Url().Xto_api());
|
||||
Schema_tbl_mgr tbl_mgr = db_mgr.Tbl_mgr();
|
||||
Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.new_("sqlite_master", String_.Ary_empty, String_.Ary("type", "name", "sql"));
|
||||
Db_qry__select_in_tbl qry = Db_qry__select_in_tbl.new_("sqlite_master", String_.Ary_empty, String_.Ary("type", "name", "sql"), Db_qry__select_in_tbl.Order_by_null);
|
||||
Db_stmt stmt = Db_stmt_.new_select_as_rdr(conn, qry);
|
||||
Db_rdr rdr = stmt.Exec_select_as_rdr();
|
||||
while (rdr.Move_next()) {
|
||||
|
@ -18,8 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
public class Fsd_dir_itm {
|
||||
public Fsd_dir_itm(int id, int owner, String name) {this.id = id; this.owner = owner; this.name = name;}
|
||||
public int Id() {return id;} public Fsd_dir_itm Id_(int v) {id = v; return this;} private int id;
|
||||
public int Owner() {return owner;} public Fsd_dir_itm Owner_(int v) {owner = v; return this;} private int owner;
|
||||
public String Name() {return name;} public Fsd_dir_itm Name_(String v) {name = v; return this;} private String name;
|
||||
public int Id() {return id;} private final int id;
|
||||
public int Owner() {return owner;} private final int owner;
|
||||
public String Name() {return name;} private final String name;
|
||||
public static final Fsd_dir_itm Null = new Fsd_dir_itm(0, 0, "");
|
||||
}
|
||||
|
@ -17,13 +17,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
public class Fsd_fil_itm {
|
||||
public int Id() {return id;} public Fsd_fil_itm Id_(int v) {id = v; return this;} private int id;
|
||||
public int Owner() {return owner;} public Fsd_fil_itm Owner_(int v) {owner = v; return this;} private int owner;
|
||||
public int Ext_id() {return ext_id;} public Fsd_fil_itm Ext_id_(int v) {ext_id = v; return this;} private int ext_id;
|
||||
public String Name() {return name;} public Fsd_fil_itm Name_(String v) {name = v; return this;} private String name;
|
||||
public int Db_bin_id() {return bin_db_id;} public Fsd_fil_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
|
||||
public int Id() {return id;} private int id;
|
||||
public int Owner() {return owner;} private int owner;
|
||||
public int Ext_id() {return ext_id;} private int ext_id;
|
||||
public String Name() {return name;} private String name;
|
||||
public int Db_bin_id() {return bin_db_id;} private int bin_db_id;
|
||||
public int Mnt_id() {return mnt_id;} public Fsd_fil_itm Mnt_id_(int v) {mnt_id = v; return this;} private int mnt_id;
|
||||
public Fsd_fil_itm Init(int id, int owner, int ext_id, String name, int bin_db_id) {this.id = id; this.owner = owner; this.ext_id = ext_id; this.name = name; this.bin_db_id = bin_db_id; return this;}
|
||||
public void Init_for_insert(int bin_db_id, int dir_id, int fil_id) {
|
||||
this.bin_db_id = bin_db_id; this.owner = dir_id; this.id = fil_id;
|
||||
}
|
||||
public static final int Null_id = 0;
|
||||
public static final Fsd_fil_itm Null = new Fsd_fil_itm().Init(Null_id, 0, 0, "", Fsd_bin_tbl.Null_db_bin_id);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class Fsd_fil_tbl {
|
||||
}
|
||||
public Fsd_fil_itm Select_itm_by_name(int dir_id, String fil_name) {
|
||||
if (stmt_select_by_name == null) {
|
||||
Db_qry_select qry = Db_qry_select.new_().From_(tbl_name).Cols_(flds.To_str_ary()).Where_(Db_crt_.eq_many_(fld_owner_id, fld_name)).Indexed_by_(Idx_owner);
|
||||
Db_qry__select_cmd qry = Db_qry__select_cmd.new_().From_(tbl_name).Cols_(flds.To_str_ary()).Where_(Db_crt_.eq_many_(fld_owner_id, fld_name)).Indexed_by_(Idx_owner);
|
||||
stmt_select_by_name = conn.Rls_reg(conn.Stmt_new(qry));
|
||||
}
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
|
@ -17,25 +17,56 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
public class Fsd_thm_itm {
|
||||
protected Fsd_thm_itm() {}
|
||||
public void Ctor(int id, int owner_id, int w, double time, int page, int h, long size, String modified, String hash) {
|
||||
this.id = id; this.owner_id = owner_id; this.width = w; this.thumbtime = time; this.page = page; this.height = h; this.size = size; this.modified = modified; this.hash = hash;
|
||||
public int Id() {return id;} private int id;
|
||||
public int Owner_id() {return owner_id;} private int owner_id;
|
||||
public int W() {return w;} private int w;
|
||||
public double Time() {return time;} private double time;
|
||||
public int Page() {return page;} private int page;
|
||||
public int H() {return h;} private int h;
|
||||
public long Size() {return size;} private long size;
|
||||
public String Modified() {return modified;} private String modified;
|
||||
public String Hash() {return hash;} private String hash;
|
||||
public int Dir_id() {return dir_id;} private int dir_id;
|
||||
public int Db_bin_id() {return bin_db_id;} private int bin_db_id;
|
||||
public int Mnt_id() {return mnt_id;} private int mnt_id;
|
||||
public int Req_w() {return req_w;} private int req_w;
|
||||
public double Req_time() {return req_time;} private double req_time;
|
||||
public int Req_page() {return req_page;} private int req_page;
|
||||
public void Init_by_load(int bin_db_id, int id, int owner_id, int w, double time, int page, int h, long size, String modified, String hash) {
|
||||
this.bin_db_id = bin_db_id; this.id = id; this.owner_id = owner_id;
|
||||
this.w = w; this.time = time; this.page = page; this.h = h; this.size = size; this.modified = modified; this.hash = hash;
|
||||
}
|
||||
public int Id() {return id;} public Fsd_thm_itm Id_(int v) {id = v; return this;} private int id;
|
||||
public Fsd_fil_itm Owner() {return owner;} public Fsd_thm_itm Owner_(Fsd_fil_itm v) {owner = v; return this;} private Fsd_fil_itm owner = Fsd_fil_itm.Null;
|
||||
public int Owner_id() {return owner_id;} public Fsd_thm_itm Owner_id_(int v) {owner_id = v; return this;} private int owner_id;
|
||||
public int Width() {return width;} public Fsd_thm_itm Width_(int v) {width = v; return this;} private int width;
|
||||
public double Thumbtime() {return thumbtime;} public Fsd_thm_itm Thumbtime_(double v) {thumbtime = v; return this;} private double thumbtime;
|
||||
public int Page() {return page;} public Fsd_thm_itm Page_(int v) {page = v; return this;} private int page;
|
||||
public int Height() {return height;} public Fsd_thm_itm Height_(int v) {height = v; return this;} private int height;
|
||||
public long Size() {return size;} public Fsd_thm_itm Size_(long v) {size = v; return this;} private long size;
|
||||
public String Modified() {return modified;} public Fsd_thm_itm Modified_(String v) {modified = v; return this;} private String modified;
|
||||
public String Hash() {return hash;} public Fsd_thm_itm Hash_(String v) {hash = v; return this;} private String hash;
|
||||
public int Dir_id() {return dir_id;} public Fsd_thm_itm Dir_id_(int v) {dir_id = v; return this;} private int dir_id;
|
||||
public int Db_bin_id() {return bin_db_id;} public Fsd_thm_itm Db_bin_id_(int v) {bin_db_id = v; return this;} private int bin_db_id;
|
||||
public int Mnt_id() {return mnt_id;} public Fsd_thm_itm Mnt_id_(int v) {mnt_id = v; return this;} private int mnt_id;
|
||||
public static Fsd_thm_itm new_() {return new Fsd_thm_itm();} // NOTE: Owner is null by default
|
||||
public static Fsd_thm_itm load_() {return new Fsd_thm_itm().Owner_(new Fsd_fil_itm());} // NOTE: Owner is new'd b/c load will use owner.Ext_id
|
||||
public void Init_by_insert(int bin_db_id, int dir_id, int fil_id, int thm_id) {this.bin_db_id = bin_db_id; this.dir_id = dir_id; this.owner_id = fil_id; this.id = thm_id;}
|
||||
public void Init_by_req(int w, double time, int page) {this.w = w; this.time = time; this.page = page;}
|
||||
public void Init_by_match(Fsd_thm_itm comp) {
|
||||
this.req_w = w;
|
||||
this.req_time = time;
|
||||
this.req_page = page;
|
||||
this.id = comp.id;
|
||||
this.owner_id = comp.owner_id;
|
||||
this.w = comp.w;
|
||||
this.time = comp.time;
|
||||
this.page = comp.page;
|
||||
this.h = comp.h;
|
||||
this.size = comp.size;
|
||||
this.modified = comp.modified;
|
||||
this.hash = comp.hash;
|
||||
this.dir_id = comp.dir_id;
|
||||
this.bin_db_id = comp.bin_db_id;
|
||||
this.mnt_id = comp.mnt_id;
|
||||
}
|
||||
public Fsd_thm_itm Mnt_id_(int v) {mnt_id = v; return this;}
|
||||
public static final Fsd_thm_itm Null = new Fsd_thm_itm();
|
||||
public static final Fsd_thm_itm[] Ary_empty = new Fsd_thm_itm[0];
|
||||
public static Fsd_thm_itm new_() {return new Fsd_thm_itm();} Fsd_thm_itm() {}
|
||||
}
|
||||
class Fsdb_thm_itm_sorter implements gplx.lists.ComparerAble {
|
||||
public int compare(Object lhsObj, Object rhsObj) {
|
||||
Fsd_thm_itm lhs = (Fsd_thm_itm)lhsObj;
|
||||
Fsd_thm_itm rhs = (Fsd_thm_itm)rhsObj;
|
||||
int comp = Int_.Compare (lhs.W() , rhs.W()); if (comp != CompareAble_.Same) return -comp; // sort by decreasing width
|
||||
comp = Double_.Compare (lhs.Time() , rhs.Time()); if (comp != CompareAble_.Same) return comp; // sort by increasing time
|
||||
return Int_.Compare (lhs.Page() , rhs.Page()); // sort by increasing page
|
||||
}
|
||||
public static final Fsdb_thm_itm_sorter I = new Fsdb_thm_itm_sorter(); Fsdb_thm_itm_sorter() {}
|
||||
}
|
||||
|
@ -75,11 +75,11 @@ public class Fsd_thm_tbl {
|
||||
.Val_int(fld_w, width)
|
||||
.Val_int(fld_h, height);
|
||||
if (this.Schema_thm_page()) {
|
||||
stmt_insert.Val_double (fld_time, gplx.xowa.files.Xof_doc_thumb.Db_save_double(thumbtime));
|
||||
stmt_insert.Val_int (fld_page, gplx.xowa.files.Xof_doc_page.Db_save_int(page));
|
||||
stmt_insert.Val_double (fld_time, gplx.xowa.files.Xof_lnki_time.Db_save_double(thumbtime));
|
||||
stmt_insert.Val_int (fld_page, gplx.xowa.files.Xof_lnki_page.Db_save_int(page));
|
||||
}
|
||||
else
|
||||
stmt_insert.Val_int (fld_thumbtime, gplx.xowa.files.Xof_doc_thumb.Db_save_int(thumbtime));
|
||||
stmt_insert.Val_int (fld_thumbtime, gplx.xowa.files.Xof_lnki_time.Db_save_int(thumbtime));
|
||||
stmt_insert
|
||||
.Val_int(fld_bin_db_id, bin_db_id)
|
||||
.Val_long(fld_size, size)
|
||||
@ -88,7 +88,7 @@ public class Fsd_thm_tbl {
|
||||
.Exec_insert();
|
||||
}
|
||||
private Db_stmt Select_by_fil_w_stmt() {
|
||||
Db_qry_select qry = Db_qry_.select_().From_(tbl_name).Cols_all_();
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_(tbl_name).Cols_all_();
|
||||
gplx.core.criterias.Criteria crt
|
||||
= this.Schema_thm_page()
|
||||
? Db_crt_.eq_many_(fld_owner_id, fld_w, fld_time, fld_page)
|
||||
@ -103,14 +103,14 @@ public class Fsd_thm_tbl {
|
||||
try {
|
||||
stmt_select_by_fil_w.Clear()
|
||||
.Crt_int(fld_owner_id, owner_id)
|
||||
.Crt_int(fld_w, thm.Width())
|
||||
.Crt_int(fld_w, thm.W())
|
||||
;
|
||||
if (this.Schema_thm_page()) {
|
||||
stmt_select_by_fil_w.Crt_double(fld_time, gplx.xowa.files.Xof_doc_thumb.Db_save_double(thm.Thumbtime()));
|
||||
stmt_select_by_fil_w.Crt_int(fld_page, gplx.xowa.files.Xof_doc_page.Db_save_int(thm.Page()));
|
||||
stmt_select_by_fil_w.Crt_double(fld_time, gplx.xowa.files.Xof_lnki_time.Db_save_double(thm.Time()));
|
||||
stmt_select_by_fil_w.Crt_int(fld_page, gplx.xowa.files.Xof_lnki_page.Db_save_int(thm.Page()));
|
||||
}
|
||||
else {
|
||||
stmt_select_by_fil_w.Crt_int(fld_time, gplx.xowa.files.Xof_doc_thumb.Db_save_int(thm.Thumbtime()));
|
||||
stmt_select_by_fil_w.Crt_int(fld_time, gplx.xowa.files.Xof_lnki_time.Db_save_int(thm.Time()));
|
||||
}
|
||||
rdr = stmt_select_by_fil_w.Exec_select_as_rdr();
|
||||
return rdr.Move_next()
|
||||
@ -119,6 +119,21 @@ public class Fsd_thm_tbl {
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
public boolean Select_itm_by_fil_width2(int owner_id, Fsd_thm_itm thm) {
|
||||
if (stmt_select_by_fil_w == null) stmt_select_by_fil_w = conn.Rls_reg(conn.Stmt_select(tbl_name, flds, fld_owner_id));
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
try {
|
||||
ListAdp list = ListAdp_.new_();
|
||||
rdr = stmt_select_by_fil_w.Clear().Crt_int(fld_owner_id, thm.Owner_id()).Exec_select_as_rdr();
|
||||
while (rdr.Move_next()) {
|
||||
Fsd_thm_itm itm = Fsd_thm_itm.new_();
|
||||
Ctor_by_load(itm, rdr, this.Schema_thm_page());
|
||||
list.Add(itm);
|
||||
}
|
||||
return Match_nearest(list, thm, schema_thm_page);
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private boolean Ctor_by_load(Fsd_thm_itm itm, Db_rdr rdr, boolean schema_thm_page) {
|
||||
int id = rdr.Read_int(fld_id);
|
||||
int owner_id = rdr.Read_int(fld_owner_id);
|
||||
@ -131,17 +146,39 @@ public class Fsd_thm_tbl {
|
||||
double time = 0;
|
||||
int page = 0;
|
||||
if (schema_thm_page) {
|
||||
time = gplx.xowa.files.Xof_doc_thumb.Db_load_double(rdr, fld_time);
|
||||
page = gplx.xowa.files.Xof_doc_page.Db_load_int(rdr, fld_page);
|
||||
time = gplx.xowa.files.Xof_lnki_time.Db_load_double(rdr, fld_time);
|
||||
page = gplx.xowa.files.Xof_lnki_page.Db_load_int(rdr, fld_page);
|
||||
}
|
||||
else {
|
||||
time = gplx.xowa.files.Xof_doc_thumb.Db_load_int(rdr, fld_thumbtime);
|
||||
page = gplx.xowa.files.Xof_doc_page.Null;
|
||||
time = gplx.xowa.files.Xof_lnki_time.Db_load_int(rdr, fld_thumbtime);
|
||||
page = gplx.xowa.files.Xof_lnki_page.Null;
|
||||
}
|
||||
itm.Ctor(id, owner_id, width, time, page, height, size, modified, hash);
|
||||
itm.Db_bin_id_(bin_db_id);
|
||||
itm.Init_by_load(bin_db_id, id, owner_id, width, time, page, height, size, modified, hash);
|
||||
return true;
|
||||
}
|
||||
public static final DateAdp Modified_null = null;
|
||||
public static final String Hash_null = "";
|
||||
public static boolean Match_nearest(ListAdp list, Fsd_thm_itm thm, boolean schema_thm_page) {
|
||||
int len = list.Count(); if (len == 0) return Bool_.N;
|
||||
list.SortBy(Fsdb_thm_itm_sorter.I);
|
||||
int thm_w = thm.W(), thm_page = thm.Page(); double thm_time = thm.Time();
|
||||
Fsd_thm_itm max = null;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Fsd_thm_itm comp = (Fsd_thm_itm)list.FetchAt(i);
|
||||
int comp_w = comp.W();
|
||||
int comp_page = schema_thm_page ? comp.Page() : thm_page;
|
||||
if ( thm_w == comp_w
|
||||
&& thm_time == comp.Time()
|
||||
&& thm_page == comp_page
|
||||
) { // exact match
|
||||
thm.Init_by_match(comp);
|
||||
return Bool_.Y;
|
||||
}
|
||||
if (comp_w > thm_w) max = comp;
|
||||
else break;
|
||||
}
|
||||
if (max == null) return Bool_.N;
|
||||
thm.Init_by_match(max);
|
||||
return Bool_.Y;
|
||||
}
|
||||
}
|
||||
|
58
400_xowa/src/gplx/fsdb/data/Fsd_thm_tbl_tst.java
Normal file
58
400_xowa/src/gplx/fsdb/data/Fsd_thm_tbl_tst.java
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
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.fsdb.data; import gplx.*; import gplx.fsdb.*;
|
||||
import org.junit.*;
|
||||
public class Fsd_thm_tbl_tst {
|
||||
@Before public void init() {fxt.Clear();} private Fsd_thm_tbl_fxt fxt = new Fsd_thm_tbl_fxt();
|
||||
@Test public void Basic() {
|
||||
fxt.Init_list(fxt.Make(100), fxt.Make(200), fxt.Make(400));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(400), fxt.Make(400));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(200), fxt.Make(200));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(100), fxt.Make(100));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(350), fxt.Make(400));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(150), fxt.Make(200));
|
||||
fxt.Test_match_nearest_itm(fxt.Make(500), Fsd_thm_itm.Null);
|
||||
}
|
||||
@Test public void Empty() {
|
||||
fxt.Init_list(); // no items
|
||||
fxt.Test_match_nearest_itm(fxt.Make(100), Fsd_thm_itm.Null);
|
||||
}
|
||||
}
|
||||
class Fsd_thm_tbl_fxt {
|
||||
private final ListAdp list = ListAdp_.new_();
|
||||
public void Clear() {list.Clear();}
|
||||
public Fsd_thm_itm Make(int w) {
|
||||
double time = gplx.xowa.files.Xof_lnki_time.Null;
|
||||
int page = gplx.xowa.files.Xof_lnki_page.Null;
|
||||
Fsd_thm_itm rv = Fsd_thm_itm.new_();
|
||||
rv.Init_by_req(w, time, page);
|
||||
return rv;
|
||||
}
|
||||
public void Init_list(Fsd_thm_itm... ary) {list.AddMany((Object[])ary);}
|
||||
public void Test_match_nearest_itm(Fsd_thm_itm req, Fsd_thm_itm expd) {
|
||||
Fsd_thm_tbl.Match_nearest(list, req, Bool_.Y);
|
||||
if (expd == Fsd_thm_itm.Null) {
|
||||
Tfds.Eq(req.Req_w(), 0);
|
||||
}
|
||||
else {
|
||||
Tfds.Eq(expd.W(), req.W());
|
||||
Tfds.Eq(expd.Time(), req.Time());
|
||||
Tfds.Eq(expd.Page(), req.Page());
|
||||
}
|
||||
}
|
||||
}
|
@ -42,14 +42,12 @@ public class Fsm_abc_mgr implements RlsAble {
|
||||
}
|
||||
public void Fil_insert(Fsd_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
|
||||
rv.Db_bin_id_(bin_db_id);
|
||||
int fil_id = atr_mgr.Fil_insert(rv, dir, fil, ext_id, modified, hash, bin_db_id, bin_len, bin_rdr);
|
||||
bin_len = bin_mgr.Insert(bin_db_id, fil_id, Fsd_bin_tbl.Owner_tid_fil, bin_len, bin_rdr);
|
||||
bin_mgr.Increment(bin_len);
|
||||
}
|
||||
public void Thm_insert(Fsd_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
int bin_db_id = bin_mgr.Get_id_for_insert(bin_len);
|
||||
rv.Db_bin_id_(bin_db_id);
|
||||
int thm_id = atr_mgr.Thm_insert(rv, dir, fil, ext_id, w, h, thumbtime, page, modified, hash, bin_db_id, bin_len, bin_rdr);
|
||||
bin_len = bin_mgr.Insert(bin_db_id, thm_id, Fsd_bin_tbl.Owner_tid_thm, bin_len, bin_rdr);
|
||||
bin_mgr.Increment(bin_len);
|
||||
|
@ -73,7 +73,7 @@ public class Fsm_atr_fil implements RlsAble {
|
||||
public int Fil_insert(Fsd_fil_itm rv, String dir, String fil, int ext_id, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
int dir_id = Dir_id__get_or_insert(dir);
|
||||
int fil_id = Fil_id__get_or_insert(Xtn_tid_none, dir_id, fil, ext_id, modified, hash, bin_db_id, bin_len);
|
||||
rv.Id_(fil_id).Owner_(dir_id);
|
||||
rv.Init_for_insert(bin_db_id, dir_id, fil_id);
|
||||
return fil_id;
|
||||
}
|
||||
public int Img_insert(Fsd_img_itm rv, String dir, String fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, int bin_db_id, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
@ -87,7 +87,7 @@ public class Fsm_atr_fil implements RlsAble {
|
||||
int fil_id = Fil_id__get_or_insert(Xtn_tid_thm, dir_id, fil, ext_id, modified, hash, Fsd_bin_tbl.Null_db_bin_id, Fsd_bin_tbl.Null_size); // NOTE: bin_db_id must be set to NULL
|
||||
int thm_id = abc_mgr.Next_id();
|
||||
tbl_thm.Insert(thm_id, fil_id, thm_w, thm_h, thumbtime, page, bin_db_id, bin_len, modified, hash);
|
||||
rv.Id_(thm_id).Owner_id_(fil_id).Dir_id_(dir_id);
|
||||
rv.Init_by_insert(bin_db_id, dir_id, fil_id, thm_id);
|
||||
return thm_id;
|
||||
}
|
||||
public static Fsm_atr_fil make_(Fsm_abc_mgr abc_mgr, int id, Io_url url, String path_bgn) {
|
||||
|
@ -40,7 +40,7 @@ public class Fsm_bin_tbl {
|
||||
}
|
||||
public Fsm_bin_fil[] Select_all(Io_url dir) {
|
||||
ListAdp rv = ListAdp_.new_();
|
||||
Db_qry qry = Db_qry_select.new_().From_(tbl_name).Cols_all_().Where_(Db_crt_.eq_many_(Db_meta_fld.Ary_empy)).OrderBy_asc_(fld_uid);
|
||||
Db_qry qry = Db_qry__select_cmd.new_().From_(tbl_name).Cols_all_().Where_(Db_crt_.eq_many_(Db_meta_fld.Ary_empy)).OrderBy_asc_(fld_uid);
|
||||
Db_rdr rdr = Db_rdr_.Null;
|
||||
try {
|
||||
rdr = conn.Stmt_new(qry).Clear().Exec_select_as_rdr();
|
||||
|
@ -76,12 +76,15 @@ public class Fsm_mnt_mgr implements GfoInvkAble {
|
||||
return false;
|
||||
}
|
||||
public int Insert_to_mnt() {return insert_to_mnt;} public Fsm_mnt_mgr Insert_to_mnt_(int v) {insert_to_mnt = v; return this;} private int insert_to_mnt = Mnt_idx_user;
|
||||
public void Fil_insert(Fsd_fil_itm rv , byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
public void Fil_insert(byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {Fil_insert(new Fsd_fil_itm(), dir, fil, ext_id, modified, hash, bin_len, bin_rdr);}
|
||||
public void Fil_insert(Fsd_fil_itm rv, byte[] dir, byte[] fil, int ext_id, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
ary[insert_to_mnt].Fil_insert(rv, dir, fil, ext_id, modified, hash, bin_len, bin_rdr);
|
||||
}
|
||||
public void Thm_insert(Fsd_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double thumbtime, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
ary[insert_to_mnt].Thm_insert(rv, dir, fil, ext_id, w, h, thumbtime, page, modified, hash, bin_len, bin_rdr);
|
||||
public void Thm_insert(byte[] dir, byte[] fil, int ext_id, int w, int h, double time, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {Thm_insert(Fsd_thm_itm.new_(), dir, fil, ext_id, w, h, time, page, modified, hash, bin_len, bin_rdr);}
|
||||
public void Thm_insert(Fsd_thm_itm rv, byte[] dir, byte[] fil, int ext_id, int w, int h, double time, int page, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
ary[insert_to_mnt].Thm_insert(rv, dir, fil, ext_id, w, h, time, page, modified, hash, bin_len, bin_rdr);
|
||||
}
|
||||
public void Img_insert(byte[] dir, byte[] fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {Img_insert(new Fsd_img_itm(), dir, fil, ext_id, img_w, img_h, modified, hash, bin_len, bin_rdr);}
|
||||
public void Img_insert(Fsd_img_itm rv, byte[] dir, byte[] fil, int ext_id, int img_w, int img_h, DateAdp modified, String hash, long bin_len, gplx.ios.Io_stream_rdr bin_rdr) {
|
||||
ary[insert_to_mnt].Img_insert(rv, dir, fil, ext_id, modified, hash, bin_len, bin_rdr, img_w, img_h);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Xoa_app_ {
|
||||
boot_mgr.Run(args);
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "2.3.1.1";
|
||||
public static final String Version = "2.3.2.1";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys;
|
||||
public static String User_agent = "";
|
||||
@ -46,7 +46,6 @@ public class Xoa_app_ {
|
||||
public static Io_stream_zip_mgr Utl__zip_mgr() {return utl__zip_mgr;} private static final Io_stream_zip_mgr utl__zip_mgr = new Io_stream_zip_mgr();
|
||||
|
||||
public static Xoa_gfs_mgr Gfs_mgr() {return gfs_mgr;} public static void Gfs_mgr_(Xoa_gfs_mgr v) {gfs_mgr = v;} private static Xoa_gfs_mgr gfs_mgr;
|
||||
// public static Xoa_lang_mgr Lang_mgr() {return lang_mgr;} public static void Lang_mgr_(Xoa_lang_mgr v) {lang_mgr = v;} private static Xoa_lang_mgr lang_mgr;
|
||||
|
||||
public static final byte Mode_console = 0, Mode_gui = 1, Mode_http = 2;
|
||||
}
|
||||
|
@ -19,12 +19,13 @@ package gplx.xowa.apis.xowa.html; import gplx.*; import gplx.xowa.*; import gplx
|
||||
public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
public Xoapi_toggle_itm(byte[] key_bry) {this.key_bry = key_bry;}
|
||||
public byte[] Key_bry() {return key_bry;} private byte[] key_bry;
|
||||
public byte[] Heading_bry() {return heading_bry;} private byte[] heading_bry;
|
||||
public byte[] Icon_src() {return icon_src;} private byte[] icon_src = Bry_.Empty;
|
||||
public byte[] Icon_title() {return icon_title;} private byte[] icon_title = Bry_.Empty;
|
||||
public byte[] Elem_display() {return elem_display;} private byte[] elem_display = Bry_.Empty;
|
||||
public byte[] Html_toggle_hdr_cls() {return html_toggle_hdr_cls;} public Xoapi_toggle_itm Html_toggle_hdr_cls_(byte[] v) {html_toggle_hdr_cls = v; return this;} private byte[] html_toggle_hdr_cls = Bry_.Empty;
|
||||
public boolean Visible() {return visible;} private boolean visible;
|
||||
public Xoapi_toggle_itm Init(Xowe_wiki wiki) {
|
||||
public Xoapi_toggle_itm Init(Xowe_wiki wiki, byte[] heading_bry) {
|
||||
if (Img_src_y == null) {
|
||||
Io_url img_dir = wiki.Appe().User().Fsys_mgr().App_img_dir().GenSubDir_nest("window", "portal");
|
||||
Img_src_y = img_dir.GenSubFil("twisty_down.png").To_http_file_bry();
|
||||
@ -34,6 +35,7 @@ public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
byte[] img_title_msg = visible ? Img_title_msg_y : Img_title_msg_n;
|
||||
icon_title = wiki.Msg_mgr().Val_by_key_obj(img_title_msg);
|
||||
elem_display = visible ? Img_display_y : Img_display_n;
|
||||
this.heading_bry = heading_bry;
|
||||
Html_toggle_gen();
|
||||
return this;
|
||||
}
|
||||
@ -65,8 +67,8 @@ public class Xoapi_toggle_itm implements GfoInvkAble {
|
||||
}
|
||||
Bry_fmtr fmtr = Bry_fmtr.new_(); Bry_bfr bfr = Bry_bfr.new_(8);
|
||||
html_toggle_btn
|
||||
= fmtr.Fmt_("<a href='javascript:xowa_toggle_visible(\"~{key}\");'><img id='~{key}-toggle-icon' src='~{src}' title='~{title}' /></a>")
|
||||
.Keys_("key", "src", "title").Bld_bry_many(bfr, key_bry, icon_src, icon_title)
|
||||
= fmtr.Fmt_("<a href='javascript:xowa_toggle_visible(\"~{key}\");' style='text-decoration: none !important;'>~{heading}<img id='~{key}-toggle-icon' src='~{src}' title='~{title}' /></a>")
|
||||
.Keys_("key", "src", "title", "heading").Bld_bry_many(bfr, key_bry, icon_src, icon_title, heading_bry)
|
||||
;
|
||||
html_toggle_hdr
|
||||
= fmtr.Fmt_(" id='~{key}-toggle-elem' style='~{display}~{toggle_hdr_cls}'")
|
||||
|
@ -21,7 +21,7 @@ import gplx.dbs.*; import gplx.dbs.qrys.*; import gplx.xowa.dbs.*; import gplx.x
|
||||
public class Db_mgr_fxt {
|
||||
public Db_mgr_fxt Ctor_fsys() {bldr_fxt = new Xob_fxt().Ctor(Xoa_test_.Url_root().GenSubDir("root")); return this;}
|
||||
public Db_mgr_fxt Ctor_mem() {bldr_fxt = new Xob_fxt().Ctor_mem(); return this;} private Xob_fxt bldr_fxt;
|
||||
public Xodb_page page_(int id, String modified_on, boolean type_redirect, int text_len) {return new Xodb_page().Id_(id).Modified_on_(DateAdp_.parse_gplx(modified_on)).Type_redirect_(type_redirect).Text_len_(text_len);}
|
||||
public Xodb_page page_(int id, String modified_on, boolean type_redirect, int text_len) {return new Xodb_page().Id_(id).Modified_on_(DateAdp_.parse_gplx(modified_on)).Redirected_(type_redirect).Wtxt_len_(text_len);}
|
||||
public Xowe_wiki Wiki() {return bldr_fxt.Wiki();}
|
||||
public Xob_bldr Bldr() {return bldr_fxt.Bldr();}
|
||||
public Db_mgr_fxt doc_ary_(Xodb_page... v) {bldr_fxt.doc_ary_(v); return this;}
|
||||
@ -56,14 +56,14 @@ public class Db_mgr_fxt {
|
||||
wiki.Db_mgr_as_sql().Load_mgr().Load_by_ttl(actl, ns, ttl_bry);
|
||||
Tfds.Eq(expd.Id(), actl.Id());
|
||||
Tfds.Eq_date(expd.Modified_on(), actl.Modified_on());
|
||||
Tfds.Eq(expd.Type_redirect(), actl.Type_redirect());
|
||||
Tfds.Eq(expd.Text_len(), actl.Text_len());
|
||||
Tfds.Eq(expd.Redirected(), actl.Redirected());
|
||||
Tfds.Eq(expd.Wtxt_len(), actl.Wtxt_len());
|
||||
} private Xodb_page actl = new Xodb_page();
|
||||
public void Test_load_page(int ns_id, int page_id, String expd) {
|
||||
Xowe_wiki wiki = bldr_fxt.Wiki();
|
||||
Xow_ns ns = wiki.Ns_mgr().Ids_get_or_null(ns_id);
|
||||
wiki.Db_mgr_as_sql().Load_mgr().Load_page(actl.Id_(page_id), ns, false);
|
||||
Tfds.Eq(expd, String_.new_ascii_(actl.Text()));
|
||||
Tfds.Eq(expd, String_.new_ascii_(actl.Wtxt()));
|
||||
}
|
||||
public void Test_search(String search_word_str, int... expd) {
|
||||
Xowe_wiki wiki = bldr_fxt.Wiki();
|
||||
|
@ -35,7 +35,7 @@ public class Xob_base_fxt {
|
||||
public Xowe_wiki Wiki() {return wiki;} private Xowe_wiki wiki;
|
||||
public GfoInvkAble Bldr_itm() {return bldr_itm;} GfoInvkAble bldr_itm;
|
||||
public Xodb_page page_(String ttl) {return page_(ttl, "");}
|
||||
public Xodb_page page_(String ttl, String text) {return new Xodb_page().Ttl_(Bry_.new_utf8_(ttl), wiki.Ns_mgr()).Text_(Bry_.new_utf8_(text));}
|
||||
public Xodb_page page_(String ttl, String text) {return new Xodb_page().Ttl_(Bry_.new_utf8_(ttl), wiki.Ns_mgr()).Wtxt_(Bry_.new_utf8_(text));}
|
||||
public Io_fil_chkr meta_(String url, String data) {return new Io_fil_chkr(Io_url_.mem_fil_(url), data);}
|
||||
public void Init_fxts(Xob_bldr bldr, Xowe_wiki wiki, Xob_base_fxt... fxt_ary) {
|
||||
int fxt_ary_len = fxt_ary.length;
|
||||
|
@ -20,6 +20,7 @@ import gplx.core.primitives.*;
|
||||
import gplx.xowa.wikis.*; import gplx.xowa.xtns.wdatas.imports.*; import gplx.xowa.bldrs.imports.ctgs.*; import gplx.xowa.bldrs.imports.*; import gplx.xowa.bldrs.oimgs.*;
|
||||
import gplx.xowa.bldrs.wikis.redirects.*; import gplx.xowa.bldrs.wikis.images.*;
|
||||
import gplx.xowa.bldrs.files.*; import gplx.xowa.files.origs.*;
|
||||
import gplx.xowa.html.hdumps.bldrs.*;
|
||||
public class Xob_cmd_mgr implements GfoInvkAble {
|
||||
public Xob_cmd_mgr(Xob_bldr bldr) {this.bldr = bldr;} private Xob_bldr bldr;
|
||||
public void Clear() {list.Clear(); dump_rdrs.Clear();}
|
||||
@ -60,6 +61,7 @@ public class Xob_cmd_mgr implements GfoInvkAble {
|
||||
else if (String_.Eq(cmd_key, Xob_download_wkr.KEY_oimg)) return Add(new Xob_download_wkr(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_page_regy_cmd.KEY_oimg)) return Add(new Xob_page_regy_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_cmd_exec_sql.KEY)) return Add(new Xob_cmd_exec_sql(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_rl_regy_cmd.Cmd_key_const)) return Add(new Xob_rl_regy_cmd(bldr, wiki));
|
||||
|
||||
else if (String_.Eq(cmd_key, Xob_redirect_cmd.KEY_redirect)) return Add(new Xob_redirect_cmd(bldr, wiki));
|
||||
else if (String_.Eq(cmd_key, Xob_wiki_image_sql.KEY)) return Add(new Xob_wiki_image_sql(bldr, wiki));
|
||||
|
@ -52,7 +52,7 @@ public class Xob_fxt {
|
||||
public Xob_fxt doc_ary_(Xodb_page... v) {doc_ary = v; return this;} private Xodb_page[] doc_ary;
|
||||
public Xodb_page doc_wo_date_(int id, String title, String text) {return doc_(id, "2012-01-02 13:14", title, text);}
|
||||
public Xodb_page doc_(int id, String date, String title, String text) {
|
||||
Xodb_page rv = new Xodb_page().Id_(id).Ttl_(Bry_.new_utf8_(title), wiki.Ns_mgr()).Text_(Bry_.new_utf8_(text));
|
||||
Xodb_page rv = new Xodb_page().Id_(id).Ttl_(Bry_.new_utf8_(title), wiki.Ns_mgr()).Wtxt_(Bry_.new_utf8_(text));
|
||||
int[] modified_on = new int[7];
|
||||
dateParser.Parse_iso8651_like(modified_on, date);
|
||||
rv.Modified_on_(DateAdp_.seg_(modified_on));
|
||||
|
@ -168,7 +168,7 @@ public class Xob_fsdb_make extends Xob_itm_basic_base implements Xob_cmd {
|
||||
rdr = Xob_xfer_regy_tbl.Select_by_lnki_page_id(conn, page_id_val, select_interval);
|
||||
while (rdr.MoveNextPeer()) {
|
||||
pages_found = true; // at least one page found; set true
|
||||
Xodb_tbl_oimg_xfer_itm itm = Xodb_tbl_oimg_xfer_itm.new_rdr_(rdr);
|
||||
Xodb_tbl_oimg_xfer_itm itm = Xodb_tbl_oimg_xfer_itm.new_rdr_( rdr);
|
||||
if (itm.Lnki_page_id() == page_id_val // if same page_id but lnki_id < last, then ignore; needed b/c select selects by page_id, and need to be handle breaks between pages
|
||||
&& itm.Lnki_id() <= lnki_id_val)
|
||||
continue;
|
||||
@ -310,20 +310,17 @@ class Xodb_tbl_oimg_xfer_itm extends Xof_fsdb_itm { public int Lnki_id() {ret
|
||||
rv.lnki_id = rdr.ReadInt(Xob_xfer_regy_tbl.Fld_lnki_id);
|
||||
rv.lnki_page_id = rdr.ReadInt(Xob_xfer_regy_tbl.Fld_lnki_page_id);
|
||||
rv.lnki_ext_id = rdr.ReadInt(Xob_xfer_regy_tbl.Fld_lnki_ext);
|
||||
rv.File_is_orig_ (rdr.ReadByte(Xob_xfer_regy_tbl.Fld_file_is_orig) == Bool_.Y_byte);
|
||||
byte[] ttl = rdr.ReadBryByStr(Xob_xfer_regy_tbl.Fld_lnki_ttl);
|
||||
rv.Ctor_by_orig
|
||||
( rdr.ReadByte(Xob_xfer_regy_tbl.Fld_orig_repo)
|
||||
, ttl
|
||||
rv.Ctor_by_fsdb_make
|
||||
( rdr.ReadBryByStr(Xob_xfer_regy_tbl.Fld_lnki_ttl)
|
||||
, rdr.ReadInt(Xob_xfer_regy_tbl.Fld_file_w), rdr.ReadInt(Xob_xfer_regy_tbl.Fld_file_h) // set lnki_size; Xof_bin_mgr uses lnki_size
|
||||
, Xof_lnki_time.Db_load_double(rdr, Xob_xfer_regy_tbl.Fld_lnki_time)
|
||||
, Xof_lnki_page.Db_load_int(rdr, Xob_xfer_regy_tbl.Fld_lnki_page)
|
||||
, rdr.ReadByte(Xob_xfer_regy_tbl.Fld_orig_repo)
|
||||
, rdr.ReadInt(Xob_xfer_regy_tbl.Fld_orig_w)
|
||||
, rdr.ReadInt(Xob_xfer_regy_tbl.Fld_orig_h)
|
||||
, Bry_.Empty
|
||||
, rdr.ReadByte(Xob_xfer_regy_tbl.Fld_file_is_orig) == Bool_.Y_byte
|
||||
);
|
||||
rv.Lnki_ttl_(ttl);
|
||||
rv.Html_size_(rdr.ReadInt(Xob_xfer_regy_tbl.Fld_file_w), rdr.ReadInt(Xob_xfer_regy_tbl.Fld_file_h)); // set html_size as file_size (may try to optimize later by removing similar thumbs (EX: 220,221 -> 220))
|
||||
rv.Lnki_size_(rdr.ReadInt(Xob_xfer_regy_tbl.Fld_file_w), rdr.ReadInt(Xob_xfer_regy_tbl.Fld_file_h)); // set lnki_size; Xof_bin_mgr uses lnki_size;
|
||||
rv.Lnki_page_ (Xof_doc_page.Db_load_int(rdr, Xob_xfer_regy_tbl.Fld_lnki_page));
|
||||
rv.Lnki_time_ (Xof_doc_thumb.Db_load_double(rdr, Xob_xfer_regy_tbl.Fld_lnki_time));
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class Xob_lnki_temp_tbl {
|
||||
.Val_int(w)
|
||||
.Val_int(h)
|
||||
.Val_double(upright)
|
||||
.Val_double(gplx.xowa.files.Xof_doc_thumb.Db_save_double(thumbtime))
|
||||
.Val_double(gplx.xowa.files.Xof_lnki_time.Db_save_double(thumbtime))
|
||||
.Val_int(page)
|
||||
.Exec_insert();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
|
||||
private int[] ns_ids = Int_.Ary(Xow_ns_.Id_main);// , Xow_ns_.Id_category, Xow_ns_.Id_template
|
||||
private boolean wiki_ns_file_is_case_match_all = true; private Xowe_wiki commons_wiki;
|
||||
private Xob_hdump_bldr hdump_bldr; private long hdump_max = Io_mgr.Len_gb;
|
||||
private Xob_link_dump_cmd link_dump_cmd;
|
||||
public Xob_lnki_temp_wkr(Xob_bldr bldr, Xowe_wiki wiki) {this.Cmd_ctor(bldr, wiki);}
|
||||
@Override public String Cmd_key() {return KEY_oimg;} public static final String KEY_oimg = "file.lnki_temp";
|
||||
@Override public byte Init_redirect() {return Bool_.N_byte;}
|
||||
@ -73,12 +74,14 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
|
||||
if (gen_hdump) {
|
||||
hdump_bldr = new Xob_hdump_bldr(wiki.Db_mgr_as_sql(), conn, hdump_max);
|
||||
hdump_bldr.Bld_init();
|
||||
link_dump_cmd = new Xob_link_dump_cmd();
|
||||
link_dump_cmd.Init_by_wiki(wiki);
|
||||
}
|
||||
conn.Txn_mgr().Txn_bgn_if_none();
|
||||
log_mgr.Txn_bgn();
|
||||
}
|
||||
@Override public void Exec_pg_itm_hook(Xow_ns ns, Xodb_page db_page, byte[] page_src) {
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ns.Gen_ttl(db_page.Ttl_wo_ns()));
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, ns.Gen_ttl(db_page.Ttl_page_db()));
|
||||
byte[] ttl_bry = ttl.Page_db();
|
||||
byte page_tid = Xow_page_tid.Identify(wiki.Domain_tid(), ns.Id(), ttl_bry);
|
||||
if (page_tid != Xow_page_tid.Tid_wikitext) return; // ignore js, css, lua, json
|
||||
@ -98,16 +101,30 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
|
||||
if (gen_hdump) {
|
||||
page.Root_(root);
|
||||
hdump_bldr.Insert_page(page);
|
||||
link_dump_cmd.Page_bgn(page.Revision_data().Id());
|
||||
ListAdp lnki_list = page.Lnki_list();
|
||||
int len = lnki_list.Count();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xop_lnki_tkn lnki = (Xop_lnki_tkn)lnki_list.FetchAt(i);
|
||||
Xoa_ttl trg_ttl = lnki.Ttl();
|
||||
link_dump_cmd.Add(lnki.Html_id(), trg_ttl.Ns().Id(), trg_ttl.Page_db());
|
||||
}
|
||||
}
|
||||
root.Clear();
|
||||
}
|
||||
}
|
||||
@Override public void Exec_commit_hook() {
|
||||
conn.Txn_mgr().Txn_end_all_bgn_if_none(); // save lnki_temp
|
||||
if (gen_hdump) hdump_bldr.Commit();
|
||||
if (gen_hdump) {
|
||||
hdump_bldr.Commit();
|
||||
link_dump_cmd.Wkr_commit();
|
||||
}
|
||||
}
|
||||
@Override public void Exec_end_hook() {
|
||||
if (gen_hdump) hdump_bldr.Bld_term();
|
||||
if (gen_hdump) {
|
||||
hdump_bldr.Bld_term();
|
||||
link_dump_cmd.Wkr_end();
|
||||
}
|
||||
Gfo_usr_dlg_._.Warn_many("", "", invoke_wkr.Err_filter_mgr().Print());
|
||||
wiki.Appe().Log_mgr().Txn_end();
|
||||
conn.Txn_mgr().Txn_end();
|
||||
@ -116,15 +133,15 @@ public class Xob_lnki_temp_wkr extends Xob_dump_mgr_base implements Xopg_redlink
|
||||
if (lnki.Ttl().ForceLiteralLink()) return; // ignore literal links which creat a link to file, but do not show the image; EX: [[:File:A.png|thumb|120px]] creates a link to File:A.png, regardless of other display-oriented args
|
||||
byte[] ttl = lnki.Ttl().Page_db();
|
||||
Xof_ext ext = Xof_ext_.new_by_ttl_(ttl);
|
||||
double lnki_thumbtime = lnki.Thumbtime();
|
||||
double lnki_thumbtime = lnki.Time();
|
||||
int lnki_page = lnki.Page();
|
||||
byte[] ttl_commons = Xto_commons(wiki_ns_file_is_case_match_all, commons_wiki, ttl);
|
||||
if ( Xof_doc_page.Null_n(lnki_page) // page set
|
||||
&& Xof_doc_thumb.Null_n(lnki_thumbtime)) // thumbtime set
|
||||
if ( Xof_lnki_page.Null_n(lnki_page) // page set
|
||||
&& Xof_lnki_time.Null_n(lnki_thumbtime)) // thumbtime set
|
||||
usr_dlg.Warn_many("", "", "page and thumbtime both set; this may be an issue with fsdb: page=~{0} ttl=~{1}", ctx.Cur_page().Ttl().Page_db_as_str(), String_.new_utf8_(ttl));
|
||||
if (lnki.Ns_id() == Xow_ns_.Id_media)
|
||||
lnki_src_tid = Xob_lnki_src_tid.Tid_media;
|
||||
Xob_lnki_temp_tbl.Insert(stmt, ctx.Cur_page().Revision_data().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki.Lnki_type(), lnki_src_tid, lnki.Lnki_w(), lnki.Lnki_h(), lnki.Upright(), lnki_thumbtime, lnki_page);
|
||||
Xob_lnki_temp_tbl.Insert(stmt, ctx.Cur_page().Revision_data().Id(), ttl, ttl_commons, Byte_.By_int(ext.Id()), lnki.Lnki_type(), lnki_src_tid, lnki.W(), lnki.H(), lnki.Upright(), lnki_thumbtime, lnki_page);
|
||||
}
|
||||
@Override public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.Match(k, Invk_wdata_enabled_)) wdata_enabled = m.ReadYn("v");
|
||||
|
@ -28,12 +28,12 @@ public class Xob_orig_qry_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
Xob_bmk_mgr bmk = new Xob_bmk_mgr();
|
||||
bmk.Init(conn, this.Cmd_key(), true, false, true);
|
||||
bmk.Load();
|
||||
Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
// Xof_fsdb_itm itm = new Xof_fsdb_itm();
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
try {
|
||||
// rdr = Select(conn, bmk.Repo_prv(), bmk.Ttl_prv());
|
||||
while (rdr.MoveNextPeer()) {
|
||||
Load_itm(itm, rdr);
|
||||
// Load_itm(itm, rdr);
|
||||
// QueryItm
|
||||
}
|
||||
}
|
||||
@ -48,9 +48,6 @@ public class Xob_orig_qry_cmd extends Xob_itm_basic_base implements Xob_cmd {
|
||||
}
|
||||
*/
|
||||
}
|
||||
private void Load_itm(Xof_fsdb_itm itm, DataRdr rdr) {
|
||||
itm.Lnki_ttl_(null);
|
||||
}
|
||||
public DataRdr Select(Db_conn p, byte prv_repo_id, byte[] prv_ttl) {
|
||||
String sql = String_.Concat_lines_nl_skip_last
|
||||
( "SELECT lnki_ttl"
|
||||
|
@ -53,8 +53,8 @@ public class Xob_xfer_temp_cmd_orig extends Xob_itm_basic_base implements Xob_cm
|
||||
, orig_w, orig_h
|
||||
, orig_w, orig_h // file_w, file_h is same as orig_w,orig_h; i.e.: make same file_w as orig_w
|
||||
, Xof_img_size.Null, Xof_img_size.Null // html_w, html_h is -1; i.e.: will not be displayed in page at specific size (this matches logic in Xob_xfer_temp_cmd_thumb)
|
||||
, Xof_doc_thumb.Null
|
||||
, Xof_doc_page.Null
|
||||
, Xof_lnki_time.Null
|
||||
, Xof_lnki_page.Null
|
||||
, 0);
|
||||
}
|
||||
conn.Txn_mgr().Txn_end_all();
|
||||
|
@ -47,8 +47,8 @@ class Xob_xfer_temp_itm {
|
||||
= orig_w = orig_h = orig_page_id = Int_.Neg1;
|
||||
join_ttl = redirect_src = orig_media_type = null;
|
||||
lnki_upright = Xop_lnki_tkn.Upright_null;
|
||||
lnki_thumbtime = Xof_doc_thumb.Null;
|
||||
lnki_page = Xof_doc_page.Null;
|
||||
lnki_thumbtime = Xof_lnki_time.Null;
|
||||
lnki_page = Xof_lnki_page.Null;
|
||||
}
|
||||
public void Load(DataRdr rdr) {
|
||||
lnki_id = rdr.ReadInt(Xob_lnki_regy_tbl.Fld_lnki_id);
|
||||
@ -59,7 +59,7 @@ class Xob_xfer_temp_itm {
|
||||
lnki_w = rdr.ReadInt(Xob_lnki_regy_tbl.Fld_lnki_w);
|
||||
lnki_h = rdr.ReadInt(Xob_lnki_regy_tbl.Fld_lnki_h);
|
||||
lnki_upright = rdr.ReadDouble(Xob_lnki_regy_tbl.Fld_lnki_upright);
|
||||
lnki_thumbtime = Xof_doc_thumb.Db_load_double(rdr, Xob_lnki_regy_tbl.Fld_lnki_time);
|
||||
lnki_thumbtime = Xof_lnki_time.Db_load_double(rdr, Xob_lnki_regy_tbl.Fld_lnki_time);
|
||||
lnki_page = rdr.ReadInt(Xob_lnki_regy_tbl.Fld_lnki_page);
|
||||
lnki_count = rdr.ReadInt(Xob_lnki_regy_tbl.Fld_lnki_count);
|
||||
orig_repo = rdr.ReadByte(Xob_orig_regy_tbl.Fld_orig_repo);
|
||||
@ -89,13 +89,13 @@ class Xob_xfer_temp_itm {
|
||||
// }
|
||||
lnki_ext = orig_ext_id;
|
||||
orig_media_type_tid = Xof_media_type.Xto_byte(orig_media_type);
|
||||
if ( Xof_doc_thumb.Null_n(lnki_thumbtime) // thumbtime defined
|
||||
if ( Xof_lnki_time.Null_n(lnki_thumbtime) // thumbtime defined
|
||||
&& orig_media_type_tid != Xof_media_type.Tid_video // video can have thumbtime
|
||||
)
|
||||
lnki_thumbtime = Xof_doc_thumb.Null; // set thumbtime to NULL; actually occurs for one file: [[File:Crash.arp.600pix.jpg|thumb|thumbtime=2]]
|
||||
if ( Xof_doc_page.Null_n(lnki_page)
|
||||
lnki_thumbtime = Xof_lnki_time.Null; // set thumbtime to NULL; actually occurs for one file: [[File:Crash.arp.600pix.jpg|thumb|thumbtime=2]]
|
||||
if ( Xof_lnki_page.Null_n(lnki_page)
|
||||
&& !Xof_ext_.Id_supports_page(orig_ext_id)) // djvu / pdf can have page parameters, which are currently being stored in thumbtime; DATE:2014-01-18
|
||||
lnki_page = Xof_doc_page.Null;
|
||||
lnki_page = Xof_lnki_page.Null;
|
||||
if (orig_page_id == -1) { // no orig found (i.e.: not in local's / remote's image.sql);
|
||||
chk_tid = Chk_tid_orig_page_id_is_null;
|
||||
return false;
|
||||
|
@ -54,7 +54,7 @@ public class Xob_xfer_temp_itm_tst {
|
||||
( KeyVal_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
|
||||
, KeyVal_.new_(Xob_lnki_regy_tbl.Fld_lnki_time , (double)3)
|
||||
);
|
||||
fxt.Test_lnki_thumbtime(Xof_doc_thumb.Null);
|
||||
fxt.Test_lnki_thumbtime(Xof_lnki_time.Null);
|
||||
|
||||
fxt.Reset().Test_bgn
|
||||
( KeyVal_.new_(Xob_orig_regy_tbl.Fld_orig_media_type , Xof_media_type.Name_video)
|
||||
@ -67,7 +67,7 @@ public class Xob_xfer_temp_itm_tst {
|
||||
( KeyVal_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_jpg)
|
||||
, KeyVal_.new_(Xob_lnki_regy_tbl.Fld_lnki_page , 3)
|
||||
);
|
||||
fxt.Test_lnki_page(Xof_doc_page.Null);
|
||||
fxt.Test_lnki_page(Xof_lnki_page.Null);
|
||||
|
||||
fxt.Reset().Test_bgn
|
||||
( KeyVal_.new_(Xob_orig_regy_tbl.Fld_orig_file_ext , Xof_ext_.Id_pdf)
|
||||
@ -136,7 +136,7 @@ class Xob_xfer_temp_itm_fxt {
|
||||
( Xof_ext_.Id_png, 1, Xof_repo_itm.Repo_remote
|
||||
, "A.png", Xof_ext_.Id_png, "A.png", Xop_lnki_type.Id_thumb, Xob_lnki_src_tid.Tid_file
|
||||
, 220, 200, 1, 2, 440, 400, 3
|
||||
, Xop_lnki_tkn.Upright_null, Xof_doc_thumb.Null, Xof_doc_page.Null
|
||||
, Xop_lnki_tkn.Upright_null, Xof_lnki_time.Null, Xof_lnki_page.Null
|
||||
, Xof_media_type.Name_bitmap, "png"
|
||||
));
|
||||
GfoNdeList subs = GfoNdeList_.new_();
|
||||
|
@ -38,7 +38,7 @@ class Xob_xfer_temp_tbl {
|
||||
.Val_int(file_h)
|
||||
.Val_int(html_w)
|
||||
.Val_int(html_h)
|
||||
.Val_double(Xof_doc_thumb.Db_save_double(thumbtime))
|
||||
.Val_double(Xof_lnki_time.Db_save_double(thumbtime))
|
||||
.Val_int(page)
|
||||
.Val_int(count)
|
||||
.Exec_insert();
|
||||
|
@ -60,33 +60,33 @@ public class Xob_page_sql extends Xob_itm_basic_base implements Xobd_wkr, GfoInv
|
||||
int page_id = page.Id();
|
||||
DateAdp modified = page.Modified_on();
|
||||
if (modified.compareTo(modified_latest) == CompareAble_.More) modified_latest = modified;
|
||||
byte[] text = page.Text();
|
||||
int text_len = page.Text_len();
|
||||
byte[] text = page.Wtxt();
|
||||
int text_len = page.Wtxt_len();
|
||||
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(text, text_len);
|
||||
boolean redirect = redirect_ttl != null;
|
||||
page.Type_redirect_(redirect);
|
||||
page.Redirected_(redirect);
|
||||
Xow_ns ns = page.Ns();
|
||||
int random_int = ns.Count() + 1;
|
||||
ns.Count_(random_int);
|
||||
if (dg_enabled) {
|
||||
if (dg_match_mgr.Match(1, page_id, ns.Id(), page.Ttl_wo_ns(), page.Ttl_w_ns(), wiki.Lang(), text)) return;
|
||||
if (dg_match_mgr.Match(1, page_id, ns.Id(), page.Ttl_page_db(), page.Ttl_full_db(), wiki.Lang(), text)) return;
|
||||
}
|
||||
text = zip_mgr.Zip(data_storage_format, text);
|
||||
int text_stmt_idx = text_stmts_mgr.Stmt_by_ns(ns.Bldr_file_idx(), text.length); // NOTE: was text.length, but want text_len which is original page_len, not compressed; DATE:2014-08-04
|
||||
Db_stmt text_stmt = text_stmts_mgr.Stmt_at(text_stmt_idx);
|
||||
try {
|
||||
db_mgr.Page_create(page_stmt, text_stmt, page_id, page.Ns_id(), page.Ttl_wo_ns(), redirect, modified, text, random_int, text_stmt_idx);
|
||||
db_mgr.Page_create(page_stmt, text_stmt, page_id, page.Ns_id(), page.Ttl_page_db(), redirect, modified, text, random_int, text_stmt_idx);
|
||||
}
|
||||
catch (Exception e) {
|
||||
usr_dlg.Warn_many("", "", "failed to insert page: id=~{0} ns=~{1} title=~{2} error=~{3}", page.Id(), page.Ns_id(), String_.new_utf8_(page.Ttl_wo_ns()), Err_.Message_gplx_brief(e));
|
||||
usr_dlg.Warn_many("", "", "failed to insert page: id=~{0} ns=~{1} title=~{2} error=~{3}", page.Id(), page.Ns_id(), String_.new_utf8_(page.Ttl_page_db()), Err_.Message_gplx_brief(e));
|
||||
page_stmt.Reset_stmt(); // must new stmt variable, else java.sql.SQLException: "statement is not executing"
|
||||
text_stmt.Reset_stmt(); // must new stmt variable, else java.sql.SQLException: "statement is not executing"
|
||||
}
|
||||
if (redirect && redirect_id_enabled) {
|
||||
redirect_tbl.Insert(page_id, page.Ttl_wo_ns(), redirect_ttl);
|
||||
redirect_tbl.Insert(page_id, page.Ttl_page_db(), redirect_ttl);
|
||||
}
|
||||
++page_count_all;
|
||||
if (ns.Id_main() && !page.Type_redirect()) ++page_count_main;
|
||||
if (ns.Id_main() && !page.Redirected()) ++page_count_main;
|
||||
if (page_count_all % txn_commit_interval == 0) {
|
||||
Db_conn conn = text_stmts_mgr.Conn_at(text_stmt_idx);
|
||||
conn.Txn_mgr().Txn_end_all_bgn_if_none();
|
||||
|
@ -34,9 +34,9 @@ public class Xob_page_txt extends Xob_itm_dump_base implements Xobd_wkr, GfoInvk
|
||||
Xob_xdat_file_wtr[] page_wtr_regy = new Xob_xdat_file_wtr[Ns_ordinal_max]; static final int Ns_ordinal_max = Xow_ns_mgr_.Ordinal_max; // ASSUME: no more than 128 ns in a wiki
|
||||
Xob_stat_type data_rpt_typ; Xob_stat_mgr stat_mgr = new Xob_stat_mgr(); byte page_storage_type;
|
||||
public void Wkr_run(Xodb_page page) {
|
||||
int id = page.Id(); byte[] ttl_wo_ns = page.Ttl_wo_ns(), text = page.Text(); int ttl_len = ttl_wo_ns.length, text_len = text.length; Xow_ns ns = page.Ns();
|
||||
int id = page.Id(); byte[] ttl_wo_ns = page.Ttl_page_db(), text = page.Wtxt(); int ttl_len = ttl_wo_ns.length, text_len = text.length; Xow_ns ns = page.Ns();
|
||||
boolean redirect = redirect_mgr.Is_redirect(text, text_len);
|
||||
page.Type_redirect_(redirect);
|
||||
page.Redirected_(redirect);
|
||||
|
||||
// page: EX: \t123\t2012-06-09\ttitle\ttext\n; NOTE: 512k * ~20 ns = 10 MB max memory; no need for intermediary flushing
|
||||
Xob_xdat_file_wtr page_wtr = Page_wtr_get(ns);
|
||||
@ -47,7 +47,7 @@ public class Xob_page_txt extends Xob_itm_dump_base implements Xobd_wkr, GfoInvk
|
||||
// idx: EX: 00100|aB64|Ttl;
|
||||
Xob_tmp_wtr ttl_wtr = ttl_wtr_mgr.Get_or_new(ns);
|
||||
int file_idx = page_wtr.Fil_idx(), row_idx = page_wtr.Idx_pos() - ListAdp_.LastIdxOffset;
|
||||
page.Text_db_id_(file_idx).Db_row_idx_(row_idx);
|
||||
page.Wtxt_db_id_(file_idx).Tdb_row_idx_(row_idx);
|
||||
if (ttl_wtr.FlushNeeded(Xodb_page_.Txt_ttl_len__fixed + ttl_len)) ttl_wtr.Flush(bldr.Usr_dlg());
|
||||
Xodb_page_.Txt_ttl_save(ttl_wtr.Bfr(), id, file_idx, row_idx, redirect, text_len, ttl_wo_ns);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public abstract class Xob_search_base extends Xob_itm_dump_base implements Xobd_
|
||||
public void Wkr_run(Xodb_page page) {
|
||||
// if (page.Ns_id() != Xow_ns_.Id_main) return; // limit to main ns for now
|
||||
try {
|
||||
byte[] ttl = page.Ttl_wo_ns();
|
||||
byte[] ttl = page.Ttl_page_db();
|
||||
byte[][] words = Split(lang, list, dump_bfr, ttl);
|
||||
Xob_tmp_wtr wtr = tmp_wtr_mgr.Get_or_new(ns_main == null ? page.Ns() : ns_main);
|
||||
int words_len = words.length;
|
||||
@ -48,7 +48,7 @@ public abstract class Xob_search_base extends Xob_itm_dump_base implements Xobd_
|
||||
byte[] word = words[i];
|
||||
wtr.Bfr() .Add(word) .Add_byte(Byte_ascii.Pipe)
|
||||
.Add_base85_len_5(page.Id()) .Add_byte(Byte_ascii.Semic)
|
||||
.Add_base85_len_5(page.Text().length) .Add_byte(Byte_ascii.NewLine);
|
||||
.Add_base85_len_5(page.Wtxt().length) .Add_byte(Byte_ascii.NewLine);
|
||||
}
|
||||
} catch (Exception e) {bldr.Usr_dlg().Warn_many("", "", "search_index:fatal error: err=~{0}", Err_.Message_gplx_brief(e));} // never let single page crash entire import
|
||||
}
|
||||
|
@ -98,12 +98,12 @@ public class Xobc_core_calc_stats extends Xob_itm_basic_base implements Xob_cmd
|
||||
int rv = 0;
|
||||
byte[] bry = Io_mgr._.LoadFilBry(fil);
|
||||
Xob_xdat_file xdat_file = new Xob_xdat_file().Parse(bry, bry.length, fil);
|
||||
Xodb_page page = Xodb_page.tmp_();
|
||||
Xodb_page page = Xodb_page.new_tmp();
|
||||
int count = xdat_file.Count();
|
||||
for (int i = 0; i < count; i++) {
|
||||
byte[] ttl_bry = xdat_file.Get_bry(i);
|
||||
Xodb_page_.Txt_ttl_load(page, ttl_bry);
|
||||
rv += page.Type_redirect() ? 0 : 1;
|
||||
rv += page.Redirected() ? 0 : 1;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ public class Xobc_core_make_id extends Xob_itm_dump_base implements Xobd_wkr, Gf
|
||||
this.Init_dump(KEY, wiki.Tdb_fsys_mgr().Site_dir().GenSubDir(Xotdb_dir_info_.Name_id));
|
||||
}
|
||||
public void Wkr_run(Xodb_page page) {
|
||||
byte[] ttl = page.Ttl_wo_ns();
|
||||
byte[] ttl = page.Ttl_page_db();
|
||||
if (dump_bfr.Len() + row_fixed_len + ttl.length > dump_fil_len) Io_mgr._.AppendFilBfr(dump_url_gen.Nxt_url(), dump_bfr);
|
||||
Xodb_page_.Txt_id_save(dump_bfr, page);
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class Xobc_tst {
|
||||
ListAdp actl = ListAdp_.new_();
|
||||
Xodb_page page = new Xodb_page();
|
||||
while (parser.Read(page)) {
|
||||
actl.Add(String_.new_utf8_(page.Text()));
|
||||
actl.Add(String_.new_utf8_(page.Wtxt()));
|
||||
}
|
||||
Tfds.Eq_ary(expd, actl.XtoStrAry());
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class Xob_category_registry_sql implements Xob_cmd {
|
||||
|
||||
Xodb_mgr_sql db_mgr = Xodb_mgr_sql.Get_or_load(wiki);
|
||||
Db_conn conn = db_mgr.Core_data_mgr().Conn_core();
|
||||
Db_qry_select qry = Db_qry_select.new_()
|
||||
Db_qry__select_cmd qry = Db_qry__select_cmd.new_()
|
||||
.Cols_(Xodb_page_tbl.Fld_page_title, Xodb_page_tbl.Fld_page_id)
|
||||
.From_(Xodb_page_tbl.Tbl_name)
|
||||
.Where_(Db_crt_.eq_(Xodb_page_tbl.Fld_page_ns, Xow_ns_.Id_category))
|
||||
|
@ -65,7 +65,7 @@ public abstract class Xob_ctg_v1_base extends Xob_itm_dump_base implements Xobd_
|
||||
}
|
||||
}
|
||||
@gplx.Virtual public void Log(byte err_tid, Xodb_page page, byte[] src, int ctg_bgn) {
|
||||
String title = String_.new_utf8_(page.Ttl_w_ns());
|
||||
String title = String_.new_utf8_(page.Ttl_full_db());
|
||||
int ctg_end = ctg_bgn + 40; if (ctg_end > src.length) ctg_end = src.length;
|
||||
String ctg_str = String_.Replace(String_.new_utf8_(src, ctg_bgn, ctg_end), "\n", "");
|
||||
String err = "";
|
||||
|
@ -41,7 +41,7 @@ class Xodb_page_wkr_ctg_fxt {
|
||||
byte[] bry = Bry_.new_utf8_("[[Category:");
|
||||
wkr.Wkr_hooks().Add(bry, bry);
|
||||
mgr.Wkr_add(wkr);
|
||||
Xodb_page page = new Xodb_page().Text_(src);//.Ttl_(Bry_.new_utf8_("Test"), new Xow_ns_mgr());
|
||||
Xodb_page page = new Xodb_page().Wtxt_(src);//.Ttl_(Bry_.new_utf8_("Test"), new Xow_ns_mgr());
|
||||
mgr.Wkr_bgn(bldr);
|
||||
mgr.Wkr_run(page);
|
||||
byte[][] ttl = (byte[][])wkr.Found().Xto_ary(byte[].class);
|
||||
|
@ -134,9 +134,9 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
|
||||
if ((exec_count % progress_interval) == 0)
|
||||
usr_dlg.Prog_many("", "", "parsing: ns=~{0} db=~{1} pg=~{2} count=~{3} time=~{4} rate=~{5} ttl=~{6}"
|
||||
, ns.Id(), db_id, page.Id(), exec_count
|
||||
, Env_.TickCount_elapsed_in_sec(time_bgn), rate_mgr.Rate_as_str(), String_.new_utf8_(page.Ttl_wo_ns()));
|
||||
, Env_.TickCount_elapsed_in_sec(time_bgn), rate_mgr.Rate_as_str(), String_.new_utf8_(page.Ttl_page_db()));
|
||||
ctx.Clear();
|
||||
Exec_pg_itm_hook(ns, page, page.Text());
|
||||
Exec_pg_itm_hook(ns, page, page.Wtxt());
|
||||
ctx.App().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released
|
||||
if (ctx.Wiki().Cache_mgr().Tmpl_result_cache().Count() > 50000)
|
||||
ctx.Wiki().Cache_mgr().Tmpl_result_cache().Clear();
|
||||
@ -145,12 +145,12 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
|
||||
if ((exec_count % poll_interval) == 0)
|
||||
poll_mgr.Poll();
|
||||
if ((exec_count % commit_interval) == 0)
|
||||
Exec_commit(ns.Id(), db_id, page.Id(), page.Ttl_wo_ns());
|
||||
Exec_commit(ns.Id(), db_id, page.Id(), page.Ttl_page_db());
|
||||
if ((exec_count % cleanup_interval) == 0)
|
||||
Free();
|
||||
}
|
||||
catch (Exception exc) {
|
||||
bldr.Usr_dlg().Warn_many(GRP_KEY, "parse", "failed to parse ~{0} error ~{1}", String_.new_utf8_(page.Ttl_wo_ns()), Err_.Message_lang(exc));
|
||||
bldr.Usr_dlg().Warn_many(GRP_KEY, "parse", "failed to parse ~{0} error ~{1}", String_.new_utf8_(page.Ttl_page_db()), Err_.Message_lang(exc));
|
||||
ctx.App().Utl__bfr_mkr().Clear();
|
||||
this.Free();
|
||||
}
|
||||
@ -230,7 +230,7 @@ class Xob_dump_mgr_base_ {
|
||||
for (int i = 0; i < page_count; i++) {
|
||||
page = (Xodb_page)pages.FetchAt(i);
|
||||
Xot_defn_tmpl defn = new Xot_defn_tmpl();
|
||||
defn.Init_by_new(ns_tmpl, ns_tmpl.Gen_ttl(page.Ttl_wo_ns()), page.Text(), null, false); // NOTE: passing null, false; will be overriden later when Parse is called
|
||||
defn.Init_by_new(ns_tmpl, ns_tmpl.Gen_ttl(page.Ttl_page_db()), page.Wtxt(), null, false); // NOTE: passing null, false; will be overriden later when Parse is called
|
||||
defn_cache.Add(defn, ns_tmpl.Case_match());
|
||||
++load_count;
|
||||
if ((load_count % 10000) == 0) usr_dlg.Prog_many("", "", "tmpl_loading: ~{0}", load_count);
|
||||
|
@ -65,7 +65,7 @@ class Xob_dump_src_id {
|
||||
while (rdr.MoveNextPeer()) {
|
||||
Xodb_page page = New_page(db_mgr, cur_ns, rdr);
|
||||
list.Add(page);
|
||||
size_len += page.Text_len();
|
||||
size_len += page.Wtxt_len();
|
||||
if (size_len > size_max)
|
||||
break;
|
||||
}
|
||||
@ -84,12 +84,12 @@ class Xob_dump_src_id {
|
||||
}
|
||||
private static Xodb_page New_page(Xodb_mgr_sql db_mgr, int ns_id, DataRdr rdr) {
|
||||
Xodb_page rv = new Xodb_page();
|
||||
rv.Ns_id_(ns_id);
|
||||
rv.Id_(rdr.ReadInt(Xodb_page_tbl.Fld_page_id));
|
||||
rv.Ttl_wo_ns_(rdr.ReadBryByStr(Xodb_page_tbl.Fld_page_title));
|
||||
rv.Ns_id_(ns_id);
|
||||
rv.Ttl_page_db_(rdr.ReadBryByStr(Xodb_page_tbl.Fld_page_title));
|
||||
byte[] old_text = rdr.ReadBry(Xodb_text_tbl.Fld_old_text);
|
||||
old_text = db_mgr.Wiki().Appe().Zip_mgr().Unzip(db_mgr.Data_storage_format(), old_text);
|
||||
rv.Text_(old_text);
|
||||
rv.Wtxt_(old_text);
|
||||
return rv;
|
||||
}
|
||||
private static String New_rdr__redirect_clause(byte redirect) {
|
||||
|
@ -43,7 +43,7 @@ public class Xob_redirect_cmd extends Xob_dump_mgr_base {
|
||||
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(page_src, page_src.length);
|
||||
byte[] redirect_ttl_bry = Xoa_ttl.Replace_spaces(redirect_ttl.Page_db()); // NOTE: spaces can still exist b/c redirect is scraped from #REDIRECT which sometimes has a mix; EX: "A_b c"
|
||||
redirect_ttl_bry = encoder.Decode(redirect_ttl_bry);
|
||||
redirect_tbl.Insert(page.Id(), Xoa_ttl.Replace_spaces(page.Ttl_wo_ns()), -1, redirect_ttl.Ns().Id(), redirect_ttl_bry, redirect_ttl.Anch_txt(), 1);
|
||||
redirect_tbl.Insert(page.Id(), Xoa_ttl.Replace_spaces(page.Ttl_page_db()), -1, redirect_ttl.Ns().Id(), redirect_ttl_bry, redirect_ttl.Anch_txt(), 1);
|
||||
}
|
||||
@Override public void Exec_commit_hook() {
|
||||
conn.Txn_mgr().Txn_end_all_bgn_if_none();
|
||||
|
@ -33,15 +33,15 @@ public class Xob_redirect_tbl {
|
||||
public void Update_trg_redirect_id(Io_url core_url, int max_redirected_depth) {
|
||||
Sqlite_engine_.Db_attach(conn, "page_db", core_url.Raw()); // link database with page table
|
||||
conn.Exec_sql(Sql_get_page_data); // fill in page_id, page_ns, page_is_redirect for trg_ttl; EX: Page_A has "#REDIRECT Page_B"; Page_B is in redirect tbl; find its id, ttl, redirect status
|
||||
for (int i = 0; i < max_redirected_depth; i++) { // loop to find redirected redirects; note that it is bounded by depth (to guard against circular redirects)
|
||||
for (int i = 0; i < max_redirected_depth; i++) { // loop to find redirected redirects; note that it is bounded by depth (to guard against circular redirects)
|
||||
int affected = conn.Exec_sql(Sql_get_redirect_redirects); // find redirects that are also redirects
|
||||
if (affected == 0) break; // no more redirected redirects; stop
|
||||
if (affected == 0) break; // no more redirected redirects; stop
|
||||
conn.Exec_sql(Sql_get_redirect_page_data); // get page data for redirects
|
||||
}
|
||||
Sqlite_engine_.Db_detach(conn, "page_db");
|
||||
}
|
||||
public void Update_src_redirect_id(Io_url core_url, Db_conn core_provider) {
|
||||
core_provider.Exec_sql(Sql_ddl__page_redirect_id); // create page.page_redirect_id
|
||||
core_provider.Exec_sql(Sql_ddl__page_redirect_id); // create page.page_redirect_id
|
||||
Sqlite_engine_.Idx_create(conn, Idx_trg_src);
|
||||
Sqlite_engine_.Db_attach(conn, "page_db", core_url.Raw()); // link database with page table
|
||||
conn.Exec_sql(Sql_update_redirect_id); // update page_redirect_id
|
||||
|
@ -39,7 +39,7 @@ public class Xob_xml_page_bldr {
|
||||
}
|
||||
public Xob_xml_page_bldr Add(Xodb_page doc) {
|
||||
bfr.Add(Indent_2).Add(Xob_xml_parser_.Bry_page_bgn).Add_byte_nl();
|
||||
bfr.Add(Indent_4).Add(Xob_xml_parser_.Bry_title_bgn).Add(doc.Ttl_w_ns()).Add(Xob_xml_parser_.Bry_title_end).Add_byte_nl();
|
||||
bfr.Add(Indent_4).Add(Xob_xml_parser_.Bry_title_bgn).Add(doc.Ttl_full_db()).Add(Xob_xml_parser_.Bry_title_end).Add_byte_nl();
|
||||
bfr.Add(Indent_4).Add(Xob_xml_parser_.Bry_id_bgn).Add_int_variable(doc.Id()).Add(Xob_xml_parser_.Bry_id_end).Add_byte_nl();
|
||||
bfr.Add(Indent_4).Add(Xob_xml_parser_.Bry_redirect_bgn_frag).Add(Nde_inline).Add_byte_nl();
|
||||
bfr.Add(Indent_4).Add(Xob_xml_parser_.Bry_revision_bgn).Add_byte_nl();
|
||||
@ -51,7 +51,7 @@ public class Xob_xml_page_bldr {
|
||||
bfr.Add(Indent_6).Add(Xob_xml_parser_.Bry_contributor_end).Add_byte_nl();
|
||||
bfr.Add(Indent_6).Add(Xob_xml_parser_.Bry_minor_bgn_frag).Add(Nde_inline).Add_byte_nl();
|
||||
bfr.Add(Indent_6).Add(Xob_xml_parser_.Bry_comment_bgn).Add(Revision_comment).Add(Xob_xml_parser_.Bry_comment_end).Add_byte_nl();
|
||||
bfr.Add(Indent_6).Add(Xob_xml_parser_.Bry_text_bgn).Add(doc.Text()).Add(Xob_xml_parser_.Bry_text_end).Add_byte_nl();
|
||||
bfr.Add(Indent_6).Add(Xob_xml_parser_.Bry_text_bgn).Add(doc.Wtxt()).Add(Xob_xml_parser_.Bry_text_end).Add_byte_nl();
|
||||
bfr.Add(Indent_4).Add(Xob_xml_parser_.Bry_revision_end).Add_byte_nl();
|
||||
bfr.Add(Indent_2).Add(Xob_xml_parser_.Bry_page_end).Add_byte_nl();
|
||||
return this;
|
||||
|
@ -80,7 +80,7 @@ public class Xob_xml_parser {
|
||||
title_needed = false;
|
||||
}
|
||||
break;
|
||||
case Xob_xml_parser_.Id_text_end: data_bfr_add = false; rv.Text_(data_bfr.Xto_bry_and_clear()); break;
|
||||
case Xob_xml_parser_.Id_text_end: data_bfr_add = false; rv.Wtxt_(data_bfr.Xto_bry_and_clear()); break;
|
||||
case Xob_xml_parser_.Id_amp: case Xob_xml_parser_.Id_quot: case Xob_xml_parser_.Id_lt: case Xob_xml_parser_.Id_gt:
|
||||
case Xob_xml_parser_.Id_cr_nl: case Xob_xml_parser_.Id_cr:
|
||||
if (data_bfr_add) data_bfr.Add_byte(itm.Subst_byte());
|
||||
|
@ -44,28 +44,28 @@ public class Xob_xml_parser_tst {
|
||||
@Test public void Xml() {
|
||||
Xodb_page doc = doc_(1, "a", ""a & b <> a | b"", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_utf8_("\"a & b <> a | b\"")), 0);
|
||||
tst_parse(fil, doc.Wtxt_(Bry_.new_utf8_("\"a & b <> a | b\"")), 0);
|
||||
}
|
||||
@Test public void Tab() {
|
||||
Xodb_page doc = doc_(1, "a", "a \t b", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_utf8_("a 	 b")), 0);
|
||||
tst_parse(fil, doc.Wtxt_(Bry_.new_utf8_("a 	 b")), 0);
|
||||
}
|
||||
@Test public void Tab_disable() {
|
||||
Xodb_page doc = doc_(1, "a", "a \t b", Date_1);
|
||||
page_parser.Trie_tab_del_();
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_utf8_("a \t b")), 0);
|
||||
tst_parse(fil, doc.Wtxt_(Bry_.new_utf8_("a \t b")), 0);
|
||||
}
|
||||
@Test public void Cr_nl() {
|
||||
Xodb_page doc = doc_(1, "a", "a \r\n b", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_utf8_("a \n b")), 0);
|
||||
tst_parse(fil, doc.Wtxt_(Bry_.new_utf8_("a \n b")), 0);
|
||||
}
|
||||
@Test public void Cr() {
|
||||
Xodb_page doc = doc_(1, "a", "a \r b", Date_1);
|
||||
fil = page_bldr.Add(doc).XtoByteStreamRdr();
|
||||
tst_parse(fil, doc.Text_(Bry_.new_utf8_("a \n b")), 0);
|
||||
tst_parse(fil, doc.Wtxt_(Bry_.new_utf8_("a \n b")), 0);
|
||||
}
|
||||
@Test public void Text_long() {
|
||||
String s = String_.Repeat("a", 1024);
|
||||
@ -87,24 +87,24 @@ public class Xob_xml_parser_tst {
|
||||
@Test public void Ns_file() {
|
||||
Xodb_page doc = doc_(1, "File:a", "a", Date_1);
|
||||
Tfds.Eq(Xow_ns_.Id_file, doc.Ns_id());
|
||||
Tfds.Eq("a", String_.new_utf8_(doc.Ttl_wo_ns()));
|
||||
Tfds.Eq("a", String_.new_utf8_(doc.Ttl_page_db()));
|
||||
}
|
||||
@Test public void Ns_main() {
|
||||
Xodb_page doc = doc_(1, "a", "a", Date_1);
|
||||
Tfds.Eq(Xow_ns_.Id_main, doc.Ns_id());
|
||||
Tfds.Eq("a", String_.new_utf8_(doc.Ttl_wo_ns()));
|
||||
Tfds.Eq("a", String_.new_utf8_(doc.Ttl_page_db()));
|
||||
}
|
||||
@Test public void Ns_main_book() {
|
||||
Xodb_page doc = doc_(1, "Book", "a", Date_1);
|
||||
Tfds.Eq(Xow_ns_.Id_main, doc.Ns_id());
|
||||
Tfds.Eq("Book", String_.new_utf8_(doc.Ttl_wo_ns()));
|
||||
Tfds.Eq("Book", String_.new_utf8_(doc.Ttl_page_db()));
|
||||
}
|
||||
@Test public void XmlEntities() {
|
||||
Xodb_page orig = doc_(1, "A&b", "a", Date_1);
|
||||
Xodb_page actl = new Xodb_page();
|
||||
fil = page_bldr.Add(orig).XtoByteStreamRdr();
|
||||
page_parser.Parse_page(actl, usr_dlg, fil, fil.Bfr(), 0, ns_mgr);
|
||||
Tfds.Eq("A&b", String_.new_utf8_(actl.Ttl_w_ns()));
|
||||
Tfds.Eq("A&b", String_.new_utf8_(actl.Ttl_full_db()));
|
||||
}
|
||||
@Test public void Root() {
|
||||
Xodb_page doc = doc_(1, "a", "a", Date_1);
|
||||
@ -122,13 +122,13 @@ public class Xob_xml_parser_tst {
|
||||
Xodb_page actl = new Xodb_page();
|
||||
int rv = page_parser.Parse_page(actl, usr_dlg, fil, fil.Bfr(), cur_pos, ns_mgr);
|
||||
Tfds.Eq(expd.Id(), actl.Id(), "id");
|
||||
Tfds.Eq(String_.new_utf8_(expd.Ttl_w_ns()), String_.new_utf8_(actl.Ttl_w_ns()), "title");
|
||||
Tfds.Eq(String_.new_utf8_(expd.Text()), String_.new_utf8_(actl.Text()), "text");
|
||||
Tfds.Eq(String_.new_utf8_(expd.Ttl_full_db()), String_.new_utf8_(actl.Ttl_full_db()), "title");
|
||||
Tfds.Eq(String_.new_utf8_(expd.Wtxt()), String_.new_utf8_(actl.Wtxt()), "text");
|
||||
Tfds.Eq_date(expd.Modified_on(), actl.Modified_on(), "timestamp");
|
||||
return rv;
|
||||
}
|
||||
Xodb_page doc_(int id, String title, String text, String date) {
|
||||
Xodb_page rv = new Xodb_page().Id_(id).Ttl_(Bry_.new_ascii_(title), ns_mgr).Text_(Bry_.new_ascii_(text));
|
||||
Xodb_page rv = new Xodb_page().Id_(id).Ttl_(Bry_.new_ascii_(title), ns_mgr).Wtxt_(Bry_.new_ascii_(text));
|
||||
int[] modified_on = new int[7];
|
||||
dateParser.Parse_iso8651_like(modified_on, date);
|
||||
rv.Modified_on_(DateAdp_.seg_(modified_on));
|
||||
|
@ -61,7 +61,7 @@ public class Xoctg_html_mgr implements GfoInvkAble {
|
||||
boolean id_exists = wiki.Db_mgr().Load_mgr().Load_by_id(dbo_page, itm.Id());
|
||||
Xoa_ttl itm_ttl = null;
|
||||
if (id_exists)
|
||||
itm_ttl = Xoa_ttl.parse_(wiki, dbo_page.Ns_id(), dbo_page.Ttl_wo_ns());
|
||||
itm_ttl = Xoa_ttl.parse_(wiki, dbo_page.Ns_id(), dbo_page.Ttl_page_db());
|
||||
else {
|
||||
itm_ttl = Xoa_ttl.parse_(wiki, itm.Sortkey());
|
||||
if (itm_ttl == null)
|
||||
|
@ -31,7 +31,7 @@ public class Xoctg_pagelist_itms implements Bry_fmtr_arg {
|
||||
int len = itms.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_page page = (Xodb_page)itms.FetchAt(i);
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Xow_ns_.Id_category, page.Ttl_wo_ns());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, Xow_ns_.Id_category, page.Ttl_page_db());
|
||||
byte[] lnki_cls = 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_parser.Build_to_bry(wiki, ttl);
|
||||
byte[] lnki_ttl = ttl.Full_txt();
|
||||
|
@ -73,7 +73,7 @@ class Xoctg_pagelist_mgr_fxt {
|
||||
Xodb_page page = new Xodb_page();
|
||||
Xodb_category_itm ctg_xtn = Xodb_category_itm.load_(0, 0, hidden, 0, 0, 0);
|
||||
page.Xtn_(ctg_xtn);
|
||||
page.Ttl_wo_ns_(Bry_.new_ascii_(ttl));
|
||||
page.Ttl_page_db_(Bry_.new_ascii_(ttl));
|
||||
init_ctgs.AddMany(page);
|
||||
}
|
||||
} private ListAdp init_ctgs = ListAdp_.new_();
|
||||
|
@ -52,7 +52,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
}
|
||||
public boolean Load_by_ttl(Xodb_page rv, Xow_ns ns, byte[] ttl) {return db_mgr.Tbl_page().Select_by_ttl(rv, ns, ttl);}
|
||||
public void Load_by_ttls(Cancelable cancelable, OrderedHash rv, boolean fill_idx_fields_only, int bgn, int end) {db_mgr.Tbl_page().Select_by_ttl_in(cancelable, rv, db_mgr.Db_ctx(), fill_idx_fields_only, bgn, end);}
|
||||
public void Load_page(Xodb_page rv, Xow_ns ns, boolean timestamp_enabled) {rv.Text_(db_mgr.Tbl_text().Select(rv.Text_db_id(), rv.Id()));}
|
||||
public void Load_page(Xodb_page rv, Xow_ns ns, boolean timestamp_enabled) {rv.Wtxt_(db_mgr.Tbl_text().Select(rv.Wtxt_db_id(), rv.Id()));}
|
||||
public boolean Load_by_id (Xodb_page rv, int id) {return db_mgr.Tbl_page().Select_by_id(rv, id);}
|
||||
public void Load_by_ids(Cancelable cancelable, ListAdp rv, int bgn, int end) {db_mgr.Tbl_page().Select_by_id_list(cancelable, false, rv, bgn, end);}
|
||||
public boolean Load_ctg_v1(Xoctg_view_ctg rv, byte[] ctg_bry) {
|
||||
@ -98,9 +98,9 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
view_grp = rv.Grp_by_tid(cur_tid);
|
||||
prv_tid = cur_tid;
|
||||
}
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, db_page.Ns_id(), db_page.Ttl_wo_ns());
|
||||
Xoa_ttl ttl = Xoa_ttl.parse_(wiki, db_page.Ns_id(), db_page.Ttl_page_db());
|
||||
Xoctg_view_itm view_itm = new Xoctg_view_itm().Sortkey_(db_ctg.Sortkey()).Ttl_(ttl);
|
||||
view_itm.Load_by_ttl_data(cur_tid, db_page.Id(), Xodb_page.Timestamp_null, db_page.Text_len());
|
||||
view_itm.Load_by_ttl_data(cur_tid, db_page.Id(), Xodb_page.Modified_on_null_int, db_page.Wtxt_len());
|
||||
view_grp.Itms_add(view_itm);
|
||||
}
|
||||
len = Xoa_ctg_mgr.Tid__max;
|
||||
@ -154,7 +154,7 @@ public class Xodb_load_mgr_sql implements Xodb_load_mgr {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_page page = new Xodb_page();
|
||||
byte[] ttl = Xoa_ttl.Replace_spaces(ctg_ttls[i]); // NOTE: ctg_ttls has spaces since v1 rendered it literally;
|
||||
page.Ttl_wo_ns_(ttl);
|
||||
page.Ttl_page_db_(ttl);
|
||||
if (!hash.Has(ttl))
|
||||
hash.Add(ttl, page);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
|
||||
public Xodb_page[] pages_(Xodb_page... ary) {return ary;}
|
||||
public Xodb_page ctg_(int id, String ttl, boolean hidden, int count_subcs, int count_files, int count_pages) {
|
||||
Xodb_page rv = new Xodb_page().Ns_id_(Xow_ns_.Id_category).Id_(id).Ttl_wo_ns_(Bry_.new_ascii_(ttl));
|
||||
Xodb_page rv = new Xodb_page().Ns_id_(Xow_ns_.Id_category).Id_(id).Ttl_page_db_(Bry_.new_ascii_(ttl));
|
||||
Xodb_category_itm ctg = Xodb_category_itm.load_(id, 0, hidden, count_subcs, count_files, count_pages);
|
||||
rv.Xtn_(ctg);
|
||||
return rv;
|
||||
@ -66,7 +66,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
DateAdp modified = DateAdp_.Now();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_page page = ary[i];
|
||||
db_mgr.Tbl_page().Insert(page_stmt, page.Id(), page.Ns_id(), page.Ttl_wo_ns(), false, modified, 10, page.Id(), 0, 0);
|
||||
db_mgr.Tbl_page().Insert(page_stmt, page.Id(), page.Ns_id(), page.Ttl_page_db(), false, modified, 10, page.Id(), 0, 0);
|
||||
Xodb_category_itm ctg_itm = (Xodb_category_itm)page.Xtn();
|
||||
db_mgr.Tbl_category().Insert(category_stmt, ctg_itm.Id(), ctg_itm.Count_pages(), ctg_itm.Count_subcs(), ctg_itm.Count_files(), Bool_.Xto_byte(ctg_itm.Hidden()), 0);
|
||||
}
|
||||
@ -76,7 +76,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
int len = ary.length;
|
||||
byte[][] ttls = new byte[len][];
|
||||
for (int i = 0; i < len; i++) {
|
||||
ttls[i] = ary[i].Ttl_wo_ns();
|
||||
ttls[i] = ary[i].Ttl_page_db();
|
||||
}
|
||||
Xodb_page[] actl = wiki.Db_mgr_as_sql().Load_mgr().Load_ctg_list(ttls);
|
||||
Tfds.Eq_str_lines(Xto_str(ary), Xto_str(actl));
|
||||
@ -88,7 +88,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
Xodb_page page = ary[i];
|
||||
Xodb_category_itm ctg_itm = (Xodb_category_itm)page.Xtn();
|
||||
bfr.Add_int_variable(page.Id()).Add_byte_pipe();
|
||||
bfr.Add(page.Ttl_wo_ns()).Add_byte_pipe();
|
||||
bfr.Add(page.Ttl_page_db()).Add_byte_pipe();
|
||||
bfr.Add_byte(Bool_.Xto_byte(ctg_itm.Hidden())).Add_byte_nl();
|
||||
}
|
||||
return bfr.Xto_str_and_clear();
|
||||
@ -146,7 +146,7 @@ class Xodb_load_mgr_sql_fxt {
|
||||
String[] rv = new String[len];
|
||||
for (int i = 0; i< len; i++) {
|
||||
Xodb_page itm = (Xodb_page)list.FetchAt(i);
|
||||
rv[i] = String_.new_ascii_(itm.Ttl_wo_ns());
|
||||
rv[i] = String_.new_ascii_(itm.Ttl_page_db());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -185,7 +185,7 @@ class Xoctg_mok_ctg {
|
||||
Xoctg_page_xtn db_ctg = new Xoctg_page_xtn(ctg_tid, ttl);
|
||||
Xodb_page page = new Xodb_page();
|
||||
int page_id = next_id.Val_add_post();
|
||||
page.Id_(page_id).Ns_id_(ns_id).Ttl_wo_ns_(ttl).Xtn_(db_ctg);
|
||||
page.Id_(page_id).Ns_id_(ns_id).Ttl_page_db_(ttl).Xtn_(db_ctg);
|
||||
grp.Itms().Add(page);
|
||||
}
|
||||
grp.Last_plus_one_sortkey_(Bry_.new_ascii_(last_itm_plus_one_sortkey));
|
||||
|
@ -24,7 +24,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
} private Xowe_wiki wiki; Xotdb_fsys_mgr fsys_mgr;
|
||||
Xob_xdat_file tmp_xdat_file = new Xob_xdat_file(); Xob_xdat_itm tmp_xdat_itm = new Xob_xdat_itm();
|
||||
public void Load_init (Xowe_wiki wiki) {}
|
||||
public void Load_page(Xodb_page rv, Xow_ns ns, boolean timestamp_enabled) {Load_page(rv, rv.Text_db_id(), rv.Db_row_idx(), ns, timestamp_enabled, tmp_xdat_file, tmp_xdat_itm);}
|
||||
public void Load_page(Xodb_page rv, Xow_ns ns, boolean timestamp_enabled) {Load_page(rv, rv.Wtxt_db_id(), rv.Tdb_row_idx(), ns, timestamp_enabled, tmp_xdat_file, tmp_xdat_itm);}
|
||||
public void Load_page(Xodb_page rv, int txt_fil_idx, int txt_row_idx, Xow_ns ns, boolean timestamp_enabled, Xob_xdat_file xdat_file, Xob_xdat_itm xdat_itm) {
|
||||
Io_url file = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_page, ns.Id(), txt_fil_idx);
|
||||
byte[] bry = gplx.ios.Io_stream_rdr_.Load_all(file); int bry_len = bry.length;
|
||||
@ -36,13 +36,13 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
if (!Load_xdat_itm(tmp_xdat_itm, ns, Xotdb_dir_info_.Tid_ttl, ttl, Xodb_page_.Txt_ttl_pos, Byte_ascii.Tab, true)) return false;
|
||||
Xodb_page_.Txt_ttl_load(rv, tmp_xdat_itm.Itm_bry());
|
||||
rv.Exists_(true);
|
||||
return Bry_.Eq(rv.Ttl_wo_ns(), ttl);
|
||||
return Bry_.Eq(rv.Ttl_page_db(), ttl);
|
||||
}
|
||||
public void Load_by_ttls(Cancelable cancelable, OrderedHash rv, boolean fill_idx_fields_only, int bgn, int end) {// NOTE: Load_by_ttls just a wrapper around Load_by_ttl; for xdat, Load_by_ttl is fast enough
|
||||
for (int i = bgn; i < end; i++) {
|
||||
if (cancelable.Canceled()) return;
|
||||
Xodb_page page = (Xodb_page)rv.FetchAt(i);
|
||||
Load_by_ttl(page, page.Ns(), page.Ttl_wo_ns());
|
||||
Load_by_ttl(page, page.Ns(), page.Ttl_page_db());
|
||||
}
|
||||
}
|
||||
public void Load_by_ids(Cancelable cancelable, ListAdp list, int bgn, int end) {
|
||||
@ -60,7 +60,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
prv_fil_idx = cur_fil_idx;
|
||||
}
|
||||
if (!this.Load_by_id(tmp_page, tmp_xdat_file, id_bry)) continue; // id not found in file; ignore
|
||||
itm.Ns_id_(tmp_page.Ns_id()).Ttl_wo_ns_(tmp_page.Ttl_wo_ns());
|
||||
itm.Ns_id_(tmp_page.Ns_id()).Ttl_page_db_(tmp_page.Ttl_page_db());
|
||||
msg_wtr.Write_prog_cur(i, wiki.Appe().Usr_dlg());
|
||||
}
|
||||
} Xodb_page tmp_page = new Xodb_page();
|
||||
@ -115,7 +115,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
int page_id = Base85_utl.XtoIntByAry(raw, pos, pos + 4);
|
||||
pos += 6; // 5 + 1 for semic;
|
||||
int page_len = Base85_utl.XtoIntByAry(raw, pos, pos + 4);
|
||||
rv.Add(Xodb_page.srch_(page_id, page_len));
|
||||
rv.Add(Xodb_page.new_srch(page_id, page_len));
|
||||
pos += 6; // 5 + 1 for pipe
|
||||
// if (match.Itms_len() == max_results) break;
|
||||
}
|
||||
@ -259,7 +259,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
Xob_random_itm file = files[file_idx];
|
||||
tmp_xdat_file.GetAt(tmp_xdat_itm, random_idx - file.Bgn()); // get nth row; EX: random_idx=120; .Bgn=103 -> get 17th
|
||||
Xodb_page page = Xodb_page_.Txt_ttl_load(tmp_xdat_itm.Itm_bry());
|
||||
return page.Ttl_wo_ns();
|
||||
return page.Ttl_page_db();
|
||||
}
|
||||
private static Xob_random_itm[] Build_random_itms(Xowd_regy_mgr mgr, Int_obj_ref count) {
|
||||
// convert regy to list of random_itms (similar to regy_itms, but has integer bgn / end; EX: [0]:0,50; [1]:51-102; [2]:103-130)
|
||||
@ -299,7 +299,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
Xodb_page itm = (Xodb_page)ctgs.FetchAt(i);
|
||||
byte itm_tid = Load_ctg_v1_tid(itm.Ns_id());
|
||||
Xoctg_view_itm sub = Load_ctg_v1_sub(itm_tid, itm);
|
||||
sub.Ttl_(Xoa_ttl.parse_(wiki, itm.Ns_id(), itm.Ttl_wo_ns())).Sortkey_(itm.Ttl_wo_ns());
|
||||
sub.Ttl_(Xoa_ttl.parse_(wiki, itm.Ns_id(), itm.Ttl_page_db())).Sortkey_(itm.Ttl_page_db());
|
||||
view_ctg.Grp_by_tid(itm_tid).Itms_add(sub);
|
||||
}
|
||||
for (byte i = 0; i < Xoa_ctg_mgr.Tid__max; i++) {
|
||||
@ -342,7 +342,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
}
|
||||
private static Xoctg_view_itm Load_ctg_v1_sub(byte tid, Xodb_page data) {
|
||||
Xoctg_view_itm rv = new Xoctg_view_itm();
|
||||
rv.Load_by_ttl_data(tid, data.Id(), 0, data.Text_len());
|
||||
rv.Load_by_ttl_data(tid, data.Id(), 0, data.Wtxt_len());
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -355,7 +355,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
}
|
||||
int name_bgn = timestamp_end + 1;
|
||||
int name_end = Bry_finder.Find_fwd(src, Xodb_page_.Txt_page_dlm, name_bgn, src_len);
|
||||
page.Text_(Bry_.Mid(src, name_end + 1, row_end - 1)); // +1 to skip dlm
|
||||
page.Wtxt_(Bry_.Mid(src, name_end + 1, row_end - 1)); // +1 to skip dlm
|
||||
}
|
||||
Xowd_regy_mgr Get_regy_by_site(byte regy_tid) {
|
||||
Xowd_regy_mgr rv = site_regys[regy_tid];
|
||||
@ -410,7 +410,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
for (; row_idx < rows_len; row_idx++) {
|
||||
xdat_file.GetAt(xdat_itm, row_idx);
|
||||
Xodb_page ttl_itm = Xodb_page_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
if (!include_redirects && ttl_itm.Type_redirect()) continue;
|
||||
if (!include_redirects && ttl_itm.Redirected()) continue;
|
||||
++count;
|
||||
nxt_itm = ttl_itm;
|
||||
if (count == total) {
|
||||
@ -449,7 +449,7 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
for (; row_idx > -1; row_idx--) {
|
||||
xdat_file.GetAt(xdat_itm, row_idx);
|
||||
Xodb_page ttl_itm = Xodb_page_.Txt_ttl_load(Bry_.Mid(xdat_itm.Src(), xdat_itm.Itm_bgn(), xdat_itm.Itm_end()));
|
||||
if (!include_redirects && ttl_itm.Type_redirect()) continue;
|
||||
if (!include_redirects && ttl_itm.Redirected()) continue;
|
||||
// list.Add(ttl_itm);
|
||||
++count;
|
||||
prv_itm = ttl_itm;
|
||||
@ -525,8 +525,8 @@ public class Xodb_load_mgr_txt implements Xodb_load_mgr {
|
||||
Xodb_page page = new Xodb_page();
|
||||
this.Load_by_ttl(page, ns, ttl);
|
||||
|
||||
Load_ctg_v2_main(ctg_temp, page.Ttl_wo_ns());
|
||||
Xodb_category_itm ctg_itm = Xodb_category_itm.load_(page.Id(), page.Text_db_id(), ctg_temp.Hidden(), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_subc), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_file), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_page));
|
||||
Load_ctg_v2_main(ctg_temp, page.Ttl_page_db());
|
||||
Xodb_category_itm ctg_itm = Xodb_category_itm.load_(page.Id(), page.Wtxt_db_id(), ctg_temp.Hidden(), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_subc), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_file), ctg_temp.Total_by_tid(Xoa_ctg_mgr.Tid_page));
|
||||
page.Xtn_(ctg_itm);
|
||||
rv[i] = page;
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
tbl_text.Insert(text_stmt, page_id, text, data_storage_format);
|
||||
}
|
||||
public boolean Ctg_select_v1(Xoctg_view_ctg view_ctg, Db_conn ctg_provider, Xodb_category_itm ctg) {
|
||||
Db_qry_select qry = Db_qry_.select_().Cols_(Xodb_categorylinks_tbl.Fld_cl_from)
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().Cols_(Xodb_categorylinks_tbl.Fld_cl_from)
|
||||
.From_(Xodb_categorylinks_tbl.Tbl_name)
|
||||
.Where_(Db_crt_.eq_(Xodb_categorylinks_tbl.Fld_cl_to_id, ctg.Id()))
|
||||
;
|
||||
@ -118,9 +118,9 @@ public class Xodb_mgr_sql implements Xodb_mgr, GfoInvkAble {
|
||||
byte ctg_tid = Xodb_load_mgr_txt.Load_ctg_v1_tid(page.Ns_id());
|
||||
Xoctg_view_grp ctg_grp = view_ctg.Grp_by_tid(ctg_tid);
|
||||
Xoctg_view_itm ctg_itm = new Xoctg_view_itm();
|
||||
ctg_itm.Load_by_ttl_data(ctg_tid, page.Id(), 0, page.Text_len());
|
||||
ctg_itm.Ttl_(Xoa_ttl.parse_(wiki, page.Ns_id(), page.Ttl_wo_ns()));
|
||||
ctg_itm.Sortkey_(page.Ttl_wo_ns());
|
||||
ctg_itm.Load_by_ttl_data(ctg_tid, page.Id(), 0, page.Wtxt_len());
|
||||
ctg_itm.Ttl_(Xoa_ttl.parse_(wiki, page.Ns_id(), page.Ttl_page_db()));
|
||||
ctg_itm.Sortkey_(page.Ttl_page_db());
|
||||
ctg_grp.Itms_add(ctg_itm);
|
||||
rv = true;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class Xodb_save_mgr_sql implements Xodb_save_mgr {
|
||||
Xodb_page db_page = new Xodb_page();
|
||||
db_mgr.Load_mgr().Load_by_id(db_page, page.Revision_data().Id());
|
||||
text = zip_mgr.Zip(db_mgr.Data_storage_format(), text);
|
||||
db_mgr.Tbl_text().Update(db_page.Text_db_id(), page.Revision_data().Id(), text);
|
||||
db_mgr.Tbl_text().Update(db_page.Wtxt_db_id(), page.Revision_data().Id(), text);
|
||||
}
|
||||
public void Data_rename(Xoae_page page, int trg_ns, byte[] trg_ttl) {
|
||||
Db_qry qry = Db_qry_.update_common_("page", Db_crt_.eq_("page_id", page.Revision_data().Id())
|
||||
|
@ -30,7 +30,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
public void Clear() {page_id_next = 0;} // TEST: needed for ctg_test
|
||||
public void Data_create(Xoa_ttl ttl, byte[] text) {
|
||||
Xow_ns ns_itm = ttl.Ns(); byte[] ttl_bry = ttl.Page_db();
|
||||
Xodb_page db_page = Xodb_page.tmp_();
|
||||
Xodb_page db_page = Xodb_page.new_tmp();
|
||||
boolean found = load_mgr.Load_by_ttl(db_page, ns_itm, ttl_bry);
|
||||
if (found) throw Err_mgr._.fmt_(GRP_KEY, "title_exists", "create requested but title already exists: ~{0}", String_.new_utf8_(ttl_bry));
|
||||
int text_len = text.length;
|
||||
@ -50,7 +50,7 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
tmp_bfr.Mkr_rls();
|
||||
|
||||
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(text, text_len);
|
||||
db_page.Set_all_(page_id, fil_idx, row_idx, redirect_ttl != null, text_len, ttl.Page_db());
|
||||
db_page.Init(page_id, ttl.Page_db(), redirect_ttl != null, text_len, fil_idx, row_idx);
|
||||
Xodb_page_.Txt_ttl_save(tmp, db_page);
|
||||
byte[] ttl_row_bry = tmp.Mkr_rls().Xto_bry_and_clear();
|
||||
Xowd_hive_mgr ttl_hive = new Xowd_hive_mgr(wiki, Xotdb_dir_info_.Tid_ttl);
|
||||
@ -68,18 +68,18 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
private void Data_update_under(Xoae_page page, byte[] text, byte[] new_ttl) {
|
||||
Xoa_ttl ttl = page.Ttl();
|
||||
Xow_ns ns = ttl.Ns(); byte[] ttl_bry = ttl.Page_db();
|
||||
Xodb_page db_page = Xodb_page.tmp_();
|
||||
Xodb_page db_page = Xodb_page.new_tmp();
|
||||
if (!load_mgr.Load_by_ttl(db_page, ns, ttl_bry)) throw Err_mgr._.fmt_(GRP_KEY, "title_missing", "update requested but title does not exist: ~{0}", String_.new_utf8_(ttl_bry));
|
||||
byte[] old_ttl = ttl_bry;
|
||||
if (new_ttl != null) {
|
||||
ttl_bry = new_ttl;
|
||||
db_page.Ttl_wo_ns_(new_ttl);
|
||||
db_page.Ttl_page_db_(new_ttl);
|
||||
}
|
||||
// update page
|
||||
Xob_xdat_file page_rdr = new Xob_xdat_file(); Xob_xdat_itm page_itm = new Xob_xdat_itm();
|
||||
load_mgr.Load_page(tmp_page, db_page.Text_db_id(), db_page.Db_row_idx(), ns, true, page_rdr, page_itm);
|
||||
load_mgr.Load_page(tmp_page, db_page.Wtxt_db_id(), db_page.Tdb_row_idx(), ns, true, page_rdr, page_itm);
|
||||
Bry_bfr tmp_bfr = wiki.Utl__bfr_mkr().Get_b512();
|
||||
if (text == null) text = tmp_page.Text();
|
||||
if (text == null) text = tmp_page.Wtxt();
|
||||
int text_len = text.length;
|
||||
DateAdp modified_on = tmp_page.Modified_on();
|
||||
if (update_modified_on_enabled) {
|
||||
@ -88,13 +88,13 @@ public class Xodb_save_mgr_txt implements Xodb_save_mgr {
|
||||
}
|
||||
Xodb_page_.Txt_page_save(tmp_bfr, db_page.Id(), modified_on, ttl_bry, text, true);
|
||||
page_rdr.Update(tmp_bfr, page_itm, tmp_bfr.Xto_bry_and_clear());
|
||||
Io_url page_rdr_url = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_page, ttl.Ns().Id(), db_page.Text_db_id());
|
||||
Io_url page_rdr_url = fsys_mgr.Url_ns_fil(Xotdb_dir_info_.Tid_page, ttl.Ns().Id(), db_page.Wtxt_db_id());
|
||||
this.Data_save(Xotdb_dir_info_.Tid_page, page_rdr, page_rdr_url, tmp_bfr);
|
||||
tmp_bfr.Mkr_rls();
|
||||
// update ttl
|
||||
Xoa_ttl redirect_ttl = redirect_mgr.Extract_redirect(text, text_len);
|
||||
db_page.Text_len_(text_len);
|
||||
db_page.Type_redirect_(redirect_ttl != null);
|
||||
db_page.Wtxt_len_(text_len);
|
||||
db_page.Redirected_(redirect_ttl != null);
|
||||
Bry_bfr tmp = wiki.Utl__bfr_mkr().Get_b512();
|
||||
Xodb_page_.Txt_ttl_save(tmp, db_page);
|
||||
byte[] ttl_row_bry = tmp.Xto_bry_and_clear();
|
||||
|
@ -43,7 +43,7 @@ public class Xodb_categorylinks_tbl {
|
||||
gplx.core.criterias.Criteria comp_crt = !arg_is_from
|
||||
? Db_crt_.mte_(Fld_cl_sortkey, arg_sortkey_str) // from: sortkey >= 'val'
|
||||
: Db_crt_.lte_(Fld_cl_sortkey, arg_sortkey_str); // until: sortkey <= 'val'
|
||||
Db_qry_select qry = Db_qry_.select_().Cols_(Fld_cl_from, Fld_cl_sortkey).From_(Tbl_name)
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().Cols_(Fld_cl_from, Fld_cl_sortkey).From_(Tbl_name)
|
||||
.Where_(gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_cl_to_id, -1), Db_crt_.eq_(Fld_cl_type_id, arg_tid), comp_crt))
|
||||
.OrderBy_(Fld_cl_sortkey, !arg_is_from)
|
||||
.Limit_(limit + 1); // + 1 to get last_plus_one for next page / previous page
|
||||
|
@ -51,10 +51,10 @@ class Xodb_in_wkr_page_title extends Xodb_in_wkr_page_base {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
Xodb_page page = (Xodb_page)hash.FetchAt(i);
|
||||
stmt.Val_int(in_ns);
|
||||
stmt.Val_bry_as_str(page.Ttl_wo_ns());
|
||||
stmt.Val_bry_as_str(page.Ttl_page_db());
|
||||
}
|
||||
}
|
||||
@Override public Xodb_page Eval_rslts_key(Xodb_page rdr_page) {return (Xodb_page)hash.Fetch(rdr_page.Ttl_wo_ns());}
|
||||
@Override public Xodb_page Eval_rslts_key(Xodb_page rdr_page) {return (Xodb_page)hash.Fetch(rdr_page.Ttl_page_db());}
|
||||
}
|
||||
class Xodb_in_wkr_page_title_ns extends Xodb_in_wkr_page_base {
|
||||
private Xow_ns_mgr ns_mgr;
|
||||
@ -73,15 +73,15 @@ class Xodb_in_wkr_page_title_ns extends Xodb_in_wkr_page_base {
|
||||
for (int i = bgn; i < end; i++) {
|
||||
Xodb_page page = (Xodb_page)hash.FetchAt(i);
|
||||
stmt.Val_int(page.Ns_id());
|
||||
stmt.Val_bry_as_str(page.Ttl_wo_ns());
|
||||
stmt.Val_bry_as_str(page.Ttl_page_db());
|
||||
}
|
||||
}
|
||||
@Override public Xodb_page Eval_rslts_key(Xodb_page rdr_page) {
|
||||
Xow_ns ns = ns_mgr.Ids_get_or_null(rdr_page.Ns_id());
|
||||
if (ns == null) return null; // NOTE: ns seems to "randomly" be null when threading during redlinks; guard against null; DATE:2014-01-03
|
||||
byte[] ttl_wo_ns = rdr_page.Ttl_wo_ns();
|
||||
byte[] ttl_wo_ns = rdr_page.Ttl_page_db();
|
||||
rdr_page.Ttl_(ns, ttl_wo_ns);
|
||||
return (Xodb_page)hash.Fetch(rdr_page.Ttl_w_ns());
|
||||
return (Xodb_page)hash.Fetch(rdr_page.Ttl_full_db());
|
||||
}
|
||||
}
|
||||
abstract class Xodb_in_wkr_page_base extends Xodb_in_wkr_base {
|
||||
|
@ -35,7 +35,7 @@ public class Xodb_page_tbl {
|
||||
public boolean Select_by_ttl(Xodb_page rv, Xow_ns ns, byte[] ttl) {
|
||||
Db_rdr rdr = Db_rdr_.Null; Db_stmt stmt = Db_stmt_.Null;
|
||||
try {
|
||||
stmt = Db_stmt_.new_select_as_rdr(conn, Db_qry__select_in_tbl.new_(Tbl_name, String_.Ary(Fld_page_ns, Fld_page_title), html_db_enabled ? Select_by_id_flds__hdump : Select_by_id_flds__basic));
|
||||
stmt = Db_stmt_.new_select_as_rdr(conn, Db_qry__select_in_tbl.new_(Tbl_name, String_.Ary(Fld_page_ns, Fld_page_title), html_db_enabled ? Select_by_id_flds__hdump : Select_by_id_flds__basic, Db_qry__select_in_tbl.Order_by_null));
|
||||
rdr = stmt.Val_int(ns.Id()).Val_str(String_.new_utf8_(ttl)).Exec_select_as_rdr();
|
||||
if (rdr.Move_next()) {
|
||||
Read_page__all2(rv, rdr, html_db_enabled);
|
||||
@ -45,17 +45,22 @@ public class Xodb_page_tbl {
|
||||
return false;
|
||||
}
|
||||
public static void Read_page__all2(Xodb_page page, Db_rdr rdr, boolean html_db_enabled) {
|
||||
page.Id_ (rdr.Read_int(Fld_page_id));
|
||||
page.Ns_id_ (rdr.Read_int(Fld_page_ns));
|
||||
page.Ttl_wo_ns_ (rdr.Read_bry_by_str(Fld_page_title));
|
||||
page.Modified_on_ (DateAdp_.parse_fmt(rdr.Read_str(Fld_page_touched), Page_touched_fmt));
|
||||
page.Type_redirect_ (rdr.Read_byte(Fld_page_is_redirect) == 1);
|
||||
page.Text_len_ (rdr.Read_int(Fld_page_len));
|
||||
page.Text_db_id_ (rdr.Read_int(Fld_page_file_idx));
|
||||
int html_db_id = -1, redirected_id = -1;
|
||||
if (html_db_enabled) {
|
||||
page.Html_db_id_(rdr.Read_int(Fld_page_html_db_id));
|
||||
page.Redirect_id_(rdr.Read_int(Fld_page_is_redirect));
|
||||
html_db_id = rdr.Read_int(Fld_page_html_db_id);
|
||||
redirected_id = rdr.Read_int(Fld_page_redirect_id);
|
||||
}
|
||||
page.Init_by_sql
|
||||
( rdr.Read_int(Fld_page_id)
|
||||
, rdr.Read_int(Fld_page_ns)
|
||||
, rdr.Read_bry_by_str(Fld_page_title)
|
||||
, DateAdp_.parse_fmt(rdr.Read_str(Fld_page_touched), Page_touched_fmt)
|
||||
, rdr.Read_bool_by_byte(Fld_page_is_redirect)
|
||||
, rdr.Read_int(Fld_page_len)
|
||||
, rdr.Read_int(Fld_page_file_idx)
|
||||
, html_db_id
|
||||
, redirected_id
|
||||
);
|
||||
}
|
||||
public boolean Select_by_id(Xodb_page rv, int page_id) {
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
@ -103,7 +108,7 @@ public class Xodb_page_tbl {
|
||||
stmt.Exec_insert();
|
||||
}
|
||||
public DataRdr Select_all(Db_conn p) {
|
||||
Db_qry_select qry = Db_qry_select.new_().From_(Tbl_name).Cols_(Fld_page_id, Fld_page_title).OrderBy_asc_(Fld_page_id);
|
||||
Db_qry__select_cmd qry = Db_qry__select_cmd.new_().From_(Tbl_name).Cols_(Fld_page_id, Fld_page_title).OrderBy_asc_(Fld_page_id);
|
||||
return p.Exec_qry_as_rdr(qry);
|
||||
}
|
||||
private DataRdr Load_ttls_starting_with_rdr(int ns_id, byte[] ttl_frag, boolean include_redirects, int max_results, int min_page_len, int browse_len, boolean fwd, boolean search_suggest) {
|
||||
@ -113,7 +118,7 @@ public class Xodb_page_tbl {
|
||||
crt = Criteria_.And(crt, Db_crt_.eq_(Fld_page_is_redirect, Byte_.Zero));
|
||||
String[] cols = search_suggest ? Flds_select_idx : html_db_enabled ? Flds_select_all__html_y : Flds_select_all__html_n;
|
||||
int limit = fwd ? max_results + 1 : max_results; // + 1 to get next item
|
||||
Db_qry_select select = Db_qry_.select_cols_(Tbl_name, crt, cols).Limit_(limit).OrderBy_(Fld_page_title, fwd);
|
||||
Db_qry__select_cmd select = Db_qry_.select_cols_(Tbl_name, crt, cols).Limit_(limit).OrderBy_(Fld_page_title, fwd);
|
||||
return select.Exec_qry_as_rdr(conn);
|
||||
}
|
||||
public void Load_ttls_for_all_pages(Cancelable cancelable, ListAdp rslt_list, Xodb_page rslt_nxt, Xodb_page 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) {
|
||||
@ -127,7 +132,7 @@ public class Xodb_page_tbl {
|
||||
if (cancelable.Canceled()) return;
|
||||
Xodb_page page = new Xodb_page();
|
||||
Read_page__idx(page, rdr);
|
||||
if (max_val_check && !Bry_.HasAtBgn(page.Ttl_wo_ns(), key)) break;
|
||||
if (max_val_check && !Bry_.HasAtBgn(page.Ttl_page_db(), key)) break;
|
||||
nxt_itm = page;
|
||||
if (rslt_idx == max_results) {} // last item which is not meant for rslts, but only for nxt itm
|
||||
else {
|
||||
@ -211,7 +216,7 @@ public class Xodb_page_tbl {
|
||||
public void Select_by_search(Cancelable cancelable, ListAdp rv, byte[] search, int results_max) {
|
||||
if (Bry_.Len_eq_0(search)) return; // do not allow empty search
|
||||
Criteria crt = gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_page_ns, Xow_ns_.Id_main), Db_crt_.like_(Fld_page_title, ""));
|
||||
Db_qry_select qry = Db_qry_.select_().From_(Tbl_name).Cols_(Fld_page_id, Fld_page_len, Fld_page_ns, Fld_page_title).Where_(crt); // NOTE: use fields from main index only
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_(Tbl_name).Cols_(Fld_page_id, Fld_page_len, Fld_page_ns, Fld_page_title).Where_(crt); // NOTE: use fields from main index only
|
||||
DataRdr rdr = DataRdr_.Null;
|
||||
Db_stmt stmt = Db_stmt_.Null;
|
||||
search = Bry_.Replace(search, Byte_ascii.Asterisk, Byte_ascii.Percent);
|
||||
@ -223,8 +228,8 @@ public class Xodb_page_tbl {
|
||||
Xodb_page page = new Xodb_page();
|
||||
page.Id_ (rdr.ReadInt(Fld_page_id));
|
||||
page.Ns_id_ (rdr.ReadInt(Fld_page_ns));
|
||||
page.Ttl_wo_ns_ (rdr.ReadBryByStr(Fld_page_title));
|
||||
page.Text_len_ (rdr.ReadInt(Fld_page_len));
|
||||
page.Ttl_page_db_ (rdr.ReadBryByStr(Fld_page_title));
|
||||
page.Wtxt_len_ (rdr.ReadInt(Fld_page_len));
|
||||
rv.Add(page);
|
||||
}
|
||||
} finally {rdr.Rls(); stmt.Rls();}
|
||||
@ -239,7 +244,7 @@ public class Xodb_page_tbl {
|
||||
Criteria crt = gplx.core.criterias.Criteria_.And_many(Db_crt_.eq_(Fld_page_ns, -1), Db_crt_.mt_(Fld_page_title, ""));
|
||||
if (redirect != Bool_.__byte)
|
||||
crt = gplx.core.criterias.Criteria_.And(crt, Db_crt_.eq_(Fld_page_is_redirect, redirect));
|
||||
Db_qry_select qry = Db_qry_.select_().From_(Tbl_name).Cols_(html_db_enabled ? Flds_select_all__html_y : Flds_select_all__html_n)
|
||||
Db_qry__select_cmd qry = Db_qry_.select_().From_(Tbl_name).Cols_(html_db_enabled ? Flds_select_all__html_y : Flds_select_all__html_n)
|
||||
.Where_(crt)
|
||||
.Limit_(limit);
|
||||
return p.Stmt_new(qry);
|
||||
@ -286,22 +291,27 @@ public class Xodb_page_tbl {
|
||||
;
|
||||
public static final boolean Load_idx_flds_only_y = true;
|
||||
public static void Read_page__all(Xodb_page page, DataRdr rdr, boolean html_db_enabled) {
|
||||
page.Id_ (rdr.ReadInt(Fld_page_id));
|
||||
page.Ns_id_ (rdr.ReadInt(Fld_page_ns));
|
||||
page.Ttl_wo_ns_ (rdr.ReadBryByStr(Fld_page_title));
|
||||
page.Modified_on_ (DateAdp_.parse_fmt(rdr.ReadStr(Fld_page_touched), Page_touched_fmt));
|
||||
page.Type_redirect_ (rdr.ReadByte(Fld_page_is_redirect) == 1);
|
||||
page.Text_len_ (rdr.ReadInt(Fld_page_len));
|
||||
page.Text_db_id_ (rdr.ReadInt(Fld_page_file_idx));
|
||||
int html_db_id = -1, redirected_id = -1;
|
||||
if (html_db_enabled) {
|
||||
page.Html_db_id_(rdr.ReadInt(Fld_page_html_db_id));
|
||||
page.Redirect_id_(rdr.ReadInt(Fld_page_redirect_id));
|
||||
html_db_id = rdr.ReadInt(Fld_page_html_db_id);
|
||||
redirected_id = rdr.ReadInt(Fld_page_redirect_id);
|
||||
}
|
||||
page.Init_by_sql
|
||||
( rdr.ReadInt(Fld_page_id)
|
||||
, rdr.ReadInt(Fld_page_ns)
|
||||
, rdr.ReadBryByStr(Fld_page_title)
|
||||
, DateAdp_.parse_fmt(rdr.ReadStr(Fld_page_touched), Page_touched_fmt)
|
||||
, rdr.ReadByte(Fld_page_is_redirect) == 1
|
||||
, rdr.ReadInt(Fld_page_len)
|
||||
, rdr.ReadInt(Fld_page_file_idx)
|
||||
, html_db_id
|
||||
, redirected_id
|
||||
);
|
||||
}
|
||||
public static void Read_page__idx(Xodb_page page, DataRdr rdr) {
|
||||
page.Id_ (rdr.ReadInt(Fld_page_id));
|
||||
page.Ns_id_ (rdr.ReadInt(Fld_page_ns));
|
||||
page.Ttl_wo_ns_ (rdr.ReadBryByStr(Fld_page_title));
|
||||
page.Text_len_ (rdr.ReadInt(Fld_page_len));
|
||||
page.Ttl_page_db_ (rdr.ReadBryByStr(Fld_page_title));
|
||||
page.Wtxt_len_ (rdr.ReadInt(Fld_page_len));
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class Xodb_search_title_word_tbl {
|
||||
.Exec_insert();
|
||||
}
|
||||
public static void Select_by_word(Cancelable cancelable, ListAdp rv, Xodb_ctx db_ctx, byte[] search, int results_max, Db_conn p) {
|
||||
Db_qry_select qry = Db_qry_.select_()
|
||||
Db_qry__select_cmd qry = Db_qry_.select_()
|
||||
.Cols_(Xodb_search_title_word_tbl.Fld_stw_word_id)
|
||||
.From_(Xodb_search_title_word_tbl.Tbl_name, "w")
|
||||
;
|
||||
|
@ -51,7 +51,7 @@ public class Xodb_text_tbl {
|
||||
ListAdp pages = ListAdp_.new_();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xodb_page page = (Xodb_page)hash.FetchAt(i);
|
||||
if (page.Text_db_id() == file.Id())
|
||||
if (page.Wtxt_db_id() == file.Id())
|
||||
pages.Add(page);
|
||||
}
|
||||
len = pages.Count();
|
||||
@ -74,7 +74,7 @@ public class Xodb_text_tbl {
|
||||
byte[] old_text = rdr.ReadBry(Fld_old_text);
|
||||
old_text = zip_mgr.Unzip(db_mgr.Data_storage_format(), old_text);
|
||||
Xodb_page page = (Xodb_page)hash.Fetch(Int_obj_val.new_(page_id));
|
||||
page.Text_(old_text);
|
||||
page.Wtxt_(old_text);
|
||||
}
|
||||
} finally {rdr.Rls(); stmt.Rls();}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class Xodb_xowa_cfg_tbl {
|
||||
public int Select_val_as_int(String grp, String key) {return Int_.parse_(Select_val(grp, key));}
|
||||
public String Select_val(String grp, String key) {return Select_val_or(grp, key, null);}
|
||||
public String Select_val_or(String grp, String key, String or) {
|
||||
Db_qry_select qry = Db_qry_.select_val_(Tbl_name, Fld_cfg_val, Where_grp_key(grp, key));
|
||||
Db_qry__select_cmd qry = Db_qry_.select_val_(Tbl_name, Fld_cfg_val, Where_grp_key(grp, key));
|
||||
String rv = (String)qry.ExecRdr_val(conn);
|
||||
return rv == null ? or : rv;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class Xof_ext_ {
|
||||
private static final Xof_ext[] Ary = new Xof_ext[Id__max];
|
||||
|
||||
public static byte[] Get_ext_by_id_(int id) {
|
||||
if (id < 0 || id >= Id__max) throw Err_.new_fmt_("index out of bounds; {id}", id);
|
||||
if (id < 0 || id >= Id__max) throw Err_.new_fmt_("index out of bounds; {0}", id);
|
||||
return Bry__ary[id];
|
||||
}
|
||||
public static int Get_id_by_ext_(byte[] ext_bry) {
|
||||
|
@ -20,19 +20,24 @@ public interface Xof_file_itm {
|
||||
byte[] Lnki_ttl();
|
||||
byte[] Lnki_md5();
|
||||
Xof_ext Lnki_ext();
|
||||
// byte[] Lnki_redirect();
|
||||
byte Lnki_type();
|
||||
int Lnki_w();
|
||||
int Lnki_h();
|
||||
double Lnki_upright();
|
||||
double Lnki_time();
|
||||
int Lnki_page();
|
||||
byte Orig_repo_id();
|
||||
byte[] Orig_repo_name();
|
||||
byte[] Orig_ttl();
|
||||
int Orig_ext();
|
||||
int Orig_w();
|
||||
int Orig_h();
|
||||
// byte Orig_repo();
|
||||
byte[] Orig_redirect();
|
||||
boolean Img_is_thumbable();
|
||||
int File_w();
|
||||
int Html_uid();
|
||||
byte Html_elem_tid();
|
||||
int Html_w();
|
||||
int Html_h();
|
||||
// Io_url Html_url();
|
||||
int Gallery_mgr_h();
|
||||
}
|
||||
|
136
400_xowa/src/gplx/xowa/files/Xof_file_wkr.java
Normal file
136
400_xowa/src/gplx/xowa/files/Xof_file_wkr.java
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
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.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.threads.*;
|
||||
import gplx.fsdb.*; import gplx.fsdb.meta.*; import gplx.fsdb.data.*; import gplx.xowa.files.fsdb.*;
|
||||
import gplx.xowa.files.repos.*; import gplx.xowa.files.origs.*; import gplx.xowa.files.bins.*; import gplx.xowa.files.caches.*; import gplx.xowa.files.gui.*;
|
||||
import gplx.xowa.html.hdumps.core.*;
|
||||
class Xof_redlink_wkr implements Gfo_thread_wkr {
|
||||
private Xog_js_wkr js_wkr; private int[] uids;
|
||||
public Xof_redlink_wkr(Xog_js_wkr js_wkr, int[] uids) {
|
||||
this.js_wkr = js_wkr; this.uids = uids;
|
||||
}
|
||||
public String Name() {return "xowa.redlinks";}
|
||||
public boolean Resume() {return true;}
|
||||
public void Exec() {
|
||||
int len = uids.length;
|
||||
for (int i = 0; i < len; ++i) {
|
||||
int uid = uids[i];
|
||||
js_wkr.Html_atr_set(Int_.Xto_str(uid), "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Xof_file_wkr implements Gfo_thread_wkr {
|
||||
private final Xof_orig_mgr orig_mgr; private final Xof_bin_mgr bin_mgr; private final Fsm_mnt_mgr mnt_mgr; private final Xof_cache_mgr cache_mgr;
|
||||
private final Gfo_usr_dlg usr_dlg; private final Xow_repo_mgr repo_mgr; private final Xog_js_wkr js_wkr;
|
||||
private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_(); private final Xof_img_size img_size = new Xof_img_size();
|
||||
private final Xoa_page hpg; private final ListAdp imgs; private final byte exec_tid;
|
||||
public Xof_file_wkr(Xof_orig_mgr orig_mgr, Xof_bin_mgr bin_mgr, Fsm_mnt_mgr mnt_mgr, Xof_cache_mgr cache_mgr, Xow_repo_mgr repo_mgr, Xog_js_wkr js_wkr, Xoa_page hpg, ListAdp imgs, byte exec_tid) {
|
||||
this.orig_mgr = orig_mgr; this.bin_mgr = bin_mgr; this.mnt_mgr = mnt_mgr; this.cache_mgr = cache_mgr;
|
||||
this.usr_dlg = Gfo_usr_dlg_._; this.repo_mgr = repo_mgr; this.js_wkr = js_wkr;
|
||||
this.hpg = hpg; this.imgs = imgs; this.exec_tid = exec_tid;
|
||||
}
|
||||
public String Name() {return "xowa.load_imgs";}
|
||||
public boolean Resume() {return true;}
|
||||
public void Exec() {
|
||||
int len = imgs.Count();
|
||||
for (int i = 0; i < len; ++i)
|
||||
Ctor_by_hdump(exec_tid, hpg, (Xohd_data_itm__base)imgs.FetchAt(i));
|
||||
}
|
||||
private void Ctor_by_hdump(byte exec_tid, Xoa_page hpg, Xohd_data_itm__base hdump) {
|
||||
Xof_fsdb_itm fsdb = new Xof_fsdb_itm();
|
||||
fsdb.Ctor_by_lnki(hdump.Lnki_ttl(), hdump.Lnki_type(), hdump.Lnki_w(), hdump.Lnki_h(), Xof_patch_upright_tid_.Tid_all, hdump.Lnki_upright(), hdump.Lnki_time(), hdump.Lnki_page());
|
||||
fsdb.Lnki_ext_(Xof_ext_.new_by_id_(hdump.Lnki_ext()));
|
||||
fsdb.Html_uid_(hdump.Html_uid());
|
||||
fsdb.Orig_exists_n_();
|
||||
Xof_orig_itm orig = orig_mgr.Find_by_ttl_or_null(fsdb.Lnki_ttl()); if (orig == Xof_orig_itm.Null) return;
|
||||
Eval_orig(exec_tid, orig, fsdb, url_bldr, repo_mgr, img_size);
|
||||
Show_img(exec_tid, fsdb, usr_dlg, bin_mgr, mnt_mgr, cache_mgr, repo_mgr, js_wkr, img_size, url_bldr, hpg);
|
||||
}
|
||||
public static void Show_img(byte exec_tid, Xof_fsdb_itm fsdb, Gfo_usr_dlg usr_dlg, Xof_bin_mgr bin_mgr, Fsm_mnt_mgr mnt_mgr, Xof_cache_mgr cache_mgr, Xow_repo_mgr repo_mgr, Xog_js_wkr js_wkr, Xof_img_size img_size, Xof_url_bldr url_bldr, Xoa_page hpg) {
|
||||
try {
|
||||
if (fsdb.Orig_ext() < 0) {
|
||||
usr_dlg.Warn_many("", "", "file.missing.ext: file=~{0} width=~{1} page=~{2}", fsdb.Lnki_ttl(), fsdb.Lnki_w(), hpg.Ttl().Full_db());
|
||||
return;
|
||||
}
|
||||
Xof_repo_pair repo_pair = null;
|
||||
switch (fsdb.Orig_repo_id()) {
|
||||
case Xof_repo_itm.Repo_local:
|
||||
case Xof_repo_itm.Repo_remote:
|
||||
repo_pair = repo_mgr.Repos_get_by_id(fsdb.Orig_repo_id());
|
||||
break;
|
||||
}
|
||||
if (repo_pair == null) {
|
||||
usr_dlg.Warn_many("", "", "file.missing.repo: file=~{0} width=~{1} page=~{2}", fsdb.Lnki_ttl(), fsdb.Lnki_w(), hpg.Ttl().Full_db());
|
||||
return;
|
||||
}
|
||||
Xof_repo_itm repo = repo_pair.Trg();
|
||||
fsdb.Ctor_for_html(exec_tid, img_size, repo, url_bldr);
|
||||
if (fsdb.Lnki_ext().Is_not_viewable(exec_tid)) return; // file not viewable; exit; EX: exec_tid = page and fsdb is audio
|
||||
if (!Io_mgr._.ExistsFil(fsdb.Html_view_url())) {
|
||||
if (bin_mgr.Find_to_url_as_bool(exec_tid, fsdb)) {
|
||||
if (fsdb.Fsdb_insert()) Save_bin(fsdb, mnt_mgr);
|
||||
}
|
||||
else {
|
||||
usr_dlg.Warn_many("", "", "file.missing.bin: file=~{0} width=~{1} page=~{2}", fsdb.Lnki_ttl(), fsdb.Lnki_w(), hpg.Ttl().Full_db());
|
||||
fsdb.File_exists_n_();
|
||||
// gplx.xowa.files.gui.Js_img_mgr.Update_img_missing(usr_dlg, fsdb.Html_uid()); // TODO: update caption with "" if image is missing
|
||||
return;
|
||||
}
|
||||
}
|
||||
Js_img_mgr.Update_img(hpg, js_wkr, fsdb);
|
||||
cache_mgr.Reg_and_check_for_size_0(fsdb);
|
||||
} catch (Exception e) {
|
||||
usr_dlg.Warn_many("", "", "file.unknown: ~{0}", Err_.Message_gplx_brief(e));
|
||||
}
|
||||
}
|
||||
public static void Eval_orig(byte exec_tid, Xof_orig_itm orig, Xof_fsdb_itm fsdb, Xof_url_bldr url_bldr, Xow_repo_mgr repo_mgr, Xof_img_size img_size) {
|
||||
fsdb.Orig_exists_y_();
|
||||
byte repo_id = orig.Repo();
|
||||
Xof_repo_pair repo_pair = repo_mgr.Repos_get_by_id(repo_id);
|
||||
Xof_repo_itm repo_itm = repo_pair.Trg();
|
||||
fsdb.Ctor_by_orig(repo_id, repo_pair.Wiki_domain(), orig.Page(), orig.Ext(), orig.W(), orig.H(), orig.Redirect());
|
||||
fsdb.Ctor_for_html(exec_tid, img_size, repo_itm, url_bldr);
|
||||
}
|
||||
private static void Save_bin(Xof_fsdb_itm itm, Fsm_mnt_mgr mnt_mgr) {
|
||||
Io_url html_url = itm.Html_view_url();
|
||||
long bin_len = Io_mgr._.QueryFil(html_url).Size();
|
||||
gplx.ios.Io_stream_rdr bin_rdr = gplx.ios.Io_stream_rdr_.file_(html_url);
|
||||
try {
|
||||
bin_rdr.Open();
|
||||
mnt_mgr.Txn_open();
|
||||
if (itm.Lnki_ext().Id_is_thumbable_img()) {
|
||||
if (itm.File_is_orig())
|
||||
mnt_mgr.Img_insert(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_ext().Id(), itm.Html_w(), itm.Html_h(), Fsd_thm_tbl.Modified_null, Fsd_thm_tbl.Hash_null, bin_len, bin_rdr);
|
||||
else
|
||||
mnt_mgr.Thm_insert(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_ext().Id(), itm.Html_w(), itm.Html_h(), itm.Lnki_time(), itm.Lnki_page(), Fsd_thm_tbl.Modified_null, Fsd_thm_tbl.Hash_null, bin_len, bin_rdr);
|
||||
}
|
||||
else {
|
||||
if (itm.Lnki_ext().Id_is_video() && !itm.File_is_orig()) // insert as thumbnail
|
||||
mnt_mgr.Thm_insert(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_ext().Id(), itm.Html_w(), itm.Html_h(), itm.Lnki_time(), itm.Lnki_page(), Fsd_thm_tbl.Modified_null, Fsd_thm_tbl.Hash_null, bin_len, bin_rdr);
|
||||
else
|
||||
mnt_mgr.Fil_insert(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_ext().Id(), Fsd_thm_tbl.Modified_null, Fsd_thm_tbl.Hash_null, bin_len, bin_rdr);
|
||||
}
|
||||
mnt_mgr.Txn_save();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to save file: ttl=~{0} url=~{1} err=~{2}", String_.new_utf8_(itm.Lnki_ttl()), html_url.Raw(), Err_.Message_gplx(e));
|
||||
}
|
||||
finally {bin_rdr.Rls();}
|
||||
}
|
||||
}
|
@ -19,19 +19,16 @@ package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
public class Xof_fsdb_mode {
|
||||
private int tid;
|
||||
Xof_fsdb_mode(int tid) {this.tid = tid;}
|
||||
public boolean Tid_unknown() {return tid == Tid_int_unknown;}
|
||||
public boolean Tid_wmf() {return tid == Tid_int_wmf;}
|
||||
public boolean Tid_view() {return tid == Tid_int_view;}
|
||||
public boolean Tid_make() {return tid == Tid_int_make;}
|
||||
public void Tid_view_y_() {tid = Tid_int_view;}
|
||||
public void Tid_make_y_() {tid = Tid_int_make;}
|
||||
private static final int
|
||||
Tid_int_unknown = 0
|
||||
, Tid_int_wmf = 1
|
||||
Tid_int_wmf = 1
|
||||
, Tid_int_view = 2
|
||||
, Tid_int_make = 3
|
||||
;
|
||||
// public static Xof_fsdb_mode new_unknown() {return new Xof_fsdb_mode(Tid_int_unknown);}
|
||||
public static Xof_fsdb_mode new_wmf() {return new Xof_fsdb_mode(Tid_int_wmf);}
|
||||
public static Xof_fsdb_mode new_view() {return new Xof_fsdb_mode(Tid_int_view);}
|
||||
}
|
||||
|
@ -20,96 +20,70 @@ import gplx.xowa.files.repos.*; import gplx.xowa.files.fsdb.*; import gplx.xowa.
|
||||
import gplx.xowa.parsers.lnkis.*;
|
||||
public class Xof_lnki_file_mgr {
|
||||
private boolean page_init_needed = true;
|
||||
private final ListAdp fsdb_list = ListAdp_.new_();
|
||||
private final OrderedHash orig_regy = OrderedHash_.new_bry_(), xfer_list = OrderedHash_.new_bry_();
|
||||
private Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_(); private Xof_img_size tmp_img_size = new Xof_img_size();
|
||||
private final ListAdp fsdb_list = ListAdp_.new_(); private final OrderedHash orig_regy = OrderedHash_.new_bry_(), fsdb_hash = OrderedHash_.new_bry_();
|
||||
private final Xof_img_size img_size = new Xof_img_size(); private final Xof_url_bldr url_bldr = Xof_url_bldr.new_v2_();
|
||||
public void Clear() {
|
||||
page_init_needed = true;
|
||||
fsdb_list.Clear();
|
||||
xfer_list.Clear();
|
||||
orig_regy.Clear();
|
||||
fsdb_list.Clear(); fsdb_hash.Clear(); orig_regy.Clear();
|
||||
}
|
||||
public boolean Find(Xowe_wiki wiki, Xoae_page page, byte exec_tid, Xof_xfer_itm xfer_itm) {
|
||||
public boolean Find(Xowe_wiki wiki, Xoae_page page, byte exec_tid, Xof_xfer_itm xfer) {
|
||||
try {
|
||||
if (page_init_needed) {
|
||||
page_init_needed = false;
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki(wiki); // NOTE: fsdb_mgr may not be init'd for wiki; assert that that it is
|
||||
Create_xfer_itms(page.Lnki_list(), wiki.File_mgr().Patch_upright()); // NOTE: Patch_upright check must occur after Init_by_wiki; DATE:2014-05-31
|
||||
wiki.File_mgr().Fsdb_mgr().Init_by_wiki(wiki); // NOTE: fsdb_mgr may not be init'd for wiki; assert that that it is
|
||||
Make_fsdb_list(page.Lnki_list(), wiki.File_mgr().Patch_upright()); // NOTE: Patch_upright check must occur after Init_by_wiki; DATE:2014-05-31
|
||||
wiki.File_mgr().Fsdb_mgr().Orig_mgr().Find_by_list(orig_regy, fsdb_list, exec_tid);
|
||||
Hash_xfer_itms();
|
||||
Make_fsdb_hash();
|
||||
}
|
||||
Xof_fsdb_itm fsdb_itm = (Xof_fsdb_itm)xfer_list.Fetch(xfer_itm.Lnki_ttl());
|
||||
if (fsdb_itm == null) // no orig_data found for the current item
|
||||
return false;
|
||||
else {
|
||||
if (fsdb_itm.Orig_repo_name() == null) return false; // itm not found; return now, else null exception later;
|
||||
xfer_itm.Lnki_ext_(fsdb_itm.Lnki_ext()); // WORKAROUND: hacky, but fsdb_itm knows when ogg is ogv whereas xfer_itm does not; so, always override xfer_itm.ext with fsdb's; DATE:2014-02-02
|
||||
xfer_itm.Url_bldr_(url_bldr); // default Url_bldr for xfer_itm uses @ for thumbtime; switch to -; DATE:2014-02-02
|
||||
Init_fsdb_by_xfer(fsdb_itm, xfer_itm); // copy xfer itm props to fsdb_itm;
|
||||
xfer_itm.Set__orig(fsdb_itm.Orig_w(), fsdb_itm.Orig_h(), xfer_itm.Orig_file_len()); // copy orig props from orig_itm to xfer_itm
|
||||
Xof_repo_itm repo = wiki.File_mgr().Repo_mgr().Repos_get_by_wiki(fsdb_itm.Orig_repo_name()).Trg();
|
||||
fsdb_itm.Ctor_by_html(repo, url_bldr, tmp_img_size, exec_tid);
|
||||
xfer_itm.Trg_repo_(repo);
|
||||
xfer_itm.Html_orig_src_(Bry_.new_utf8_(fsdb_itm.Html_orig_url().To_http_file_str())); // always set orig_url; note that w,h are not necessary for orig url; orig url needed for [[Media:]] links; DATE:2014-01-19
|
||||
gplx.ios.IoItmFil fil = Io_mgr._.QueryFil(fsdb_itm.Html_view_url());
|
||||
if (fil.Exists()) {
|
||||
if (fil.Size() == 0) // NOTE: fix; XOWA used to write 0 byte files if file was missing, delete them and do not return true; DATE:2014-06-21
|
||||
Io_mgr._.DeleteFil(fsdb_itm.Html_view_url());
|
||||
else {
|
||||
xfer_itm.Calc_by_fsdb(fsdb_itm.Html_w(), fsdb_itm.Html_h(), fsdb_itm.Html_view_url(), fsdb_itm.Html_orig_url());
|
||||
return true;
|
||||
}
|
||||
Xof_fsdb_itm fsdb = (Xof_fsdb_itm)fsdb_hash.Fetch(xfer.Lnki_ttl());
|
||||
xfer.File_exists_n_();
|
||||
if (fsdb == null) return false; // no orig_data found for the ttl
|
||||
Xof_repo_itm repo = wiki.File_mgr().Repo_mgr().Repos_get_by_wiki(fsdb.Orig_repo_name()).Trg();
|
||||
fsdb.Lnki_size_(xfer.Lnki_w(), xfer.Lnki_h()); // NOTE: must overwrite fsdb.size with xfer.size when the same image shows up in multiple sizes on a page; (only one item in wiki_orig); EX: w:Portal:Canada; [[File:Flag of Canada.svg|300x150px]]; [[File:Flag of Canada.svg|23px]]; DATE:2014-02-14
|
||||
fsdb.Ctor_for_html(exec_tid, img_size, repo, url_bldr);
|
||||
xfer.Url_bldr_(url_bldr); // default Url_bldr for xfer uses @ for thumbtime; switch to -; DATE:2014-02-02
|
||||
xfer.Trg_repo_(repo);
|
||||
xfer.Lnki_ext_(fsdb.Lnki_ext()); // WORKAROUND: hacky, but fsdb knows when ogg is ogv whereas xfer does not; so, always override xfer.ext with fsdb's; DATE:2014-02-02
|
||||
xfer.Init_by_orig(fsdb.Orig_repo_id(), fsdb.Orig_repo_name(), fsdb.Orig_ttl(), fsdb.Orig_ext(), fsdb.Orig_w(), fsdb.Orig_h(), fsdb.Orig_redirect(), xfer.Orig_file_len()); // copy orig props from orig_itm to xfer
|
||||
xfer.Html_orig_url_(Bry_.new_utf8_(fsdb.Html_orig_url().To_http_file_str())); // always set orig_url; note that w,h are not necessary for orig url; orig url needed for [[Media:]] links; DATE:2014-01-19
|
||||
gplx.ios.IoItmFil fil = Io_mgr._.QueryFil(fsdb.Html_view_url());
|
||||
if (fil.Exists()) {
|
||||
if (fil.Size() == 0) // NOTE: fix; XOWA used to write 0 byte files if file was missing, delete them and do not return true; DATE:2014-06-21
|
||||
Io_mgr._.DeleteFil(fsdb.Html_view_url());
|
||||
else {
|
||||
xfer.Calc_by_fsdb(fsdb.Html_w(), fsdb.Html_h(), fsdb.Html_view_url(), fsdb.Html_orig_url());
|
||||
xfer.File_exists_y_();
|
||||
return true;
|
||||
}
|
||||
// TODO: replace above with this block; WHEN: mocking file database tests; DATE:2014-05-03
|
||||
// boolean found = Io_mgr._.ExistsFil(fsdb_itm.Html_url());
|
||||
// Io_url html_url = found ? fsdb_itm.Html_url() : null;
|
||||
// xfer_itm.Atrs_calc_by_fsdb(fsdb_itm.Html_w(), fsdb_itm.Html_h(), html_url, fsdb_itm.Html_orig_url());
|
||||
// return found;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
wiki.Appe().Usr_dlg().Warn_many("", "", "failed to find img: img=~{0} err=~{1}", String_.new_utf8_(xfer_itm.Lnki_ttl()), Err_.Message_gplx_brief(e));
|
||||
Xoa_app_.Usr_dlg().Warn_many("", "", "failed to find img: img=~{0} err=~{1}", String_.new_utf8_(xfer.Lnki_ttl()), Err_.Message_gplx_brief(e));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private void Create_xfer_itms(ListAdp lnki_list, int upright_patch) {
|
||||
private void Make_fsdb_list(ListAdp lnki_list, int upright_patch) {
|
||||
int len = lnki_list.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xop_lnki_tkn lnki_tkn = (Xop_lnki_tkn)lnki_list.FetchAt(i);
|
||||
Xof_fsdb_itm fsdb_itm = new Xof_fsdb_itm();
|
||||
Init_fsdb_by_lnki(fsdb_itm, lnki_tkn, upright_patch);
|
||||
fsdb_list.Add(fsdb_itm);
|
||||
Xof_fsdb_itm fsdb = new Xof_fsdb_itm();
|
||||
fsdb.Ctor_by_lnki(lnki_tkn.Ttl().Page_db(), lnki_tkn.Lnki_type(), lnki_tkn.W(), lnki_tkn.H(), upright_patch, lnki_tkn.Upright(), lnki_tkn.Time(), lnki_tkn.Page());
|
||||
fsdb_list.Add(fsdb);
|
||||
}
|
||||
}
|
||||
private void Hash_xfer_itms() {
|
||||
private void Make_fsdb_hash() {
|
||||
int len = fsdb_list.Count();
|
||||
for (int i = 0; i < len; i++) {
|
||||
Xof_fsdb_itm fsdb_itm = (Xof_fsdb_itm)fsdb_list.FetchAt(i);
|
||||
Hash_xfer_itms_add(fsdb_itm.Lnki_ttl(), fsdb_itm);
|
||||
Hash_xfer_itms_add(fsdb_itm.Orig_ttl(), fsdb_itm); // redirect
|
||||
Xof_fsdb_itm fsdb = (Xof_fsdb_itm)fsdb_list.FetchAt(i);
|
||||
Make_fsdb_hash_add(fsdb.Lnki_ttl(), fsdb);
|
||||
Make_fsdb_hash_add(fsdb.Orig_ttl(), fsdb); // redirect
|
||||
}
|
||||
}
|
||||
private void Hash_xfer_itms_add(byte[] key, Xof_fsdb_itm itm) {
|
||||
private void Make_fsdb_hash_add(byte[] key, Xof_fsdb_itm itm) {
|
||||
if ( Bry_.Len_gt_0(key) // ignore null / empty itms; needed for redirects
|
||||
&& !xfer_list.Has(key) // don't add if already there
|
||||
&& !fsdb_hash.Has(key) // don't add if already there
|
||||
&& orig_regy.Has(key) // add if found in orig_regy
|
||||
)
|
||||
xfer_list.Add(key, itm);
|
||||
}
|
||||
private void Init_fsdb_by_lnki(Xof_fsdb_itm fsdb_itm, Xop_lnki_tkn lnki_tkn, int lnki_upright_patch) {
|
||||
byte[] lnki_ttl = lnki_tkn.Ttl().Page_db();
|
||||
Xof_ext lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl);
|
||||
byte[] lnki_md5 = Xof_xfer_itm_.Md5_(lnki_ttl);
|
||||
fsdb_itm.Ctor_by_lnki(lnki_ttl, lnki_ext, lnki_md5, lnki_tkn.Lnki_type(), lnki_tkn.Lnki_w(), lnki_tkn.Lnki_h(), lnki_upright_patch, lnki_tkn.Upright(), lnki_tkn.Thumbtime(), lnki_tkn.Page());
|
||||
}
|
||||
private void Init_fsdb_by_xfer(Xof_fsdb_itm fsdb_itm, Xof_xfer_itm xfer_itm) { // DELETE: DATE:2014-02-04
|
||||
fsdb_itm.Lnki_size_(xfer_itm.Lnki_w(), xfer_itm.Lnki_h()); // NOTE: must overwrite fsdb_itm.size with xfer_itm.size when the same image shows up in multiple sizes on a page; (only one item in wiki_orig); EX: w:Portal:Canada; [[File:Flag of Canada.svg|300x150px]]; [[File:Flag of Canada.svg|23px]]; DATE:2014-02-14
|
||||
fsdb_itm.Lnki_type_(xfer_itm.Lnki_type()); // NOTE: must overwrite lnki_type, else multiple images on same page with different type wont show; PAGE:en.w:History_of_painting; DATE:2014-03-06
|
||||
fsdb_itm.Lnki_page_(xfer_itm.Lnki_page());
|
||||
fsdb_itm.Lnki_time_(xfer_itm.Lnki_time());
|
||||
// byte[] lnki_ttl = xfer_itm.Lnki_ttl();
|
||||
// Xof_ext lnki_ext = xfer_itm.Lnki_ext();
|
||||
// byte[] lnki_md5 = Xof_xfer_itm_.Md5_(lnki_ttl);
|
||||
// fsdb_itm.Init_by_lnki(lnki_ttl, lnki_ext, lnki_md5, xfer_itm.Lnki_type(), xfer_itm.Lnki_w(), xfer_itm.Lnki_h(), xfer_itm.Lnki_upright(), xfer_itm.Lnki_thumbtime(), xfer_itm.Lnki_page());
|
||||
fsdb_hash.Add(key, itm);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xof_doc_page {
|
||||
public class Xof_lnki_page {
|
||||
public static final int Null = -1;
|
||||
public static boolean Null_y(int v) {return v == Null;}
|
||||
public static boolean Null_n(int v) {return v != Null;}
|
@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.dbs.*;
|
||||
public class Xof_doc_thumb {
|
||||
public class Xof_lnki_time {
|
||||
public static double Db_save_double(double v) {return v;}
|
||||
public static double Db_load_double(DataRdr rdr, String fld) {return rdr.ReadDouble(fld);}
|
||||
public static double Db_load_double(Db_rdr rdr, String fld) {return rdr.Read_double(fld);}
|
||||
@ -33,9 +33,9 @@ public class Xof_doc_thumb {
|
||||
public static final int Null_as_int = -1;
|
||||
|
||||
public static double Convert_to_xowa_thumbtime (int ext, double val) {return Xof_ext_.Id_supports_thumbtime(ext) ? val : Null;}
|
||||
public static int Convert_to_xowa_page (int ext, double val) {return Xof_ext_.Id_supports_page(ext) ? (int)val : Xof_doc_page.Null;}
|
||||
public static int Convert_to_xowa_page (int ext, double val) {return Xof_ext_.Id_supports_page(ext) ? (int)val : Xof_lnki_page.Null;}
|
||||
public static double Convert_to_fsdb_thumbtime (int ext, double thumbtime, int page) {
|
||||
return page != Xof_doc_page.Null
|
||||
return page != Xof_lnki_page.Null
|
||||
&& Xof_ext_.Id_supports_page(ext) // redefine thumbtime to page if pdf
|
||||
? page
|
||||
: thumbtime
|
@ -20,7 +20,7 @@ import gplx.xowa.files.repos.*; import gplx.xowa.files.fsdb.*;
|
||||
public class Xof_url_bldr {
|
||||
private final Bry_bfr bfr = Bry_bfr.reset_(400);
|
||||
private byte[] ttl; private byte[] md5; private Xof_ext ext; private boolean file_is_thumb; private int file_w;
|
||||
private double time = Xof_doc_thumb.Null; private int page = Xof_doc_page.Null; private byte time_dlm = Byte_ascii.At;
|
||||
private double time = Xof_lnki_time.Null; private int page = Xof_lnki_page.Null; private byte time_dlm = Byte_ascii.At;
|
||||
private byte[] root; private byte dir_spr; private boolean fsys_tid_is_wnt; private boolean wmf_dir_hive; private boolean wmf_protocol_is_file; private int md5_dir_depth; private byte[] area;
|
||||
public Xof_url_bldr Root_(byte[] v) {root = v; return this;}
|
||||
public Xof_url_bldr Init_by_root(byte[] root, byte dir_spr, boolean wmf_dir_hive, boolean wmf_protocol_is_file, int md5_dir_depth) {
|
||||
@ -63,13 +63,9 @@ public class Xof_url_bldr {
|
||||
public byte[] Xto_bry() {Bld(); byte[] rv = bfr.Xto_bry_and_clear(); Clear(); return rv;}
|
||||
public String Xto_str() {Bld(); String rv = bfr.Xto_str(); Clear(); return rv;}
|
||||
public Io_url Xto_url() {Bld(); Io_url rv = Io_url_.new_fil_(bfr.Xto_str()); Clear(); return rv;}
|
||||
public Io_url To_url(Xow_repo_mgr repo_mgr, Xof_fsdb_itm itm, boolean orig) {return To_url(repo_mgr.Repos_get_by_wiki(itm.Orig_repo_name()), itm, orig ? Xof_repo_itm.Mode_orig : Xof_repo_itm.Mode_thumb, Bool_.N);}
|
||||
public Io_url To_url(Xof_repo_pair repo_pair, Xof_fsdb_itm itm, boolean orig) {return To_url(repo_pair, itm, orig ? Xof_repo_itm.Mode_orig : Xof_repo_itm.Mode_thumb, Bool_.N);}
|
||||
public Io_url To_url(Xof_repo_pair repo_pair, Xof_fsdb_itm itm, byte mode, boolean src) {
|
||||
return src
|
||||
? this.Init_for_src_file(mode, repo_pair.Src(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url()
|
||||
: this.Init_for_trg_file(mode, repo_pair.Trg(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url()
|
||||
;
|
||||
public Io_url To_url_trg(Xof_repo_itm repo_itm, Xof_fsdb_itm itm, boolean orig) {
|
||||
byte mode = orig ? Xof_repo_itm.Mode_orig : Xof_repo_itm.Mode_thumb;
|
||||
return this.Init_for_trg_file(mode, repo_itm, itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), itm.Html_w(), itm.Lnki_time(), itm.Lnki_page()).Xto_url();
|
||||
}
|
||||
private void Bld() {
|
||||
Add_core();
|
||||
@ -104,9 +100,9 @@ public class Xof_url_bldr {
|
||||
private Xof_url_bldr Add_thumb_xowa() {
|
||||
bfr.Add_byte(dir_spr); // add dir_spr; EX: "\"
|
||||
bfr.Add_int_variable(file_w).Add(Bry_px); // add file_w; EX: "220px"
|
||||
if (Xof_doc_thumb.Null_n(time))
|
||||
bfr.Add_byte(time_dlm).Add_str(Xof_doc_thumb.X_str(time)); // add time EX: "@5"
|
||||
else if (page != Xof_doc_page.Null)
|
||||
if (Xof_lnki_time.Null_n(time))
|
||||
bfr.Add_byte(time_dlm).Add_str(Xof_lnki_time.X_str(time)); // add time EX: "@5"
|
||||
else if (page != Xof_lnki_page.Null)
|
||||
bfr.Add_byte(Byte_ascii.Dash).Add_int_variable(page); // add page EX: "-5"
|
||||
bfr.Add_byte(Byte_ascii.Dot); // add . EX: "."
|
||||
if (file_is_thumb)
|
||||
@ -122,8 +118,8 @@ public class Xof_url_bldr {
|
||||
case Xof_ext_.Id_ogg:
|
||||
case Xof_ext_.Id_ogv:
|
||||
case Xof_ext_.Id_webm:
|
||||
if (Xof_doc_thumb.Null_n(time))
|
||||
bfr.Add(Bry_seek).Add_str(Xof_doc_thumb.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
if (Xof_lnki_time.Null_n(time))
|
||||
bfr.Add(Bry_seek).Add_str(Xof_lnki_time.X_str(time)).Add_byte(Byte_ascii.Dash);// add seek; EX: "seek%3D5-"
|
||||
else
|
||||
bfr.Add(Bry_mid); // add mid; EX: "mid-"
|
||||
break;
|
||||
@ -164,7 +160,7 @@ public class Xof_url_bldr {
|
||||
return this;
|
||||
}
|
||||
private void Add_thumb_wmf_page(byte[] bry_page_1, byte[] bry_page) {
|
||||
if (Xof_doc_thumb.Null_y(page))
|
||||
if (Xof_lnki_time.Null_y(page))
|
||||
bfr.Add(bry_page_1); // add "lossy-page1-" EX: "lossy-page1-"
|
||||
else {
|
||||
bfr.Add(bry_page); // add "lossy-page" EX: "lossy-page"
|
||||
@ -174,7 +170,7 @@ public class Xof_url_bldr {
|
||||
}
|
||||
private Xof_url_bldr Clear() {
|
||||
root = area = ttl = md5 = null;
|
||||
file_w = 0; time = Xof_doc_thumb.Null;
|
||||
file_w = 0; time = Xof_lnki_time.Null;
|
||||
ext = null;
|
||||
bfr.Clear();
|
||||
return this;
|
||||
|
@ -36,13 +36,13 @@ class Xof_url_bldr_fxt {
|
||||
public Xof_url_bldr_fxt Root_(String v) {root = v; return this;} private String root;
|
||||
public Xof_url_bldr_fxt Md5_(String v) {md5 = v; return this;} private String md5;
|
||||
public Xof_url_bldr_fxt Ttl_(String v) {ttl = v; ext = Xof_ext_.new_by_ttl_(Bry_.new_utf8_(v)); return this;} private String ttl; Xof_ext ext;
|
||||
public Xof_url_bldr_fxt Page_(int v) {page = v; return this;} private int page = Xof_doc_page.Null;
|
||||
public Xof_url_bldr_fxt Seek_(int v) {seek = v; return this;} private double seek = Xof_doc_thumb.Null;
|
||||
public Xof_url_bldr_fxt Page_(int v) {page = v; return this;} private int page = Xof_lnki_page.Null;
|
||||
public Xof_url_bldr_fxt Seek_(int v) {seek = v; return this;} private double seek = Xof_lnki_time.Null;
|
||||
public Xof_url_bldr_fxt Expd_src_(String v) {expd_src = v; return this;} private String expd_src;
|
||||
private void Clear() {
|
||||
dir_spr = Byte_.Zero; ext = null; root = md5 = ttl = expd_src = null;
|
||||
seek = Xof_doc_thumb.Null;
|
||||
page = Xof_doc_page.Null;
|
||||
seek = Xof_lnki_time.Null;
|
||||
page = Xof_lnki_page.Null;
|
||||
}
|
||||
public Xof_url_bldr_fxt tst() {
|
||||
url_bldr.Init_by_root(Bry_.new_utf8_(root), dir_spr, Bool_.Y, Bool_.N, 2);
|
||||
|
@ -17,33 +17,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package gplx.xowa.files; import gplx.*; import gplx.xowa.*;
|
||||
import gplx.xowa.files.gui.*; import gplx.xowa.files.repos.*;
|
||||
public class Xof_xfer_itm implements Xof_file_itm {
|
||||
public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
|
||||
public byte[] Lnki_md5() {return lnki_md5;} private byte[] lnki_md5;
|
||||
public Xof_ext Lnki_ext() {return lnki_ext;} public void Lnki_ext_(Xof_ext v) {lnki_ext = v;} private Xof_ext lnki_ext;
|
||||
public byte[] Lnki_redirect() {return lnki_redirect;} private byte[] lnki_redirect;
|
||||
public byte Lnki_type() {return lnki_type;} private byte lnki_type;
|
||||
public int Lnki_w() {return lnki_w;} private int lnki_w;
|
||||
public int Lnki_h() {return lnki_h;} private int lnki_h;
|
||||
public double Lnki_upright() {return lnki_upright;} private double lnki_upright;
|
||||
public double Lnki_time() {return lnki_time;} private double lnki_time = Xof_doc_thumb.Null;
|
||||
public int Lnki_page() {return lnki_page;} private int lnki_page = Xof_doc_page.Null;
|
||||
public int Orig_w() {return orig_w;} private int orig_w;
|
||||
public int Orig_h() {return orig_h;} private int orig_h;
|
||||
public int Orig_file_len() {return orig_file_len;} private int orig_file_len;
|
||||
public int Html_uid() {return html_uid;} private int html_uid = -1;
|
||||
public byte Html_elem_tid() {return html_elem_tid;} public Xof_xfer_itm Html_elem_tid_(byte v) {html_elem_tid = v; return this;} private byte html_elem_tid = Xof_html_elem.Tid_none;
|
||||
public int Html_w() {return html_w;} private int html_w;
|
||||
public int Html_h() {return html_h;} private int html_h;
|
||||
public byte[] Html_view_src() {return html_view_src;} private byte[] html_view_src = Bry_.Empty;
|
||||
public byte[] Html_orig_src() {return html_orig_src;} public void Html_orig_src_(byte[] v) {this.html_orig_src = v;} private byte[] html_orig_src = Bry_.Empty;
|
||||
public boolean Html_pass() {return html_pass;} private boolean html_pass;
|
||||
public Js_img_wkr Html_img_wkr() {return html_img_wkr;} public Xof_xfer_itm Html_img_wkr_(Js_img_wkr v) {html_img_wkr = v; return this;} private Js_img_wkr html_img_wkr;
|
||||
public int File_w() {return file_w == -1 ? html_w : file_w;} public void File_w_(int v) {file_w = v;} private int file_w = -1; // NOTE: for itm_meta, file_w == html_w
|
||||
public boolean Img_is_thumbable() {return img_is_thumbable;} private boolean img_is_thumbable; // SEE:NOTE_1:Lnki_thumbable
|
||||
public boolean Img_is_orig() {return !img_is_thumbable;}
|
||||
public int Gallery_mgr_h() {return gallery_mgr_h;} public Xof_xfer_itm Gallery_mgr_h_(int v) {gallery_mgr_h = v; return this;} private int gallery_mgr_h = Int_.Neg1;
|
||||
public boolean File_found() {return file_found;} public Xof_xfer_itm File_found_(boolean v) {file_found = v; return this;} private boolean file_found;
|
||||
public class Xof_xfer_itm implements Xof_file_itm {
|
||||
public byte[] Lnki_ttl() {return lnki_ttl;} private byte[] lnki_ttl;
|
||||
public byte[] Lnki_md5() {return lnki_md5;} private byte[] lnki_md5;
|
||||
public Xof_ext Lnki_ext() {return lnki_ext;} private Xof_ext lnki_ext;
|
||||
public byte Lnki_type() {return lnki_type;} private byte lnki_type;
|
||||
public int Lnki_w() {return lnki_w;} private int lnki_w;
|
||||
public int Lnki_h() {return lnki_h;} private int lnki_h;
|
||||
public double Lnki_upright() {return lnki_upright;} private double lnki_upright;
|
||||
public double Lnki_time() {return lnki_time;} private double lnki_time = Xof_lnki_time.Null;
|
||||
public int Lnki_page() {return lnki_page;} private int lnki_page = Xof_lnki_page.Null;
|
||||
public byte Orig_repo_id() {return orig_repo_id;} private byte orig_repo_id = Xof_repo_itm.Repo_null;
|
||||
public byte[] Orig_repo_name() {return orig_repo_name;} private byte[] orig_repo_name;
|
||||
public byte[] Orig_ttl() {return orig_ttl;} private byte[] orig_ttl;
|
||||
public int Orig_ext() {return orig_ext;} private int orig_ext;
|
||||
public int Orig_w() {return orig_w;} private int orig_w;
|
||||
public int Orig_h() {return orig_h;} private int orig_h;
|
||||
public byte[] Orig_redirect() {return orig_redirect;} private byte[] orig_redirect;
|
||||
public int Orig_file_len() {return orig_file_len;} private int orig_file_len;
|
||||
public int File_w() {return file_w == -1 ? html_w : file_w;} public void File_w_(int v) {file_w = v;} private int file_w = -1; // NOTE: for itm_meta, file_w == html_w
|
||||
public int Html_uid() {return html_uid;} private int html_uid = -1;
|
||||
public byte Html_elem_tid() {return html_elem_tid;} private byte html_elem_tid = Xof_html_elem.Tid_none;
|
||||
public int Html_w() {return html_w;} private int html_w;
|
||||
public int Html_h() {return html_h;} private int html_h;
|
||||
public byte[] Html_view_url() {return html_view_url;} private byte[] html_view_url = Bry_.Empty;
|
||||
public byte[] Html_orig_url() {return html_orig_url;} public void Html_orig_url_(byte[] v) {this.html_orig_url = v;} private byte[] html_orig_url = Bry_.Empty;
|
||||
public int Gallery_mgr_h() {return gallery_mgr_h;} public Xof_xfer_itm Gallery_mgr_h_(int v) {gallery_mgr_h = v; return this;} private int gallery_mgr_h = Int_.Neg1;
|
||||
public Js_img_wkr Html_img_wkr() {return html_img_wkr;} public Xof_xfer_itm Html_img_wkr_(Js_img_wkr v) {html_img_wkr = v; return this;} private Js_img_wkr html_img_wkr;
|
||||
public boolean Html_pass() {return html_pass;} private boolean html_pass;
|
||||
public boolean Img_is_thumbable() {return img_is_thumbable;} private boolean img_is_thumbable; // SEE:NOTE_1:Lnki_thumbable
|
||||
public boolean Img_is_orig() {return !img_is_thumbable;}
|
||||
public boolean File_found() {return file_found;} public Xof_xfer_itm File_found_(boolean v) {file_found = v; return this;}
|
||||
public boolean File_exists() {return file_exists;} public void File_exists_y_() {file_exists = Bool_.Y;} public void File_exists_n_() {file_exists = Bool_.N;} private boolean file_exists;
|
||||
private boolean file_found;
|
||||
public Xof_meta_itm Meta_itm() {return meta_itm;} private Xof_meta_itm meta_itm;
|
||||
public Xof_repo_itm Trg_repo() {return trg_repo;}
|
||||
public Xof_xfer_itm Trg_repo_(Xof_repo_itm v) {
|
||||
@ -59,13 +65,13 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
public Xof_url_bldr Url_bldr(){ return url_bldr;}
|
||||
public Xof_xfer_itm Url_bldr_(Xof_url_bldr v) {url_bldr = v; return this;} private Xof_url_bldr url_bldr = Xof_url_bldr.Temp;
|
||||
public Xof_xfer_itm Clear() {
|
||||
lnki_type = Byte_.Max_value_127;
|
||||
lnki_w = lnki_h = file_w = orig_w = orig_h = html_w = html_h = gallery_mgr_h = Int_.Neg1;
|
||||
lnki_upright = Int_.Neg1; lnki_time = Xof_doc_thumb.Null; lnki_page = Xof_doc_page.Null;
|
||||
img_is_thumbable = false;
|
||||
lnki_type = orig_repo_id = Byte_.Max_value_127;
|
||||
lnki_w = lnki_h = file_w = orig_ext = orig_w = orig_h = html_w = html_h = gallery_mgr_h = Int_.Neg1;
|
||||
lnki_upright = Int_.Neg1; lnki_time = Xof_lnki_time.Null; lnki_page = Xof_lnki_page.Null;
|
||||
file_found = file_exists = img_is_thumbable = false;
|
||||
orig_file_len = 0; // NOTE: cannot be -1, or else will always download orig; see ext rule chk and (orig_file_len < 0)
|
||||
lnki_redirect = null; lnki_ttl = null; lnki_md5 = null; lnki_ext = null;
|
||||
html_orig_src = html_view_src = Bry_.Empty;
|
||||
orig_repo_name = orig_ttl = orig_redirect = null; lnki_ttl = null; lnki_md5 = null; lnki_ext = null;
|
||||
html_orig_url = html_view_url = Bry_.Empty;
|
||||
trg_repo_idx = Int_.Neg1; meta_itm = null;
|
||||
html_uid = Int_.Neg1; html_elem_tid = Xof_html_elem.Tid_none;
|
||||
return this;
|
||||
@ -74,40 +80,60 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
Xof_xfer_itm rv = new Xof_xfer_itm();
|
||||
rv.lnki_type = lnki_type; rv.lnki_w = lnki_w; rv.lnki_h = lnki_h; rv.lnki_upright = lnki_upright; rv.lnki_time = lnki_time; rv.lnki_page = lnki_page;
|
||||
rv.img_is_thumbable = img_is_thumbable;
|
||||
rv.orig_w = orig_w; rv.orig_h = orig_h; rv.orig_file_len = orig_file_len;
|
||||
rv.lnki_redirect = lnki_redirect; rv.lnki_ttl = lnki_ttl; rv.lnki_md5 = lnki_md5; rv.lnki_ext = lnki_ext;
|
||||
rv.html_w = html_w; rv.html_h = html_h; rv.html_view_src = html_view_src; rv.html_orig_src = html_orig_src;
|
||||
rv.orig_repo_id = orig_repo_id; rv.orig_repo_name = orig_repo_name; rv.orig_ttl = orig_ttl; rv.orig_ext = orig_ext; rv.orig_w = orig_w; rv.orig_h = orig_h; rv.orig_redirect = orig_redirect;
|
||||
rv.orig_file_len = orig_file_len;
|
||||
rv.lnki_ttl = lnki_ttl; rv.lnki_md5 = lnki_md5; rv.lnki_ext = lnki_ext;
|
||||
rv.html_w = html_w; rv.html_h = html_h; rv.html_view_url = html_view_url; rv.html_orig_url = html_orig_url;
|
||||
rv.file_w = file_w;
|
||||
rv.trg_repo_idx = trg_repo_idx;
|
||||
rv.trg_repo_root = trg_repo_root;
|
||||
rv.meta_itm = meta_itm; // NOTE: shared reference
|
||||
rv.html_uid = html_uid; rv.html_elem_tid = html_elem_tid;
|
||||
rv.gallery_mgr_h = gallery_mgr_h;
|
||||
rv.file_exists = file_exists;
|
||||
return rv;
|
||||
}
|
||||
public Xof_xfer_itm Init_by_lnki(byte[] ttl, byte[] redirect, byte lnki_type, int w, int h, double upright, double thumbtime, int lnki_page) {
|
||||
public Xof_xfer_itm Init_by_lnki(byte[] ttl, byte[] redirect, byte lnki_type, int w, int h, double upright, double time, int page) {
|
||||
this.Set__ttl(ttl, redirect);
|
||||
this.lnki_type = lnki_type; this.lnki_w = w; this.lnki_h = h; this.lnki_upright = upright; this.lnki_time = thumbtime; this.lnki_page = lnki_page;
|
||||
this.lnki_type = lnki_type; this.lnki_w = w; this.lnki_h = h; this.lnki_upright = upright; this.lnki_time = time; this.lnki_page = page;
|
||||
img_is_thumbable = Xof_xfer_itm_.Lnki_thumbable_calc(lnki_type, lnki_w, lnki_h);
|
||||
if (lnki_time != Xof_doc_thumb.Null && !lnki_ext.Id_is_media()) // thumbtime is set, but ext is not media; PAGE:en.w:Moon; EX:[[File:A.png|thumbtime=0:02]] DATE:2014-07-22
|
||||
lnki_time = Xof_doc_thumb.Null; // disable thumbtime
|
||||
if (lnki_time != Xof_lnki_time.Null && !lnki_ext.Id_is_media()) // thumbtime is set, but ext is not media; PAGE:en.w:Moon; EX:[[File:A.png|thumbtime=0:02]] DATE:2014-07-22
|
||||
lnki_time = Xof_lnki_time.Null; // disable thumbtime
|
||||
return this;
|
||||
}
|
||||
public void Init_by_orig_old(int w, int h, int orig_file_len) {
|
||||
this.orig_w = w; this.orig_h = h; this.orig_file_len = orig_file_len;
|
||||
}
|
||||
public void Init_by_orig(byte orig_repo_id, byte[] orig_repo_name, byte[] orig_ttl, int orig_ext, int orig_w, int orig_h, byte[] orig_redirect, int orig_file_len) {
|
||||
this.orig_repo_id = orig_repo_id; this.orig_repo_name = orig_repo_name;
|
||||
this.orig_ttl = orig_ttl; this.orig_ext = orig_ext;
|
||||
this.orig_w = orig_w; this.orig_h = orig_h; this.orig_redirect = orig_redirect;
|
||||
if (orig_ext != lnki_ext.Id())
|
||||
this.Lnki_ext_(Xof_ext_.new_by_id_(orig_ext)); // overwrite ext with whatever's in file_orig; needed for ogg -> oga / ogv
|
||||
if (Bry_.Len_gt_0(orig_redirect)) // redirect exists; EX: A.png redirected to B.png
|
||||
this.Lnki_ttl_(orig_redirect); // update fsdb with atrs of B.png
|
||||
this.orig_file_len = orig_file_len;
|
||||
}
|
||||
private void Lnki_ttl_(byte[] v) {
|
||||
lnki_ttl = v;
|
||||
lnki_ext = Xof_ext_.new_by_ttl_(v);
|
||||
lnki_md5 = Xof_xfer_itm_.Md5_calc(v);
|
||||
}
|
||||
public void Init_for_gallery(int html_w, int html_h, int file_w) {
|
||||
this.html_w = html_w; this.html_h = html_h;
|
||||
this.file_w = file_w;
|
||||
}
|
||||
public void Init_for_gallery_update(int html_w, int html_h, String view_src, String orig_src) {
|
||||
this.html_w = html_w; this.html_h = html_h;
|
||||
this.html_view_src = Bry_.new_utf8_(view_src);
|
||||
this.html_orig_src = Bry_.new_utf8_(orig_src);
|
||||
this.html_view_url = Bry_.new_utf8_(view_src);
|
||||
this.html_orig_url = Bry_.new_utf8_(orig_src);
|
||||
this.html_pass = true;
|
||||
this.file_found = true;
|
||||
}
|
||||
public void Init_for_test__img(int html_w, int html_h, byte[] html_view_src, byte[] html_orig_src) {this.html_w = html_w; this.html_h = html_h; this.html_view_src = html_view_src; this.html_orig_src = html_orig_src;}
|
||||
public void Init_for_test__img(int html_w, int html_h, byte[] html_view_url, byte[] html_orig_url) {this.html_w = html_w; this.html_h = html_h; this.html_view_url = html_view_url; this.html_orig_url = html_orig_url;}
|
||||
public Xof_xfer_itm Set__ttl(byte[] ttl, byte[] redirect) {
|
||||
this.lnki_redirect = redirect;
|
||||
this.lnki_ttl = lnki_redirect == Xop_redirect_mgr.Redirect_null_bry ? Bry_.Copy(ttl) : lnki_redirect;
|
||||
this.orig_redirect = redirect;
|
||||
this.lnki_ttl = orig_redirect == Xop_redirect_mgr.Redirect_null_bry ? Bry_.Copy(ttl) : orig_redirect;
|
||||
this.lnki_ttl = Xof_xfer_itm_.Md5_decoder.Decode_lax(Xof_xfer_itm_.Ttl_standardize(lnki_ttl)); // NOTE: this line is repeated in static method below
|
||||
this.lnki_md5 = Xof_xfer_itm_.Md5_calc(lnki_ttl); // NOTE: md5 is calculated off of url_decoded ttl; EX: A%2Cb is converted to A,b and then md5'd. note that A%2Cb still remains the title
|
||||
this.lnki_ext = Xof_ext_.new_by_ttl_(lnki_ttl);
|
||||
@ -115,7 +141,6 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
}
|
||||
public void Set__html_size(int html_w, int html_h) {this.html_w = html_w; this.html_h = html_h; }
|
||||
public Xof_xfer_itm Set__html_uid_tid(int uid, byte tid) {html_uid = uid; html_elem_tid = tid; return this;}
|
||||
public Xof_xfer_itm Set__orig(int w, int h, int orig_file_len) {this.orig_w = w; this.orig_h = h; this.orig_file_len = orig_file_len; return this;}
|
||||
public void Set__meta(Xof_meta_itm meta_itm, Xof_repo_itm trg_repo, int thumb_w_img) {
|
||||
this.meta_itm = meta_itm; Trg_repo_(trg_repo); this.thumb_w_img = thumb_w_img;
|
||||
this.orig_w = meta_itm.Orig_w(); this.orig_h = meta_itm.Orig_h(); // orig_w / orig_h needed for imap; DATE:2014-08-08
|
||||
@ -125,13 +150,15 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
html_pass = true;
|
||||
this.html_w = html_w;
|
||||
this.html_h = html_h;
|
||||
this.html_orig_src = Bry_.new_utf8_(orig_url.To_http_file_str());
|
||||
this.html_view_src = Bry_.new_utf8_(view_url.To_http_file_str());
|
||||
this.html_orig_url = Bry_.new_utf8_(orig_url.To_http_file_str());
|
||||
this.html_view_url = Bry_.new_utf8_(view_url.To_http_file_str());
|
||||
}
|
||||
public void Lnki_ext_(Xof_ext v) {lnki_ext = v;}
|
||||
public Xof_xfer_itm Html_elem_tid_(byte v) {html_elem_tid = v; return this;}
|
||||
public boolean Calc_by_meta() {return Calc_by_meta(false);}
|
||||
public boolean Calc_by_meta(boolean caller_is_file_page) {
|
||||
html_pass = false;
|
||||
html_orig_src = html_view_src = Bry_.Empty;
|
||||
html_orig_url = html_view_url = Bry_.Empty;
|
||||
html_w = lnki_w; html_h = lnki_h;
|
||||
if (meta_itm == null || trg_repo == null) return false;
|
||||
if (meta_itm.Ptr_ttl_exists()) {
|
||||
@ -143,19 +170,19 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
html_w = Xof_img_size.Thumb_width_ogv;
|
||||
if (img_is_thumbable) { // file is thumb
|
||||
if (lnki_ext.Id_is_video()) { // video is a special case; src is thumb_w but html_w / html_h is based on calc
|
||||
html_orig_src = Trg_html(Xof_repo_itm.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
if (meta_itm.Thumbs_indicates_oga() && lnki_ext.Id_is_ogv()) {lnki_ext = Xof_ext_.new_by_ext_(Xof_ext_.Bry_oga); return true;} // if audio, do not thumb; NOTE: must happen after html_orig_src, b/c html must still be generated to auto-download files; NOTE: must change ext to oga b/c ogg may trigger video code elsewhere
|
||||
Xof_meta_thumb thumb = meta_itm.Thumbs_get_vid(Xof_doc_thumb.X_int(lnki_time));
|
||||
html_orig_url = Trg_html(Xof_repo_itm.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
if (meta_itm.Thumbs_indicates_oga() && lnki_ext.Id_is_ogv()) {lnki_ext = Xof_ext_.new_by_ext_(Xof_ext_.Bry_oga); return true;} // if audio, do not thumb; NOTE: must happen after html_orig_url, b/c html must still be generated to auto-download files; NOTE: must change ext to oga b/c ogg may trigger video code elsewhere
|
||||
Xof_meta_thumb thumb = meta_itm.Thumbs_get_vid(Xof_lnki_time.X_int(lnki_time));
|
||||
if (thumb != null) {
|
||||
Xof_xfer_itm_.Calc_xfer_size(calc_size, lnki_type, thumb_w_img, thumb.Width(), thumb.Height(), html_w, html_h, img_is_thumbable, lnki_upright);
|
||||
html_w = calc_size.Val_0(); html_h = calc_size.Val_1();
|
||||
html_view_src = Trg_html(Xof_repo_itm.Mode_thumb, thumb.Width()); // NOTE: must pass thumb.Width() not html_w b/c only one thumb generated for a video file
|
||||
html_view_url = Trg_html(Xof_repo_itm.Mode_thumb, thumb.Width()); // NOTE: must pass thumb.Width() not html_w b/c only one thumb generated for a video file
|
||||
html_pass = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else { // regular thumb
|
||||
html_orig_src = Trg_html(Xof_repo_itm.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
html_orig_url = Trg_html(Xof_repo_itm.Mode_orig, Xof_img_size.Size_null_deprecated);
|
||||
if (lnki_ext.Id_is_audio()) return true; // if audio, do not thumb; even if user requests thumb;
|
||||
Xof_meta_thumb[] thumbs = meta_itm.Thumbs(); int thumbs_len = thumbs.length; Xof_meta_thumb thumb = null;
|
||||
if (lnki_h > 0 && orig_w < 1 && thumbs_len > 0) { // if height is specified and no orig, then iterate over thumbs to find similar height; NOTE: this is a fallback case; orig_w/h is optimal; EX: c:Jacques-Louis David and <gallery>
|
||||
@ -175,7 +202,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
Xof_xfer_itm_.Calc_xfer_size(calc_size, lnki_type, thumb_w_img, meta_itm.Orig_w(), meta_itm.Orig_h(), html_w, html_h, img_is_thumbable, lnki_upright, limit_size); // calc html_h and html_w; can differ from lnki_w, lnki_h; note that -1 width is handled by thumb_w_img
|
||||
html_w = calc_size.Val_0();
|
||||
if (html_h != -1) html_h = calc_size.Val_1(); // NOTE: if -1 (no height specified) do not set height; EX:Tokage_2011-07-15.jpg; DATE:2013-06-03
|
||||
html_view_src = Trg_html(Xof_repo_itm.Mode_thumb, this.File_w());
|
||||
html_view_url = Trg_html(Xof_repo_itm.Mode_thumb, this.File_w());
|
||||
thumb = meta_itm.Thumbs_get_img(html_w, 0);
|
||||
if (thumb == null) { // exact thumb not found
|
||||
if (html_w == meta_itm.Orig_w() // html_w matches orig_w; occurs when thumb,upright requested, but upright size is larger than orig; PAGE:en.w:St. Petersburg
|
||||
@ -183,7 +210,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
&& meta_itm.Orig_exists() == Xof_meta_itm.Exists_y
|
||||
) {
|
||||
html_h = meta_itm.Orig_h();
|
||||
html_view_src = Trg_html(Xof_repo_itm.Mode_orig, -1);
|
||||
html_view_url = Trg_html(Xof_repo_itm.Mode_orig, -1);
|
||||
html_pass = true;
|
||||
return true;
|
||||
}
|
||||
@ -201,21 +228,21 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
}
|
||||
else { // file is orig
|
||||
byte mode_id = lnki_ext.Id_is_svg() ? Xof_repo_itm.Mode_thumb : Xof_repo_itm.Mode_orig; // svgs will always return thumb; EX:[[A.svg]] -> A.svg.png
|
||||
html_view_src = html_orig_src = Trg_html(mode_id, this.File_w());
|
||||
if (meta_itm.Thumbs_indicates_oga() && lnki_ext.Id_is_ogv()) {lnki_ext = Xof_ext_.new_by_ext_(Xof_ext_.Bry_oga); return true;} // if audio, do not thumb; NOTE: must happen after html_orig_src, b/c html must still be generated to auto-download files; NOTE: must change ext to oga b/c ogg may trigger video code elsewhere
|
||||
html_view_url = html_orig_url = Trg_html(mode_id, this.File_w());
|
||||
if (meta_itm.Thumbs_indicates_oga() && lnki_ext.Id_is_ogv()) {lnki_ext = Xof_ext_.new_by_ext_(Xof_ext_.Bry_oga); return true;} // if audio, do not thumb; NOTE: must happen after html_orig_url, b/c html must still be generated to auto-download files; NOTE: must change ext to oga b/c ogg may trigger video code elsewhere
|
||||
if (lnki_ext.Id_is_audio()) return true; // if audio, return true; SEE:NOTE_2
|
||||
else if (lnki_ext.Id_is_video()) {
|
||||
Xof_meta_thumb thumb = meta_itm.Thumbs_get_vid(Xof_doc_thumb.X_int(lnki_time)); // get thumb at lnki_time; NOTE: in most cases this will just be the 1st thumb; note that orig video files don't have an official thumb
|
||||
Xof_meta_thumb thumb = meta_itm.Thumbs_get_vid(Xof_lnki_time.X_int(lnki_time)); // get thumb at lnki_time; NOTE: in most cases this will just be the 1st thumb; note that orig video files don't have an official thumb
|
||||
if (thumb != null) {
|
||||
html_w = thumb.Width(); html_h = thumb.Height(); // NOTE: take thumb_size; do not rescale to html_w, html_h b/c html_w will default to 220; native width of thumbnail should be used; DATE:2013-04-11
|
||||
html_view_src = Trg_html(Xof_repo_itm.Mode_thumb, thumb.Width()); // NOTE: must pass thumb.Width() not html_w b/c only one thumb generated for a video file
|
||||
html_view_url = Trg_html(Xof_repo_itm.Mode_thumb, thumb.Width()); // NOTE: must pass thumb.Width() not html_w b/c only one thumb generated for a video file
|
||||
html_pass = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (meta_itm.Orig_exists() == Xof_meta_itm.Exists_y) { // file found previously >>> gen html
|
||||
html_w = meta_itm.Orig_w(); html_h = meta_itm.Orig_h();
|
||||
html_view_src = Trg_html(mode_id, this.File_w());
|
||||
html_view_url = Trg_html(mode_id, this.File_w());
|
||||
html_pass = true;
|
||||
return true;
|
||||
}
|
||||
@ -228,7 +255,7 @@ public class Xof_xfer_itm implements Xof_file_itm {
|
||||
private boolean Calc_by_meta_found(byte lnki_type, int model_w, int model_h) {
|
||||
Xof_xfer_itm_.Calc_xfer_size(calc_size, lnki_type, thumb_w_img, model_w, model_h, html_w, html_h, img_is_thumbable, lnki_upright, false); // recalc html_w, html_h; note that false passed b/c truncation is not needed
|
||||
html_w = calc_size.Val_0(); html_h = calc_size.Val_1();
|
||||
html_view_src = Trg_html(Xof_repo_itm.Mode_thumb, model_w); // note that thumb.Width is used (the actual file width), not html_w
|
||||
html_view_url = Trg_html(Xof_repo_itm.Mode_thumb, model_w); // note that thumb.Width is used (the actual file width), not html_w
|
||||
html_pass = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -40,36 +40,34 @@ public class Xof_bin_mgr implements GfoInvkAble {
|
||||
Io_stream_rdr rdr = Find_as_rdr(exec_tid, itm);
|
||||
if (rdr == Io_stream_rdr_.Null) return Io_url_.Null;
|
||||
Io_url trg = itm.Html_view_url();
|
||||
if (itm.Rslt_fil_created()) return trg; // rdr is opened directly from trg; return its url; occurs when url goes through imageMagick / inkscape, or when thumb is already on disk;
|
||||
Io_stream_wtr_.Save_rdr(trg, rdr); // rdr is stream; either from http_wmf or fsdb; save to trg and return;
|
||||
if (itm.Rslt_bin() == Xof_bin_wkr_.Tid_fsdb_xowa) { // rdr is coming from fsdb; register in cache
|
||||
if (!Env_.Mode_testing())
|
||||
cache_mgr.Reg(itm, rdr.Len());
|
||||
}
|
||||
if (itm.File_resized()) return trg; // rdr is opened directly from trg; return its url; occurs when url goes through imageMagick / inkscape, or when thumb is already on disk;
|
||||
Io_stream_wtr_.Save_rdr(trg, rdr); // rdr is stream; either from http_wmf or fsdb; save to trg and return;
|
||||
if (!Env_.Mode_testing()) cache_mgr.Reg(itm, rdr.Len());
|
||||
return trg;
|
||||
}
|
||||
public Io_stream_rdr Find_as_rdr(byte exec_tid, Xof_fsdb_itm itm) {
|
||||
Io_stream_rdr rv = Io_stream_rdr_.Null;
|
||||
Xof_repo_itm repo = repo_mgr.Repos_get_by_wiki(itm.Orig_repo_name()).Trg();
|
||||
boolean file_is_orig = itm.File_is_orig();
|
||||
if (file_is_orig || exec_tid == Xof_exec_tid.Tid_viewer_app) { // orig or viewer_app; note that viewer_app always return orig
|
||||
Io_url trg = url_bldr.To_url(repo_mgr, itm, Bool_.Y);
|
||||
Io_url trg = url_bldr.To_url_trg(repo, itm, Bool_.Y);
|
||||
itm.Html_view_url_(trg);
|
||||
for (int i = 0; i < wkrs_len; i++) {
|
||||
Xof_bin_wkr wkr = wkrs[i];
|
||||
rv = wkr.Get_as_rdr(itm, Bool_.N, itm.Html_w());
|
||||
if (rv == Io_stream_rdr_.Null) continue; // orig not found; continue;
|
||||
itm.Rslt_bin_(wkr.Tid());
|
||||
itm.File_exists_y_();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else { // thumb
|
||||
Io_url trg = url_bldr.To_url(repo_mgr, itm, Bool_.N);
|
||||
Io_url trg = url_bldr.To_url_trg(repo, itm, Bool_.N);
|
||||
itm.Html_view_url_(trg);
|
||||
for (int i = 0; i < wkrs_len; i++) {
|
||||
Xof_bin_wkr wkr = wkrs[i];
|
||||
rv = wkr.Get_as_rdr(itm, Bool_.Y, itm.Html_w()); // get thumb's bin
|
||||
if (rv != Io_stream_rdr_.Null) { // thumb's bin exists;
|
||||
itm.Rslt_bin_(wkr.Tid());
|
||||
itm.File_exists_y_();
|
||||
return rv;
|
||||
}
|
||||
usr_dlg.Log_direct(String_.Format("thumb not found; ttl={0} w={1} ", String_.new_utf8_(itm.Lnki_ttl()), itm.Lnki_w()));
|
||||
@ -79,12 +77,11 @@ public class Xof_bin_mgr implements GfoInvkAble {
|
||||
continue; // nothing found; continue;
|
||||
}
|
||||
if (!wkr.Resize_allowed()) continue;
|
||||
Io_url orig = url_bldr.To_url(repo_mgr, itm, Bool_.Y); // get orig url
|
||||
Io_url orig = url_bldr.To_url_trg(repo, itm, Bool_.Y); // get orig url
|
||||
Io_stream_wtr_.Save_rdr(orig, rv);
|
||||
boolean resized = Resize(exec_tid, itm, file_is_orig, orig, trg);
|
||||
if (!resized) continue;
|
||||
itm.Rslt_bin_(wkr.Tid());
|
||||
itm.Rslt_fil_created_(true);
|
||||
itm.File_exists_y_();
|
||||
rv = Io_stream_rdr_.file_(trg); // return stream of resized url; (result of imageMagick / inkscape)
|
||||
rv.Open();
|
||||
return rv;
|
||||
@ -95,7 +92,7 @@ public class Xof_bin_mgr implements GfoInvkAble {
|
||||
private boolean Resize(byte exec_tid, Xof_fsdb_itm itm, boolean file_is_orig, Io_url src, Io_url trg) {
|
||||
tmp_size.Html_size_calc(exec_tid, itm.Lnki_w(), itm.Lnki_h(), itm.Lnki_type(), mnt_mgr.Patch_upright(), itm.Lnki_upright(), itm.Lnki_ext().Id(), itm.Orig_w(), itm.Orig_h(), Xof_img_size.Thumb_width_img);
|
||||
boolean rv = resizer.Exec(src, trg, tmp_size.Html_w(), tmp_size.Html_h(), itm.Lnki_ext().Id(), resize_warning);
|
||||
itm.Rslt_cnv_(rv ? Xof_cnv_wkr_.Tid_y : Xof_cnv_wkr_.Tid_n);
|
||||
itm.File_resized_y_();
|
||||
return rv;
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
|
@ -41,10 +41,10 @@ public class Xof_bin_wkr__fsdb_sql implements Xof_bin_wkr, GfoInvkAble {
|
||||
private void Find_ids(byte[] orig_repo, byte[] orig_ttl, int orig_ext, double lnki_time, int lnki_page, boolean is_thumb, int w, Int_obj_ref tmp_itm_id, Int_obj_ref tmp_bin_id, Int_obj_ref tmp_mnt_id) {
|
||||
synchronized (tmp_bin_id) {
|
||||
byte[] dir = orig_repo, fil = orig_ttl;
|
||||
double time = Xof_doc_thumb.Convert_to_fsdb_thumbtime(orig_ext, lnki_time, lnki_page);
|
||||
double time = Xof_lnki_time.Convert_to_fsdb_thumbtime(orig_ext, lnki_time, lnki_page);
|
||||
if (is_thumb) {
|
||||
Fsd_thm_itm thm_itm = Fsd_thm_itm.load_();
|
||||
Init_thm(orig_ext, w, lnki_time, lnki_page, thm_itm);
|
||||
Fsd_thm_itm thm_itm = Fsd_thm_itm.new_();
|
||||
thm_itm.Init_by_req(w, lnki_time, lnki_page);
|
||||
boolean found = mnt_mgr.Thm_select_bin(dir, fil, thm_itm);
|
||||
tmp_itm_id.Val_(thm_itm.Id());
|
||||
tmp_bin_id.Val_(found ? thm_itm.Db_bin_id() : Fsd_bin_tbl.Null_db_bin_id);
|
||||
@ -58,12 +58,6 @@ public class Xof_bin_wkr__fsdb_sql implements Xof_bin_wkr, GfoInvkAble {
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Init_thm(int src_ext_id, int src_w, double src_time, int src_page, Fsd_thm_itm trg) {
|
||||
trg.Owner().Ext_id_(src_ext_id);
|
||||
trg.Width_(src_w);
|
||||
trg.Thumbtime_(src_time);
|
||||
trg.Page_(src_page);
|
||||
}
|
||||
public Object Invk(GfsCtx ctx, int ikey, String k, GfoMsg m) {
|
||||
if (ctx.MatchIn(k, Invk_url_)) mnt_mgr.Init_by_wiki(m.ReadIoUrl("v"), Bool_.Y);
|
||||
else return GfoInvkAble_.Rv_unhandled;
|
||||
|
@ -24,15 +24,18 @@ public class Xof_bin_wkr__http_wmf implements Xof_bin_wkr {
|
||||
public byte Tid() {return Xof_bin_wkr_.Tid_http_wmf;}
|
||||
public boolean Resize_allowed() {return bin_wkr_resize;} public void Resize_allowed_(boolean v) {bin_wkr_resize = v;} private boolean bin_wkr_resize = true;
|
||||
public int Fail_timeout() {return fail_timeout;} public Xof_bin_wkr__http_wmf Fail_timeout_(int v) {fail_timeout = v; return this;} private int fail_timeout = 0; // NOTE: always default to 0; manually set to 1000 for fsdb_make only; DATE:2014-06-21
|
||||
public Io_stream_rdr Get_as_rdr(Xof_fsdb_itm itm, boolean is_thumb, int w) {
|
||||
Download_init(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), is_thumb, w, itm.Lnki_time(), itm.Lnki_page(), Io_url_.Null);
|
||||
public Io_stream_rdr Get_as_rdr(Xof_fsdb_itm fsdb, boolean is_thumb, int w) {
|
||||
Download_init(fsdb.Orig_repo_name(), fsdb.Lnki_ttl(), fsdb.Lnki_md5(), fsdb.Lnki_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), Io_url_.Null);
|
||||
Io_stream_rdr rdr = download_wkr.Exec_as_rdr();
|
||||
boolean rv = rdr.Len() != IoItmFil.Size_invalid; // NOTE: use IoItmFil.Size_invalid, not Io_stream_rdr_.Read_done; DATE:2014-06-21
|
||||
if (!rv) Handle_error();
|
||||
fsdb.Fsdb_insert_y_();
|
||||
return rv ? rdr : Io_stream_rdr_.Null;
|
||||
}
|
||||
public boolean Get_to_fsys(Xof_fsdb_itm itm, boolean is_thumb, int w, Io_url bin_url) {
|
||||
return Get_to_fsys(itm.Orig_repo_name(), itm.Lnki_ttl(), itm.Lnki_md5(), itm.Lnki_ext(), is_thumb, w, itm.Lnki_time(), itm.Lnki_page(), bin_url);
|
||||
public boolean Get_to_fsys(Xof_fsdb_itm fsdb, boolean is_thumb, int w, Io_url bin_url) {
|
||||
boolean rv = Get_to_fsys(fsdb.Orig_repo_name(), fsdb.Lnki_ttl(), fsdb.Lnki_md5(), fsdb.Lnki_ext(), is_thumb, w, fsdb.Lnki_time(), fsdb.Lnki_page(), bin_url);
|
||||
if (rv) fsdb.Fsdb_insert_y_();
|
||||
return rv;
|
||||
}
|
||||
private boolean Get_to_fsys(byte[] orig_repo, byte[] orig_ttl, byte[] orig_md5, Xof_ext orig_ext, boolean lnki_is_thumb, int file_w, double lnki_time, int lnki_page, Io_url file_url) {
|
||||
Download_init(orig_repo, orig_ttl, orig_md5, orig_ext, lnki_is_thumb, file_w, lnki_time, lnki_page, file_url);
|
||||
|
65
400_xowa/src/gplx/xowa/files/caches/Xofc_cache_itm.java
Normal file
65
400_xowa/src/gplx/xowa/files/caches/Xofc_cache_itm.java
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
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.files.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.files.*;
|
||||
class Xofc_cache_itm {
|
||||
public Xofc_cache_itm
|
||||
( Bry_bfr lnki_key_bfr, int uid, byte db_state
|
||||
, int lnki_wiki, byte[] lnki_ttl, int lnki_type, double lnki_upright, int lnki_w, int lnki_h, double lnki_time, int lnki_page
|
||||
, int orig_wiki, byte[] orig_ttl, int orig_ext, int file_w, int file_h, double file_time, int file_page
|
||||
, long temp_file_size, int temp_view_count, long temp_view_date, int temp_w
|
||||
) {
|
||||
this.uid = uid; this.db_state = db_state;
|
||||
this.lnki_wiki = lnki_wiki; this.lnki_ttl = lnki_ttl; this.lnki_type = lnki_type; this.lnki_upright = lnki_upright; this.lnki_w = lnki_w; this.lnki_h = lnki_h; this.lnki_time = lnki_time; this.lnki_page = lnki_page;
|
||||
this.orig_wiki = orig_wiki; this.orig_ttl = orig_ttl; this.orig_ext = orig_ext; this.file_w = file_w; this.file_h = file_h; this.file_time = file_time; this.file_page = file_page;
|
||||
this.temp_file_size = temp_file_size; this.temp_view_count = temp_view_count; this.temp_view_date = temp_view_date; this.temp_w = temp_w;
|
||||
lnki_key_bfr
|
||||
.Add_int_variable(lnki_wiki).Add_byte_pipe()
|
||||
.Add(lnki_ttl).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_type).Add_byte_pipe()
|
||||
.Add_double(lnki_upright).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_w).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_h).Add_byte_pipe()
|
||||
.Add_double(lnki_time).Add_byte_pipe()
|
||||
.Add_int_variable(lnki_page)
|
||||
;
|
||||
lnki_key = lnki_key_bfr.Xto_bry_and_clear();
|
||||
}
|
||||
public int Uid() {return uid;} private int uid;
|
||||
public byte Db_state() {return db_state;} public void Db_state_(byte v) {db_state = v;} private byte db_state;
|
||||
public byte[] Lnki_key() {return lnki_key;} private final byte[] lnki_key;
|
||||
public int Lnki_wiki() {return lnki_wiki;} private final int lnki_wiki;
|
||||
public byte[] Lnki_ttl() {return lnki_ttl;} private final byte[] lnki_ttl;
|
||||
public int Lnki_type() {return lnki_type;} private final int lnki_type;
|
||||
public double Lnki_upright() {return lnki_upright;} private final double lnki_upright;
|
||||
public int Lnki_w() {return lnki_w;} private final int lnki_w;
|
||||
public int Lnki_h() {return lnki_h;} private final int lnki_h;
|
||||
public double Lnki_time() {return lnki_time;} private final double lnki_time;
|
||||
public int Lnki_page() {return lnki_page;} private final int lnki_page;
|
||||
public int Orig_wiki() {return orig_wiki;} private final int orig_wiki;
|
||||
public byte[] Orig_ttl() {return orig_ttl;} private final byte[] orig_ttl;
|
||||
public int Orig_ext() {return orig_ext;} private final int orig_ext;
|
||||
public int File_w() {return file_w;} private final int file_w;
|
||||
public int File_h() {return file_h;} private final int file_h;
|
||||
public double File_time() {return file_time;} private final double file_time;
|
||||
public int File_page() {return file_page;} private final int file_page;
|
||||
public long Temp_file_size() {return temp_file_size;} private long temp_file_size;
|
||||
public int Temp_view_count() {return temp_view_count;} private int temp_view_count;
|
||||
public long Temp_view_date() {return temp_view_date;} private long temp_view_date;
|
||||
public int Temp_w() {return temp_w;} private int temp_w;
|
||||
public static final Xofc_cache_itm Null = null;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user