[tracker/merge: 8/8] SPARQL: Remove DROP GRAPH support



commit 2c40241c5fc918c5e64a90c05d0b053a802088a7
Author: Jürg Billeter <j bitron ch>
Date:   Wed Jun 9 16:47:02 2010 +0200

    SPARQL: Remove DROP GRAPH support
    
    The DROP GRAPH implementation was not conforming to the SPARQL
    specification and the miner no longer uses it.

 data/ontologies/11-rdf.ontology               |   13 +--
 data/ontologies/30-nie.ontology               |    1 -
 data/ontologies/31-nao.ontology               |    3 +-
 docs/tools/ontology-graph.c                   |   12 --
 src/libtracker-data/libtracker-data.vapi      |    1 -
 src/libtracker-data/tracker-data-manager.c    |   36 +----
 src/libtracker-data/tracker-data-update.c     |  232 -------------------------
 src/libtracker-data/tracker-data-update.h     |    3 -
 src/libtracker-data/tracker-property.c        |   27 ---
 src/libtracker-data/tracker-property.h        |    3 -
 src/libtracker-data/tracker-sparql-query.vala |   22 +--
 11 files changed, 11 insertions(+), 342 deletions(-)
---
diff --git a/data/ontologies/11-rdf.ontology b/data/ontologies/11-rdf.ontology
index 5d02162..2fd7077 100644
--- a/data/ontologies/11-rdf.ontology
+++ b/data/ontologies/11-rdf.ontology
@@ -101,12 +101,6 @@ tracker:transient a rdf:Property ;
 	rdfs:domain rdf:Property ;
 	rdfs:range xsd:boolean .
 
-tracker:isAnnotation a rdf:Property ;
-        rdfs:comment "The property is never embedded on physical files" ;
-	nrl:maxCardinality 1 ;
-	rdfs:domain rdf:Property ;
-	rdfs:range xsd:boolean .
-
 tracker:weight a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain rdf:Property ;
@@ -120,13 +114,10 @@ tracker:defaultValue a rdf:Property ;
 tracker:added a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain rdfs:Resource ;
-	rdfs:range xsd:dateTime ;
-	tracker:isAnnotation true .
+	rdfs:range xsd:dateTime .
 
 # implicitly updated modification time
 tracker:modified a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain rdfs:Resource ;
-	rdfs:range xsd:integer ;
-	tracker:isAnnotation true .
-
+	rdfs:range xsd:integer .
diff --git a/data/ontologies/30-nie.ontology b/data/ontologies/30-nie.ontology
index 5729a19..b24e5b8 100644
--- a/data/ontologies/30-nie.ontology
+++ b/data/ontologies/30-nie.ontology
@@ -268,7 +268,6 @@ nie:usageCounter a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nie:InformationElement ;
 	rdfs:range xsd:integer ;
-	tracker:isAnnotation true ;
 	tracker:weight 3 .
 
 nie:url a rdf:Property ;
diff --git a/data/ontologies/31-nao.ontology b/data/ontologies/31-nao.ontology
index 3701999..68856b9 100644
--- a/data/ontologies/31-nao.ontology
+++ b/data/ontologies/31-nao.ontology
@@ -36,8 +36,7 @@ nao:hasTag a rdf:Property ;
 	rdfs:domain rdfs:Resource ;
 	rdfs:range rdfs:Resource ;
 	tracker:writeback true ;
-	tracker:indexed true ;
-	tracker:isAnnotation true .
+	tracker:indexed true .
 
 nao:identifier a rdf:Property ;
 	nrl:maxCardinality 1 ;
diff --git a/docs/tools/ontology-graph.c b/docs/tools/ontology-graph.c
index 78b6a9c..b95b4d6 100644
--- a/docs/tools/ontology-graph.c
+++ b/docs/tools/ontology-graph.c
@@ -252,18 +252,6 @@ load_ontology_file_from_path (const gchar	 *ontology_file)
 			if (g_strcmp0 (object, "true") == 0) {
 				tracker_property_set_transient (property, TRUE);
 			}
-		} else if (g_strcmp0 (predicate, TRACKER_PREFIX "isAnnotation") == 0) {
-			TrackerProperty *property;
-
-			property = tracker_ontologies_get_property_by_uri (subject);
-			if (property == NULL) {
-				g_critical ("%s: Unknown property %s", ontology_file, subject);
-				continue;
-			}
-
-			if (g_strcmp0 (object, "true") == 0) {
-				tracker_property_set_embedded (property, FALSE);
-			}
 		} else if (g_strcmp0 (predicate, TRACKER_PREFIX "fulltextIndexed") == 0) {
 			TrackerProperty *property;
 
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 6a0afe9..e1b2730 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -84,7 +84,6 @@ namespace Tracker {
 		public void insert_statement (string graph, string subject, string predicate, string object) throws DataError, DateError;
 		public void insert_statement_with_uri (string graph, string subject, string predicate, string object) throws DataError;
 		public void insert_statement_with_string (string graph, string subject, string predicate, string object) throws DataError, DateError;
-		public void delete_resource_description (string graph, string uri) throws DataError;
 		public void update_buffer_flush () throws DBInterfaceError;
 		public void update_buffer_might_flush () throws DBInterfaceError;
 	}
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 5acedee..5eeab0e 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -645,22 +645,6 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
 		if (g_strcmp0 (object, "true") == 0) {
 			tracker_property_set_transient (property, TRUE);
 		}
-	} else if (g_strcmp0 (predicate, TRACKER_PREFIX "isAnnotation") == 0) {
-		TrackerProperty *property;
-
-		property = tracker_ontologies_get_property_by_uri (subject);
-		if (property == NULL) {
-			g_critical ("%s: Unknown property %s", ontology_path, subject);
-			return;
-		}
-
-		if (tracker_property_get_is_new (property) != in_update) {
-			return;
-		}
-
-		if (g_strcmp0 (object, "true") == 0) {
-			tracker_property_set_embedded (property, FALSE);
-		}
 	} else if (g_strcmp0 (predicate, TRACKER_PREFIX "fulltextIndexed") == 0) {
 		TrackerProperty *property;
 
@@ -1094,7 +1078,6 @@ tracker_data_ontology_process_statement (const gchar *graph,
 	           g_strcmp0 (predicate, NRL_MAX_CARDINALITY) == 0           ||
 	           g_strcmp0 (predicate, TRACKER_PREFIX "indexed") == 0      ||
 	           g_strcmp0 (predicate, TRACKER_PREFIX "transient") == 0    ||
-	           g_strcmp0 (predicate, TRACKER_PREFIX "isAnnotation") == 0 ||
 	           g_strcmp0 (predicate, TRACKER_PREFIX "fulltextIndexed") == 0) {
 		TrackerProperty *prop;
 
@@ -1430,7 +1413,6 @@ db_get_static_data (TrackerDBInterface *iface)
 	                                              "\"tracker:fulltextIndexed\", "
 	                                              "\"tracker:fulltextNoLimit\", "
 	                                              "\"tracker:transient\", "
-	                                              "\"tracker:isAnnotation\", "
 	                                              "\"tracker:writeback\", "
 	                                              "(SELECT 1 FROM \"rdfs:Resource_rdf:type\" WHERE ID = \"rdf:Property\".ID AND "
 	                                              "\"rdf:type\" = (SELECT ID FROM Resource WHERE Uri = '" NRL_INVERSE_FUNCTIONAL_PROPERTY "')), "
@@ -1448,7 +1430,7 @@ db_get_static_data (TrackerDBInterface *iface)
 			TrackerProperty *property;
 			const gchar     *uri, *domain_uri, *range_uri, *secondary_index_uri, *default_value;
 			gboolean         multi_valued, indexed, fulltext_indexed, fulltext_no_limit;
-			gboolean         transient, annotation, is_inverse_functional_property;
+			gboolean         transient, is_inverse_functional_property;
 			gboolean         writeback;
 			gint             id;
 
@@ -1512,19 +1494,8 @@ db_get_static_data (TrackerDBInterface *iface)
 				transient = FALSE;
 			}
 
-			tracker_db_cursor_get_value (cursor, 10, &value);
-
-			if (G_VALUE_TYPE (&value) != 0) {
-				annotation = (g_value_get_int (&value) == 1);
-				g_value_unset (&value);
-			} else {
-				/* NULL */
-				annotation = FALSE;
-			}
-
-
 			/* tracker:writeback column */
-			tracker_db_cursor_get_value (cursor, 11, &value);
+			tracker_db_cursor_get_value (cursor, 10, &value);
 
 			if (G_VALUE_TYPE (&value) != 0) {
 				writeback = (g_value_get_int (&value) == 1);
@@ -1535,7 +1506,7 @@ db_get_static_data (TrackerDBInterface *iface)
 			}
 
 			/* NRL_INVERSE_FUNCTIONAL_PROPERTY column */
-			tracker_db_cursor_get_value (cursor, 12, &value);
+			tracker_db_cursor_get_value (cursor, 11, &value);
 
 			if (G_VALUE_TYPE (&value) != 0) {
 				is_inverse_functional_property = TRUE;
@@ -1566,7 +1537,6 @@ db_get_static_data (TrackerDBInterface *iface)
 
 			tracker_property_set_fulltext_indexed (property, fulltext_indexed);
 			tracker_property_set_fulltext_no_limit (property, fulltext_no_limit);
-			tracker_property_set_embedded (property, !annotation);
 			tracker_property_set_is_inverse_functional_property (property, is_inverse_functional_property);
 			property_add_super_properties_from_db (iface, property);
 
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 0ae6391..ea9a230 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2121,238 +2121,6 @@ format_sql_value_as_string (GString         *sql,
 	}
 }
 
-/**
- * Removes the description of a resource (embedded metadata), but keeps
- * annotations (non-embedded/user metadata) stored about the resource.
- */
-void
-tracker_data_delete_resource_description (const gchar *graph,
-                                          const gchar *url,
-                                          GError **error)
-{
-	TrackerDBInterface *iface;
-	TrackerDBStatement *stmt;
-	TrackerDBResultSet *result_set = NULL, *single_result, *multi_result = NULL;
-	TrackerClass       *class;
-	gchar              *urn;
-	GString            *sql;
-	TrackerProperty   **properties, *property;
-	int                 i;
-	gboolean            first, bail_out = FALSE;
-	gint                resource_id;
-	guint               p, n_props;
-	GError             *actual_error = NULL;
-
-	/* We use result_sets instead of cursors here because it's possible
-	 * that otherwise the query of the outer cursor would be reused by the
-	 * cursors of the inner queries. */
-
-	iface = tracker_db_manager_get_db_interface ();
-
-	/* DROP GRAPH <url> - url here is nie:url */
-
-	stmt = tracker_db_interface_create_statement (iface, &actual_error,
-	                                              "SELECT ID, (SELECT Uri FROM Resource WHERE ID = \"nie:DataObject\".ID) FROM \"nie:DataObject\" WHERE \"nie:DataObject\".\"nie:url\" = ?");
-
-	if (stmt) {
-		tracker_db_statement_bind_text (stmt, 0, url);
-		result_set = tracker_db_statement_execute (stmt, &actual_error);
-		g_object_unref (stmt);
-	}
-
-	if (actual_error) {
-		g_propagate_error (error, actual_error);
-		return;
-	}
-
-	if (result_set) {
-		tracker_db_result_set_get (result_set, 0, &resource_id, -1);
-		tracker_db_result_set_get (result_set, 1, &urn, -1);
-		g_object_unref (result_set);
-	} else {
-		/* For fallback to the old behaviour, we could do this here:
-		 * resource_id = tracker_data_query_resource_id (url); */
-		return;
-	}
-
-	properties = tracker_ontologies_get_properties (&n_props);
-
-	stmt = tracker_db_interface_create_statement (iface, &actual_error,
-	                                              "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
-
-	if (stmt) {
-		tracker_db_statement_bind_int (stmt, 0, resource_id);
-		result_set = tracker_db_statement_execute (stmt, &actual_error);
-		g_object_unref (stmt);
-	}
-
-	if (actual_error) {
-		g_propagate_error (error, actual_error);
-		return;
-	}
-
-	if (result_set) {
-		do {
-			gchar *class_uri;
-
-			tracker_db_result_set_get (result_set, 0, &class_uri, -1);
-
-			class = tracker_ontologies_get_class_by_uri (class_uri);
-
-			if (class == NULL) {
-				g_warning ("Class '%s' not found in the ontology", class_uri);
-				g_free (class_uri);
-				continue;
-			}
-			g_free (class_uri);
-
-			/* retrieve single value properties for current class */
-
-			sql = g_string_new ("SELECT ");
-
-			first = TRUE;
-
-			for (p = 0; p < n_props; p++) {
-				property = properties[p];
-
-				if (tracker_property_get_domain (property) == class) {
-					if (!tracker_property_get_embedded (property)) {
-						continue;
-					}
-
-					if (!tracker_property_get_multiple_values (property)) {
-						if (!first) {
-							g_string_append (sql, ", ");
-						}
-						first = FALSE;
-
-						format_sql_value_as_string (sql, property);
-					}
-				}
-			}
-
-			single_result = NULL;
-			if (!first) {
-				g_string_append_printf (sql, " FROM \"%s\" WHERE ID = ?", tracker_class_get_name (class));
-				stmt = tracker_db_interface_create_statement (iface, &actual_error, "%s", sql->str);
-
-				if (stmt) {
-					tracker_db_statement_bind_int (stmt, 0, resource_id);
-					single_result = tracker_db_statement_execute (stmt, &actual_error);
-					g_object_unref (stmt);
-				}
-
-				if (actual_error) {
-					g_propagate_error (error, actual_error);
-					bail_out = TRUE;
-					break;
-				}
-			}
-
-			g_string_free (sql, TRUE);
-
-			i = 0;
-			for (p = 0; p < n_props; p++) {
-				property = properties[p];
-
-				if (tracker_property_get_domain (property) != class) {
-					continue;
-				}
-
-				if (!tracker_property_get_embedded (property)) {
-					continue;
-				}
-
-				if (strcmp (tracker_property_get_uri (property), RDF_PREFIX "type") == 0) {
-					/* Do not delete rdf:type statements */
-					continue;
-				}
-
-				if (!tracker_property_get_multiple_values (property)) {
-					gchar *value;
-
-					/* single value property, value in single_result_set */
-
-					tracker_db_result_set_get (single_result, i++, &value, -1);
-
-					if (value) {
-						tracker_data_delete_statement (graph, urn,
-						                               tracker_property_get_uri (property),
-						                               value,
-						                               &actual_error);
-						if (actual_error) {
-							g_propagate_error (error, actual_error);
-							bail_out = TRUE;
-							break;
-						}
-						g_free (value);
-					}
-
-				} else {
-					/* multi value property, retrieve values from DB */
-
-					sql = g_string_new ("SELECT ");
-
-					format_sql_value_as_string (sql, property);
-
-					g_string_append_printf (sql,
-					                        " FROM \"%s\" WHERE ID = ?",
-					                        tracker_property_get_table_name (property));
-
-					stmt = tracker_db_interface_create_statement (iface, &actual_error, "%s", sql->str);
-
-					if (stmt) {
-						tracker_db_statement_bind_int (stmt, 0, resource_id);
-						multi_result = tracker_db_statement_execute (stmt, NULL);
-						g_object_unref (stmt);
-					}
-
-					if (actual_error) {
-						g_propagate_error (error, actual_error);
-						bail_out = TRUE;
-						break;
-					}
-
-					if (multi_result) {
-						do {
-							gchar *value;
-
-							tracker_db_result_set_get (multi_result, 0, &value, -1);
-
-							tracker_data_delete_statement (graph, urn,
-							                               tracker_property_get_uri (property),
-							                               value,
-							                               &actual_error);
-
-							g_free (value);
-
-							if (actual_error) {
-								g_propagate_error (error, actual_error);
-								bail_out = TRUE;
-								break;
-							}
-
-						} while (tracker_db_result_set_iter_next (multi_result));
-
-						g_object_unref (multi_result);
-					}
-
-					g_string_free (sql, TRUE);
-				}
-			}
-
-			if (!first) {
-				g_object_unref (single_result);
-			}
-
-		} while (!bail_out && tracker_db_result_set_iter_next (result_set));
-
-		g_object_unref (result_set);
-	}
-
-	g_free (urn);
-}
-
 void
 tracker_data_begin_transaction (GError **error)
 {
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 11444f9..54643f1 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -57,9 +57,6 @@ typedef void (*TrackerBusyCallback)      (const gchar *status,
 GQuark   tracker_data_error_quark                   (void);
 
 /* Metadata */
-void     tracker_data_delete_resource_description   (const gchar               *graph,
-                                                     const gchar               *url,
-                                                     GError                   **error);
 void     tracker_data_delete_statement              (const gchar               *graph,
                                                      const gchar               *subject,
                                                      const gchar               *predicate,
diff --git a/src/libtracker-data/tracker-property.c b/src/libtracker-data/tracker-property.c
index 9e8ad3a..f43652c 100644
--- a/src/libtracker-data/tracker-property.c
+++ b/src/libtracker-data/tracker-property.c
@@ -54,7 +54,6 @@ struct _TrackerPropertyPrivate {
 	TrackerProperty *secondary_index;
 	gboolean       fulltext_indexed;
 	gboolean       fulltext_no_limit;
-	gboolean       embedded;
 	gboolean       multiple_values;
 	gboolean       transient;
 	gboolean       is_inverse_functional_property;
@@ -129,7 +128,6 @@ tracker_property_init (TrackerProperty *property)
 
 	priv->id = 0;
 	priv->weight = 1;
-	priv->embedded = TRUE;
 	priv->transient = FALSE;
 	priv->multiple_values = TRUE;
 	priv->super_properties = g_array_new (TRUE, TRUE, sizeof (TrackerProperty *));
@@ -395,18 +393,6 @@ tracker_property_get_db_schema_changed (TrackerProperty *property)
 }
 
 gboolean
-tracker_property_get_embedded (TrackerProperty *property)
-{
-	TrackerPropertyPrivate *priv;
-
-	g_return_val_if_fail (TRACKER_IS_PROPERTY (property), FALSE);
-
-	priv = GET_PRIV (property);
-
-	return priv->embedded;
-}
-
-gboolean
 tracker_property_get_multiple_values (TrackerProperty *property)
 {
 	TrackerPropertyPrivate *priv;
@@ -689,19 +675,6 @@ tracker_property_set_fulltext_no_limit (TrackerProperty *property,
 }
 
 void
-tracker_property_set_embedded (TrackerProperty *property,
-                               gboolean         value)
-{
-	TrackerPropertyPrivate *priv;
-
-	g_return_if_fail (TRACKER_IS_PROPERTY (property));
-
-	priv = GET_PRIV (property);
-
-	priv->embedded = value;
-}
-
-void
 tracker_property_set_multiple_values (TrackerProperty *property,
                                       gboolean         value)
 {
diff --git a/src/libtracker-data/tracker-property.h b/src/libtracker-data/tracker-property.h
index 5ee3561..4441e20 100644
--- a/src/libtracker-data/tracker-property.h
+++ b/src/libtracker-data/tracker-property.h
@@ -86,7 +86,6 @@ gboolean            tracker_property_get_indexed           (TrackerProperty
 TrackerProperty *   tracker_property_get_secondary_index   (TrackerProperty      *property);
 gboolean            tracker_property_get_fulltext_indexed  (TrackerProperty      *property);
 gboolean            tracker_property_get_fulltext_no_limit (TrackerProperty      *property);
-gboolean            tracker_property_get_embedded          (TrackerProperty      *property);
 gboolean            tracker_property_get_multiple_values   (TrackerProperty      *property);
 gboolean            tracker_property_get_transient         (TrackerProperty      *property);
 gboolean            tracker_property_get_is_new            (TrackerProperty      *property);
@@ -114,8 +113,6 @@ void                tracker_property_set_fulltext_indexed  (TrackerProperty
                                                             gboolean              value);
 void                tracker_property_set_fulltext_no_limit (TrackerProperty      *property,
                                                             gboolean              value);
-void                tracker_property_set_embedded          (TrackerProperty      *property,
-                                                            gboolean              value);
 void                tracker_property_set_multiple_values   (TrackerProperty      *property,
                                                             gboolean              value);
 void                tracker_property_set_transient         (TrackerProperty      *property,
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 4eba6d5..666ad59 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -410,8 +410,9 @@ public class Tracker.Sparql.Query : Object {
 			return execute_ask ();
 		case SparqlTokenType.INSERT:
 		case SparqlTokenType.DELETE:
-		case SparqlTokenType.DROP:
 			throw get_error ("INSERT and DELETE are not supported in query mode");
+		case SparqlTokenType.DROP:
+			throw get_internal_error ("DROP GRAPH is not supported");
 		default:
 			throw get_error ("expected SELECT or ASK");
 		}
@@ -433,8 +434,9 @@ public class Tracker.Sparql.Query : Object {
 			return execute_ask_cursor ();
 		case SparqlTokenType.INSERT:
 		case SparqlTokenType.DELETE:
-		case SparqlTokenType.DROP:
 			throw get_error ("INSERT and DELETE are not supported in query mode");
+		case SparqlTokenType.DROP:
+			throw get_internal_error ("DROP GRAPH is not supported");
 		default:
 			throw get_error ("expected SELECT or ASK");
 		}
@@ -477,8 +479,7 @@ public class Tracker.Sparql.Query : Object {
 				}
 				break;
 			case SparqlTokenType.DROP:
-				execute_drop_graph ();
-				break;
+				throw get_internal_error ("DROP GRAPH is not supported");
 			case SparqlTokenType.SELECT:
 			case SparqlTokenType.CONSTRUCT:
 			case SparqlTokenType.DESCRIBE:
@@ -732,19 +733,6 @@ public class Tracker.Sparql.Query : Object {
 		return update_blank_nodes;
 	}
 
-	void execute_drop_graph () throws DBInterfaceError, DataError, SparqlError {
-		expect (SparqlTokenType.DROP);
-		expect (SparqlTokenType.GRAPH);
-
-		bool is_var;
-		string url = pattern.parse_var_or_term (null, out is_var);
-
-		Data.delete_resource_description (url, url);
-
-		// ensure possible WHERE clause in next part gets the correct results
-		Data.update_buffer_flush ();
-	}
-
 	internal string resolve_prefixed_name (string prefix, string local_name) throws SparqlError {
 		string ns = prefix_map.lookup (prefix);
 		if (ns == null) {



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