1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/* -*- Mode: Vala; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* libgdadata
* Copyright (C) Daniel Espinosa Ortiz 2011 <esodan@gmail.com>
*
* libgda is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* libgda 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Gee;
using Gda;
namespace GdaData
{
public class DataBase : Object, DbObject, DbNamedObject, DbCollection
{
private bool _update_meta = false;
public HashMap<string,DbSchema> _schemas = new HashMap<string,DbSchema> ();
// DbObject Interface
public Connection connection { get; set; }
public bool update_meta { get { return _update_meta; } set { _update_meta = value; } }
public void update () throws Error
{
if (update_meta)
connection.update_meta_store (null);
var store = connection.get_meta_store ();
var msch = store.extract ("SELECT * FROM _schemata", null);
int r;
for ( r = 0; r < msch.get_n_rows (); r++) {
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);
}
update_meta = false;
}
public void save () throws Error {}
public void append () throws Error {}
public void drop (bool cascade) throws Error {}
// DbNamedObject
public string name { get; set; }
// DbCollection Interface
public Collection<DbSchema> schemas { owned get { return _schemas.values; }}
}
}
|