1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2025-05-31 22:44:34 +00:00

App_cfg: Add db layer

This commit is contained in:
gnosygnu 2016-11-05 06:40:02 -04:00
parent 25918b139b
commit e346afeea1
8 changed files with 273 additions and 124 deletions

View File

@ -32,7 +32,7 @@ public class Xoa_app_ {
}
}
public static final String Name = "xowa";
public static final String Version = "3.10.4.2";
public static final String Version = "3.10.4.3";
public static String Build_date = "2012-12-30 00:00:00";
public static String Op_sys_str;
public static String User_agent = "";

View File

@ -1,123 +0,0 @@
/*
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012 gnosygnu@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//namespace gplx.xowa.addons.apps.cfgs.dbs {
// using gplx.dbs; using gplx.dbs.utls;
// class Xocfg_data_itm : Db_tbl {
// private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
// private final String fld_itm_id, fld_itm_val, fld_itm_date;
// private final Db_conn conn;
// public Xocfg_data_itm(Db_conn conn) {
// this.conn = conn;
// this.tbl_name = "cfg_data_itm";
// this.fld_itm_id = flds.Add_int("itm_id"); // EX: '1'
// // ctx_id; app,wiki,ns
// this.fld_itm_date = flds.Add_str("itm_date", 32); // EX: '20160901_010203'
// this.fld_itm_val = flds.Add_str("itm_val", 4096); // EX: 'abc'
// conn.Rls_reg(this);
// }
// public String Tbl_name() {return tbl_name;} private final String tbl_name;
// public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
// public void Upsert(int itm_id, String itm_date, String itm_val) {
// Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld_itm_id), itm_id, itm_date, itm_val);
// }
// public void Rls() {}
// }
// class Xocfg_meta_itm : Db_tbl {
// private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
// private final String fld_grp_id, fld_itm_id, fld_itm_sort, fld_itm_key, fld_scope_id, fld_type_id, fld_itm_dflt;
// private final Db_conn conn;
// public Xocfg_meta_itm(Db_conn conn) {
// this.conn = conn;
// this.tbl_name = "cfg_meta_itm";
// this.fld_grp_id = flds.Add_int("grp_id"); // EX: '1'
// this.fld_itm_id = flds.Add_int("itm_id"); // EX: '2'
// this.fld_itm_sort = flds.Add_int("itm_sort"); // EX: '3'
// this.fld_scope_id = flds.Add_int("itm_scope_id"); // EX: '1'; REF: cfg_meta_scope; ENUM: app-only, wiki-only, ...
// this.fld_type_id = flds.Add_int("itm_type_id"); // EX: '1'; REF: cfg_meta_type; ENUM: int, String, ...
// this.fld_itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
// this.fld_itm_dflt = flds.Add_str("itm_dflt", 4096); // EX: 'abc'
// // display_name
// // help_text
// // locale
// conn.Rls_reg(this);
// }
// public String Tbl_name() {return tbl_name;} private final String tbl_name;
// public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
// public void Upsert(int grp_id, int itm_id, int itm_sort, int scope_id, int type_id, String itm_key, String itm_dflt) {
// Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld_grp_id, fld_itm_id), grp_id, itm_id, itm_sort, scope_id, type_id, itm_key, itm_dflt);
// }
// public void Rls() {}
// }
// class Xocfg_meta_grp : Db_tbl {
// private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
// private final String fld_grp_id, fld_grp_key;
// private final Db_conn conn;
// public Xocfg_meta_grp(Db_conn conn) {
// this.conn = conn;
// this.tbl_name = "cfg_meta_grp";
// this.fld_grp_id = flds.Add_int("grp_id");
// this.fld_grp_key = flds.Add_str("grp_key", 255);
// // display
// conn.Rls_reg(this);
// }
// public String Tbl_name() {return tbl_name;} private final String tbl_name;
// public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
// public void Upsert(int grp_id, String grp_key) {
// Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld_grp_id), grp_id, grp_key);
// }
// public void Rls() {}
// }
// class Xocfg_meta_grp_map : Db_tbl {
// private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
// private final String fld_map_src, fld_map_trg, fld_map_sort;
// private final Db_conn conn;
// public Xocfg_meta_grp_map(Db_conn conn) {
// this.conn = conn;
// this.tbl_name = "cfg_meta_grp_map";
// this.fld_map_src = flds.Add_int("map_src");
// this.fld_map_trg = flds.Add_int("map_trg");
// this.fld_map_sort = flds.Add_int("map_sort");
// conn.Rls_reg(this);
// }
// public String Tbl_name() {return tbl_name;} private final String tbl_name;
// public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
// public void Upsert(int map_src, int map_trg, int map_sort) {
// Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld_map_src), map_src, map_trg, map_sort);
// }
// public void Rls() {}
// }
///*
//EXEC cfg_select 'xowa.wiki.page.sync', 'scope'
//
//SELECT @grp_id = grp_id FROM grp WHERE key = 'xowa.wiki.page.sync';
//@aboe = SELECT * FROM grp_map WHERE owner_id = @grp_id ORDER BY sort
//SELECT * FROM meta_itm WHERE grp_id IN (@above)
//
//{{#grp}}
// {{#itm_key}}
// Coalesce({{#itm_val}}, {{#itm_dflt}})
// {{#itm_dirty}}
// {{#itm_notes}}
//{{#grp}}
//
//grp_0 -> Name of page
//grp_1 -> H2
//grp_2 -> H3
//...
//*/
//}

View File

@ -0,0 +1,34 @@
/*
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.*;
import gplx.dbs.*;
public class Xocfg_db_mgr {
public Xocfg_db_mgr(Db_conn conn) {
this.tbl__grp_meta = new Xocfg_grp_meta(conn);
this.tbl__grp_map = new Xocfg_grp_map(conn);
this.tbl__itm_meta = new Xocfg_itm_meta(conn);
this.tbl__itm_data = new Xocfg_itm_data(conn);
this.tbl__nde_i18n = new Xocfg_nde_i18n(conn);
conn.Meta_tbl_assert(tbl__grp_meta, tbl__grp_map, tbl__itm_meta, tbl__itm_data, tbl__nde_i18n);
}
public Xocfg_grp_meta Tbl__grp_meta() {return tbl__grp_meta;} private final Xocfg_grp_meta tbl__grp_meta;
public Xocfg_grp_map Tbl__grp_map() {return tbl__grp_map ;} private final Xocfg_grp_map tbl__grp_map;
public Xocfg_itm_meta Tbl__itm_meta() {return tbl__itm_meta;} private final Xocfg_itm_meta tbl__itm_meta;
public Xocfg_itm_data Tbl__itm_data() {return tbl__itm_data;} private final Xocfg_itm_data tbl__itm_data;
public Xocfg_nde_i18n Tbl__nde_i18n() {return tbl__nde_i18n;} private final Xocfg_nde_i18n tbl__nde_i18n;
}

View File

@ -0,0 +1,50 @@
/*
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.*;
import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xocfg_grp_map implements Db_tbl {
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld__map_src, fld__map_trg, fld__map_sort;
private final Db_conn conn;
public Xocfg_grp_map(Db_conn conn) {
this.conn = conn;
this.tbl_name = "cfg_grp_map";
this.fld__map_src = flds.Add_int("map_src");
this.fld__map_trg = flds.Add_int("map_trg");
this.fld__map_sort = flds.Add_int("map_sort");
conn.Rls_reg(this);
}
public String Tbl_name() {return tbl_name;} private final String tbl_name;
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
public void Upsert(int map_src, int map_trg, int map_sort) {
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__map_src), map_src, map_trg, map_sort);
}
public void Select_stub() {
Db_rdr rdr = Db_rdr_.Empty;
rdr.Read_int(fld__map_src);
rdr.Read_int(fld__map_trg);
rdr.Read_int(fld__map_sort);
}
public void Rls() {}
}
/*
grp_0 -> Name of page
grp_1 -> H2
grp_2 -> H3
...
*/

View File

@ -0,0 +1,42 @@
/*
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.*;
import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xocfg_grp_meta implements Db_tbl {
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld__grp_id, fld__grp_key;
private final Db_conn conn;
public Xocfg_grp_meta(Db_conn conn) {
this.conn = conn;
this.tbl_name = "cfg_grp_meta";
this.fld__grp_id = flds.Add_int("grp_id");
this.fld__grp_key = flds.Add_str("grp_key", 255);
conn.Rls_reg(this);
}
public String Tbl_name() {return tbl_name;} private final String tbl_name;
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
public void Upsert(int grp_id, String grp_key) {
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__grp_id), grp_id, grp_key);
}
public void Select_stub() {
Db_rdr rdr = Db_rdr_.Empty;
rdr.Read_int(fld__grp_id);
rdr.Read_str(fld__grp_key);
}
public void Rls() {}
}

View File

@ -0,0 +1,46 @@
/*
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.*;
import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xocfg_itm_data implements Db_tbl {
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld__itm_id, fld__itm_ctx, fld__itm_val, fld__itm_date;
private final Db_conn conn;
public Xocfg_itm_data(Db_conn conn) {
this.conn = conn;
this.tbl_name = "cfg_itm_data";
this.fld__itm_id = flds.Add_int("itm_id"); // EX: '1'
this.fld__itm_ctx = flds.Add_str("itm_ctx", 255); // EX: 'app'; 'en.w'; 'ns-10'
this.fld__itm_val = flds.Add_str("itm_val", 4096); // EX: 'abc'
this.fld__itm_date = flds.Add_str("itm_date", 16); // EX: '20160901_010203'
conn.Rls_reg(this);
}
public String Tbl_name() {return tbl_name;} private final String tbl_name;
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
public void Upsert(int itm_id, String itm_val, String itm_date) {
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__itm_id), itm_id, itm_date, itm_val);
}
public void Select_stub() {
Db_rdr rdr = Db_rdr_.Empty;
rdr.Read_int(fld__itm_id);
rdr.Read_str(fld__itm_ctx);
rdr.Read_str(fld__itm_val);
rdr.Read_str(fld__itm_date);
}
public void Rls() {}
}

View File

@ -0,0 +1,52 @@
/*
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.*;
import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xocfg_itm_meta implements Db_tbl {
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld__grp_id, fld__itm_id, fld__itm_sort, fld__itm_key, fld__itm_scope_id, fld__itm_type_id, fld__itm_dflt;
private final Db_conn conn;
public Xocfg_itm_meta(Db_conn conn) {
this.conn = conn;
this.tbl_name = "cfg_itm_meta";
this.fld__grp_id = flds.Add_int("grp_id"); // EX: '1'
this.fld__itm_id = flds.Add_int("itm_id"); // EX: '2'
this.fld__itm_sort = flds.Add_int("itm_sort"); // EX: '1'
this.fld__itm_scope_id = flds.Add_int("itm_scope_id"); // EX: '1'; REF: cfg_scope_regy; ENUM: app-only, wiki-only, ...
this.fld__itm_type_id = flds.Add_int("itm_type_id"); // EX: '1'; REF: cfg_type_regy; ENUM: int, String, ...
this.fld__itm_key = flds.Add_str("itm_key", 255); // EX: 'cfg_1'
this.fld__itm_dflt = flds.Add_str("itm_dflt", 4096); // EX: 'abc'
conn.Rls_reg(this);
}
public String Tbl_name() {return tbl_name;} private final String tbl_name;
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
public void Upsert(int grp_id, int itm_id, int itm_sort, int scope_id, int type_id, String itm_key, String itm_dflt) {
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__grp_id, fld__itm_id), grp_id, itm_id, itm_sort, scope_id, type_id, itm_key, itm_dflt);
}
public void Select_stub() {
Db_rdr rdr = Db_rdr_.Empty;
rdr.Read_int(fld__grp_id);
rdr.Read_int(fld__itm_id);
rdr.Read_int(fld__itm_sort);
rdr.Read_int(fld__itm_scope_id);
rdr.Read_int(fld__itm_type_id);
rdr.Read_str(fld__itm_key);
rdr.Read_str(fld__itm_dflt);
}
public void Rls() {}
}

View File

@ -0,0 +1,48 @@
/*
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.*;
import gplx.dbs.*; import gplx.dbs.utls.*;
public class Xocfg_nde_i18n implements Db_tbl {
private final Dbmeta_fld_list flds = new Dbmeta_fld_list();
private final String fld__nde_type, fld__nde_id, fld__nde_locale, fld__nde_name, fld__nde_help;
private final Db_conn conn;
public Xocfg_nde_i18n(Db_conn conn) {
this.conn = conn;
this.tbl_name = "cfg_nde_i18n";
this.fld__nde_type = flds.Add_int("nde_type"); // EX: 1=grp; 2=itm
this.fld__nde_id = flds.Add_int("nde_id"); // EX: '2'
this.fld__nde_locale = flds.Add_str("nde_locale", 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 in html'
conn.Rls_reg(this);
}
public String Tbl_name() {return tbl_name;} private final String tbl_name;
public void Create_tbl() {conn.Meta_tbl_create(Dbmeta_tbl_itm.New(tbl_name, flds));}
public void Upsert(int nde_type, int nde_id, String nde_locale, String nde_name, String nde_help) {
Db_tbl__crud_.Upsert(conn, tbl_name, flds, String_.Ary(fld__nde_type, fld__nde_id, fld__nde_locale), nde_type, nde_id, nde_locale, nde_name, nde_help);
}
public void Select_stub() {
Db_rdr rdr = Db_rdr_.Empty;
rdr.Read_int(fld__nde_type);
rdr.Read_int(fld__nde_id);
rdr.Read_str(fld__nde_locale);
rdr.Read_str(fld__nde_name);
rdr.Read_str(fld__nde_help);
}
public void Rls() {}
}