[tracker] tracker-extract: Fixed mock up extractor to use TrackerSparqlBuilder



commit c6d901d014ebd2b22723cc7fa735e2725185fa3c
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Nov 4 16:14:35 2009 +0000

    tracker-extract: Fixed mock up extractor to use TrackerSparqlBuilder

 src/tracker-extract/tracker-extract-mockup.c |   59 ++++++++++++++++----------
 1 files changed, 37 insertions(+), 22 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-mockup.c b/src/tracker-extract/tracker-extract-mockup.c
index 23182ed..a68647a 100644
--- a/src/tracker-extract/tracker-extract-mockup.c
+++ b/src/tracker-extract/tracker-extract-mockup.c
@@ -20,30 +20,16 @@
 
 #include "config.h"
 
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-#include <png.h>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-
-#include <libtracker-common/tracker-file-utils.h>
 #include <libtracker-common/tracker-statement-list.h>
-#include <libtracker-common/tracker-type-utils.h>
 
 #include "tracker-main.h"
 
-static void extract_mockup (const gchar *uri,
-			    TrackerSparqlBuilder   *metadata);
+static void extract_mockup (const gchar          *uri,
+			    TrackerSparqlBuilder *metadata);
 
 typedef struct {
-	gchar	     *key;
-	gchar        *value;
+	gchar *key;
+	gchar *value;
 } MockupTag;
 
 static MockupTag tags[] = {
@@ -54,6 +40,8 @@ static MockupTag tags[] = {
 	{ "Audio:Genre", "Genre" },
 	{ "Image:Location", "Here" },
 	{ "Image:Software", "Softa" },
+	{ "Image:Height", "480" },
+	{ "Image:ExposureTime", "0.223" },
 	{ NULL, NULL }
 };
 
@@ -65,13 +53,40 @@ static TrackerExtractData data[] = {
 };
 
 static void
-extract_mockup (const gchar *uri,
-		TrackerSparqlBuilder   *metadata)
+extract_mockup (const gchar           *uri,
+		TrackerSparqlBuilder  *metadata)
 {
 	MockupTag *p;
 
-	for (p=tags;p->key;++p) {		
-		tracker_statement_list_insert (metadata, uri, p->key, p->value);
+	tracker_sparql_builder_subject_iri (metadata, uri);
+	tracker_sparql_builder_predicate (metadata, "a");
+	tracker_sparql_builder_object (metadata, "nfo:Document");
+
+	for (p = tags; p->key; ++p) {
+		if (!p->key) {
+			continue;
+		}
+
+		if (strcmp (p->key, "Image:Height") == 0) {
+			gint64 value;
+
+			value = g_ascii_strtoll (p->value, NULL, 10);
+			tracker_sparql_builder_predicate (metadata, p->key);
+			tracker_sparql_builder_object_int64 (metadata, value);
+		} else if (strcmp (p->key, "Image:ExposureTime") == 0) {
+			gdouble value;
+
+			value = g_strtod (p->value, NULL);
+			tracker_sparql_builder_predicate (metadata, p->key);
+			tracker_sparql_builder_object_double (metadata, value);
+		} else {
+			/* If property is a raw string undefined in
+			 * ontology use object_unvalidated() API, otherwise,
+			 * just _object() API:
+			 */
+			tracker_sparql_builder_predicate (metadata, p->key);
+			tracker_sparql_builder_object_unvalidated (metadata, p->value);
+		}
 	}
 }
 



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