[tracker/wip/carlosg/portal: 6/36] libtracker-data: Refactor find_graph() function
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/portal: 6/36] libtracker-data: Refactor find_graph() function
- Date: Fri, 17 Jul 2020 11:41:39 +0000 (UTC)
commit 94329a07714018208091752942c0ebdba6b324b4
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Jan 23 18:07:19 2020 +0100
libtracker-data: Refactor find_graph() function
Since we'll be adding policy from TrackerSparql on top, wrap the
TrackerDataManager function to find IDs for graphs.
src/libtracker-data/tracker-sparql.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 4fca1d650..7c594238a 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -789,6 +789,13 @@ tracker_sparql_add_union_graph_subquery_for_class (TrackerSparql *sparql,
tracker_sparql_swap_builder (sparql, old);
}
+static gint
+tracker_sparql_find_graph (TrackerSparql *sparql,
+ const gchar *name)
+{
+ return tracker_data_manager_find_graph (sparql->data_manager, name);
+}
+
static void
_prepend_path_element (TrackerSparql *sparql,
TrackerPathElement *path_elem)
@@ -824,7 +831,7 @@ _prepend_path_element (TrackerSparql *sparql,
table_name = g_strdup_printf ("\"%s\".\"%s\"", graph,
tracker_property_get_table_name
(path_elem->data.property));
graph_column = g_strdup_printf ("%d",
- tracker_data_manager_find_graph
(sparql->data_manager, graph));
+ tracker_sparql_find_graph (sparql, graph));
} else {
/* Graph does not exist, ensure to come back empty */
table_name = g_strdup ("(SELECT 0 AS ID, NULL, NULL, 0, 0 LIMIT 0)");
@@ -947,7 +954,7 @@ _prepend_path_element (TrackerSparql *sparql,
graph = tracker_token_get_idstring (&sparql->current_state.graph);
_append_string_printf (sparql,
"AND graph = %d",
- tracker_data_manager_find_graph (sparql->data_manager, graph));
+ tracker_sparql_find_graph (sparql, graph));
}
_append_string (sparql, ") ");
@@ -1518,7 +1525,7 @@ _add_quad (TrackerSparql *sparql,
return FALSE;
}
- if (!graph_db || !tracker_data_manager_find_graph (sparql->data_manager, graph_db))
+ if (!graph_db || !tracker_sparql_find_graph (sparql, graph_db))
tracker_sparql_add_union_graph_subquery_for_class (sparql, subject_type);
is_rdf_type = TRUE;
@@ -1577,14 +1584,14 @@ _add_quad (TrackerSparql *sparql,
}
if (domain_index) {
- if (!graph_db || !tracker_data_manager_find_graph
(sparql->data_manager, graph_db))
+ if (!graph_db || !tracker_sparql_find_graph (sparql,
graph_db))
tracker_sparql_add_union_graph_subquery_for_class
(sparql, domain_index);
db_table = tracker_class_get_name (domain_index);
}
}
}
- if (!graph_db || !tracker_data_manager_find_graph (sparql->data_manager, graph_db))
+ if (!graph_db || !tracker_sparql_find_graph (sparql, graph_db))
tracker_sparql_add_union_graph_subquery (sparql, property);
/* We can never share the table with multiple triples for
@@ -2225,7 +2232,7 @@ _end_triples_block (TrackerSparql *sparql,
_append_string_printf (sparql, "\"%s\" ", table->sql_db_tablename);
} else {
if (table->graph &&
- tracker_data_manager_find_graph (sparql->data_manager, table->graph)) {
+ tracker_sparql_find_graph (sparql, table->graph)) {
_append_string_printf (sparql, "\"%s\".\"%s\" ",
table->graph,
table->sql_db_tablename);
@@ -3716,7 +3723,7 @@ translate_Clear (TrackerSparql *sparql,
} else {
graph = tracker_token_get_idstring (&sparql->current_state.graph);
- if (tracker_data_manager_find_graph (sparql->data_manager, graph) == 0)
+ if (tracker_sparql_find_graph (sparql, graph) == 0)
_raise (UNKNOWN_GRAPH, "Unknown graph", graph);
graphs = g_list_prepend (graphs, (gpointer) graph);
@@ -3804,7 +3811,7 @@ translate_Create (TrackerSparql *sparql,
graph_name = tracker_token_get_idstring (&sparql->current_state.graph);
- if (tracker_data_manager_find_graph (sparql->data_manager, graph_name) != 0) {
+ if (tracker_sparql_find_graph (sparql, graph_name) != 0) {
inner_error = g_error_new (TRACKER_SPARQL_ERROR,
TRACKER_SPARQL_ERROR_CONSTRAINT,
"Graph '%s' already exists",
@@ -3853,7 +3860,7 @@ translate_Add (TrackerSparql *sparql,
}
if (source &&
- !tracker_data_manager_find_graph (sparql->data_manager, source)) {
+ !tracker_sparql_find_graph (sparql, source)) {
g_set_error (&inner_error, TRACKER_SPARQL_ERROR,
TRACKER_SPARQL_ERROR_UNKNOWN_GRAPH,
"Unknown graph '%s'", source);
@@ -3861,7 +3868,7 @@ translate_Add (TrackerSparql *sparql,
}
if (destination &&
- !tracker_data_manager_find_graph (sparql->data_manager, destination)) {
+ !tracker_sparql_find_graph (sparql, destination)) {
if (!tracker_data_manager_create_graph (sparql->data_manager,
destination, &inner_error))
goto error;
@@ -3915,7 +3922,7 @@ translate_Move (TrackerSparql *sparql,
}
if (source &&
- !tracker_data_manager_find_graph (sparql->data_manager, source)) {
+ !tracker_sparql_find_graph (sparql, source)) {
g_set_error (&inner_error, TRACKER_SPARQL_ERROR,
TRACKER_SPARQL_ERROR_UNKNOWN_GRAPH,
"Unknown graph '%s'", source);
@@ -3923,7 +3930,7 @@ translate_Move (TrackerSparql *sparql,
}
if (destination &&
- !tracker_data_manager_find_graph (sparql->data_manager, destination)) {
+ !tracker_sparql_find_graph (sparql, destination)) {
if (!tracker_data_manager_create_graph (sparql->data_manager,
destination, &inner_error))
goto error;
@@ -3989,7 +3996,7 @@ translate_Copy (TrackerSparql *sparql,
}
if (source &&
- !tracker_data_manager_find_graph (sparql->data_manager, source)) {
+ !tracker_sparql_find_graph (sparql, source)) {
g_set_error (&inner_error, TRACKER_SPARQL_ERROR,
TRACKER_SPARQL_ERROR_UNKNOWN_GRAPH,
"Unknown graph '%s'", source);
@@ -3997,7 +4004,7 @@ translate_Copy (TrackerSparql *sparql,
}
if (destination &&
- !tracker_data_manager_find_graph (sparql->data_manager, destination)) {
+ !tracker_sparql_find_graph (sparql, destination)) {
if (!tracker_data_manager_create_graph (sparql->data_manager,
destination, &inner_error))
goto error;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]