[tracker/tracker-0.10] libtracker-data: Support for removing rdfs:subPropertyOf



commit 1671f836caac2bbbe8d3c6f632b9642b077a16f2
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Sep 13 13:35:16 2011 +0200

    libtracker-data: Support for removing rdfs:subPropertyOf
    
    Fixes NB#281335.

 src/libtracker-data/tracker-data-manager.c |   39 ++++++++++++++++++++++-----
 src/libtracker-data/tracker-property.c     |   22 +++++++++++++++
 src/libtracker-data/tracker-property.h     |    2 +
 3 files changed, 55 insertions(+), 8 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 020c56c..487a6ad 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1393,6 +1393,7 @@ check_for_deleted_super_properties (TrackerProperty  *property,
                                     GError          **error)
 {
 	TrackerProperty **last_super_properties;
+	GList *to_remove = NULL;
 
 	last_super_properties = tracker_property_get_last_super_properties (property);
 
@@ -1418,18 +1419,40 @@ check_for_deleted_super_properties (TrackerProperty  *property,
 		}
 
 		if (!found) {
-			const gchar *ontology_path = "Unknown";
-			const gchar *subject = tracker_property_get_uri (property);
-
-			handle_unsupported_ontology_change (ontology_path,
-			                                    subject,
-			                                    "rdfs:subPropertyOf", "-", "-",
-			                                    error);
-			return;
+			to_remove = g_list_prepend (to_remove, last_super_property);
 		}
 
 		last_super_properties++;
 	}
+
+	if (to_remove) {
+		GList *copy = to_remove;
+
+		while (copy) {
+			GError *n_error = NULL;
+			TrackerProperty *prop_to_remove = copy->data;
+			const gchar *object = tracker_property_get_uri (prop_to_remove);
+			const gchar *subject = tracker_property_get_uri (property);
+
+			tracker_property_del_super_property (property, prop_to_remove);
+
+			tracker_data_delete_statement (NULL, subject,
+			                               RDFS_PREFIX "subPropertyOf",
+			                               object, &n_error);
+
+			if (!n_error) {
+				tracker_data_update_buffer_flush (&n_error);
+			}
+
+			if (n_error) {
+				g_propagate_error (error, n_error);
+				return;
+			}
+
+			copy = copy->next;
+		}
+		g_list_free (to_remove);
+	}
 }
 
 static void
diff --git a/src/libtracker-data/tracker-property.c b/src/libtracker-data/tracker-property.c
index 0b1ade7..4286696 100644
--- a/src/libtracker-data/tracker-property.c
+++ b/src/libtracker-data/tracker-property.c
@@ -1049,6 +1049,28 @@ tracker_property_add_super_property (TrackerProperty *property,
 }
 
 void
+tracker_property_del_super_property (TrackerProperty *property,
+                                     TrackerProperty *value)
+{
+	TrackerPropertyPrivate *priv;
+	guint i;
+
+	g_return_if_fail (TRACKER_IS_PROPERTY (property));
+	g_return_if_fail (TRACKER_IS_PROPERTY (value));
+
+	priv = GET_PRIV (property);
+
+	for (i = 0; priv->super_properties->len; i++) {
+		TrackerProperty *c_value = g_array_index (priv->super_properties, TrackerProperty*, i);
+
+		if (c_value == value) {
+			priv->super_properties = g_array_remove_index (priv->super_properties, i);
+			return;
+		}
+	}
+}
+
+void
 tracker_property_set_default_value (TrackerProperty *property,
                                     const gchar     *value)
 {
diff --git a/src/libtracker-data/tracker-property.h b/src/libtracker-data/tracker-property.h
index e6bac49..02794c0 100644
--- a/src/libtracker-data/tracker-property.h
+++ b/src/libtracker-data/tracker-property.h
@@ -147,6 +147,8 @@ void                tracker_property_set_force_journal       (TrackerProperty
                                                               gboolean              value);
 void                tracker_property_add_super_property      (TrackerProperty      *property,
                                                               TrackerProperty      *value);
+void                tracker_property_del_super_property      (TrackerProperty      *property,
+                                                              TrackerProperty      *value);
 TrackerProperty   **tracker_property_get_last_super_properties
                                                              (TrackerProperty      *property);
 void                tracker_property_reset_super_properties  (TrackerProperty      *property);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]