[tracker/experiment-with-roi] libtracker-extract: Support graph in tracker_xmp_apply_regions()
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/experiment-with-roi] libtracker-extract: Support graph in tracker_xmp_apply_regions()
- Date: Tue, 6 Sep 2011 16:37:03 +0000 (UTC)
commit 3acc9ea01ad6d2db45dfe0df3c70b6abccacf2a6
Author: Martyn Russell <martyn lanedo com>
Date: Tue Sep 6 17:34:41 2011 +0100
libtracker-extract: Support graph in tracker_xmp_apply_regions()
src/libtracker-extract/tracker-xmp.c | 39 ++++++++++++++++-----------
src/libtracker-extract/tracker-xmp.h | 1 +
src/tracker-extract/tracker-extract-jpeg.c | 2 +-
src/tracker-extract/tracker-extract-pdf.c | 2 +-
src/tracker-extract/tracker-extract-tiff.c | 2 +-
tests/libtracker-extract/tracker-test-xmp.c | 18 ++++++------
6 files changed, 36 insertions(+), 28 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index 0e72d68..3db3c2f 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -1179,7 +1179,7 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
if (data->regions) {
- tracker_xmp_apply_regions (preupdate, metadata, where, uri, data);
+ tracker_xmp_apply_regions (preupdate, metadata, graph, where, uri, data);
}
return TRUE;
@@ -1188,12 +1188,12 @@ tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
gboolean
tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
+ const gchar *graph,
GString *where,
const gchar *uri,
TrackerXmpData *data)
{
GSList *iter;
- TrackerXmpRegion *region;
g_return_val_if_fail (TRACKER_SPARQL_IS_BUILDER (preupdate), FALSE);
g_return_val_if_fail (TRACKER_SPARQL_IS_BUILDER (preupdate), FALSE);
@@ -1205,19 +1205,20 @@ tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
}
for (iter = data->regions; iter != NULL; iter = iter->next) {
- gchar *reguuid;
+ TrackerXmpRegion *region;
+ gchar *uuid;
- reguuid = tracker_sparql_get_uuid_urn ();
region = (TrackerXmpRegion *) iter->data;
+ uuid = tracker_sparql_get_uuid_urn ();
- tracker_sparql_builder_predicate (metadata, "nfo:hasRegionOfInterest");
- tracker_sparql_builder_object_iri (metadata, reguuid);
-
- tracker_sparql_builder_insert_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, reguuid);
+ tracker_sparql_builder_insert_open (preupdate, NULL);
+ if (graph) {
+ tracker_sparql_builder_graph_open (preupdate, graph);
+ }
- tracker_sparql_builder_predicate (preupdate, "a");
- tracker_sparql_builder_object (preupdate, "nfo:RegionOfInterest");
+ tracker_sparql_builder_subject_iri (preupdate, uuid);
+ tracker_sparql_builder_predicate (preupdate, "a");
+ tracker_sparql_builder_object (preupdate, "nfo:RegionOfInterest");
if (region->title) {
tracker_sparql_builder_predicate (preupdate, "nie:title");
@@ -1254,12 +1255,9 @@ tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_object_unvalidated (preupdate, region->height);
}
-
- tracker_sparql_builder_insert_close (preupdate);
-
if (region->link_uri && region->link_class) {
tracker_sparql_builder_insert_open (preupdate, NULL);
- tracker_sparql_builder_subject_iri (preupdate, reguuid);
+ tracker_sparql_builder_subject_variable (preupdate, "region");
tracker_sparql_builder_predicate (preupdate, "nfo:roiRefersTo");
tracker_sparql_builder_object_iri (preupdate, region->link_uri);
tracker_sparql_builder_insert_close (preupdate);
@@ -1271,7 +1269,16 @@ tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_where_close (preupdate);
}
- g_free (reguuid);
+ if (graph) {
+ tracker_sparql_builder_graph_close (preupdate);
+ }
+ tracker_sparql_builder_insert_close (preupdate);
+
+ /* Handle non-preupdate metadata */
+ tracker_sparql_builder_predicate (metadata, "nfo:hasRegionOfInterest");
+ tracker_sparql_builder_object_iri (metadata, uuid);
+
+ g_free (uuid);
}
return TRUE;
diff --git a/src/libtracker-extract/tracker-xmp.h b/src/libtracker-extract/tracker-xmp.h
index 54c801b..2703a99 100644
--- a/src/libtracker-extract/tracker-xmp.h
+++ b/src/libtracker-extract/tracker-xmp.h
@@ -118,6 +118,7 @@ gboolean tracker_xmp_apply (TrackerSparqlBuilder *preupdate,
TrackerXmpData *data);
gboolean tracker_xmp_apply_regions (TrackerSparqlBuilder *preupdate,
TrackerSparqlBuilder *metadata,
+ const gchar *graph,
GString *where,
const gchar *uri,
TrackerXmpData *data);
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 37396b8..e25dc84 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -435,7 +435,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
}
if (xd->regions) {
- tracker_xmp_apply_regions (preupdate, metadata, where, uri, xd);
+ tracker_xmp_apply_regions (preupdate, metadata, graph, where, uri, xd);
}
if (id->keywords) {
diff --git a/src/tracker-extract/tracker-extract-pdf.c b/src/tracker-extract/tracker-extract-pdf.c
index cd2f31b..c762329 100644
--- a/src/tracker-extract/tracker-extract-pdf.c
+++ b/src/tracker-extract/tracker-extract-pdf.c
@@ -599,7 +599,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
}
if (xd->regions) {
- tracker_xmp_apply_regions (preupdate, metadata, where, uri, xd);
+ tracker_xmp_apply_regions (preupdate, metadata, graph, NULL, uri, xd);
}
tracker_xmp_free (xd);
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index 1851e23..a95b1d3 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -487,7 +487,7 @@ tracker_extract_get_metadata (TrackerExtractInfo *info)
}
if (xd->regions) {
- tracker_xmp_apply_regions (preupdate, metadata, where, uri, xd);
+ tracker_xmp_apply_regions (preupdate, metadata, graph, NULL, uri, xd);
}
if (md.address || md.state || md.country || md.city ||
diff --git a/tests/libtracker-extract/tracker-test-xmp.c b/tests/libtracker-extract/tracker-test-xmp.c
index a9624e6..715c1cc 100644
--- a/tests/libtracker-extract/tracker-test-xmp.c
+++ b/tests/libtracker-extract/tracker-test-xmp.c
@@ -387,10 +387,10 @@ test_xmp_regions (void)
data = tracker_xmp_new (contents, size, "test://file");
- g_assert_cmpint (2, ==, g_list_length (data->regions));
+ g_assert_cmpint (2, ==, g_slist_length (data->regions));
/* Regions are stacked while parsing.*/
- region = g_list_nth_data (data->regions, 0);
+ region = g_slist_nth_data (data->regions, 0);
g_assert_cmpstr (region->x, ==, "0.51");
g_assert_cmpstr (region->y, ==, "0.51");
g_assert_cmpstr (region->width, ==, "0.01");
@@ -399,7 +399,7 @@ test_xmp_regions (void)
g_assert_cmpstr (region->title, ==, "Fido");
g_assert_cmpstr (region->description, ==, "Fido looks happy!");
- region = g_list_nth_data (data->regions, 1);
+ region = g_slist_nth_data (data->regions, 1);
g_assert_cmpstr (region->x, ==, "0.5");
g_assert_cmpstr (region->y, ==, "0.5");
g_assert_cmpstr (region->width, ==, "0.06");
@@ -430,9 +430,9 @@ test_xmp_regions_quill (void)
data = tracker_xmp_new (contents, size, "test://file");
- g_assert_cmpint (2, ==, g_list_length (data->regions));
+ g_assert_cmpint (2, ==, g_slist_length (data->regions));
- region = g_list_nth_data (data->regions, 0);
+ region = g_slist_nth_data (data->regions, 0);
g_assert_cmpstr (region->x, ==, "0.4");
g_assert_cmpstr (region->y, ==, "0.3");
g_assert_cmpstr (region->width, ==, "0.17");
@@ -442,7 +442,7 @@ test_xmp_regions_quill (void)
g_assert_cmpstr (region->link_class, ==, "nco:PersonContact");
g_assert_cmpstr (region->link_uri, ==, "urn:uuid:2");
- region = g_list_nth_data (data->regions, 1);
+ region = g_slist_nth_data (data->regions, 1);
g_assert_cmpstr (region->x, ==, "0.3");
g_assert_cmpstr (region->y, ==, "0.4");
g_assert_cmpstr (region->width, ==, "0.15");
@@ -473,10 +473,10 @@ test_xmp_regions_ns_prefix (void)
data = tracker_xmp_new (contents, size, "test://file");
- g_assert_cmpint (2, ==, g_list_length (data->regions));
+ g_assert_cmpint (2, ==, g_slist_length (data->regions));
/* Regions are stacked while parsing.*/
- region = g_list_nth_data (data->regions, 0);
+ region = g_slist_nth_data (data->regions, 0);
g_assert_cmpstr (region->x, ==, "0.51");
g_assert_cmpstr (region->y, ==, "0.51");
g_assert_cmpstr (region->width, ==, "0.01");
@@ -485,7 +485,7 @@ test_xmp_regions_ns_prefix (void)
g_assert_cmpstr (region->title, ==, "Fidoz");
g_assert_cmpstr (region->description, ==, "Fido looks happy!");
- region = g_list_nth_data (data->regions, 1);
+ region = g_slist_nth_data (data->regions, 1);
g_assert_cmpstr (region->x, ==, "0.5");
g_assert_cmpstr (region->y, ==, "0.5");
g_assert_cmpstr (region->width, ==, "0.06");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]