mirror of
https://github.com/gnosygnu/xowa.git
synced 2025-06-02 15:34:37 +00:00
Add page title to log message when category does not exist in page (dynamicPageList)
This commit is contained in:
parent
01e45caa5a
commit
c032eba49c
@ -1,12 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/luaj-vm"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/100_core"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/140_dbs"/>
|
||||
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/150_gfui"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jtidy_xowa.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/luaj_xowa.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/jtidy_xowa.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/icu4j-4_8.jar"/>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
|
@ -41,13 +41,13 @@ public class Xoctg_catpage_mgr implements Gfo_invk {
|
||||
}
|
||||
}
|
||||
public void Free_mem_all() {cache.Clear();}
|
||||
public Xoctg_catpage_ctg Get_or_load_or_null(Xoctg_catpage_url catpage_url, Xoa_ttl cat_ttl, int limit) {
|
||||
public Xoctg_catpage_ctg Get_or_load_or_null(byte[] page_ttl, Xoctg_catpage_url catpage_url, Xoa_ttl cat_ttl, int limit) {
|
||||
// load categories from cat dbs; exit if not found
|
||||
Xoctg_catpage_ctg ctg = (Xoctg_catpage_ctg)cache.Get_by(cat_ttl.Full_db());
|
||||
if (ctg == null) {
|
||||
if (gplx.core.envs.Env_.Mode_testing()) return null; // needed for dpl test
|
||||
synchronized (thread_lock) { // LOCK:used by multiple wrks; DATE:2016-09-12
|
||||
ctg = loader.Load_ctg_or_null(wiki, this, catpage_url, cat_ttl, limit);
|
||||
ctg = loader.Load_ctg_or_null(wiki, page_ttl, this, catpage_url, cat_ttl, limit);
|
||||
}
|
||||
if (ctg == null) return null; // not in cache or db; exit
|
||||
// cache.Add(cat_ttl.Full_db(), ctg);
|
||||
@ -60,7 +60,7 @@ public class Xoctg_catpage_mgr implements Gfo_invk {
|
||||
Xoctg_catpage_url catpage_url = Xoctg_catpage_url_parser.Parse(page.Url());
|
||||
|
||||
// load categories from cat dbs; exit if not found
|
||||
Xoctg_catpage_ctg ctg = Get_or_load_or_null(catpage_url, page.Ttl(), grp_max);
|
||||
Xoctg_catpage_ctg ctg = Get_or_load_or_null(page.Ttl().Page_db(), catpage_url, page.Ttl(), grp_max);
|
||||
if (ctg == null) return;
|
||||
|
||||
// write html
|
||||
|
@ -19,13 +19,13 @@ package gplx.xowa.addons.wikis.ctgs.htmls.catpages.dbs; import gplx.*; import gp
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.data.tbls.*; import gplx.xowa.addons.wikis.ctgs.dbs.*;
|
||||
import gplx.xowa.addons.wikis.ctgs.htmls.catpages.doms.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.urls.*; import gplx.xowa.addons.wikis.ctgs.htmls.catpages.dbs.*;
|
||||
public class Xoctg_catpage_loader {
|
||||
public Xoctg_catpage_ctg Load_ctg_or_null(Xow_wiki wiki, Xoctg_catpage_mgr catpage_mgr, Xoctg_catpage_url cat_url, Xoa_ttl cat_ttl, int limit) {
|
||||
public Xoctg_catpage_ctg Load_ctg_or_null(Xow_wiki wiki, byte[] page_ttl_bry, Xoctg_catpage_mgr catpage_mgr, Xoctg_catpage_url cat_url, Xoa_ttl cat_ttl, int limit) {
|
||||
// get cat_id from page_tbl
|
||||
Xow_db_mgr db_mgr = wiki.Data__core_mgr();
|
||||
Xowd_page_tbl page_tbl = db_mgr.Db__core().Tbl__page();
|
||||
Xowd_page_itm page_itm = page_tbl.Select_by_ttl_as_itm_or_null(cat_ttl);
|
||||
if (page_itm == null) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "category does not exist in page table; ttl=~{0}", cat_ttl.Full_db());
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "category does not exist in page table; page=~{0} ttl=~{1}", page_ttl_bry, cat_ttl.Full_db());
|
||||
return null;
|
||||
}
|
||||
int cat_id = page_itm.Id();
|
||||
|
@ -19,26 +19,27 @@ package gplx.xowa.bldrs.sql_dumps; import gplx.*; import gplx.xowa.*; import gpl
|
||||
import org.junit.*; import gplx.core.ios.*; import gplx.core.tests.*;
|
||||
public class Xosql_dump_parser__tst {
|
||||
private final Xosql_dump_parser__fxt fxt = new Xosql_dump_parser__fxt();
|
||||
private static final String table_def = "\n KEY \n) ENGINE; ";
|
||||
@Test public void One() {
|
||||
fxt.Init(String_.Ary("c1", "c2"), "c2").Test__parse("INSERT INTO 'tbl_1' VALUES (1,2);", "2|");
|
||||
fxt.Init(String_.Ary("c1", "c2"), "c2").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,2);", "2|");
|
||||
}
|
||||
@Test public void Many() {
|
||||
fxt.Init(String_.Ary("c1", "c2"), "c2").Test__parse("INSERT INTO 'tbl_1' VALUES (1,2),(3,4),(5,6);", "2|\n4|\n6|");
|
||||
fxt.Init(String_.Ary("c1", "c2"), "c2").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,2),(3,4),(5,6);", "2|\n4|\n6|");
|
||||
}
|
||||
@Test public void Quote_basic() {
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse("INSERT INTO 'tbl_1' VALUES (1,'a','b');", "a|b|");
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,'a','b');", "a|b|");
|
||||
}
|
||||
@Test public void Escape_backslash() {
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse("INSERT INTO 'tbl_1' VALUES (1,'a\\\\b','c');", "a\\b|c|");
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,'a\\\\b','c');", "a\\b|c|");
|
||||
}
|
||||
@Test public void Escape_quote() {
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse("INSERT INTO 'tbl_1' VALUES (1,'a\"b','c');", "a\"b|c|");
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,'a\"b','c');", "a\"b|c|");
|
||||
}
|
||||
@Test public void Fld_paren_end() {
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse("INSERT INTO 'tbl_1' VALUES (1,'Психостимуляторы_(лекарственные_средства)','c');", "Психостимуляторы_(лекарственные_средства)|c|");
|
||||
fxt.Init(String_.Ary("c1", "c2", "c3"), "c2", "c3").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,'Психостимуляторы_(лекарственные_средства)','c');", "Психостимуляторы_(лекарственные_средства)|c|");
|
||||
}
|
||||
@Test public void Insert_multiple() {
|
||||
fxt.Init(String_.Ary("c1", "c2"), "c2").Test__parse("INSERT INTO 'tbl_1' VALUES (1,2);INSERT INTO 'tbl_1' VALUES (3,4)", "2|\n4|");
|
||||
fxt.Init(String_.Ary("c1", "c2"), "c2").Test__parse(table_def + "INSERT INTO 'tbl_1' VALUES (1,2);INSERT INTO 'tbl_1' VALUES (3,4)", "2|\n4|");
|
||||
}
|
||||
}
|
||||
class Xosql_dump_parser__fxt {
|
||||
|
@ -21,6 +21,7 @@ import gplx.langs.htmls.*; import gplx.xowa.htmls.*;
|
||||
import gplx.xowa.parsers.*; import gplx.xowa.parsers.xndes.*;
|
||||
import gplx.xowa.wikis.nss.*;
|
||||
class Dpl_itm {
|
||||
public byte[] Page_ttl() {return page_ttl;} private byte[] page_ttl;
|
||||
public List_adp Ctg_includes() {return ctg_includes;} private List_adp ctg_includes;
|
||||
public List_adp Ctg_excludes() {return ctg_excludes;} private List_adp ctg_excludes;
|
||||
public int Count() {return count;} private int count = Int_.Min_value;
|
||||
@ -42,6 +43,7 @@ class Dpl_itm {
|
||||
public byte Stable_pages() {return stable_pages;} private byte stable_pages;
|
||||
private Xop_ctx sub_ctx; private Xop_tkn_mkr sub_tkn_mkr; private Xop_root_tkn sub_root;
|
||||
public void Parse(Xowe_wiki wiki, Xop_ctx ctx, byte[] page_ttl, byte[] src, Xop_xnde_tkn xnde) { // parse kvps in xnde; EX:<dpl>category=abc\nredirects=y\n</dpl>
|
||||
this.page_ttl = page_ttl;
|
||||
sub_ctx = Xop_ctx.New__sub__reuse_page(ctx);
|
||||
sub_tkn_mkr = sub_ctx.Tkn_mkr();
|
||||
sub_root = sub_tkn_mkr.Root(Bry_.Empty);
|
||||
|
@ -89,12 +89,12 @@ class Dpl_page_finder {
|
||||
List_adp del_list = List_adp_.New();
|
||||
int ns_filter = itm.Ns_filter();
|
||||
Ordered_hash exclude_pages = Ordered_hash_.New();
|
||||
Find_excludes(exclude_pages, wiki, load_mgr, tmp_page, tmp_id, itm.Ctg_excludes());
|
||||
Find_excludes(exclude_pages, wiki, load_mgr, itm.Page_ttl(), tmp_page, tmp_id, itm.Ctg_excludes());
|
||||
|
||||
for (int i = 0; i < includes_len; i++) { // loop over includes
|
||||
byte[] include = (byte[])includes.Get_at(i);
|
||||
cur_regy.Clear(); del_list.Clear();
|
||||
Find_pages_in_ctg(cur_regy, wiki, load_mgr, tmp_page, tmp_id, include);
|
||||
Find_pages_in_ctg(cur_regy, wiki, load_mgr, itm.Page_ttl(), tmp_page, tmp_id, include);
|
||||
Del_old_pages_not_in_cur(i, tmp_id, old_regy, cur_regy, del_list);
|
||||
Add_cur_pages_also_in_old(i, tmp_id, old_regy, cur_regy, new_regy, exclude_pages, ns_filter);
|
||||
old_regy = new_regy;
|
||||
@ -108,16 +108,16 @@ class Dpl_page_finder {
|
||||
wiki.Db_mgr().Load_mgr().Load_by_ids(Cancelable_.Never, rv, 0, pages_len);
|
||||
rv.Sort_by(Xowd_page_itm_sorter.IdAsc);
|
||||
}
|
||||
private static void Find_excludes(Ordered_hash exclude_pages, Xowe_wiki wiki, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, List_adp exclude_ctgs) {
|
||||
private static void Find_excludes(Ordered_hash exclude_pages, Xowe_wiki wiki, Xodb_load_mgr load_mgr, byte[] page_ttl, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, List_adp exclude_ctgs) {
|
||||
if (exclude_ctgs == null) return;
|
||||
int exclude_ctgs_len = exclude_ctgs.Count();
|
||||
for (int i = 0; i < exclude_ctgs_len; i++) {
|
||||
byte[] exclude_ctg = (byte[])exclude_ctgs.Get_at(i);
|
||||
Find_pages_in_ctg(exclude_pages, wiki, load_mgr, tmp_page, tmp_id, exclude_ctg);
|
||||
Find_pages_in_ctg(exclude_pages, wiki, load_mgr, page_ttl, tmp_page, tmp_id, exclude_ctg);
|
||||
}
|
||||
}
|
||||
private static void Find_pages_in_ctg(Ordered_hash rv, Xowe_wiki wiki, Xodb_load_mgr load_mgr, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, byte[] ctg_ttl) {
|
||||
Xoctg_catpage_ctg ctg = wiki.Ctg__catpage_mgr().Get_or_load_or_null(Xoctg_catpage_url.New__blank(), wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, ctg_ttl), -1);
|
||||
private static void Find_pages_in_ctg(Ordered_hash rv, Xowe_wiki wiki, Xodb_load_mgr load_mgr, byte[] page_ttl, Xowd_page_itm tmp_page, Int_obj_ref tmp_id, byte[] ctg_ttl) {
|
||||
Xoctg_catpage_ctg ctg = wiki.Ctg__catpage_mgr().Get_or_load_or_null(page_ttl, Xoctg_catpage_url.New__blank(), wiki.Ttl_parse(gplx.xowa.wikis.nss.Xow_ns_.Tid__category, ctg_ttl), -1);
|
||||
if (ctg == null) return;
|
||||
|
||||
// loop grps to get grp
|
||||
|
Loading…
Reference in New Issue
Block a user