mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
Embeddable: Create core dbs in proper subdirectory
This commit is contained in:
@@ -13,56 +13,3 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.dbs.*; import gplx.dbs.cfgs.*;
|
||||
public class Xob_info_file {
|
||||
public Xob_info_file(int id, String type, String ns_ids, int part_id, Guid_adp guid, int schema_version, String core_file_name, String orig_file_name) {
|
||||
this.id = id; this.type = type; this.ns_ids = ns_ids; this.part_id = part_id; this.guid = guid;
|
||||
this.schema_version = schema_version; this.core_file_name = core_file_name; this.orig_file_name = orig_file_name;
|
||||
}
|
||||
public int Id() {return id;} private final int id;
|
||||
public String Type() {return type;} private final String type;
|
||||
public String Ns_ids() {return ns_ids;} private final String ns_ids;
|
||||
public int Part_id() {return part_id;} private final int part_id;
|
||||
public Guid_adp Guid() {return guid;} private final Guid_adp guid;
|
||||
public int Schema_version() {return schema_version;} private final int schema_version;
|
||||
public String Core_file_name() {return core_file_name;} private final String core_file_name;
|
||||
public String Orig_file_name() {return orig_file_name;} private final String orig_file_name;
|
||||
public void Save(Db_cfg_tbl tbl) {
|
||||
tbl.Conn().Txn_bgn("make__info__file");
|
||||
tbl.Insert_int (Cfg_grp, Cfg_key__id , id);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__type , type);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__ns_ids , ns_ids);
|
||||
tbl.Insert_int (Cfg_grp, Cfg_key__part_id , part_id);
|
||||
tbl.Insert_guid (Cfg_grp, Cfg_key__guid , guid);
|
||||
tbl.Insert_int (Cfg_grp, Cfg_key__schema_version , schema_version);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__core_file_name , core_file_name);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__orig_file_name , orig_file_name);
|
||||
tbl.Conn().Txn_end();
|
||||
}
|
||||
public static Xob_info_file Load(Db_cfg_tbl tbl) {
|
||||
Db_cfg_hash hash = tbl.Select_as_hash(Cfg_grp);
|
||||
return new Xob_info_file
|
||||
( hash.Get_by(Cfg_key__id ).To_int_or(-1)
|
||||
, hash.Get_by(Cfg_key__type ).To_str_or("unknown")
|
||||
, hash.Get_by(Cfg_key__ns_ids ).To_str_or("")
|
||||
, hash.Get_by(Cfg_key__part_id ).To_int_or(-1)
|
||||
, hash.Get_by(Cfg_key__guid ).To_guid_or(Guid_adp_.Empty)
|
||||
, hash.Get_by(Cfg_key__schema_version ).To_int_or(2)
|
||||
, hash.Get_by(Cfg_key__core_file_name ).To_str_or("")
|
||||
, hash.Get_by(Cfg_key__orig_file_name ).To_str_or("")
|
||||
);
|
||||
}
|
||||
private static final String Cfg_grp = gplx.xowa.wikis.data.Xowd_cfg_key_.Grp__bldr_db
|
||||
, Cfg_key__id = "id" // EX: 1
|
||||
, Cfg_key__type = "type" // EX: core
|
||||
, Cfg_key__ns_ids = "ns_ids" // EX: 0
|
||||
, Cfg_key__part_id = "part_id" // EX: 0
|
||||
, Cfg_key__guid = "guid" // EX: 00000000-0000-0000-0000-000000000000
|
||||
, Cfg_key__schema_version = "schema_version" // EX: 2
|
||||
, Cfg_key__core_file_name = "core_file_name" // EX: en.wikipedia.org-text.xowa
|
||||
, Cfg_key__orig_file_name = "orig_file_name" // EX: en.wikipedia.org-text-ns.000-db.002.xowa
|
||||
;
|
||||
public static final String Ns_ids_empty = "";
|
||||
public static final int Part_id_1st = 1;
|
||||
}
|
||||
|
||||
@@ -13,47 +13,3 @@ The terms of each license can be found in the source code repository:
|
||||
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
|
||||
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
|
||||
*/
|
||||
package gplx.xowa.bldrs.infos; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*;
|
||||
import gplx.dbs.cfgs.*;
|
||||
public class Xob_info_session {
|
||||
Xob_info_session(String user, String version, String wiki_domain, String dump_name, DateAdp time, Guid_adp guid) {
|
||||
this.user = user; this.version = version; this.wiki_domain = wiki_domain; this.dump_name = dump_name; this.time = time; this.guid = guid;
|
||||
}
|
||||
public String User() {return user;} private final String user;
|
||||
public String Version() {return version;} private final String version;
|
||||
public String Wiki_domain() {return wiki_domain;} private final String wiki_domain;
|
||||
public String Dump_name() {return dump_name;} private final String dump_name;
|
||||
public DateAdp Time() {return time;} private final DateAdp time;
|
||||
public Guid_adp Uuid() {return guid;} private final Guid_adp guid;
|
||||
public void Save(Db_cfg_tbl tbl) {
|
||||
tbl.Conn().Txn_bgn("make__info__session");
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__user , user);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__version , version);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__wiki_domain , wiki_domain);
|
||||
tbl.Insert_str (Cfg_grp, Cfg_key__dump_name , dump_name);
|
||||
tbl.Insert_date (Cfg_grp, Cfg_key__time , time);
|
||||
tbl.Insert_guid (Cfg_grp, Cfg_key__guid , guid);
|
||||
tbl.Conn().Txn_end();
|
||||
}
|
||||
public static Xob_info_session Load(Db_cfg_tbl tbl) {
|
||||
Db_cfg_hash hash = tbl.Select_as_hash(Cfg_grp);
|
||||
return new Xob_info_session
|
||||
( hash.Get_by(Cfg_key__user).To_str_or("")
|
||||
, hash.Get_by(Cfg_key__version).To_str_or("")
|
||||
, hash.Get_by(Cfg_key__wiki_domain).To_str_or("")
|
||||
, hash.Get_by(Cfg_key__dump_name).To_str_or("")
|
||||
, hash.Get_by(Cfg_key__time).To_date_or(DateAdp_.MinValue)
|
||||
, hash.Get_by(Cfg_key__guid).To_guid_or(Guid_adp_.Empty)
|
||||
);
|
||||
}
|
||||
public static final String Cfg_grp = gplx.xowa.wikis.data.Xowd_cfg_key_.Grp__bldr_session
|
||||
, Cfg_key__user = "user" // EX: anonymous
|
||||
, Cfg_key__version = "version" // EX: 2.3.1.4
|
||||
, Cfg_key__wiki_domain = "wiki_domain" // EX: en.wikipedia.org
|
||||
, Cfg_key__dump_name = "dump_name" // EX: enwiki-latest-pages-articles
|
||||
, Cfg_key__time = "time" // EX: 20150102 030405
|
||||
, Cfg_key__guid = "guid" // EX: 00000000-0000-0000-0000-000000000000
|
||||
;
|
||||
public static Xob_info_session new_(String user, String wiki_domain, String dump_name) {return new Xob_info_session(user, Xoa_app_.Version, wiki_domain, dump_name, Datetime_now.Get(), Guid_adp_.New());}
|
||||
public static final Xob_info_session Test = new_("anonymous", "en.wikipedia.org", "enwiki-latest-pages-articles");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user