-CREATE TABLE roles
-(
- id integer NOT NULL,
- role_id character varying(255) DEFAULT ''::character varying,
- CONSTRAINT roles_pkey PRIMARY KEY (id)
-)
-
-CREATE TABLE roles_parents
-(
- id_roles integer NOT NULL,
- id_roles_parent integer NOT NULL,
- CONSTRAINT roles_parents_pkey PRIMARY KEY (id_roles, id_roles_parent)
-)
-
-CREATE TABLE resources
-(
- id integer NOT NULL,
- resource_id character varying(255) DEFAULT ''::character varying,
- CONSTRAINT resources_pkey PRIMARY KEY (id)
-)
-
-CREATE TABLE resources_parents
-(
- id_resources integer NOT NULL,
- id_resources_parent integer NOT NULL,
- CONSTRAINT resources_parents_pkey PRIMARY KEY (id_resources, id_resources_parent)
-)
-
-CREATE TABLE rules
-(
- id integer NOT NULL,
- "type" integer,
- id_roles integer,
- id_resources integer,
- CONSTRAINT rules_pkey PRIMARY KEY (id)
-)
-COMMENT ON COLUMN rules."type" IS '1 - allow
+--
+-- PostgreSQL database dump
+--
+
+-- Dumped from database version 8.4.10
+-- Dumped by pg_dump version 9.1.2
+-- Started on 2011-12-28 08:55:26
+
+SET statement_timeout = 0;
+SET client_encoding = 'UTF8';
+SET standard_conforming_strings = off;
+SET check_function_bodies = false;
+SET client_min_messages = warning;
+SET escape_string_warning = off;
+
+--
+-- TOC entry 460 (class 2612 OID 16386)
+-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: -
+--
+
+CREATE OR REPLACE PROCEDURAL LANGUAGE plpgsql;
+
+
+SET search_path = public, pg_catalog;
+
+--
+-- TOC entry 158 (class 1255 OID 107639)
+-- Dependencies: 3 460
+-- Name: update_update(); Type: FUNCTION; Schema: public; Owner: -
+--
+
+CREATE FUNCTION update_update() RETURNS trigger
+ LANGUAGE plpgsql
+ AS $$
+ begin
+ update timestamp_update set update=now();
+ return NULL;
+end;
+$$;
+
+
+SET default_with_oids = false;
+
+--
+-- TOC entry 142 (class 1259 OID 61459)
+-- Dependencies: 1792 3
+-- Name: resources; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE resources (
+ id integer NOT NULL,
+ resource_id character varying(255) DEFAULT ''::character varying
+);
+
+
+--
+-- TOC entry 143 (class 1259 OID 61465)
+-- Dependencies: 3
+-- Name: resources_parents; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE resources_parents (
+ id_resources integer NOT NULL,
+ id_resources_parent integer NOT NULL
+);
+
+
+--
+-- TOC entry 140 (class 1259 OID 61448)
+-- Dependencies: 1791 3
+-- Name: roles; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE roles (
+ id integer NOT NULL,
+ role_id character varying(255) DEFAULT ''::character varying
+);
+
+
+--
+-- TOC entry 141 (class 1259 OID 61454)
+-- Dependencies: 3
+-- Name: roles_parents; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE roles_parents (
+ id_roles integer NOT NULL,
+ id_roles_parent integer NOT NULL
+);
+
+
+--
+-- TOC entry 144 (class 1259 OID 61470)
+-- Dependencies: 3
+-- Name: rules; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE rules (
+ id integer NOT NULL,
+ type integer,
+ id_roles integer,
+ id_resources integer
+);
+
+
+--
+-- TOC entry 1812 (class 0 OID 0)
+-- Dependencies: 144
+-- Name: COLUMN rules.type; Type: COMMENT; Schema: public; Owner: -
+--
+
+COMMENT ON COLUMN rules.type IS '1 - allow
2 - deny';
+
+
+--
+-- TOC entry 145 (class 1259 OID 107636)
+-- Dependencies: 3
+-- Name: timestamp_update; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE timestamp_update (
+ update timestamp without time zone
+);
+
+
+--
+-- TOC entry 1800 (class 2606 OID 61469)
+-- Dependencies: 143 143 143
+-- Name: resources_parents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY resources_parents
+ ADD CONSTRAINT resources_parents_pkey PRIMARY KEY (id_resources, id_resources_parent);
+
+
+--
+-- TOC entry 1798 (class 2606 OID 61464)
+-- Dependencies: 142 142
+-- Name: resources_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY resources
+ ADD CONSTRAINT resources_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1796 (class 2606 OID 61458)
+-- Dependencies: 141 141 141
+-- Name: roles_parents_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY roles_parents
+ ADD CONSTRAINT roles_parents_pkey PRIMARY KEY (id_roles, id_roles_parent);
+
+
+--
+-- TOC entry 1794 (class 2606 OID 61453)
+-- Dependencies: 140 140
+-- Name: roles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY roles
+ ADD CONSTRAINT roles_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1802 (class 2606 OID 61474)
+-- Dependencies: 144 144
+-- Name: rules_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY rules
+ ADD CONSTRAINT rules_pkey PRIMARY KEY (id);
+
+
+--
+-- TOC entry 1806 (class 2620 OID 107641)
+-- Dependencies: 143 158
+-- Name: resources_parents_updated; Type: TRIGGER; Schema: public; Owner: -
+--
+
+CREATE TRIGGER resources_parents_updated
+ AFTER INSERT OR DELETE OR UPDATE ON resources_parents
+ FOR EACH STATEMENT
+ EXECUTE PROCEDURE update_update();
+
+
+--
+-- TOC entry 1805 (class 2620 OID 107640)
+-- Dependencies: 142 158
+-- Name: resources_updated; Type: TRIGGER; Schema: public; Owner: -
+--
+
+CREATE TRIGGER resources_updated
+ AFTER INSERT OR DELETE OR UPDATE ON resources
+ FOR EACH STATEMENT
+ EXECUTE PROCEDURE update_update();
+
+
+--
+-- TOC entry 1804 (class 2620 OID 107643)
+-- Dependencies: 158 141
+-- Name: roles_parents_updated; Type: TRIGGER; Schema: public; Owner: -
+--
+
+CREATE TRIGGER roles_parents_updated
+ AFTER INSERT OR DELETE OR UPDATE ON roles_parents
+ FOR EACH STATEMENT
+ EXECUTE PROCEDURE update_update();
+
+
+--
+-- TOC entry 1803 (class 2620 OID 107642)
+-- Dependencies: 158 140
+-- Name: roles_updated; Type: TRIGGER; Schema: public; Owner: -
+--
+
+CREATE TRIGGER roles_updated
+ AFTER INSERT OR DELETE OR UPDATE ON roles
+ FOR EACH STATEMENT
+ EXECUTE PROCEDURE update_update();
+
+
+--
+-- TOC entry 1807 (class 2620 OID 107644)
+-- Dependencies: 144 158
+-- Name: rules_updated; Type: TRIGGER; Schema: public; Owner: -
+--
+
+CREATE TRIGGER rules_updated
+ AFTER INSERT OR DELETE OR UPDATE ON rules
+ FOR EACH STATEMENT
+ EXECUTE PROCEDURE update_update();
+
+
+-- Completed on 2011-12-28 08:55:26
+
+--
+-- PostgreSQL database dump complete
+--
+
/*
- * Copyright (C) 2010 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2010-2011 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
static guint _autoz_get_role_id_db (GdaConnection *gdacon, const gchar *table_name, const gchar *role_id);
static guint _autoz_get_resource_id_db (GdaConnection *gdacon, const gchar *table_name, const gchar *resource_id);
+static void _autoz_check_updated (Autoz *autoz);
+
static void autoz_set_property (GObject *object,
guint property_id,
const GValue *value,
GHashTable *rules_allow; /* struct Rule */
GHashTable *rules_deny; /* struct Rule */
+
+ GdaConnection *gdacon;
+ gchar *table_prefix;
+ GDateTime *gdt_last_load;
+ gboolean on_loading;
};
G_DEFINE_TYPE (Autoz, autoz, G_TYPE_OBJECT)
priv->rules_allow = g_hash_table_new (g_str_hash, g_str_equal);
priv->rules_deny = g_hash_table_new (g_str_hash, g_str_equal);
+
+ priv->gdacon = NULL;
+ priv->table_prefix = NULL;
+ priv->gdt_last_load = NULL;
+ priv->on_loading = FALSE;
}
/**
Autoz
*autoz_new ()
{
-
return AUTOZ (g_object_new (autoz_get_type (), NULL));
}
g_return_val_if_fail (AUTOZ_IS_IROLE (irole), FALSE);
g_return_val_if_fail (AUTOZ_IS_IROLE (irole_parent), FALSE);
+ _autoz_check_updated (autoz);
+
ret = FALSE;
priv = AUTOZ_GET_PRIVATE (autoz);
g_return_val_if_fail (IS_AUTOZ (autoz), NULL);
+ _autoz_check_updated (autoz);
+
priv = AUTOZ_GET_PRIVATE (autoz);
role = g_hash_table_lookup (priv->roles, role_id);
g_return_val_if_fail (AUTOZ_IS_IRESOURCE (iresource), FALSE);
g_return_val_if_fail (AUTOZ_IS_IRESOURCE (iresource_parent), FALSE);
+ _autoz_check_updated (autoz);
+
ret = FALSE;
priv = AUTOZ_GET_PRIVATE (autoz);
g_return_val_if_fail (IS_AUTOZ (autoz), NULL);
+ _autoz_check_updated (autoz);
+
priv = AUTOZ_GET_PRIVATE (autoz);
resource = g_hash_table_lookup (priv->resources, resource_id);
{
/* first trying for a rule for every resource */
str_id = g_strconcat (autoz_irole_get_role_id (role->irole),
- "|NULL",
- NULL);
+ "|NULL",
+ NULL);
if (g_hash_table_lookup (priv->rules_deny, str_id) != NULL)
{
g_return_val_if_fail (AUTOZ_IS_IROLE (irole), FALSE);
g_return_val_if_fail (AUTOZ_IS_IRESOURCE (iresource), FALSE);
+ _autoz_check_updated (autoz);
+
priv = AUTOZ_GET_PRIVATE (autoz);
ret = FALSE;
isAllowed = AUTOZ_NOT_FOUND;
{
/* first trying for a rule for every resource */
str_id = g_strconcat (autoz_irole_get_role_id (role->irole),
- "|NULL",
- NULL);
+ "|NULL",
+ NULL);
if (g_hash_table_lookup (priv->rules_deny, str_id) != NULL)
{
}
/**
- * autoz_load_fro_xml:
+ * autoz_load_from_xml:
* @autoz: an #Autoz object.
* @xnode:
* @replace:
error = NULL;
sql = g_strdup_printf ("DELETE FROM %sroles", table_prefix);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on deleting roles table content: %s",
error = NULL;
sql = g_strdup_printf ("DELETE FROM %sroles_parents", table_prefix);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on deleting roles_parents table content: %s",
error = NULL;
sql = g_strdup_printf ("DELETE FROM %sresources", table_prefix);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on deleting resources table content: %s",
error = NULL;
sql = g_strdup_printf ("DELETE FROM %sresources_parents", table_prefix);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on deleting resources_parents table content: %s",
error = NULL;
sql = g_strdup_printf ("DELETE FROM %srules", table_prefix);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on deleting rules table content: %s",
sql = g_strdup_printf ("SELECT COALESCE (MAX (id), 0) FROM %s",
table_name);
dm = gda_execute_select_command (gdacon, sql, &error);
+ g_free (sql);
if (dm != NULL && gda_data_model_get_n_rows (dm) == 1)
{
new_id = g_value_get_int (gda_data_model_get_value_at (dm, 0, 0, &error));
{
new_id = 1;
}
+ g_object_unref (dm);
return new_id;
}
table_name,
role_id);
dm = gda_execute_select_command (gdacon, sql, &error);
+ g_free (sql);
if (dm != NULL && gda_data_model_get_n_rows (dm) == 1)
{
id = g_value_get_int (gda_data_model_get_value_at (dm, 0, 0, &error));
{
g_warning ("Problem on getting role id from table «%s»: %s",
error->message != NULL ? error->message : "no details");
- }
+ }
+ g_object_unref (dm);
return id;
}
table_name,
resource_id);
dm = gda_execute_select_command (gdacon, sql, &error);
+ g_free (sql);
if (dm != NULL && gda_data_model_get_n_rows (dm) == 1)
{
id = g_value_get_int (gda_data_model_get_value_at (dm, 0, 0, &error));
{
g_warning ("Problem on getting resource id from table «%s»: %s",
error->message != NULL ? error->message : "no details");
- }
+ }
+ g_object_unref (dm);
return id;
}
new_id,
autoz_irole_get_role_id (AUTOZ_IROLE (role->irole)));
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on saving role «%s»: %s",
{
error = NULL;
sql = g_strdup_printf ("INSERT INTO %s"
- " (id_roles, id_roles_parent)"
- " VALUES (%d, %d)",
- table_name_parent,
- new_id,
- id_parent);
+ " (id_roles, id_roles_parent)"
+ " VALUES (%d, %d)",
+ table_name_parent,
+ new_id,
+ id_parent);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on saving role parent «%s»: %s",
- autoz_irole_get_role_id (AUTOZ_IROLE (role->irole)),
- error->message != NULL ? error->message : "no details");
+ autoz_irole_get_role_id (AUTOZ_IROLE (role->irole)),
+ error->message != NULL ? error->message : "no details");
continue;
}
}
new_id,
autoz_iresource_get_resource_id (AUTOZ_IRESOURCE (resource->iresource)));
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on saving resource «%s»: %s",
{
error = NULL;
sql = g_strdup_printf ("INSERT INTO %s"
- " (id_resources, id_resources_parent)"
- " VALUES (%d, %d)",
- table_name_parent,
- new_id,
- id_parent);
+ " (id_resources, id_resources_parent)"
+ " VALUES (%d, %d)",
+ table_name_parent,
+ new_id,
+ id_parent);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on saving resource parent «%s»: %s",
- autoz_iresource_get_resource_id (AUTOZ_IRESOURCE (resource->iresource)),
- error->message != NULL ? error->message : "no details");
+ autoz_iresource_get_resource_id (AUTOZ_IRESOURCE (resource->iresource)),
+ error->message != NULL ? error->message : "no details");
continue;
}
}
id_roles,
id_resources);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on saving rule: %s",
id_roles,
id_resources);
gda_execute_non_select_command (gdacon, sql, &error);
+ g_free (sql);
if (error != NULL)
{
g_warning ("Error on saving rule: %s",
guint row;
guint rows;
- gchar *table_name;
- gchar *table_name_parent;
-
g_return_val_if_fail (IS_AUTOZ (autoz), FALSE);
g_return_val_if_fail (GDA_IS_CONNECTION (gdacon), FALSE);
priv = AUTOZ_GET_PRIVATE (autoz);
+ priv->on_loading = TRUE;
+
ret = TRUE;
if (replace)
}
else
{
- prefix = g_strdup (table_prefix);
+ prefix = g_strstrip (g_strdup (table_prefix));
}
/* roles */
error = NULL;
- table_name = g_strdup_printf ("%sroles", prefix);
- sql = g_strdup_printf ("SELECT role_id FROM %s ORDER BY id",
- table_name);
+ sql = g_strdup_printf ("SELECT role_id FROM %sroles ORDER BY id",
+ prefix);
dm = gda_execute_select_command (gdacon, sql, &error);
g_free (sql);
if (dm != NULL && error == NULL)
irole = AUTOZ_IROLE (autoz_role_new (gda_value_stringify (gda_data_model_get_value_at (dm, 0, row, &error))));
autoz_add_role (autoz, irole);
}
-
- g_object_unref (dm);
}
else if (error != NULL)
{
- g_warning ("Error on reading table «roles»: %s",
+ g_warning ("Error on reading table «%sroles»: %s",
+ prefix,
error->message != NULL ? error->message : "no details");
}
+ g_object_unref (dm);
/* roles parents */
error = NULL;
- table_name = g_strdup_printf ("%sroles_parents", prefix);
sql = g_strdup_printf ("SELECT r1.role_id, r2.role_id"
- " FROM %s AS rp"
+ " FROM %sroles_parents AS rp"
" INNER JOIN %sroles AS r1 ON rp.id_roles = r1.id"
" INNER JOIN %sroles AS r2 ON rp.id_roles_parent = r2.id"
" ORDER BY rp.id_roles, rp.id_roles_parent",
- table_name,
+ prefix,
prefix,
prefix);
dm = gda_execute_select_command (gdacon, sql, &error);
irole_parent = AUTOZ_IROLE (autoz_role_new (gda_value_stringify (gda_data_model_get_value_at (dm, 1, row, &error))));
autoz_add_parent_to_role (autoz, irole, irole_parent);
}
-
- g_object_unref (dm);
}
else if (error != NULL)
{
- g_warning ("Error on reading table «roles_parents»: %s",
+ g_warning ("Error on reading table «%sroles_parents»: %s",
+ prefix,
error->message != NULL ? error->message : "no details");
}
+ g_object_unref (dm);
/* resources */
error = NULL;
- table_name = g_strdup_printf ("%sresources", prefix);
- sql = g_strdup_printf ("SELECT resource_id FROM %s ORDER BY id",
- table_name);
+ sql = g_strdup_printf ("SELECT resource_id FROM %sresources ORDER BY id",
+ prefix);
dm = gda_execute_select_command (gdacon, sql, &error);
g_free (sql);
if (dm != NULL && error == NULL)
iresource = AUTOZ_IRESOURCE (autoz_resource_new (gda_value_stringify (gda_data_model_get_value_at (dm, 0, row, &error))));
autoz_add_resource (autoz, iresource);
}
-
- g_object_unref (dm);
}
else if (error != NULL)
{
- g_warning ("Error on reading table «resources»: %s",
+ g_warning ("Error on reading table «%sresources»: %s",
+ prefix,
error->message != NULL ? error->message : "no details");
}
+ g_object_unref (dm);
/* resources parents */
error = NULL;
- table_name = g_strdup_printf ("%sresources_parents", prefix);
sql = g_strdup_printf ("SELECT r1.resource_id, r2.resource_id"
- " FROM %s AS rp"
+ " FROM %sresources_parents AS rp"
" INNER JOIN %sresources AS r1 ON rp.id_resources = r1.id"
" INNER JOIN %sresources AS r2 ON rp.id_resources_parent = r2.id"
" ORDER BY rp.id_resources, rp.id_resources_parent",
- table_name,
+ prefix,
prefix,
prefix);
dm = gda_execute_select_command (gdacon, sql, &error);
iresource_parent = AUTOZ_IRESOURCE (autoz_resource_new (gda_value_stringify (gda_data_model_get_value_at (dm, 1, row, &error))));
autoz_add_parent_to_resource (autoz, iresource, iresource_parent);
}
-
- g_object_unref (dm);
}
else if (error != NULL)
{
- g_warning ("Error on reading table «resources_parents»: %s",
+ g_warning ("Error on reading table «%sresources_parents»: %s",
+ prefix,
error->message != NULL ? error->message : "no details");
}
+ g_object_unref (dm);
/* rules */
error = NULL;
- table_name = g_strdup_printf ("%srules", prefix);
sql = g_strdup_printf ("SELECT ru.type, ro.role_id, re.resource_id"
- " FROM %s AS ru"
+ " FROM %srules AS ru"
" LEFT JOIN %sroles AS ro ON ru.id_roles = ro.id"
" LEFT JOIN %sresources AS re ON ru.id_resources = re.id",
- table_name,
+ prefix,
prefix,
prefix);
dm = gda_execute_select_command (gdacon, sql, &error);
if (gval == NULL || error != NULL)
{
g_warning ("Error on reading type value: %s",
- error != NULL && error->message != NULL ? error->message : "no details");
+ error != NULL && error->message != NULL ? error->message : "no details");
}
else if (gval != NULL && error == NULL && !gda_value_is_null (gval))
{
}
}
}
-
- g_object_unref (dm);
}
else if (error != NULL)
{
- g_warning ("Error on reading table «resources»: %s",
+ g_warning ("Error on reading table «%srules»: %s",
+ prefix,
error->message != NULL ? error->message : "no details");
}
+ g_object_unref (dm);
g_free (prefix);
+ if (priv->gdt_last_load != NULL)
+ {
+ g_date_time_unref (priv->gdt_last_load);
+ }
+ priv->gdt_last_load = g_date_time_new_now_local ();
+
+ priv->on_loading = FALSE;
+
return ret;
}
+gboolean
+autoz_load_from_db_with_monitor (Autoz *autoz, GdaConnection *gdacon, const gchar *table_prefix, gboolean replace)
+{
+ AutozPrivate *priv = AUTOZ_GET_PRIVATE (autoz);
+
+ g_return_val_if_fail (IS_AUTOZ (autoz), FALSE);
+ g_return_val_if_fail (GDA_IS_CONNECTION (gdacon), FALSE);
+
+ priv->gdacon = gdacon;
+ if (table_prefix == NULL)
+ {
+ if (priv->table_prefix != NULL)
+ {
+ g_free (priv->table_prefix);
+ }
+ priv->table_prefix = g_strdup ("");
+ }
+ else
+ {
+ priv->table_prefix = g_strdup (table_prefix);
+ }
+
+ autoz_load_from_db (autoz, gdacon, table_prefix, replace);
+}
+
+static void
+_autoz_check_updated (Autoz *autoz)
+{
+ GError *error;
+ gchar *sql;
+ GdaDataModel *dm;
+
+ const GValue *gval;
+ const GdaTimestamp *gda_timestamp;
+ GDateTime *gda_datetime;
+
+ AutozPrivate *priv = AUTOZ_GET_PRIVATE (autoz);
+
+ g_return_if_fail (IS_AUTOZ (autoz));
+
+ if (priv->on_loading)
+ {
+ return;
+ }
+
+ if (!GDA_IS_CONNECTION (priv->gdacon))
+ {
+ return;
+ }
+
+ error = NULL;
+ sql = g_strdup_printf ("SELECT update FROM %stimestamp_update",
+ priv->table_prefix);
+ dm = gda_execute_select_command (priv->gdacon, sql, &error);
+ g_free (sql);
+ if (dm != NULL && error == NULL && gda_data_model_get_n_rows (dm) > 0)
+ {
+ gval = gda_data_model_get_value_at (dm, 0, 0, NULL);
+ if (!gda_value_is_null (gval))
+ {
+ gda_timestamp = gda_value_get_timestamp (gval);
+ gda_datetime = g_date_time_new_local (gda_timestamp->year,
+ gda_timestamp->month,
+ gda_timestamp->day,
+ gda_timestamp->hour,
+ gda_timestamp->minute,
+ gda_timestamp->second);
+
+ if (g_date_time_compare (priv->gdt_last_load, gda_datetime) < 0)
+ {
+ /* to reload */
+ autoz_load_from_db_with_monitor (autoz, priv->gdacon, priv->table_prefix, TRUE);
+ }
+ g_date_time_unref (gda_datetime);
+ }
+ }
+ else if (error != NULL)
+ {
+ g_warning ("Error on reading table «%stimestamp_update»: %s",
+ priv->table_prefix,
+ error->message != NULL ? error->message : "no details");
+ }
+ g_object_unref (dm);
+}
+
/* PRIVATE */
static void
autoz_set_property (GObject *object,