[tracker/unsupported-ontology-change] libtracker-data: Support for removing rdfs:subPropertyOf



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

    libtracker-data: Support for removing rdfs:subPropertyOf

 src/libtracker-data/tracker-data-manager.c |   37 ++++++++++++++++++++++------
 src/libtracker-data/tracker-property.c     |   24 ++++++++++++++++++
 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..13ce215 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,38 @@ 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) {
+		while (to_remove) {
+			GError *n_error = NULL;
+			TrackerProperty *prop_to_remove = to_remove->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;
+			}
+
+			to_remove = to_remove->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..7a1ebb2 100644
--- a/src/libtracker-data/tracker-property.c
+++ b/src/libtracker-data/tracker-property.c
@@ -1048,6 +1048,30 @@ tracker_property_add_super_property (TrackerProperty *property,
 	g_array_append_val (priv->super_properties, value);
 }
 
+TrackerProperty**
+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 (TrackerProperty **) priv->super_properties->data;
+		}
+	}
+
+	return (TrackerProperty **) priv->super_properties->data;
+}
+
 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..0039c27 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);
+TrackerProperty   **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]