This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Gda Vala Extensions Interfaces

Vala Extensions defines a set of interfaces to define a generic behaviour. They expect to be the base for future implementations for Vala objects accessing a database.

Following diagram describes the available interfaces and its relations.

interfaces-uml.png

DbObject Interface

This interface requires that instantable classes implement basic functionallity.

To call that methods you must have a valid Gda.Connection object with an opened connection to a database.

This interface requires to implement the following properties:

DbTable Interface

This interface is used to describe and provide common implementations to any table in a database.

Check for tables compatibility

Table compatibility, as defined in Gda Vala Extensions, is a set of tests to garanty one table is able to copy data to another. Field compatibility are performed by compatible() method defined in DbFieldInfo interface.

The following tests are performed when A.compatible(B) is called:

This codes checks for compatibility between two tables. create_definition() is a user defined method to initiate a table by adding fields definitions that will be used as a template.

   1 Table a = new Table ();
   2 a.name = "user2"; // set to a database's table name
   3 a.connection = connection;
   4 a.update (); // Get definition from database metadata
   5 Table b = new Table ();
   6 b.name = "users"; // set to a database's table name
   7 b.connection = connection;
   8 b.update (); // Get definition from database metadata
   9 if (a.compatible (b))
  10         stdout.printf (@"You can copy data from table $(a.name) to table $(b.name)");

Check for equivalent tables

Table equivalency, as defined in Gda Vala Extensions, is a set of tests to verify that most important parts of a hard coded table (template) definition are present in other table. Then is recomended to check equivalency of a hard coded definition, agains a database table that had been updated using update() method. Field equivalency are performed by equivalent() method defined in DbFieldInfo interface.

The following tests are performed when A.equivalent(B) is called:

This codes checks for equivalency between two tables.

   1 Table a = new Table ();
   2 a.name = "pre-defined";
   3 create_definition (a); // See at Table class to see how define a table
   4 Table b = new Table ();
   5 b.name = "users"; // set to a database's table name
   6 b.connection = connection;
   7 b.update (); // Get definition from database metadata
   8 if (a.equivalent (b))
   9         stdout.printf (@"Database table $(b.name) is based on template table $(a.name)");

DbFieldInfo Interface

This interface is used to describe and provide common implementations to any field in a table. To access and update values in a database, you must use DbField interface.

Check for table's field compatibility

Table compatibility, as defined in Gda Vala Extensions, is a set of tests to garanty one field is able to copy data to another.

The following tests are performed when F.compatible(F2) is called:

This codes checks for compatibility between two table's fields definition.

   1 Table a = new Table ();
   2 a.name = "user2"; // set to a database's table name
   3 a.connection = connection;
   4 a.update (); // Get definition from database metadata
   5 Table b = new Table ();
   6 b.name = "users"; // set to a database's table name
   7 b.connection = connection;
   8 b.update (); // Get definition from database metadata
   9 var aid = a.get_field ("id");
  10 var bid = b.get_field ("id");
  11 if (aid.compatible (bid))
  12         stdout.printf (@"You can copy data from field  $(aid.name) to table $(bid.name)");

Check for table's field definition equivalent

Field equivalency, as defined in Gda Vala Extensions, is a set of tests to verify that most important properties and attributes are present in other field. Then is recomended to check equivalency of a hard coded definition, agains a database table's field that had been getted from a table using update() method. Field equivalency are performed by equivalent() defined in DbFieldInfo interface.

The following tests are performed when F.equivalent(F2) is called:

This codes checks for equivalency between a template and a database field.

   1 Table a = new Table ();
   2 a.name = "pre-defined";
   3 create_definition (a); // See at Table class to see how define a table
   4 Table b = new Table ();
   5 b.name = "users"; // set to a database's table name
   6 b.connection = connection;
   7 b.update (); // Get definition from database metadata
   8 aid = a.get_field ("id");
   9 bid = b.get_field ("id");
  10 if (aid.equivalent (bid))
  11         stdout.printf (@"Database field $(bid.name) is based on template field $(aid.name)");

2024-10-23 11:37