[tracker] tracker-xmp.c: Use TrackerSparqlBuilder.



commit c388a530264e1e930c6dbeeaabb6f8fa49794ed7
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Nov 5 12:29:50 2009 +0100

    tracker-xmp.c: Use TrackerSparqlBuilder.

 src/tracker-extract/tracker-xmp.c |  108 +++++++++++++++++++++++++------------
 1 files changed, 74 insertions(+), 34 deletions(-)
---
diff --git a/src/tracker-extract/tracker-xmp.c b/src/tracker-extract/tracker-xmp.c
index 093ad37..5003c60 100644
--- a/src/tracker-extract/tracker-xmp.c
+++ b/src/tracker-extract/tracker-xmp.c
@@ -527,11 +527,10 @@ insert_keywords (TrackerSparqlBuilder *metadata, const gchar *uri, gchar *keywor
 	if (keywords[len - 1] == '"')
 		keywords[len - 1] = '\0';
 
-	for (keyw = strtok_r (keywords, ",; ", &lasts); keyw; 
+	for (keyw = strtok_r (keywords, ",; ", &lasts); keyw;
 	     keyw = strtok_r (NULL, ",; ", &lasts)) {
-		tracker_statement_list_insert (metadata, uri, 
-		                               NIE_PREFIX "keyword", 
-		                               (const gchar*) keyw);
+		tracker_sparql_builder_predicate (metadata, "nie:keyword");
+		tracker_sparql_builder_object_unvalidated (metadata, keyw);
 	}
 }
 
@@ -549,131 +548,172 @@ tracker_apply_xmp (TrackerSparqlBuilder *metadata, const gchar *uri, TrackerXmpD
 	}
 
 	if (xmp_data->publisher) {
-		tracker_statement_list_insert (metadata, ":", RDF_PREFIX "type", NCO_PREFIX "Contact");
-		tracker_statement_list_insert (metadata, ":", NCO_PREFIX "fullname", xmp_data->publisher);
-		tracker_statement_list_insert (metadata, uri, NCO_PREFIX "publisher", ":");
+		tracker_sparql_builder_predicate (metadata, "nco:publisher");
+
+		tracker_sparql_builder_object_blank_open (metadata);
+		tracker_sparql_builder_predicate (metadata, "a");
+		tracker_sparql_builder_object (metadata, "nco:Contact");
+
+		tracker_sparql_builder_predicate (metadata, "nco:fullname");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->publisher);
+		tracker_sparql_builder_object_blank_close (metadata);
 		g_free (xmp_data->publisher);
 	}
 
 	if (xmp_data->type) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "type", xmp_data->type);
+		tracker_sparql_builder_predicate (metadata, "dc:type");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->type);
 		g_free (xmp_data->type);
 	}
 
 	if (xmp_data->format) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "format", xmp_data->format);
+		tracker_sparql_builder_predicate (metadata, "dc:format");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->format);
 		g_free (xmp_data->format);
 	}
 
 	if (xmp_data->identifier) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "identifier", xmp_data->identifier);
+		tracker_sparql_builder_predicate (metadata, "dc:identifier");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->identifier);
 		g_free (xmp_data->identifier);
 	}
 
 	if (xmp_data->source) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "source", xmp_data->source);
+		tracker_sparql_builder_predicate (metadata, "dc:source");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->source);
 		g_free (xmp_data->source);
 	}
 
 	if (xmp_data->language) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "language", xmp_data->language);
+		tracker_sparql_builder_predicate (metadata, "dc:language");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->language);
 		g_free (xmp_data->language);
 	}
 
 	if (xmp_data->relation) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "relation", xmp_data->relation);
+		tracker_sparql_builder_predicate (metadata, "dc:relation");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->relation);
 		g_free (xmp_data->relation);
 	}
 
 	if (xmp_data->coverage) {
-		tracker_statement_list_insert (metadata, uri, DC_PREFIX "coverage", xmp_data->coverage);
+		tracker_sparql_builder_predicate (metadata, "dc:coverage");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->coverage);
 		g_free (xmp_data->coverage);
 	}
 
 	if (xmp_data->license) {
-		tracker_statement_list_insert (metadata, uri, NIE_PREFIX "license", xmp_data->license);
+		tracker_sparql_builder_predicate (metadata, "dc:license");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->license);
 		g_free (xmp_data->license);
 	}
 
 	if (xmp_data->Make || xmp_data->Model) {
 		gchar *final_camera = tracker_merge (" ", 2, xmp_data->Make, xmp_data->Model); 
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "camera", final_camera);
+
+		tracker_sparql_builder_predicate (metadata, "nmm:camera");
+		tracker_sparql_builder_object_unvalidated (metadata, final_camera);
 		g_free (final_camera);
 	}
 
 	if (xmp_data->title) {
-		tracker_statement_list_insert (metadata, uri, NIE_PREFIX "title", xmp_data->title);
+		tracker_sparql_builder_predicate (metadata, "nie:title");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->title);
 		g_free (xmp_data->title);
 	}
 
 	if (xmp_data->Orientation) {
-		tracker_statement_list_insert (metadata, uri, NFO_PREFIX "orientation", xmp_data->Orientation);
+		tracker_sparql_builder_predicate (metadata, "nfo:orientation");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->Orientation);
 		g_free (xmp_data->Orientation);
 	}
 
 	if (xmp_data->rights) {
-		tracker_statement_list_insert (metadata, uri, NIE_PREFIX "copyright", xmp_data->rights);
+		tracker_sparql_builder_predicate (metadata, "nie:copyright");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->rights);
 		g_free (xmp_data->rights);
 	}
 
 	if (xmp_data->WhiteBalance) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "whiteBalance", xmp_data->WhiteBalance);
+		tracker_sparql_builder_predicate (metadata, "nmm:whiteBalance");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->WhiteBalance);
 		g_free (xmp_data->WhiteBalance);
 	}
 
 	if (xmp_data->FNumber) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "fnumber", xmp_data->FNumber);
+		tracker_sparql_builder_predicate (metadata, "nmm:fnumber");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->FNumber);
 		g_free (xmp_data->FNumber);
 	}
 
 	if (xmp_data->Flash) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "flash", xmp_data->Flash);
+		tracker_sparql_builder_predicate (metadata, "nmm:flash");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->Flash);
 		g_free (xmp_data->Flash);
 	}
 
 	if (xmp_data->FocalLength) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "focalLength", xmp_data->FocalLength);
+		tracker_sparql_builder_predicate (metadata, "nmm:focalLength");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->FocalLength);
 		g_free (xmp_data->FocalLength);
 	}
 
 	if (xmp_data->Artist || xmp_data->contributor) {
 		gchar *final_artist =  tracker_coalesce (2, xmp_data->Artist, xmp_data->contributor);
-		tracker_statement_list_insert (metadata, ":", RDF_PREFIX "type", NCO_PREFIX "Contact");
-		tracker_statement_list_insert (metadata, ":", NCO_PREFIX "fullname", final_artist);
-		tracker_statement_list_insert (metadata, uri, NCO_PREFIX "contributor", ":");
+
+		tracker_sparql_builder_predicate (metadata, "nco:contributor");
+
+		tracker_sparql_builder_object_blank_open (metadata);
+		tracker_sparql_builder_predicate (metadata, "a");
+		tracker_sparql_builder_object (metadata, "nco:Contact");
+
+		tracker_sparql_builder_predicate (metadata, "nco:fullname");
+		tracker_sparql_builder_object_unvalidated (metadata, final_artist);
+		tracker_sparql_builder_object_blank_close (metadata);
 		g_free (final_artist);
 	}
 
 	if (xmp_data->ExposureTime) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "exposureTime", xmp_data->ExposureTime);
+		tracker_sparql_builder_predicate (metadata, "nmm:exposureTime");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->ExposureTime);
 		g_free (xmp_data->ExposureTime);
 	}
 
 	if (xmp_data->ISOSpeedRatings) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "isoSpeed", xmp_data->ISOSpeedRatings);
+		tracker_sparql_builder_predicate (metadata, "nmm:isoSpeed");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->ISOSpeedRatings);
 		g_free (xmp_data->ISOSpeedRatings);
 	}
 
 	if (xmp_data->date || xmp_data->DateTimeOriginal) {
 		gchar *final_date =  tracker_coalesce (2, xmp_data->date, xmp_data->DateTimeOriginal);
-		tracker_statement_list_insert (metadata, uri, NIE_PREFIX "contentCreated", final_date);
+		tracker_sparql_builder_predicate (metadata, "nie:contentCreated");
+		tracker_sparql_builder_object_unvalidated (metadata, final_date);
 		g_free (final_date);
 	}
 
 	if (xmp_data->description) {
-		tracker_statement_list_insert (metadata, uri, NIE_PREFIX "description", xmp_data->description);
+		tracker_sparql_builder_predicate (metadata, "nie:description");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->description);
 		g_free (xmp_data->description);
 	}
 
 	if (xmp_data->MeteringMode) {
-		tracker_statement_list_insert (metadata, uri, NMM_PREFIX "meteringMode", xmp_data->MeteringMode);
+		tracker_sparql_builder_predicate (metadata, "nmm:meteringMode");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->MeteringMode);
 		g_free (xmp_data->MeteringMode);
 	}
 
 	if (xmp_data->creator) {
-		tracker_statement_list_insert (metadata, ":", RDF_PREFIX "type", NCO_PREFIX "Contact");
-		tracker_statement_list_insert (metadata, ":", NCO_PREFIX "fullname", xmp_data->creator);
-		tracker_statement_list_insert (metadata, uri, NCO_PREFIX "creator", ":");
+		tracker_sparql_builder_predicate (metadata, "nco:creator");
+
+		tracker_sparql_builder_object_blank_open (metadata);
+		tracker_sparql_builder_predicate (metadata, "a");
+		tracker_sparql_builder_object (metadata, "nco:Contact");
+
+		tracker_sparql_builder_predicate (metadata, "nco:fullname");
+		tracker_sparql_builder_object_unvalidated (metadata, xmp_data->creator);
+		tracker_sparql_builder_object_blank_close (metadata);
 		g_free (xmp_data->creator);
 	}
 }



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