@ -32,27 +32,52 @@ public class Scrib_lib_wikibase_entity implements Scrib_lib {
public boolean Procs_exec ( int key , Scrib_proc_args args , Scrib_proc_rslt rslt ) {
switch ( key ) {
case Proc_getGlobalSiteId : return GetGlobalSiteId ( args , rslt ) ;
case Proc_getLanguageCode : return GetLanguageCode ( args , rslt ) ;
// case Proc_formatStatements: return FormatStatements(args, rslt);
case Proc_formatPropertyValues : return FormatPropertyValues ( args , rslt ) ;
default : throw Err_ . new_unhandled ( key ) ;
}
}
private static final int Proc_getGlobalSiteId = 0 , Proc_ formatPropertyValues = 1 ;
public static final String Invk_getGlobalSiteId = "getGlobalSiteId" , Invk_ formatPropertyValues = "formatPropertyValues" ;
private static final String [ ] Proc_names = String_ . Ary ( Invk_getGlobalSiteId , Invk_ formatPropertyValues) ;
private static final int Proc_getGlobalSiteId = 0 , Proc_ getLanguageCode = 1 , Proc_formatPropertyValues = 2 ;
public static final String Invk_getGlobalSiteId = "getGlobalSiteId" , Invk_ getLanguageCode = "getLanguageCode" , Invk_ formatPropertyValues = "formatPropertyValues" ;
private static final String [ ] Proc_names = String_ . Ary ( Invk_getGlobalSiteId , Invk_ getLanguageCode, Invk_ formatPropertyValues) ;
public boolean GetGlobalSiteId ( Scrib_proc_args args , Scrib_proc_rslt rslt ) {
return rslt . Init_obj ( core . Wiki ( ) . Domain_abrv ( ) ) ; // ;siteGlobalID: This site's global ID (e.g. <code>'itwiki'</code>), as used in the sites table. Default: <code>$wgDBname</code>.; REF:/xtns/Wikibase/docs/options.wiki
}
public boolean GetLanguageCode ( Scrib_proc_args args , Scrib_proc_rslt rslt ) {
return rslt . Init_obj ( core . Wiki ( ) . Lang ( ) . Key_bry ( ) ) ;
}
// public boolean FormatStatements(Scrib_proc_args args, Scrib_proc_rslt rslt) {
// return FormatPropertyValues(args, rslt); // NOTE: implementation should be like Visit_entity but return [[A]] instead of <a href='A'>
// }
public boolean FormatPropertyValues ( Scrib_proc_args args , Scrib_proc_rslt rslt ) {
// get qid / pid
byte [ ] qid = args . Pull_bry ( 0 ) ;
byte [ ] pid = args . Pull_bry ( 1 ) ;
// get wdata_mgr and lang
Xoae_app app = core . App ( ) ; Xowe_wiki wiki = core . Wiki ( ) ;
Wdata_wiki_mgr wdata_mgr = app . Wiki_mgr ( ) . Wdata_mgr ( ) ;
byte [ ] lang = wiki . Wdata_wiki_lang ( ) ;
Wdata_doc wdoc = wdata_mgr . Doc_mgr . Get_by_bry_or_null ( qid ) ; if ( wdoc = = null ) { Wdata_wiki_mgr . Log_missing_qid ( core . Ctx ( ) , qid ) ; return rslt . Init_str_empty ( ) ; } // NOTE: return empty String, not nil; PAGE:fr.s:Henri_Bergson; DATE:2014-08-13
// get wdoc
Wdata_doc wdoc = wdata_mgr . Doc_mgr . Get_by_bry_or_null ( qid ) ;
if ( wdoc = = null ) {
Wdata_wiki_mgr . Log_missing_qid ( core . Ctx ( ) , qid ) ;
return rslt . Init_str_empty ( ) ; // NOTE: return empty String, not nil; PAGE:fr.s:Henri_Bergson; DATE:2014-08-13
}
// get pid_int
int pid_int = Wbase_pid_mgr . To_int_or_null ( pid ) ; // parse as num; EX: p123 -> 123; PAGE:hr.w:Hepatitis DATE:2015-11-08
if ( pid_int = = Wdata_wiki_mgr . Pid_null ) pid_int = wdata_mgr . Pid_mgr . Get_or_null ( lang , pid ) ; // parse as name; EX: name > 123
if ( pid_int = = Wdata_wiki_mgr . Pid_null ) return rslt . Init_str_empty ( ) ;
Wbase_claim_grp prop_grp = wdoc . Claim_list_get ( pid_int ) ; if ( prop_grp = = null ) return rslt . Init_str_empty ( ) ;
// get prop_grp
Wbase_claim_grp prop_grp = wdoc . Claim_list_get ( pid_int ) ;
if ( prop_grp = = null )
return rslt . Init_str_empty ( ) ;
// print it
Bry_bfr bfr = wiki . Utl__bfr_mkr ( ) . Get_b512 ( ) ;
wdata_mgr . Resolve_to_bfr ( bfr , prop_grp , lang ) ;
return rslt . Init_obj ( bfr . To_bry_and_rls ( ) ) ;