[tracker/wip/extract-graphs: 30/30] tracker-extract, libtracker-extract, xmp: Do all inserts in miner-fs's graph



commit b7de36a557a7cfb68a9d39707837bfe87ba62843
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Sep 6 11:04:12 2011 +0200

    tracker-extract, libtracker-extract, xmp: Do all inserts in miner-fs's graph

 src/libtracker-extract/tracker-xmp.c      |   28 +++++++++++++++++++++++++++-
 src/libtracker-extract/tracker-xmp.h      |    1 +
 src/tracker-extract/tracker-extract-xmp.c |    4 +++-
 3 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index 9a39b90..96a1a77 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -700,7 +700,10 @@ tracker_xmp_free (TrackerXmpData *data)
 
 /**
  * tracker_xmp_apply:
+ * @preupdate: the preupdate object to apply XMP data to.
  * @metadata: the metadata object to apply XMP data to.
+ * @graph: the graph to apply XMP data to
+ * @where: the where object
  * @uri: the URI this is related to.
  * @data: the data to push into @metadata.
  *
@@ -714,6 +717,7 @@ tracker_xmp_free (TrackerXmpData *data)
 gboolean
 tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
                    TrackerSparqlBuilder *metadata,
+                   const gchar          *graph,
                    GString              *where,
                    const gchar          *uri,
                    TrackerXmpData       *data)
@@ -748,8 +752,21 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
 
 		/* ensure tag with specified label exists */
 		tracker_sparql_builder_append (preupdate,
-		                               "INSERT { _:tag a nao:Tag ; nao:prefLabel \"");
+		                               "INSERT { ");
+
+		if (graph) {
+			tracker_sparql_builder_append (preupdate, "GRAPH <");
+			tracker_sparql_builder_append (preupdate, graph);
+			tracker_sparql_builder_append (preupdate, "> { ");
+		}
+
+		tracker_sparql_builder_append (preupdate,"_:tag a nao:Tag ; nao:prefLabel \"");
 		tracker_sparql_builder_append (preupdate, escaped);
+
+		if (graph) {
+			tracker_sparql_builder_append (preupdate, " } ");
+		}
+
 		tracker_sparql_builder_append (preupdate,
 		                               "\" }\nWHERE { FILTER (NOT EXISTS { "
 		                               "?tag a nao:Tag ; nao:prefLabel \"");
@@ -829,6 +846,10 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
 		                                              data->model ? data->model : "");
 
 		tracker_sparql_builder_insert_open (preupdate, NULL);
+		if (graph) {
+			tracker_sparql_builder_graph_open (preupdate, graph);
+		}
+
 		tracker_sparql_builder_subject_iri (preupdate, equip_uri);
 		tracker_sparql_builder_predicate (preupdate, "a");
 		tracker_sparql_builder_object (preupdate, "nfo:Equipment");
@@ -841,7 +862,12 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
 			tracker_sparql_builder_predicate (preupdate, "nfo:model");
 			tracker_sparql_builder_object_unvalidated (preupdate, data->model);
 		}
+
+		if (graph) {
+			tracker_sparql_builder_graph_close (preupdate);
+		}
 		tracker_sparql_builder_insert_close (preupdate);
+
 		tracker_sparql_builder_predicate (metadata, "nfo:equipment");
 		tracker_sparql_builder_object_iri (metadata, equip_uri);
 		g_free (equip_uri);
diff --git a/src/libtracker-extract/tracker-xmp.h b/src/libtracker-extract/tracker-xmp.h
index 1aa2c57..824cf88 100644
--- a/src/libtracker-extract/tracker-xmp.h
+++ b/src/libtracker-extract/tracker-xmp.h
@@ -98,6 +98,7 @@ TrackerXmpData * tracker_xmp_new   (const gchar          *buffer,
 void             tracker_xmp_free  (TrackerXmpData       *data);
 gboolean         tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
                                     TrackerSparqlBuilder *metadata,
+                                    const gchar          *graph,
                                     GString              *where,
                                     const gchar          *uri,
                                     TrackerXmpData       *data);
diff --git a/src/tracker-extract/tracker-extract-xmp.c b/src/tracker-extract/tracker-extract-xmp.c
index ae4a10c..13a2954 100644
--- a/src/tracker-extract/tracker-extract-xmp.c
+++ b/src/tracker-extract/tracker-extract-xmp.c
@@ -129,11 +129,13 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
 	gchar *contents;
 	gsize length;
 	GFile *file;
+	const gchar *graph;
 
 	file = tracker_extract_info_get_file (info);
 	filename = g_file_get_path (file);
 	uri = g_file_get_uri (file);
 
+	graph = tracker_extract_info_get_graph (info);
 	preupdate = tracker_extract_info_get_preupdate_builder (info);
 	metadata = tracker_extract_info_get_metadata_builder (info);
 
@@ -153,7 +155,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
 			GString *where;
 
 			where = g_string_new ("");
-			tracker_xmp_apply (preupdate, metadata, where, uri, xd);
+			tracker_xmp_apply (preupdate, metadata, graph, where, uri, xd);
 			tracker_extract_info_set_where_clause (info,
 			                                       g_string_free (where, FALSE));
 		}



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