mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Cfg: Add initial implementation to load items
This commit is contained in:
parent
08d6cc3eb9
commit
68b51fbad1
@ -32,7 +32,7 @@ public class Xoa_app_ {
|
||||
}
|
||||
}
|
||||
public static final String Name = "xowa";
|
||||
public static final String Version = "3.10.4.7";
|
||||
public static final String Version = "3.10.4.9";
|
||||
public static String Build_date = "2012-12-30 00:00:00";
|
||||
public static String Op_sys_str;
|
||||
public static String User_agent = "";
|
||||
|
@ -25,10 +25,10 @@ public class Xoitm_meta_tbl implements Db_tbl {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "cfg_itm_meta";
|
||||
this.fld__itm_id = flds.Add_int("itm_id"); // EX: '2'
|
||||
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
|
||||
this.fld__itm_scope_id = flds.Add_int("itm_scope_id"); // EX: '1'; ENUM: Xoitm_scope_tid
|
||||
this.fld__itm_gui_type = flds.Add_int("itm_gui_type"); // EX: '1'; ENUM: Xoitm_gui_tid
|
||||
this.fld__itm_gui_args = flds.Add_int("itm_gui_args"); // EX: '1,40' (numeric); '255' (textbox); 'enum_name' (combo); etc..
|
||||
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
|
||||
this.fld__itm_gui_args = flds.Add_str("itm_gui_args", 255); // EX: '1,40' (numeric); '255' (textbox); 'enum_name' (combo); etc..
|
||||
this.fld__itm_dflt = flds.Add_str("itm_dflt", 4096); // EX: 'abc'
|
||||
conn.Rls_reg(this);
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.dbs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xonde_i18n_itm {
|
||||
public Xonde_i18n_itm(int id, int tid, String lang, String name, String help) {
|
||||
this.id = id;
|
||||
this.tid = tid;
|
||||
this.lang = lang;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public int Tid() {return tid;} private final int tid;
|
||||
public String Lang() {return lang;} private final String lang;
|
||||
public String Name() {return name;} private final String name;
|
||||
public String Help() {return help;} private final String help;
|
||||
}
|
@ -24,8 +24,8 @@ public class Xonde_i18n_tbl implements Db_tbl {
|
||||
public Xonde_i18n_tbl(Db_conn conn) {
|
||||
this.conn = conn;
|
||||
this.tbl_name = "cfg_nde_i18n";
|
||||
this.fld__nde_id = flds.Add_int_pkey("nde_id"); // EX: '2'
|
||||
this.fld__nde_tid = flds.Add_int("nde_tid"); // EX: 1=grp; 2=itm
|
||||
this.fld__nde_id = flds.Add_int("nde_id"); // EX: '2'
|
||||
this.fld__nde_lang = flds.Add_str("nde_lang", 16); // EX: 'en'
|
||||
this.fld__nde_name = flds.Add_str("nde_name", 255); // EX: 'Cfg Name'
|
||||
this.fld__nde_help = flds.Add_str("nde_help", 4096); // EX: 'Help text'
|
||||
@ -36,13 +36,19 @@ public class Xonde_i18n_tbl implements Db_tbl {
|
||||
public void Upsert(int nde_tid, int nde_id, String nde_lang, String nde_name, String nde_help) {
|
||||
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__nde_tid, fld__nde_id, fld__nde_lang), nde_tid, nde_id, nde_lang, nde_name, nde_help);
|
||||
}
|
||||
public void Select_stub() {
|
||||
Db_rdr rdr = Db_rdr_.Empty;
|
||||
rdr.Read_int(fld__nde_tid);
|
||||
rdr.Read_int(fld__nde_id);
|
||||
rdr.Read_str(fld__nde_lang);
|
||||
rdr.Read_str(fld__nde_name);
|
||||
rdr.Read_str(fld__nde_help);
|
||||
public Xonde_i18n_itm Select_by_id_or_null(int id) {
|
||||
Db_rdr rdr = conn.Stmt_select(tbl_name, flds, fld__nde_id).Crt_int(fld__nde_id, id).Exec_select__rls_auto();
|
||||
try {return rdr.Move_next() ? Load(rdr) : null;}
|
||||
finally {rdr.Rls();}
|
||||
}
|
||||
private Xonde_i18n_itm Load(Db_rdr rdr) {
|
||||
return new Xonde_i18n_itm
|
||||
( rdr.Read_int(fld__nde_id)
|
||||
, rdr.Read_int(fld__nde_tid)
|
||||
, rdr.Read_str(fld__nde_lang)
|
||||
, rdr.Read_str(fld__nde_name)
|
||||
, rdr.Read_str(fld__nde_help)
|
||||
);
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
|
45
400_xowa/src/gplx/xowa/addons/apps/cfgs/gui/Xogui_grp.java
Normal file
45
400_xowa/src/gplx/xowa/addons/apps/cfgs/gui/Xogui_grp.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xogui_grp {
|
||||
public Xogui_grp(int id, int sort, String key) {
|
||||
this.id = id;
|
||||
this.sort = sort;
|
||||
this.key = key;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public int Sort() {return sort;} private final int sort;
|
||||
|
||||
public String Key() {return key;} private String key;
|
||||
|
||||
public String Lang() {return lang;} private String lang;
|
||||
public String Name() {return name;} private String name;
|
||||
public String Help() {return help;} private String help;
|
||||
public void Load_by_grp(String lang, String name, String help, String key) {
|
||||
this.lang = lang;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void Grps__add(Xogui_grp grp) {
|
||||
}
|
||||
public void Itms__add(Xogui_itm itm) {
|
||||
}
|
||||
}
|
57
400_xowa/src/gplx/xowa/addons/apps/cfgs/gui/Xogui_itm.java
Normal file
57
400_xowa/src/gplx/xowa/addons/apps/cfgs/gui/Xogui_itm.java
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
public class Xogui_itm {
|
||||
public Xogui_itm(int id, int sort) {
|
||||
this.id = id;
|
||||
this.sort = sort;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public int Sort() {return sort;} private final int sort;
|
||||
|
||||
public int Scope_id() {return scope_id;} private int scope_id;
|
||||
public int Gui_type() {return gui_type;} private int gui_type;
|
||||
public String Gui_args() {return gui_args;} private String gui_args;
|
||||
public String Key() {return key;} private String key;
|
||||
public String Dflt() {return dflt;} private String dflt;
|
||||
|
||||
public String Lang() {return lang;} private String lang;
|
||||
public String Name() {return name;} private String name;
|
||||
public String Help() {return help;} private String help;
|
||||
|
||||
public String Ctx() {return ctx;} private String ctx;
|
||||
public String Val() {return val;} private String val;
|
||||
public String Date() {return date;} private String date;
|
||||
public void Load_by_meta(String key, int scope_id, int gui_type, String gui_args, String dflt) {
|
||||
this.scope_id = scope_id;
|
||||
this.gui_type = gui_type;
|
||||
this.gui_args = gui_args;
|
||||
this.key = key;
|
||||
this.dflt = dflt;
|
||||
}
|
||||
public void Load_by_i18n(String lang, String name, String help) {
|
||||
this.lang = lang;
|
||||
this.name = name;
|
||||
this.help = help;
|
||||
}
|
||||
public void Load_by_data(String ctx, String val, String date) {
|
||||
this.ctx = ctx;
|
||||
this.val = val;
|
||||
this.date = date;
|
||||
}
|
||||
}
|
114
400_xowa/src/gplx/xowa/addons/apps/cfgs/gui/Xogui_mgr.java
Normal file
114
400_xowa/src/gplx/xowa/addons/apps/cfgs/gui/Xogui_mgr.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
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.addons.apps.cfgs.gui; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.apps.*; import gplx.xowa.addons.apps.cfgs.*;
|
||||
import gplx.dbs.*;
|
||||
import gplx.xowa.addons.apps.cfgs.dbs.*;
|
||||
public class Xogui_mgr {
|
||||
private final Xocfg_db_mgr db_mgr;
|
||||
public Xogui_mgr(Xocfg_db_mgr db_mgr) {
|
||||
this.db_mgr = db_mgr;
|
||||
}
|
||||
public Xogui_grp Get_by_grp(String grp_key, String lang) {
|
||||
// create hashes
|
||||
Ordered_hash owner_hash = Ordered_hash_.New();
|
||||
Ordered_hash grp_regy = Ordered_hash_.New();
|
||||
Ordered_hash itm_regy = Ordered_hash_.New();
|
||||
|
||||
// get root_itm
|
||||
Xogrp_meta_itm grp_meta = db_mgr.Tbl__grp_meta().Select_by_key_or_null(grp_key);
|
||||
if (grp_meta == null) throw Err_.new_wo_type("cfg:grp not found", "grp", grp_key);
|
||||
Xogui_grp owner = new Xogui_grp(grp_meta.Id(), 0, grp_meta.Key());
|
||||
owner_hash.Add(grp_meta.Id(), owner);
|
||||
|
||||
// keep selecting subs until no more owners
|
||||
while (owner_hash.Count() > 0) {
|
||||
owner = (Xogui_grp)owner_hash.Get_at(0);
|
||||
owner_hash.Del(owner.Id());
|
||||
Load_subs(grp_regy, itm_regy, owner_hash, owner);
|
||||
}
|
||||
|
||||
Load_itms(itm_regy);
|
||||
Load_i18n(grp_regy, itm_regy, lang);
|
||||
return owner;
|
||||
}
|
||||
private void Load_subs(Ordered_hash grp_regy, Ordered_hash itm_regy, Ordered_hash owner_hash, Xogui_grp owner) {
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT m.trg_id"
|
||||
, ", m.sort_id"
|
||||
, ", t.grp_key"
|
||||
, "FROM cfg_grp_map m"
|
||||
, " LEFT JOIN cfg_grp_meta t ON m.trg_id = t.grp_id"
|
||||
, "WHERE m.src_id = {0}"
|
||||
), owner.Id()
|
||||
);
|
||||
Db_rdr rdr = db_mgr.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
String grp_key = rdr.Read_str("grp_key");
|
||||
if (grp_key == null) {
|
||||
Xogui_grp gui_grp = new Xogui_grp(rdr.Read_int("trg_id"), rdr.Read_int("sort_id"), grp_key);
|
||||
owner.Grps__add(gui_grp);
|
||||
grp_regy.Add(gui_grp.Id(), gui_grp);
|
||||
owner_hash.Add(gui_grp.Id(), gui_grp);
|
||||
}
|
||||
else {
|
||||
Xogui_itm gui_itm = new Xogui_itm(rdr.Read_int("trg_id"), rdr.Read_int("sort_id"));
|
||||
owner.Itms__add(gui_itm);
|
||||
itm_regy.Add(gui_itm.Id(), gui_itm);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void Load_itms(Ordered_hash itm_regy) {
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT t.itm_id"
|
||||
, ", t.itm_key"
|
||||
, ", t.itm_scope_id"
|
||||
, ", t.itm_gui_type"
|
||||
, ", t.itm_gui_args"
|
||||
, ", t.itm_dflt"
|
||||
, "FROM cfg_itm_meta t"
|
||||
, "WHERE t.itm_id IN ({0})"
|
||||
), 0 // itm_regy.Ids_as_in_string()
|
||||
);
|
||||
|
||||
Db_rdr rdr = db_mgr.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
Xogui_itm gui_itm = (Xogui_itm)itm_regy.Get_at(rdr.Read_int("itm_id"));
|
||||
gui_itm.Load_by_meta(rdr.Read_str("itm_key"), rdr.Read_int("itm_scope_id"), rdr.Read_int("itm_gui_type"), rdr.Read_str("itm_gui_args"), rdr.Read_str("itm_dflt"));
|
||||
}
|
||||
}
|
||||
private void Load_i18n(Ordered_hash grp_regy, Ordered_hash itm_regy, String lang) {
|
||||
// while itms_w_no_i18n.Count > 0)
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT h.nde_id"
|
||||
, ", h.nde_name"
|
||||
, ", h.nde_help"
|
||||
, ", h.nde_lang"
|
||||
, "FROM cfg_itm_meta t"
|
||||
, "WHERE h.nde_id IN ({0})"
|
||||
, "AND h.nde_lang = '{1}'"
|
||||
), 0 // itm_regy.Ids_as_in_string()
|
||||
, "en"
|
||||
);
|
||||
|
||||
Db_rdr rdr = db_mgr.Conn().Stmt_sql(sql).Exec_select__rls_auto();
|
||||
while (rdr.Move_next()) {
|
||||
Xogui_itm gui_itm = (Xogui_itm)itm_regy.Get_at(rdr.Read_int("nde_id"));
|
||||
gui_itm.Load_by_i18n(rdr.Read_str("nde_lang"), rdr.Read_str("nde_name"), rdr.Read_str("nde_help"));
|
||||
}
|
||||
}
|
||||
}
|
@ -79,7 +79,12 @@ class Xob_catlink_mgr {
|
||||
tmp_link_tbl.Create_idx__to_ttl(); // index will be needed for join
|
||||
Db_conn page_conn = wiki.Data__core_mgr().Db__core().Conn();
|
||||
Xob_catlink_wkr wkr = new Xob_catlink_wkr();
|
||||
wkr.Make_catlink_dbs(wiki, tmp_conn, page_conn, cat_core_conn);
|
||||
try {
|
||||
wkr.Make_catlink_dbs(wiki, tmp_conn, page_conn, cat_core_conn);
|
||||
} catch (Exception e) {
|
||||
Gfo_usr_dlg_.Instance.Log_many("", "", "error while generating catlink dbs; ~{0}", Err_.Message_gplx_log(e));
|
||||
throw Err_.new_wo_type("error while generating catlink dbs", "err", Err_.Message_gplx_log(e));
|
||||
}
|
||||
|
||||
// make catcore_tbl; update page!cat_db_id
|
||||
wkr.Make_catcore_tbl(wiki, tmp_conn, page_conn, cat_core_conn);
|
||||
|
@ -59,8 +59,9 @@ class Xob_catlink_wkr {
|
||||
|
||||
// insert; notify;
|
||||
cat_link_tbl.Insert_cmd_by_batch(page_id_prv, rdr.Read_int("page_id"), rdr.Read_byte("cl_type_id"), rdr.Read_long("cl_timestamp"), sortkey, sortkey_prefix);
|
||||
if (++rows % 100000 == 0)
|
||||
Gfo_usr_dlg_.Instance.Prog_many("", "", "inserting cat_link row: ~{0}", Int_.To_str_fmt(rows, "#,##0"));
|
||||
if (++rows % 100000 == 0) {
|
||||
Gfo_usr_dlg_.Instance.Plog_many("", "", "inserting cat_link row: ~{0}", Int_.To_str_fmt(rows, "#,##0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {rdr.Rls();}
|
||||
|
Loading…
Reference in New Issue
Block a user