public static void Find_pages(List_adp rv, Xowe_wiki wiki, Dpl_itm itm) { rv.Clear(); List_adp includes = itm.Ctg_includes(); if (includes == null) return; int includes_len = includes.Count(); Ordered_hash old_regy = Ordered_hash_.New(), new_regy = Ordered_hash_.New(), cur_regy = Ordered_hash_.New(); Xodb_load_mgr load_mgr = wiki.Db_mgr().Load_mgr(); Xowd_page_itm tmp_page = new Xowd_page_itm(); Int_obj_ref tmp_id = Int_obj_ref.New_zero(); 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()); 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); 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; new_regy = Ordered_hash_.New(); } int pages_len = old_regy.Count(); for (int i = 0; i < pages_len; i++) { // loop over old and create pages Int_obj_ref old_id = (Int_obj_ref) old_regy.Get_at(i); rv.Add(new Xowd_page_itm().Id_(old_id.Val())); } wiki.Db_mgr().Load_mgr().Load_by_ids(Cancelable_.Never, rv, 0, pages_len); rv.Sort_by(Xowd_page_itm_sorter.IdAsc); }
private void Select_rows_where(List_adp rv, Mem_stmt stmt, Criteria crt) { rv.Clear(); int rows_len = rows.Count(); for (int i = 0; i < rows_len; ++i) { Mem_row itm = (Mem_row) rows.Get_at(i); if (crt.Matches(itm)) rv.Add(itm); } }
int[] Xto_int_ary(List_adp rslts) { int len = rslts.Count(); int[] rv = new int[len]; for (int i = 0; i < len; i++) { Xowd_page_itm page = (Xowd_page_itm) rslts.Get_at(i); rv[i] = page.Id(); } return rv; }
public int Delete(Mem_stmt stmt) { Db_qry_delete qry = (Db_qry_delete) stmt.Qry(); Mem_stmt_args_.Fill(stmt.Stmt_args(), qry.Where()); Select_rows_where(where_rows, stmt, qry.Where()); int where_rows_len = where_rows.Count(); for (int i = 0; i < where_rows_len; ++i) { Mem_row itm = (Mem_row) where_rows.Get_at(i); rows.Del(itm); } return where_rows_len; }
public static GfoMsg chain_(GfoMsg owner, String key) { GfoMsg sub = owner; List_adp list = List_adp_.New(); list.Add(sub.Key()); while (sub != null) { if (sub.Subs_count() == 0) break; sub = (GfoMsg) sub.Subs_getAt(0); list.Add(sub.Key()); } list.Add(key); GfoMsg root = GfoMsg_.new_parse_((String) list.Get_at(0)); GfoMsg cur = root; for (int i = 1; i < list.Count(); i++) { String k = (String) list.Get_at(i); GfoMsg mm = GfoMsg_.new_parse_(k); cur.Subs_add(mm); cur = mm; } return root; }
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) { 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); } }
public int Update(Mem_stmt stmt) { Db_qry_update qry = (Db_qry_update) stmt.Qry(); Criteria where_crt = qry.Where(); if (where_crt == null) where_crt = Criteria_.All; Mem_stmt_args_.Fill(stmt.Stmt_args(), where_crt); Select_rows_where(where_rows, stmt, where_crt); int where_rows_len = where_rows.Count(); String[] update_cols = qry.Cols_for_update(); int update_cols_len = update_cols.length; for (int i = 0; i < where_rows_len; ++i) { Mem_row itm = (Mem_row) where_rows.Get_at(i); for (int j = 0; j < update_cols_len; ++j) itm.Set_by(update_cols[j], stmt.Args_get_at(j)); } return where_rows_len; }
private static void Del_old_pages_not_in_cur( int i, Int_obj_ref tmp_id, Ordered_hash old_regy, Ordered_hash cur_regy, List_adp del_list) { if (i == 0) return; // skip logic for first ctg (which doesn't have a predecessor) int old_len = old_regy.Count(); for (int j = 0; j < old_len; j++) { // if cur is not in new, del it Int_obj_ref old_id = (Int_obj_ref) old_regy.Get_at(j); if (!cur_regy.Has(tmp_id.Val_(old_id.Val()))) // old_itm does not exist in cur_regy del_list.Add( old_id); // remove; EX: (A,B) in old; B only in cur; old should now be (A) only } int del_len = del_list.Count(); for (int j = 0; j < del_len; j++) { Int_obj_ref old_itm = (Int_obj_ref) del_list.Get_at(j); old_regy.Del(tmp_id.Val_(old_itm.Val())); } }
public void Fsdb_search_by_list( List_adp itms, Xow_wiki cur_wiki, Xoa_page page, Xog_js_wkr js_wkr) { if (!fsdb_enabled) return; int len = itms.Count(); Gfo_usr_dlg usr_dlg = Gfo_usr_dlg_.Instance; Xow_wiki wiki = page.Commons_mgr().Source_wiki_or(cur_wiki); Xou_cache_mgr cache_mgr = wiki.App().User().User_db_mgr().Cache_mgr(); for (int i = 0; i < len; i++) { if (usr_dlg.Canceled()) return; Xof_fsdb_itm fsdb = (Xof_fsdb_itm) itms.Get_at(i); if (fsdb.Hdump_mode() == Xof_fsdb_itm.Hdump_mode__null) { Xof_orig_itm orig = wiki.File__orig_mgr().Find_by_ttl_or_null(fsdb.Lnki_ttl(), i, len); if (orig != Xof_orig_itm.Null) { // orig exists; gplx.xowa.files.repos.Xof_repo_itm repo = wiki.File__repo_mgr().Get_trg_by_id_or_null(orig.Repo(), fsdb.Lnki_ttl(), Bry_.Empty); if (repo == null) continue; fsdb.Init_at_orig( orig.Repo(), repo.Wiki_domain(), orig.Ttl(), orig.Ext(), orig.W(), orig.H(), orig.Redirect()); } } fsdb.Init_at_xfer(i, len); Xof_file_wkr.Show_img( fsdb, usr_dlg, wiki.File__bin_mgr(), wiki.File__mnt_mgr(), cache_mgr, wiki.File__repo_mgr(), js_wkr, img_size, url_bldr, page); } }
public void Xtn_write( Bry_bfr bfr, Xoae_app app, Xop_ctx ctx, Xoh_html_wtr html_wtr, Xoh_wtr_ctx hctx, Xoae_page wpg, Xop_xnde_tkn xnde, byte[] src) { Xowe_wiki wiki = ctx.Wiki(); Dpl_html_data html_mode = Dpl_html_data.new_(Dpl_itm_keys.Key_unordered); int itms_len = pages.Count(); if (itms_len == 0) { if (!itm.Suppress_errors()) bfr.Add_str_a7("No pages meet these criteria."); return; } int itms_bgn = 0; if (itm.Offset() != Int_.Min_value) { itms_bgn = itm.Offset(); } if (itm.Count() != Int_.Min_value && itms_bgn + itm.Count() < itms_len) { itms_len = itms_bgn + itm.Count(); } boolean show_ns = itm.Show_ns(); Bry_bfr tmp_bfr = Bry_bfr_.Get(); Xop_amp_mgr amp_mgr = wiki.Appe().Parser_amp_mgr(); try { bfr.Add(html_mode.Grp_bgn()).Add_byte_nl(); for (int i = itms_bgn; i < itms_len; i++) { Xowd_page_itm page = (Xowd_page_itm) pages.Get_at(i); Xoa_ttl ttl = Xoa_ttl.Parse(wiki, page.Ns_id(), page.Ttl_page_db()); byte[] ttl_page_txt = show_ns ? ttl.Full_txt_w_ttl_case() : ttl.Page_txt(); if (ttl_page_txt == null) continue; // NOTE: apparently DynamicPageList allows null pages; DATE:2013-07-22 switch (html_mode.Tid()) { case Dpl_html_data.Tid_list_ul: case Dpl_html_data.Tid_list_ol: bfr.Add(Xoh_consts.Space_2).Add(html_mode.Itm_bgn()).Add(Gfh_bldr_.Bry__a_lhs_w_href); bfr.Add_str_a7("/wiki/") .Add(Gfo_url_encoder_.Href.Encode(ttl.Full_db())) .Add_byte_quote(); // NOTE: Full_db to encode spaces as underscores; // PAGE:en.q:Wikiquote:Speedy_deletions DATE:2016-01-19 Gfh_atr_.Add( bfr, Gfh_atr_.Bry__title, Xoh_html_wtr_escaper.Escape( amp_mgr, tmp_bfr, ttl .Full_txt_w_ttl_case())); // NOTE: Full_txt b/c title always includes ns, // even if show_ns is off; // PAGE:en.b:Wikibooks:WikiProject DATE:2016-01-20 if (itm.No_follow()) bfr.Add(Bry_nofollow); bfr.Add_byte(Byte_ascii.Gt); Xoh_html_wtr_escaper.Escape( amp_mgr, bfr, ttl_page_txt, 0, ttl_page_txt.length, false, false); bfr.Add(Gfh_bldr_.Bry__a_rhs).Add(html_mode.Itm_end()).Add_byte_nl(); // TODO_OLD: // lnki_wtr.Clear().Href_wiki_(ttl).Title_(ttl).Nofollow_().Write_head(bfr).Write_text(bfr).Write_tail(bfr) break; default: break; } } bfr.Add(html_mode.Grp_end()).Add_byte_nl(); } finally { tmp_bfr.Mkr_rls(); } }