mirror of
https://github.com/gnosygnu/xowa.git
synced 2026-03-02 03:49:30 +00:00
v3.1.1.1
This commit is contained in:
24
140_dbs/src/gplx/dbs/DbTstDat.java
Normal file
24
140_dbs/src/gplx/dbs/DbTstDat.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
public class DbTstDat {
|
||||
public int Idx() {return idx;} public DbTstDat Idx_(int val) {idx = val; return this;} int idx = -1;
|
||||
public String Fld() {return fld;} public DbTstDat Fld_(String v) {fld = v; return this;} private String fld = null;
|
||||
public Object Val() {return val;} public DbTstDat Val_(Object v) {val = v; return this;} Object val = null;
|
||||
public static DbTstDat new_() {return new DbTstDat();} DbTstDat() {}
|
||||
}
|
||||
31
140_dbs/src/gplx/dbs/DbTstRow.java
Normal file
31
140_dbs/src/gplx/dbs/DbTstRow.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
public class DbTstRow {
|
||||
public int Idx() {return idx;} public DbTstRow Idx_(int val) {idx = val; return this;} int idx = -1;
|
||||
public DbTstDat[] Dat() {return dat;} DbTstDat[] dat = null;
|
||||
public static DbTstRow vals_only_(Object... ary) {
|
||||
DbTstRow rv = new DbTstRow();
|
||||
int len = Array_.Len(ary);
|
||||
rv.dat = new DbTstDat[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
rv.dat[i] = DbTstDat.new_().Val_(ary[i]);
|
||||
return rv;
|
||||
}
|
||||
public static DbTstRow new_() {return new DbTstRow();} DbTstRow() {}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package gplx.dbs; import gplx.*;
|
||||
public class Db_meta_fld_list {
|
||||
private final Ordered_hash flds = Ordered_hash_.New();
|
||||
private final List_adp keys = List_adp_.new_();
|
||||
public void Clear() {flds.Clear(); keys.Clear();}
|
||||
public void Clear() {flds.Clear(); keys.Clear(); str_ary = null; fld_ary = null;}
|
||||
public Db_meta_fld Get_by(String name) {return (Db_meta_fld)flds.Get_by(name);}
|
||||
public Db_meta_fld Get_at(int idx) {return (Db_meta_fld)flds.Get_at(idx);}
|
||||
public String[] To_str_ary() {if (str_ary == null) str_ary = (String[])keys.To_ary(String.class); return str_ary;} private String[] str_ary;
|
||||
|
||||
55
140_dbs/src/gplx/dbs/Db_qry_fxt.java
Normal file
55
140_dbs/src/gplx/dbs/Db_qry_fxt.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
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.dbs; import gplx.*;
|
||||
import gplx.dbs.qrys.*; import gplx.core.gfo_ndes.*;
|
||||
public class Db_qry_fxt {
|
||||
public static void Insert_kvo(Db_conn conn, String tblName, KeyValList kvList) {
|
||||
Db_qry_insert qry = Db_qry_.insert_(tblName);
|
||||
for (int i = 0; i < kvList.Count(); i++) {
|
||||
KeyVal kv = kvList.GetAt(i);
|
||||
qry.Arg_obj_(kv.Key(), kv.Val());
|
||||
}
|
||||
qry.Exec_qry(conn);
|
||||
}
|
||||
public static GfoNde SelectAll(Db_conn conn, String tblName) {
|
||||
return Db_qry_.select_tbl_(tblName).ExecRdr_nde(conn);
|
||||
}
|
||||
public static int SelectAll_count(Db_conn conn, String tblName) {
|
||||
GfoNde nde = Db_qry_fxt.SelectAll(conn, tblName);
|
||||
return nde.Subs().Count();
|
||||
}
|
||||
public static void DeleteAll(Db_conn conn, String... ary) {
|
||||
for (String s : ary)
|
||||
Db_qry_.delete_tbl_(s).Exec_qry(conn);
|
||||
}
|
||||
public static void tst_Select(Db_conn conn, String tblName, DbTstRow... expdAry) {
|
||||
GfoNde nde = Db_qry_fxt.SelectAll(conn, tblName);
|
||||
int len = Array_.Len(expdAry);
|
||||
for (int i = 0; i < len; i++) {
|
||||
DbTstRow expdRow = expdAry[i];
|
||||
int actlIdx = (expdRow.Idx() == -1) ? i : expdRow.Idx();
|
||||
GfoNde actlNde = nde.Subs().FetchAt_asGfoNde(actlIdx);
|
||||
int fldLen = Array_.Len(expdRow.Dat());
|
||||
for (int j = 0; j < fldLen; j++) {
|
||||
DbTstDat expdDat = expdRow.Dat()[j];
|
||||
Object actlVal = expdDat.Fld() == null ? actlNde.ReadAt(j) : actlNde.Read(expdDat.Fld());
|
||||
Tfds.Eq(expdDat.Val(), actlVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user