[tracker/wip/carlosg/sparql1.1: 33/56] sm tracker data manager graphs api
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql1.1: 33/56] sm tracker data manager graphs api
- Date: Thu, 6 Jun 2019 11:18:56 +0000 (UTC)
commit 0d19b35f07a84b674541ef7b232ba408b96db74a
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu May 30 12:11:50 2019 +0200
sm tracker data manager graphs api
src/libtracker-data/tracker-data-manager.c | 50 ++++++++++++++++++++++++++----
src/libtracker-data/tracker-data-manager.h | 5 +++
2 files changed, 49 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 3eeacfc24..dcaf8edf4 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -4946,25 +4946,23 @@ tracker_data_manager_create_graph (TrackerDataManager *manager,
gint id;
iface = tracker_db_manager_get_writable_db_interface (manager->db_manager);
+
if (!tracker_db_manager_attach_database (manager->db_manager, iface,
name, TRUE, error))
return FALSE;
if (!tracker_data_ontology_setup_db (manager, iface, name,
FALSE, error))
- goto error;
-
- if (!tracker_data_manager_ensure_graphs (manager, iface, error))
- goto error;
+ goto detach;
id = tracker_data_ensure_graph (manager->data_update, name, error);
if (id == 0)
- goto error;
+ goto detach;
g_hash_table_insert (manager->graphs, g_strdup (name), GINT_TO_POINTER (id));
return TRUE;
-error:
+detach:
tracker_db_manager_detach_database (manager->db_manager, iface, name, NULL);
return FALSE;
}
@@ -4990,3 +4988,43 @@ tracker_data_manager_drop_graph (TrackerDataManager *manager,
return TRUE;
}
+
+gint
+tracker_data_manager_find_graph (TrackerDataManager *manager,
+ const gchar *name)
+{
+ TrackerDBInterface *iface;
+ GHashTable *graphs;
+
+ iface = tracker_db_manager_get_writable_db_interface (manager->db_manager);
+ graphs = tracker_data_manager_get_graphs (manager, iface, NULL);
+
+ if (!graphs)
+ return 0;
+
+ return GPOINTER_TO_UINT (g_hash_table_lookup (graphs, name));
+}
+
+const gchar *
+tracker_data_manager_find_graph_by_id (TrackerDataManager *manager,
+ gint id)
+{
+ TrackerDBInterface *iface;
+ GHashTableIter iter;
+ GHashTable *graphs;
+ gpointer key, value;
+
+ iface = tracker_db_manager_get_writable_db_interface (manager->db_manager);
+ graphs = tracker_data_manager_get_graphs (manager, iface, NULL);
+
+ if (!graphs)
+ return NULL;
+
+ g_hash_table_iter_init (&iter, graphs);
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ if (id == GPOINTER_TO_INT (value))
+ return key;
+ }
+
+ return NULL;
+}
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index ef7dec4b9..ebb992753 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -88,6 +88,11 @@ gboolean tracker_data_manager_drop_graph (TrackerDataManager *manag
const gchar *name,
GError **error);
+gint tracker_data_manager_find_graph (TrackerDataManager *manager,
+ const gchar *name);
+const gchar * tracker_data_manager_find_graph_by_id (TrackerDataManager *manager,
+ gint id);
+
G_END_DECLS
#endif /* __LIBTRACKER_DATA_MANAGER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]