[libgda] Ported to valac 0.16 and API simplification
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Ported to valac 0.16 and API simplification
- Date: Wed, 25 Jan 2012 02:31:57 +0000 (UTC)
commit 30d2a65a6d882b1d210fde65546bd67fb4c24760
Author: Daniel Espinosa <despinosa src gnome org>
Date: Tue Jan 24 20:27:34 2012 -0600
Ported to valac 0.16 and API simplification
* DataBase, Field, FieldInfo, Record, Schema and Table now implement
its base interfaces without requiring to use <Value?> thanks to fix
bug 667668
* Samples and Unit Tests updated
configure.ac | 2 +-
libgda/data/DataBase.vala | 6 +++---
libgda/data/Field.vala | 6 +++---
libgda/data/FieldInfo.vala | 8 ++++----
libgda/data/Record.vala | 10 +++++-----
libgda/data/Schema.vala | 6 +++---
libgda/data/Table.vala | 20 ++++++++++----------
samples/vala/SampleDataModelIterable.vala | 2 +-
samples/vala/SampleDataObject.vala | 2 +-
tests/vala/CheckDataModelIterator.vala | 6 +++---
tests/vala/CheckDataObject.vala | 8 ++++----
11 files changed, 38 insertions(+), 38 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 3f3d209..5437309 100644
--- a/configure.ac
+++ b/configure.ac
@@ -481,7 +481,7 @@ AC_ARG_ENABLE([vala-extensions],
have_vala=no
if test "x$found_introspection" = "xyes"
then
- VALA_MODULES="libvala-0.14 >= 0.14"
+ VALA_MODULES="libvala-0.16 >= 0.15.0"
PKG_CHECK_MODULES(VALA, $VALA_MODULES,
if test "$enable_vala" = "yes" -o "$enable_vala" = "auto"
then
diff --git a/libgda/data/DataBase.vala b/libgda/data/DataBase.vala
index 09ba030..85c89fc 100644
--- a/libgda/data/DataBase.vala
+++ b/libgda/data/DataBase.vala
@@ -22,9 +22,9 @@ using Gda;
namespace GdaData
{
- public class DataBase<G> : Object, DbObject, DbNamedObject, DbCollection<G>
+ public class DataBase : Object, DbObject, DbNamedObject, DbCollection<Value?>
{
- public HashMap<string,DbSchema<G>> _schemas = new HashMap<string,DbSchema<G>> ();
+ public HashMap<string,DbSchema<Value?>> _schemas = new HashMap<string,DbSchema<Value?>> ();
// DbObject Interface
public Connection connection { get; set; }
public void update () throws Error
@@ -34,7 +34,7 @@ namespace GdaData
var msch = store.extract_v ("SELECT * FROM _schemata", null);
int r;
for ( r = 0; r < msch.get_n_rows (); r++) {
- var schema = new Schema<G> ();
+ var schema = new Schema ();
schema.connection = this.connection;
schema.name = (string) msch.get_value_at (msch.get_column_index ("schema_name"),r);
_schemas.set (schema.name, (DbSchema) schema);
diff --git a/libgda/data/Field.vala b/libgda/data/Field.vala
index cee893d..7ad3555 100644
--- a/libgda/data/Field.vala
+++ b/libgda/data/Field.vala
@@ -22,9 +22,9 @@ using Gda;
namespace GdaData
{
- public class Field<G> : Object, DbField<G>
+ public class Field : Object, DbField<Value?>
{
- private G val;
+ private Value? val;
private string _name;
private string _column_name;
private DbField.Attribute _attributes;
@@ -43,7 +43,7 @@ namespace GdaData
public DbField.Attribute attributes {
get { return _attributes; }
}
- public string to_string () { return "GdaData.Field"; }
+ public string to_string () { return Gda.value_stringify (val); }
public Field (string col_name, DbField.Attribute attr)
{
_column_name = col_name;
diff --git a/libgda/data/FieldInfo.vala b/libgda/data/FieldInfo.vala
index 2f56e79..7a86476 100644
--- a/libgda/data/FieldInfo.vala
+++ b/libgda/data/FieldInfo.vala
@@ -20,23 +20,23 @@
using Gda;
namespace GdaData {
- public class FieldInfo<G> : Object, DbFieldInfo<G>
+ public class FieldInfo : Object, DbFieldInfo<Value?>
{
private DbField.Attribute _attr;
- private G _default_value;
+ private Value? _default_value;
private string _name;
public DbField.Attribute attributes {
get { return _attr; }
}
- public G default_value {
+ public Value? default_value {
get { return _default_value; }
}
public string name {
get { return _name; }
}
- FieldInfo (string name, DbField.Attribute attr, G default_val)
+ FieldInfo (string name, DbField.Attribute attr, Value? default_val)
{
_name = name;
_attr = attr;
diff --git a/libgda/data/Record.vala b/libgda/data/Record.vala
index 08e6ac4..66454d9 100644
--- a/libgda/data/Record.vala
+++ b/libgda/data/Record.vala
@@ -60,7 +60,7 @@ namespace GdaData {
}
else {
// FIXME: Get default attributes from table
- var n = new Field<Value?> (field.name, DbField.Attribute.NONE);
+ var n = new Field (field.name, DbField.Attribute.NONE);
n.value = field.value;
this._fields.set (field.name, n);
}
@@ -68,7 +68,7 @@ namespace GdaData {
}
public void set_field_value (string field, Value? val) throws Error
{
- var n = new Field<Value?> (field, DbField.Attribute.NONE);
+ var n = new Field (field, DbField.Attribute.NONE);
n.value = val;
this.set_field (n);
}
@@ -85,14 +85,14 @@ namespace GdaData {
}
else {
// FIXME: Get default attributes from table
- var n = new Field<Value?> (field.name, DbField.Attribute.NONE);
+ var n = new Field (field.name, DbField.Attribute.NONE);
n.value = field.value;
_keys.set (field.name, n);
}
}
public void set_key_value (string key, Value? val) throws Error
{
- var n = new Field<Value?> (key, DbField.Attribute.NONE);
+ var n = new Field (key, DbField.Attribute.NONE);
n.value = val;
this.set_key (n);
}
@@ -168,7 +168,7 @@ namespace GdaData {
}
for (int c = 0; c < m.get_n_columns (); c++) {
- var f = new Field<Value?> (m.get_column_name (c),
+ var f = new Field (m.get_column_name (c),
(DbField.Attribute) m.get_attributes_at (c, 0));
f.value = m.get_value_at (c,0);
this.set_field (f);
diff --git a/libgda/data/Schema.vala b/libgda/data/Schema.vala
index a0bbcb3..4fd3b56 100644
--- a/libgda/data/Schema.vala
+++ b/libgda/data/Schema.vala
@@ -22,9 +22,9 @@ using Gda;
namespace GdaData
{
- public class Schema<G> : Object, DbObject, DbNamedObject, DbSchema<G>
+ public class Schema : Object, DbObject, DbNamedObject, DbSchema<Value?>
{
- public HashMap<string,DbTable<G>> _tables = new HashMap<string,DbTable<G>> ();
+ public HashMap<string,DbTable<Value?>> _tables = new HashMap<string,DbTable<Value?>> ();
// DbObject Interface
public Connection connection { get; set; }
public void update () throws Error
@@ -37,7 +37,7 @@ namespace GdaData
vals.set ("name", v);
var mt = store.extract_v ("SELECT * FROM _tables WHERE schema_name = ##name::string", vals);
for (int r = 0; r < mt.get_n_rows (); r++) {
- var t = new Table<G> ();
+ var t = new Table ();
t.connection = connection;
t.name = (string) mt.get_value_at (mt.get_column_index ("table_name"), r);
t.schema = (DbSchema) this;
diff --git a/libgda/data/Table.vala b/libgda/data/Table.vala
index 4269c88..66053b2 100644
--- a/libgda/data/Table.vala
+++ b/libgda/data/Table.vala
@@ -22,16 +22,16 @@ using Gda;
namespace GdaData
{
- public class Table<G> : Object, DbObject, DbNamedObject, DbTable<G>
+ public class Table : Object, DbObject, DbNamedObject, DbTable<Value?>
{
protected DbRecordCollection _records;
- protected HashMap<string,DbFieldInfo<G>> _fields = new HashMap<string,DbFieldInfo<G>> ();
- protected HashMap<string,DbTable<G>> _fk_depends = new HashMap<string,DbTable<G>> ();
- protected HashMap<string,DbTable<G>> _fk = new HashMap<string,DbTable<G>> ();
+ protected HashMap<string,DbFieldInfo<Value?>> _fields = new HashMap<string,DbFieldInfo<Value?>> ();
+ protected HashMap<string,DbTable<Value?>> _fk_depends = new HashMap<string,DbTable<Value?>> ();
+ protected HashMap<string,DbTable<Value?>> _fk = new HashMap<string,DbTable<Value?>> ();
- public Table.with_fields_info (HashMap<string,DbFieldInfo<G>> fields)
+ public Table.with_fields_info (HashMap<string,DbFieldInfo<Value?>> fields)
{
- foreach (DbFieldInfo<G> f in fields.values) {
+ foreach (DbFieldInfo<Value?> f in fields.values) {
_fields.set (f.name, f);
}
}
@@ -44,11 +44,11 @@ namespace GdaData
public string name { get; set; }
// DbTable Interface
- public Collection<DbFieldInfo<G>> fields {
+ public Collection<DbFieldInfo<Value?>> fields {
owned get { return _fields.values; }
}
public DbSchema schema { get; set construct; }
- public Collection<DbRecord<G>> records {
+ public Collection<DbRecord<Value?>> records {
owned get {
var q = new Gda.SqlBuilder (SqlStatementType.SELECT);
q.set_table (name);
@@ -59,7 +59,7 @@ namespace GdaData
return _records;
}
}
- public Collection<DbTable<G>> fk_depends { owned get { return _fk_depends.values; } }
- public Collection<DbTable<G>> fk { owned get { return _fk.values; } }
+ public Collection<DbTable<Value?>> fk_depends { owned get { return _fk_depends.values; } }
+ public Collection<DbTable<Value?>> fk { owned get { return _fk.values; } }
}
}
diff --git a/samples/vala/SampleDataModelIterable.vala b/samples/vala/SampleDataModelIterable.vala
index 3ac6e76..5bb508e 100644
--- a/samples/vala/SampleDataModelIterable.vala
+++ b/samples/vala/SampleDataModelIterable.vala
@@ -48,7 +48,7 @@ namespace Sample {
this.connection.execute_non_select_command("INSERT INTO company (id, name, responsability) VALUES (2, \"Viasa\", \"Accessories\")");
this.connection.update_meta_store(null);
var model = this.connection.execute_select_command ("SELECT * FROM user");
- var t = new Table<Value?> ();
+ var t = new Table ();
t.connection = connection;
t.name = "user";
this.itermodel = new RecordCollection (model, t);
diff --git a/samples/vala/SampleDataObject.vala b/samples/vala/SampleDataObject.vala
index 65a7756..fafd877 100644
--- a/samples/vala/SampleDataObject.vala
+++ b/samples/vala/SampleDataObject.vala
@@ -60,7 +60,7 @@ namespace Sample {
*/
public Record ()
{
- var t = new Table<Value?> ();
+ var t = new Table ();
t.name = "user";
t.connection = this.connection;
this.table = t;
diff --git a/tests/vala/CheckDataModelIterator.vala b/tests/vala/CheckDataModelIterator.vala
index b50708d..143b45d 100644
--- a/tests/vala/CheckDataModelIterator.vala
+++ b/tests/vala/CheckDataModelIterator.vala
@@ -253,7 +253,7 @@ namespace Check {
int fails = 0;
var model = this.connection.execute_select_command ("SELECT * FROM user");
stdout.printf ("Setting up Table...");
- var t = new Table<Value?> ();
+ var t = new Table ();
t.connection = this.connection;
t.name = "user";
stdout.printf ("+++++ PASS\n");
@@ -272,13 +272,13 @@ namespace Check {
var model = this.connection.execute_select_command ("SELECT * FROM user");
((DataSelect) model).compute_modification_statements ();
var pxy = (Gda.DataModel) Gda.DataProxy.new (model);
- var t = new Table<Value?>();
+ var t = new Table ();
t.connection = this.connection;
t.name = "user";
var itermodel = new RecordCollection (pxy,t);
var row = new Record ();
row.table = t;
- var f = new Field<Value?>("id", DbField.Attribute.NONE);
+ var f = new Field ("id", DbField.Attribute.NONE);
f.value = 10;
row.set_field (f);
f.name = "name";
diff --git a/tests/vala/CheckDataObject.vala b/tests/vala/CheckDataObject.vala
index 7cc5d60..9b251f0 100644
--- a/tests/vala/CheckDataObject.vala
+++ b/tests/vala/CheckDataObject.vala
@@ -62,7 +62,7 @@ namespace Check {
stdout.printf("Setting connection\n");
r.connection = this.connection;
stdout.printf("Setting up DbTable\n");
- var t = new Table<Value?> ();
+ var t = new Table ();
stdout.printf("Setting DbTable name\n");
t.name = "user";
stdout.printf("Setting DbTable connection\n");
@@ -70,7 +70,7 @@ namespace Check {
stdout.printf(">>> Setting table to record\n");
r.table = t;
stdout.printf(">>> Setting up Key 'id'\n");
- var k = new Field<Value?>("id", DbField.Attribute.NONE);
+ var k = new Field ("id", DbField.Attribute.NONE);
stdout.printf("Setting record ID to 1...");
try {
k.value = 1;
@@ -165,7 +165,7 @@ namespace Check {
}
stdout.printf("Setting a new Table... \n");
- var t2 = new Table<Value?>();
+ var t2 = new Table ();
t2.name = "company";
t2.connection = this.connection;
r.table = t2;
@@ -205,7 +205,7 @@ namespace Check {
try {
var n = new Check.Record ();
n.connection = this.connection;
- var t = new Table<Value?> ();
+ var t = new Table ();
t.name = "user";
t.connection = this.connection;
n.table = t;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]