mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
DownloadCentral: Cleanup filter_by_lang
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
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.bldrs.centrals; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
import gplx.xowa.langs.*;
|
||||
public class Xobc_filter_mgr {
|
||||
public static Xobc_task_itm[] Filter_by_lang(Xobc_task_regy__base task_list, String lang_key_str) {
|
||||
List_adp tmp = List_adp_.New();
|
||||
|
||||
// loop tasks and find matches
|
||||
int len = task_list.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xobc_task_itm task = (Xobc_task_itm)task_list.Get_at(i);
|
||||
Xobc_task_key task_key_itm = Xobc_task_key.To_itm(task.Task_key());
|
||||
if (Xow_domain_itm_.Match_lang(task_key_itm.Wiki_domain_itm(), lang_key_str))
|
||||
tmp.Add(task);
|
||||
}
|
||||
|
||||
return (Xobc_task_itm[])tmp.To_ary_and_clear(Xobc_task_itm.class);
|
||||
}
|
||||
}
|
||||
@@ -51,21 +51,20 @@ public class Xobc_task_mgr implements Xog_json_wkr {
|
||||
user_db.Done_task_tbl().Select_all(todo_mgr, done_mgr);
|
||||
return this;
|
||||
}
|
||||
public static final String Lang_key__all = "all";
|
||||
public void Reload() {
|
||||
Gfo_log_.Instance.Info("task_mgr.reload.bgn");
|
||||
Gfobj_nde root = Gfobj_nde.New();
|
||||
Gfobj_nde lists_nde = root.New_nde("lists");
|
||||
work_mgr.Save_to(lists_nde.New_ary("work"), Lang_key__all);
|
||||
todo_mgr.Save_to(lists_nde.New_ary("todo"), Lang_key__all);
|
||||
done_mgr.Save_to(lists_nde.New_ary("done"), Lang_key__all);
|
||||
work_mgr.Save_to(lists_nde.New_ary("work"));
|
||||
todo_mgr.Save_to(lists_nde.New_ary("todo"));
|
||||
done_mgr.Save_to(lists_nde.New_ary("done"));
|
||||
cbk_mgr.Send_json(cbk_trg, "xo.bldr.core.reload__recv", root);
|
||||
}
|
||||
public void Filter_by_lang(String lang_key) {
|
||||
Gfo_log_.Instance.Info("task_mgr.reload.bgn");
|
||||
Gfo_log_.Instance.Info("task_mgr.filter_by_lang.bgn");
|
||||
Gfobj_nde root = Gfobj_nde.New();
|
||||
Gfobj_nde lists_nde = root.New_nde("lists").Add_str("list_name", "todo");
|
||||
todo_mgr.Save_to(lists_nde.New_ary("todo"), lang_key);
|
||||
todo_mgr.Save_to(lists_nde.New_ary("todo"), Xobc_filter_mgr.Filter_by_lang(todo_mgr, lang_key));
|
||||
cbk_mgr.Send_json(cbk_trg, "xo.bldr.core.reload_list__recv", root);
|
||||
}
|
||||
public void Transfer(Xobc_task_regy__base src, Xobc_task_regy__base trg, Xobc_task_itm task) {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class Xobc_task_regy_tbl implements Db_tbl {
|
||||
String sql = Db_sql_.Make_by_fmt(String_.Ary
|
||||
( "SELECT *"
|
||||
, "FROM task_regy"
|
||||
, "WHERE task_key LIKE '{0}%'"
|
||||
, "WHERE task_key LIKE '{0}%'" // DEPENDENCY:Xobc_task_key
|
||||
, "AND task_seqn != 999999"
|
||||
), wiki_domain);
|
||||
List_adp list = List_adp_.New();
|
||||
|
||||
@@ -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.bldrs.centrals.tasks; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.centrals.*;
|
||||
import gplx.xowa.wikis.domains.*;
|
||||
public class Xobc_task_key {
|
||||
public Xobc_task_key(String wiki_domain, String wiki_date, String task_type) {
|
||||
this.wiki_domain = wiki_domain;
|
||||
this.wiki_date = wiki_date;
|
||||
this.task_type = task_type;
|
||||
}
|
||||
public String Wiki_domain() {return wiki_domain;} private final String wiki_domain;
|
||||
public String Wiki_date() {return wiki_date;} private final String wiki_date;
|
||||
public String Wiki_date_ui() {return String_.Replace(wiki_date, ".", "-");}
|
||||
public String Task_type() {return task_type;} private final String task_type;
|
||||
public String Task_type_ui() {
|
||||
if (String_.Eq(task_type, "html")) return "Articles";
|
||||
else if (String_.Eq(task_type, "file")) return "Images";
|
||||
else if (String_.Eq(task_type, "text")) return "Source";
|
||||
else if (String_.Eq(task_type, "patch")) return "Patch";
|
||||
else return task_type;
|
||||
}
|
||||
public Xow_domain_itm Wiki_domain_itm() {return Xow_domain_itm_.parse(Bry_.new_u8(wiki_domain));}
|
||||
|
||||
public static Xobc_task_key To_itm(String task_key) {
|
||||
String[] ary = String_.Split(task_key, "|");
|
||||
return new Xobc_task_key(ary[0], ary[1], ary[2]);
|
||||
}
|
||||
public static String To_str(String wiki_domain, String wiki_date, String task_type) {
|
||||
return String_.Concat(wiki_domain, "|", wiki_date, "|", task_type);
|
||||
}
|
||||
}
|
||||
@@ -30,24 +30,13 @@ public abstract class Xobc_task_regy__base {
|
||||
public void Del_by(int i) {hash.Del(i);}
|
||||
public void Sort() {hash.Sort();}
|
||||
|
||||
public void Save_to(Gfobj_ary ary, String lang_key) {
|
||||
List_adp list = List_adp_.New();
|
||||
int len = hash.Len();
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Xobc_task_itm sub_task = (Xobc_task_itm)hash.Get_at(i);
|
||||
if (!String_.Eq(lang_key, Xobc_task_mgr.Lang_key__all)) {
|
||||
String task_key = sub_task.Task_key();
|
||||
if (!String_.Has_at_bgn(task_key, lang_key + ".")) continue;
|
||||
}
|
||||
list.Add(sub_task);
|
||||
}
|
||||
|
||||
len = list.Len();
|
||||
public void Save_to(Gfobj_ary ary) {Save_to(ary, (Xobc_task_itm[])hash.To_ary(Xobc_task_itm.class));}
|
||||
public void Save_to(Gfobj_ary ary, Xobc_task_itm[] itms) {
|
||||
int len = itms.length;
|
||||
Gfobj_nde[] sub_ndes = new Gfobj_nde[len];
|
||||
for (int i = 0; i < len; ++i) {
|
||||
Gfobj_nde sub_nde = sub_ndes[i] = Gfobj_nde.New();
|
||||
Xobc_task_itm sub_task = (Xobc_task_itm)list.Get_at(i);
|
||||
sub_task.Save_to(sub_nde);
|
||||
itms[i].Save_to(sub_nde);
|
||||
}
|
||||
ary.Ary_(sub_ndes);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package gplx.xowa.addons.bldrs.exports.packs.files; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.exports.*; import gplx.xowa.addons.bldrs.exports.packs.*;
|
||||
import gplx.core.progs.*; import gplx.core.ios.zips.*; import gplx.core.ios.streams.*; import gplx.core.security.*;
|
||||
import gplx.dbs.*; import gplx.xowa.wikis.data.*; import gplx.fsdb.*; import gplx.fsdb.meta.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.hosts.*;
|
||||
import gplx.xowa.addons.bldrs.centrals.dbs.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.*; import gplx.xowa.addons.bldrs.centrals.dbs.datas.imports.*; import gplx.xowa.addons.bldrs.centrals.steps.*; import gplx.xowa.addons.bldrs.centrals.hosts.*; import gplx.xowa.addons.bldrs.centrals.tasks.*;
|
||||
public class Pack_file_mgr {
|
||||
public void Exec(Xowe_wiki wiki, Pack_file_cfg cfg) {
|
||||
// init
|
||||
@@ -98,7 +98,7 @@ public class Pack_file_mgr {
|
||||
int pack_list_len = pack_list.Len();
|
||||
|
||||
// create task
|
||||
String task_key = Task_key__build(wiki.Domain_str(), wiki_date, task_type);
|
||||
String task_key = Xobc_task_key.To_str(wiki.Domain_str(), wiki_date, task_type);
|
||||
String task_name = Build_task_name(tmp_bfr, wiki, wiki_date, task_type, raw_len);
|
||||
Xobc_task_regy_tbl task_regy_tbl = bc_db.Tbl__task_regy();
|
||||
int task_id = bc_db.Conn().Sys_mgr().Autonum_next("task_regy.task_id");
|
||||
@@ -172,10 +172,4 @@ public class Pack_file_mgr {
|
||||
bc_db.Tbl__step_regy().Insert(step_id, Xobc_step_itm.Type__wiki_import);
|
||||
bc_db.Tbl__import_step().Insert(step_id, gplx.xowa.addons.bldrs.centrals.dbs.datas.Xobc_host_regy_tbl.Host_id__archive_org, wiki_abrv, wiki_date, zip_url.NameAndExt(), itm.Tid(), Xobc_zip_type.Type__zip, zip_md5, zip_len, raw_size, 0, 0);
|
||||
}
|
||||
private static String Task_key__build(String wiki_domain, String wiki_date, String task_type) {
|
||||
return String_.Concat(wiki_domain, "|", wiki_date, "|", task_type);
|
||||
}
|
||||
public static String[] Task_key__parse(String task_key) {
|
||||
return String_.Split(task_key, "|");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,10 +62,8 @@ class Xobc_info_html extends Xow_special_wtr__base {
|
||||
String torrent_fil = null;
|
||||
String key = data_db.Tbl__task_regy().Select_key_by_id_or_null(task_id);
|
||||
if (key == null) torrent_fil = "failed to get torrent for " + Int_.To_str(task_id);
|
||||
else {// convert task_key to name; en.wikipedia.org|2016.06|html
|
||||
else {
|
||||
String src_dir = host_eval.Eval_src_dir(data_db, host_id, wiki_domain);
|
||||
String[] ary = String_.Split(key, "|");
|
||||
ary[0] = String_.new_u8(wiki_domain.Abrv_wm());
|
||||
torrent_fil = String_.Format("{0}Xowa_{1}wiki_latest_archive.torrent", src_dir, wiki_domain.Lang_orig_key()); // EX: https://archive.org/download/Xowa_dewiki_latest/Xowa_dewiki_latest_archive.torrent
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user