mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Wikibase: Infer datatype from cached table not from JSON doc
This commit is contained in:
parent
b3566def7e
commit
da18f05d9f
@ -69,7 +69,8 @@ public class Scrib_lib_wikibase implements Scrib_lib {
|
||||
}
|
||||
public boolean GetEntity(Scrib_proc_args args, Scrib_proc_rslt rslt) {
|
||||
Wdata_doc wdoc = Get_wdoc_or_null(args, core); if (wdoc == null) return rslt.Init_ary_empty();
|
||||
return rslt.Init_obj(Scrib_lib_wikibase_srl.Srl(wdoc, true, false)); // "false": wbase now always uses v2; PAGE:ja.w:東京競馬場; DATE:2015-07-28
|
||||
Wbase_prop_mgr prop_mgr = core.Wiki().Appe().Wiki_mgr().Wdata_mgr().Prop_mgr();
|
||||
return rslt.Init_obj(Scrib_lib_wikibase_srl.Srl(prop_mgr, wdoc, true, false)); // "false": wbase now always uses v2; PAGE:ja.w:東京競馬場; DATE:2015-07-28
|
||||
}
|
||||
public boolean GetEntityUrl(Scrib_proc_args args, Scrib_proc_rslt rslt) {throw Err_.new_("wbase", "getEntityUrl not implemented", "url", core.Page().Url().To_str());}
|
||||
public boolean GetSetting(Scrib_proc_args args, Scrib_proc_rslt rslt) {throw Err_.new_("wbase", "getSetting not implemented", "url", core.Page().Url().To_str());}
|
||||
|
@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
|
||||
import gplx.xowa.xtns.wbases.*; import gplx.xowa.xtns.wbases.core.*; import gplx.xowa.xtns.wbases.claims.*; import gplx.xowa.xtns.wbases.claims.enums.*; import gplx.xowa.xtns.wbases.claims.itms.*; import gplx.xowa.xtns.wbases.parsers.*;
|
||||
class Scrib_lib_wikibase_srl {
|
||||
public static Keyval[] Srl(Wdata_doc wdoc, boolean header_enabled, boolean legacy_style) {// REF.MW:/Wikibase/lib/includes/serializers/EntitySerializer.php!getSerialized; http://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua
|
||||
public static Keyval[] Srl(Wbase_prop_mgr prop_mgr, Wdata_doc wdoc, boolean header_enabled, boolean legacy_style) {// REF.MW:/Wikibase/lib/includes/serializers/EntitySerializer.php!getSerialized; http://www.mediawiki.org/wiki/Extension:Wikibase_Client/Lua
|
||||
int base_adj = legacy_style ? 0 : 1;
|
||||
List_adp rv = List_adp_.New();
|
||||
if (header_enabled) {
|
||||
@ -32,7 +32,7 @@ class Scrib_lib_wikibase_srl {
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_descriptions , Srl_langtexts (Wdata_dict_langtext.Itm__language.Key_str(), Wdata_dict_langtext.Itm__value.Key_str(), wdoc.Descr_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_sitelinks , Srl_sitelinks (Wdata_dict_sitelink.Itm__site.Key_str() , Wdata_dict_sitelink.Itm__title.Key_str(), wdoc.Slink_list(), base_adj));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_aliases , Srl_aliases (base_adj, wdoc.Alias_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_claims , Srl_claims (base_adj, legacy_style, wdoc.Claim_list()));
|
||||
Srl_root(rv, Wdata_doc_parser_v2.Str_claims , Srl_claims (base_adj, legacy_style, prop_mgr, wdoc.Claim_list()));
|
||||
return (Keyval[])rv.To_ary(Keyval.class);
|
||||
}
|
||||
private static void Srl_root(List_adp rv, String label, Keyval[] ary) {
|
||||
@ -90,7 +90,7 @@ class Scrib_lib_wikibase_srl {
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static Keyval[] Srl_claims(int base_adj, boolean legacy_style, Ordered_hash claim_grps) {
|
||||
private static Keyval[] Srl_claims(int base_adj, boolean legacy_style, Wbase_prop_mgr prop_mgr, Ordered_hash claim_grps) {
|
||||
int len = claim_grps.Count(); if (len == 0) return null;
|
||||
Scrib_lib_wikibase_srl_visitor visitor = new Scrib_lib_wikibase_srl_visitor();
|
||||
int rv_len = legacy_style ? len * 2 : len; // NOTE: legacyStyle returns 2 sets of properties: official "P" and legacy "p"; DATE:2014-05-11
|
||||
@ -98,32 +98,32 @@ class Scrib_lib_wikibase_srl {
|
||||
for (int i = 0; i < len; i++) {
|
||||
Wbase_claim_grp grp = (Wbase_claim_grp)claim_grps.Get_at(i);
|
||||
String pid_str = Int_.To_str(grp.Id());
|
||||
Keyval[] grp_val = Srl_claims_prop_grp(visitor, "P" + pid_str, grp, base_adj);
|
||||
Keyval[] grp_val = Srl_claims_prop_grp(prop_mgr, visitor, "P" + pid_str, grp, base_adj);
|
||||
rv[i] = Keyval_.new_("P" + pid_str, grp_val);
|
||||
if (legacy_style)
|
||||
rv[i + len] = Keyval_.new_("p" + pid_str, grp_val); // SEE:WikibaseLuaBindings.php; This is a B/C hack to allow existing lua code to use hardcoded IDs in both lower (legacy) and upper case.; DATE:2014-05-11
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static Keyval[] Srl_claims_prop_grp(Scrib_lib_wikibase_srl_visitor visitor, String pid, Wbase_claim_grp grp, int base_adj) {
|
||||
private static Keyval[] Srl_claims_prop_grp(Wbase_prop_mgr prop_mgr, Scrib_lib_wikibase_srl_visitor visitor, String pid, Wbase_claim_grp grp, int base_adj) {
|
||||
int len = grp.Len();
|
||||
Keyval[] rv = new Keyval[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
Wbase_claim_base itm = grp.Get_at(i);
|
||||
rv[i] = Keyval_.int_(i + base_adj, Srl_claims_prop_itm(visitor, pid, itm, base_adj)); // NOTE: must be super 0 or super 1; DATE:2014-05-09
|
||||
rv[i] = Keyval_.int_(i + base_adj, Srl_claims_prop_itm(prop_mgr, visitor, pid, itm, base_adj)); // NOTE: must be super 0 or super 1; DATE:2014-05-09
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
private static Keyval[] Srl_claims_prop_itm(Scrib_lib_wikibase_srl_visitor visitor, String pid, Wbase_claim_base itm, int base_adj) {
|
||||
private static Keyval[] Srl_claims_prop_itm(Wbase_prop_mgr prop_mgr, Scrib_lib_wikibase_srl_visitor visitor, String pid, Wbase_claim_base itm, int base_adj) {
|
||||
List_adp list = List_adp_.New();
|
||||
list.Add(Keyval_.new_("id", pid));
|
||||
list.Add(Keyval_.new_("mainsnak", Srl_claims_prop_itm_core(visitor, pid, itm)));
|
||||
list.Add(Keyval_.new_("mainsnak", Srl_claims_prop_itm_core(prop_mgr, visitor, pid, itm)));
|
||||
list.Add(Keyval_.new_(Wdata_dict_claim_v1.Str_rank, Wbase_claim_rank_.Reg.Get_str_or_fail(itm.Rank_tid())));
|
||||
list.Add(Keyval_.new_("type", itm.Prop_type()));
|
||||
Srl_root(list, Wdata_dict_claim.Itm__qualifiers.Key_str(), Srl_qualifiers(visitor, itm.Qualifiers(), base_adj));
|
||||
Srl_root(list, Wdata_dict_claim.Itm__qualifiers.Key_str(), Srl_qualifiers(prop_mgr, visitor, itm.Qualifiers(), base_adj));
|
||||
return (Keyval[])list.To_ary_and_clear(Keyval.class);
|
||||
}
|
||||
private static Keyval[] Srl_qualifiers(Scrib_lib_wikibase_srl_visitor visitor, Wbase_claim_grp_list list, int base_adj) {
|
||||
private static Keyval[] Srl_qualifiers(Wbase_prop_mgr prop_mgr, Scrib_lib_wikibase_srl_visitor visitor, Wbase_claim_grp_list list, int base_adj) {
|
||||
if (list == null) return null;
|
||||
int list_len = list.Len(); if (list_len == 0) return Keyval_.Ary_empty;
|
||||
List_adp rv = List_adp_.New();
|
||||
@ -135,13 +135,13 @@ class Scrib_lib_wikibase_srl {
|
||||
String itm_pid = grp.Id_str();
|
||||
for (int j = 0; j < grp_len; ++j) {
|
||||
Wbase_claim_base itm = grp.Get_at(j);
|
||||
pid_list.Add(Keyval_.int_(j + base_adj, Srl_claims_prop_itm_core(visitor, itm_pid, itm))); // NOTE: was originally "+ 1"; changed to base_adj; PAGE:ru.w:Tor ru.w:Кактусовые DATE:2014-10-25
|
||||
pid_list.Add(Keyval_.int_(j + base_adj, Srl_claims_prop_itm_core(prop_mgr, visitor, itm_pid, itm))); // NOTE: was originally "+ 1"; changed to base_adj; PAGE:ru.w:Tor ru.w:Кактусовые DATE:2014-10-25
|
||||
}
|
||||
rv.Add(Keyval_.new_(itm_pid, (Keyval[])pid_list.To_ary_and_clear(Keyval.class)));
|
||||
}
|
||||
return (Keyval[])rv.To_ary_and_clear(Keyval.class);
|
||||
}
|
||||
private static Keyval[] Srl_claims_prop_itm_core(Scrib_lib_wikibase_srl_visitor visitor, String pid, Wbase_claim_base itm) {
|
||||
private static Keyval[] Srl_claims_prop_itm_core(Wbase_prop_mgr prop_mgr, Scrib_lib_wikibase_srl_visitor visitor, String pid, Wbase_claim_base itm) {
|
||||
boolean snak_is_valued = itm.Snak_tid() == Wbase_claim_value_type_.Tid__value; // PURPOSE: was != Wbase_claim_value_type_.Tid__novalue; PAGE:it.s:Autore:Anonimo DATE:2015-12-06
|
||||
int snak_is_valued_adj = snak_is_valued ? 1 : 0;
|
||||
Keyval[] rv = new Keyval[3 + snak_is_valued_adj];
|
||||
@ -149,7 +149,12 @@ class Scrib_lib_wikibase_srl {
|
||||
rv[0] = Keyval_.new_("datavalue", Srl_claims_prop_itm_core_val(visitor, itm));
|
||||
rv[0 + snak_is_valued_adj] = Keyval_.new_("property", pid);
|
||||
rv[1 + snak_is_valued_adj] = Keyval_.new_("snaktype", Wbase_claim_value_type_.Reg.Get_str_or_fail(itm.Snak_tid()));
|
||||
rv[2 + snak_is_valued_adj] = Keyval_.new_("datatype", Wbase_claim_type_.Get_scrib_or_unknown(itm.Val_tid())); // NOTE: datatype needed for Modules; PAGE:eo.w:WikidataKoord; DATE:2015-11-08
|
||||
|
||||
// get prop datatype; NOTE: datatype needed for Modules; PAGE:eo.w:WikidataKoord; DATE:2015-11-08
|
||||
String datatype = prop_mgr.Get_or_null(pid);
|
||||
if (datatype == null) // if null, fallback to value based on tid; needed for (a) tests and (b) old wbase dbs that don't have wbase_prop tbl; DATE:2016-12-01
|
||||
datatype = Wbase_claim_type_.Get_scrib_or_unknown(itm.Val_tid());
|
||||
rv[2 + snak_is_valued_adj] = Keyval_.new_("datatype", datatype);
|
||||
return rv;
|
||||
}
|
||||
private static Keyval[] Srl_claims_prop_itm_core_val(Scrib_lib_wikibase_srl_visitor visitor, Wbase_claim_base itm) {
|
||||
|
@ -368,6 +368,26 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
Gftest.Eq__str("timezone", keyval.Key());
|
||||
Gftest.Eq__int(0, (int)keyval.Val()); // fails when keyval.Val() is String; DATE:2016-10-28
|
||||
}
|
||||
@Test public void Claims__commonsMedia() {
|
||||
fxt.Wdata_fxt().Wdata_mgr().Prop_mgr().Loader_(Wbase_prop_mgr_loader_.New_mock(Keyval_.new_("P2", "commonsMedia")));
|
||||
fxt.Init_prop(fxt.Wdata_fxt().Make_claim_string(2, "abc"));
|
||||
fxt.Test
|
||||
( "claims:"
|
||||
, " P2:"
|
||||
, " 1:"
|
||||
, " id:'P2'"
|
||||
, " mainsnak:"
|
||||
, " datavalue:"
|
||||
, " type:'string'"
|
||||
, " value:'abc'"
|
||||
, " property:'P2'"
|
||||
, " snaktype:'value'"
|
||||
, " datatype:'commonsMedia'"
|
||||
, " rank:'normal'"
|
||||
, " type:'statement'"
|
||||
, ""
|
||||
);
|
||||
}
|
||||
@Test public void Type_is_property() { // PURPOSE: type should be "property"; PAGE:ru.w:Викитека:Проект:Викиданные DATE:2016-11-23
|
||||
fxt.Init_header_enabled_y_();
|
||||
fxt.Wdata_fxt().doc_("Property:P1", fxt.Wdata_fxt().Make_claim_string(123, "abc"));
|
||||
@ -391,11 +411,13 @@ public class Scrib_lib_wikibase_srl_tst {
|
||||
}
|
||||
class Scrib_lib_wikibase_srl_fxt {
|
||||
private Wdata_doc_bldr wdoc_bldr;
|
||||
private Wbase_prop_mgr prop_mgr;
|
||||
public void Clear() {
|
||||
wdata_fxt = new Wdata_wiki_mgr_fxt();
|
||||
wdata_fxt.Init();
|
||||
wdoc_bldr = wdata_fxt.Wdoc_bldr("q2");
|
||||
header_enabled = false;
|
||||
this.prop_mgr = wdata_fxt.App().Wiki_mgr().Wdata_mgr().Prop_mgr();
|
||||
}
|
||||
public Wdata_wiki_mgr_fxt Wdata_fxt() {return wdata_fxt;} private Wdata_wiki_mgr_fxt wdata_fxt;
|
||||
private boolean header_enabled;
|
||||
@ -419,13 +441,13 @@ class Scrib_lib_wikibase_srl_fxt {
|
||||
public Scrib_lib_wikibase_srl_fxt Init_prop(Wbase_claim_base prop) {wdoc_bldr.Add_claims(prop); return this;}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(String... expd) {return Test(false, expd);}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(boolean base0, String... expd) {
|
||||
Keyval[] actl = Scrib_lib_wikibase_srl.Srl(wdoc_bldr.Xto_wdoc(), header_enabled, base0);
|
||||
Keyval[] actl = Scrib_lib_wikibase_srl.Srl(prop_mgr, wdoc_bldr.Xto_wdoc(), header_enabled, base0);
|
||||
Tfds.Eq_ary_str(expd, String_.SplitLines_nl(Xto_str(actl)));
|
||||
return this;
|
||||
}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(Wdata_doc wdoc, String... expd) {return Test(false, wdoc, expd);}
|
||||
public Scrib_lib_wikibase_srl_fxt Test(boolean base0, Wdata_doc wdoc, String... expd) {
|
||||
Keyval[] actl = Scrib_lib_wikibase_srl.Srl(wdoc, header_enabled, base0);
|
||||
Keyval[] actl = Scrib_lib_wikibase_srl.Srl(prop_mgr, wdoc, header_enabled, base0);
|
||||
Tfds.Eq_ary_str(expd, String_.SplitLines_nl(Xto_str(actl)));
|
||||
return this;
|
||||
}
|
||||
|
@ -121,15 +121,15 @@ public class Scrib_lib_wikibase_tst {
|
||||
class Wbase_snak_utl_ {
|
||||
public static Keyval[] Get_snaks_ary(Wdata_wiki_mgr_fxt wdata_fxt, Wbase_claim_base... ary) {
|
||||
Wdata_doc wdoc = wdata_fxt.Wdoc_bldr("q2").Add_claims(ary).Xto_wdoc();
|
||||
return Keyval_.Ary(Keyval_.int_(1, Get_snaks(wdoc)));
|
||||
return Keyval_.Ary(Keyval_.int_(1, Get_snaks(wdata_fxt, wdoc)));
|
||||
}
|
||||
public static Keyval[] Get_snak(Wdata_wiki_mgr_fxt wdata_fxt, Wbase_claim_base itm) {
|
||||
Wdata_doc wdoc = wdata_fxt.Wdoc_bldr("q2").Add_claims(itm).Xto_wdoc();
|
||||
Keyval[] snak_props = Get_subs_by_path(Get_snaks(wdoc), 0);
|
||||
Keyval[] snak_props = Get_subs_by_path(Get_snaks(wdata_fxt, wdoc), 0);
|
||||
return Keyval_.Ary(Keyval_.int_(1, snak_props));
|
||||
}
|
||||
private static Keyval[] Get_snaks(Wdata_doc wdoc) {
|
||||
Keyval[] wdoc_root = Scrib_lib_wikibase_srl.Srl(wdoc, false, false);
|
||||
private static Keyval[] Get_snaks(Wdata_wiki_mgr_fxt wdata_fxt, Wdata_doc wdoc) {
|
||||
Keyval[] wdoc_root = Scrib_lib_wikibase_srl.Srl(wdata_fxt.Wdata_mgr().Prop_mgr(), wdoc, false, false);
|
||||
Keyval[] snaks = Get_subs_by_path(wdoc_root, 0, 0);
|
||||
int snaks_len = snaks.length;
|
||||
Keyval[] rv = new Keyval[snaks_len];
|
||||
|
44
400_xowa/src/gplx/xowa/xtns/wbases/Wbase_prop_mgr.java
Normal file
44
400_xowa/src/gplx/xowa/xtns/wbases/Wbase_prop_mgr.java
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
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.xtns.wbases; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.wikis.data.*;
|
||||
public class Wbase_prop_mgr { // lang-agnostic registry of props; EX: "p15" -> commonsmedia
|
||||
private boolean init_needed = true;
|
||||
private Ordered_hash hash;
|
||||
public Wbase_prop_mgr(Wbase_prop_mgr_loader loader) {
|
||||
this.loader = loader;
|
||||
}
|
||||
public Wbase_prop_mgr_loader Loader() {return loader;} private Wbase_prop_mgr_loader loader;
|
||||
public void Loader_(Wbase_prop_mgr_loader v) {
|
||||
loader = v;
|
||||
init_needed = true;
|
||||
}
|
||||
private void Init() {
|
||||
init_needed = false;
|
||||
hash = loader.Load();
|
||||
}
|
||||
public String Get_or_null(String pid) {
|
||||
if (init_needed) Init();
|
||||
if (hash == null) return null;
|
||||
String rv = (String)hash.Get_by(pid);
|
||||
if (rv == null) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "wbase:could not find datatype for pid; pid=~{0}", pid);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
@ -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.xowa.xtns.wbases; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
import gplx.xowa.wikis.data.*;
|
||||
public interface Wbase_prop_mgr_loader {
|
||||
Ordered_hash Load();
|
||||
}
|
@ -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.xtns.wbases; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*;
|
||||
public class Wbase_prop_mgr_loader_ {
|
||||
public static Wbase_prop_mgr_loader New_mock(Keyval... pairs) {
|
||||
return new Wbase_prop_mgr_loader__mock(pairs);
|
||||
}
|
||||
public static Wbase_prop_mgr_loader New_db(Wdata_wiki_mgr wbase_mgr) {
|
||||
return new Wbase_prop_mgr_loader__db(wbase_mgr);
|
||||
}
|
||||
}
|
||||
class Wbase_prop_mgr_loader__mock implements Wbase_prop_mgr_loader {
|
||||
private final Keyval[] pairs;
|
||||
public Wbase_prop_mgr_loader__mock(Keyval[] pairs) {
|
||||
this.pairs = pairs;
|
||||
}
|
||||
public Ordered_hash Load() {
|
||||
Ordered_hash rv = Ordered_hash_.New();
|
||||
for (Keyval kv : pairs)
|
||||
rv.Add(kv.Key(), kv.Val_to_str_or_empty());
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
class Wbase_prop_mgr_loader__db implements Wbase_prop_mgr_loader {
|
||||
private final Wdata_wiki_mgr wbase_mgr;
|
||||
public Wbase_prop_mgr_loader__db(Wdata_wiki_mgr wbase_mgr) {
|
||||
this.wbase_mgr = wbase_mgr;
|
||||
}
|
||||
public Ordered_hash Load() {
|
||||
gplx.xowa.wikis.data.Xow_db_file wbase_db = wbase_mgr.Wdata_wiki().Data__core_mgr().Db__wbase();
|
||||
if (!wbase_db.Conn().Meta_tbl_exists(wbase_db.Tbl__wbase_prop().Tbl_name())) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "wbase:prop tbl missing");
|
||||
return null;
|
||||
}
|
||||
return wbase_db.Tbl__wbase_prop().Select_all();
|
||||
}
|
||||
}
|
@ -28,13 +28,14 @@ public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
private final Wdata_prop_val_visitor prop_val_visitor;
|
||||
private final Wdata_doc_parser wdoc_parser_v1 = new Wdata_doc_parser_v1(), wdoc_parser_v2 = new Wdata_doc_parser_v2();
|
||||
private final Object thread_lock = new Object();
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(32);
|
||||
private final Bry_bfr tmp_bfr = Bry_bfr_.New_w_size(32);
|
||||
public Wdata_wiki_mgr(Xoae_app app) {
|
||||
this.app = app;
|
||||
this.evt_mgr = new Gfo_evt_mgr(this);
|
||||
this.Qid_mgr = new Wbase_qid_mgr(this);
|
||||
this.Pid_mgr = new Wbase_pid_mgr(this);
|
||||
this.Doc_mgr = new Wbase_doc_mgr(app, this, this.Qid_mgr);
|
||||
this.prop_mgr = new Wbase_prop_mgr(Wbase_prop_mgr_loader_.New_db(this));
|
||||
this.prop_val_visitor = new Wdata_prop_val_visitor(app, this);
|
||||
this.Enabled_(true);
|
||||
}
|
||||
@ -42,6 +43,7 @@ public class Wdata_wiki_mgr implements Gfo_evt_itm, Gfo_invk {
|
||||
public final Wbase_qid_mgr Qid_mgr;
|
||||
public final Wbase_pid_mgr Pid_mgr;
|
||||
public final Wbase_doc_mgr Doc_mgr;
|
||||
public Wbase_prop_mgr Prop_mgr() {return prop_mgr;} private final Wbase_prop_mgr prop_mgr;
|
||||
public boolean Enabled() {return enabled;} private boolean enabled;
|
||||
public void Enabled_(boolean v) {
|
||||
this.enabled = v;
|
||||
|
@ -34,6 +34,7 @@ public class Wdata_wiki_mgr_fxt {
|
||||
app.Xwiki_mgr__sitelink_mgr().Init_by_app();
|
||||
wdoc_bldr = new Wdata_doc_bldr();
|
||||
wdata_mgr = app.Wiki_mgr().Wdata_mgr();
|
||||
wdata_mgr.Prop_mgr().Loader_(Wbase_prop_mgr_loader_.New_mock());
|
||||
wdata_mgr.Clear();
|
||||
if (reset) {
|
||||
Io_mgr.Instance.InitEngine_mem();
|
||||
|
@ -49,14 +49,14 @@ public class Xowb_prop_tbl implements Db_tbl {
|
||||
return rv;
|
||||
}
|
||||
private void Select_all__add(Ordered_hash hash, Db_rdr rdr) {
|
||||
byte[] pid = rdr.Read_bry_by_str(fld__wbp_pid);
|
||||
String pid = rdr.Read_str(fld__wbp_pid);
|
||||
byte datatype_id = (byte)rdr.Read_int(fld__wbp_datatype);
|
||||
Wbase_enum_itm datatype_itm = Wbase_claim_type_.Reg.Get_itm_or((byte)datatype_id, null);
|
||||
if (datatype_itm == null) {
|
||||
Gfo_usr_dlg_.Instance.Warn_many("", "", "wbase:invalid prop datatype_id; pid=~{0} datatype=~{1}", pid, datatype_id);
|
||||
datatype_itm = Wbase_claim_type_.Itm__string;
|
||||
}
|
||||
hash.Add(pid, datatype_itm);
|
||||
hash.Add_if_dupe_use_1st(pid, datatype_itm.Key_str());
|
||||
}
|
||||
public void Rls() {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user