[tracker/sparql-update: 3/23] libtracker-data: Correct GraphUpdated for REPLACE support
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/sparql-update: 3/23] libtracker-data: Correct GraphUpdated for REPLACE support
- Date: Mon, 21 Mar 2011 11:19:31 +0000 (UTC)
commit fc487e75a446b714df16f03b12e4cf88781e0ceb
Author: Philip Van Hoof <philip codeminded be>
Date: Thu Mar 10 11:20:08 2011 +0100
libtracker-data: Correct GraphUpdated for REPLACE support
src/libtracker-data/tracker-data-update.c | 62 ++++++++++++++++++++++------
1 files changed, 48 insertions(+), 14 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 4fced5b..70484e3 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2619,6 +2619,27 @@ tracker_data_update_statement_with_uri (const gchar *graph,
change = TRUE;
} else {
+ guint old_object_id = 0;
+ GValueArray *old_values;
+ gboolean multiple_values;
+ GError *new_error = NULL;
+
+ multiple_values = tracker_property_get_multiple_values (property);
+
+ /* We can disable correct object-id for deletes array here */
+ if (!multiple_values) {
+ old_values = get_old_property_values (property, &new_error);
+ if (!new_error) {
+ if (old_values->n_values > 0) {
+ /* evel knievel cast */
+ old_object_id = (guint) g_value_get_int64 (g_value_array_get_nth (old_values, 0));
+ }
+ } else {
+ g_warning ("%s", new_error->message);
+ g_clear_error (&new_error);
+ }
+ }
+
/* update or add value to metadata database */
change = cache_update_metadata_decomposed (property, object, 0, graph, 0, &actual_error);
if (actual_error) {
@@ -2631,19 +2652,25 @@ tracker_data_update_statement_with_uri (const gchar *graph,
final_prop_id = (prop_id != 0) ? prop_id : tracker_data_query_resource_id (predicate);
object_id = query_resource_id (object);
- if (insert_callbacks) {
+ if (!multiple_values && delete_callbacks) {
guint n;
+
for (n = 0; n < delete_callbacks->len; n++) {
TrackerStatementDelegate *delegate;
/* Don't pass object to the delete, it's not correct */
delegate = g_ptr_array_index (delete_callbacks, n);
delegate->callback (graph_id, graph, resource_buffer->id, subject,
- final_prop_id, 0,
+ final_prop_id, old_object_id,
NULL,
resource_buffer->types,
delegate->user_data);
}
+ }
+
+ if (insert_callbacks) {
+ guint n;
+
for (n = 0; n < insert_callbacks->len; n++) {
TrackerStatementDelegate *delegate;
@@ -2676,9 +2703,9 @@ tracker_data_update_statement_with_string (const gchar *graph,
{
GError *actual_error = NULL;
TrackerProperty *property;
- gboolean change, tried = FALSE;
- gint graph_id = 0, pred_id = 0;
-
+ gboolean change, tried = FALSE;
+ gint graph_id = 0, pred_id = 0;
+ gboolean multiple_values;
g_return_if_fail (subject != NULL);
g_return_if_fail (predicate != NULL);
@@ -2699,6 +2726,8 @@ tracker_data_update_statement_with_string (const gchar *graph,
pred_id = tracker_property_get_id (property);
}
+ multiple_values = tracker_property_get_multiple_values (property);
+
if (!tracker_property_get_transient (property)) {
has_persistent = TRUE;
}
@@ -2720,12 +2749,14 @@ tracker_data_update_statement_with_string (const gchar *graph,
return;
}
- if (insert_callbacks && change) {
- guint n;
-
+ if (((!multiple_values && delete_callbacks) || insert_callbacks) && change) {
graph_id = (graph != NULL ? query_resource_id (graph) : 0);
pred_id = (pred_id != 0) ? pred_id : tracker_data_query_resource_id (predicate);
tried = TRUE;
+ }
+
+ if ((!multiple_values && delete_callbacks) && change) {
+ guint n;
for (n = 0; n < delete_callbacks->len; n++) {
TrackerStatementDelegate *delegate;
@@ -2738,7 +2769,10 @@ tracker_data_update_statement_with_string (const gchar *graph,
resource_buffer->types,
delegate->user_data);
}
+ }
+ if (insert_callbacks && change) {
+ guint n;
for (n = 0; n < insert_callbacks->len; n++) {
TrackerStatementDelegate *delegate;
@@ -2763,14 +2797,14 @@ tracker_data_update_statement_with_string (const gchar *graph,
damaged = tracker_ontologies_get_property_by_uri (TRACKER_TRACKER_PREFIX "damaged");
tracker_db_journal_append_update_statement (graph_id,
- resource_buffer->id,
- tracker_property_get_id (damaged),
- "true");
+ resource_buffer->id,
+ tracker_property_get_id (damaged),
+ "true");
} else {
tracker_db_journal_append_update_statement (graph_id,
- resource_buffer->id,
- pred_id,
- object);
+ resource_buffer->id,
+ pred_id,
+ object);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]