[tracker/equipment-onto: 3/3] tracker-extract, libtracker-extract: Adapted extractors to nfo:Equipment ontology change
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/equipment-onto: 3/3] tracker-extract, libtracker-extract: Adapted extractors to nfo:Equipment ontology change
- Date: Tue, 7 Sep 2010 09:58:48 +0000 (UTC)
commit dfdca96df57fe2c2b04743a646c61a3dcc0d09b5
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Sep 7 11:52:07 2010 +0200
tracker-extract, libtracker-extract: Adapted extractors to nfo:Equipment ontology change
src/libtracker-extract/tracker-xmp.c | 18 +++++++---
src/tracker-extract/tracker-extract-gif.c | 31 ++++++++--------
src/tracker-extract/tracker-extract-gstreamer.c | 35 ++++++++----------
src/tracker-extract/tracker-extract-gupnp-dlna.c | 36 ++++++++-----------
src/tracker-extract/tracker-extract-jpeg.c | 41 +++++++++------------
src/tracker-extract/tracker-extract-pdf.cpp | 23 ++++++------
src/tracker-extract/tracker-extract-png.c | 40 +++++++++------------
src/tracker-extract/tracker-extract-tiff.c | 33 +++++++++--------
src/tracker-writeback/tracker-writeback-xmp.c | 1 +
9 files changed, 126 insertions(+), 132 deletions(-)
---
diff --git a/src/libtracker-extract/tracker-xmp.c b/src/libtracker-extract/tracker-xmp.c
index 872ec1d..4a3f752 100644
--- a/src/libtracker-extract/tracker-xmp.c
+++ b/src/libtracker-extract/tracker-xmp.c
@@ -750,11 +750,19 @@ tracker_xmp_apply (TrackerSparqlBuilder *metadata,
}
if (data->make || data->model) {
- gchar *final_camera = tracker_merge_const (" ", 2, data->make, data->model);
-
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, final_camera);
- g_free (final_camera);
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (data->model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, data->model);
+ }
+ if (data->make) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, data->make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
if (data->title || data->title2 || data->pdf_title) {
diff --git a/src/tracker-extract/tracker-extract-gif.c b/src/tracker-extract/tracker-extract-gif.c
index c5a7693..8618edc 100644
--- a/src/tracker-extract/tracker-extract-gif.c
+++ b/src/tracker-extract/tracker-extract-gif.c
@@ -36,7 +36,6 @@ typedef struct {
const gchar *title;
const gchar *date;
const gchar *artist;
- gchar *camera;
} MergeData;
typedef struct {
@@ -178,14 +177,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
xd = g_new0 (TrackerXmpData, 1);
}
- /* Don't merge if the make is in the model */
- if ((xd->make == NULL || xd->model == NULL) ||
- (xd->make && xd->model && strstr (xd->model, xd->make) == NULL)) {
- md.camera = tracker_merge_const (" ", 2, xd->make, xd->model);
- } else {
- md.camera = g_strdup (xd->model);
- }
-
md.title = tracker_coalesce_strip (3, xd->title, xd->title2, xd->pdf_title);
md.date = tracker_coalesce_strip (2, xd->date, xd->time_original);
md.artist = tracker_coalesce_strip (2, xd->artist, xd->contributor);
@@ -231,16 +222,27 @@ read_metadata (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_object_unvalidated (metadata, xd->copyright);
}
+ if (xd->make || xd->model) {
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (xd->model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, xd->model);
+ }
+ if (xd->make) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, xd->make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
+ }
+
if (md.title) {
tracker_sparql_builder_predicate (metadata, "nie:title");
tracker_sparql_builder_object_unvalidated (metadata, md.title);
}
- if (md.camera) {
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, md.camera);
- }
-
if (md.artist) {
gchar *uri = tracker_sparql_escape_uri_printf ("urn:contact:%s", md.artist);
@@ -425,7 +427,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
}
tracker_xmp_free (xd);
- g_free (md.camera);
}
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index 7cfe014..8c96075 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -496,7 +496,7 @@ extract_metadata (MetadataExtractor *extractor,
gchar **scount)
{
const gchar *temp;
- gchar *s, *make = NULL, *model = NULL, *manuf = NULL, *make_model = NULL;
+ gchar *s, *make = NULL, *model = NULL, *manuf = NULL;
gboolean ret;
gint count;
gboolean needs_audio = FALSE;
@@ -761,26 +761,21 @@ extract_metadata (MetadataExtractor *extractor,
gst_tag_list_get_string (extractor->tagcache, GST_TAG_DEVICE_MAKE, &make);
gst_tag_list_get_string (extractor->tagcache, GST_TAG_DEVICE_MANUFACTURER, &manuf);
- if (make && model && manuf) {
- make_model = tracker_merge_const (" ", 3, manuf, make, model);
- } else if (make && model) {
- make_model = tracker_merge_const (" ", 2, make, model);
- } else if (make && manuf) {
- make_model = tracker_merge_const (" ", 2, manuf, make);
- } else if (model && manuf) {
- make_model = tracker_merge_const (" ", 2, manuf, model);
- } else if (model) {
- make_model = g_strdup (model);
- } else if (make) {
- make_model = g_strdup (make);
- } else if (manuf) {
- make_model = g_strdup (manuf);
- }
- if (make_model) {
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, make_model);
- g_free (make_model);
+ if (make || model || manuf) {
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, model);
+ }
+ if (make || manuf) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, manuf ? manuf : make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
g_free (make);
diff --git a/src/tracker-extract/tracker-extract-gupnp-dlna.c b/src/tracker-extract/tracker-extract-gupnp-dlna.c
index d9ddf93..ecf859d 100644
--- a/src/tracker-extract/tracker-extract-gupnp-dlna.c
+++ b/src/tracker-extract/tracker-extract-gupnp-dlna.c
@@ -423,7 +423,7 @@ extract_metadata (MetadataExtractor *extractor,
gchar **scount)
{
const gchar *temp;
- gchar *s, *make = NULL, *model = NULL, *manuf = NULL, *make_model = NULL;
+ gchar *s, *make = NULL, *model = NULL, *manuf = NULL;
gboolean ret;
gint count;
gboolean needs_audio = FALSE;
@@ -666,26 +666,20 @@ extract_metadata (MetadataExtractor *extractor,
gst_tag_list_get_string (extractor->tags, GST_TAG_DEVICE_MAKE, &make);
gst_tag_list_get_string (extractor->tags, GST_TAG_DEVICE_MANUFACTURER, &manuf);
- if (make && model && manuf) {
- make_model = tracker_merge_const (" ", 3, manuf, make, model);
- } else if (make && model) {
- make_model = tracker_merge_const (" ", 2, make, model);
- } else if (make && manuf) {
- make_model = tracker_merge_const (" ", 2, manuf, make);
- } else if (model && manuf) {
- make_model = tracker_merge_const (" ", 2, manuf, model);
- } else if (model) {
- make_model = g_strdup (model);
- } else if (make) {
- make_model = g_strdup (make);
- } else if (manuf) {
- make_model = g_strdup (manuf);
- }
-
- if (make_model) {
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, make_model);
- g_free (make_model);
+ if (make || model || manuf) {
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, model);
+ }
+ if (make || manuf) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, manuf ? manuf : make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
g_free (make);
diff --git a/src/tracker-extract/tracker-extract-jpeg.c b/src/tracker-extract/tracker-extract-jpeg.c
index 5d37fe0..b888975 100644
--- a/src/tracker-extract/tracker-extract-jpeg.c
+++ b/src/tracker-extract/tracker-extract-jpeg.c
@@ -54,7 +54,8 @@
#endif /* HAVE_LIBIPTCDATA */
typedef struct {
- gchar *camera;
+ const gchar *make;
+ const gchar *model;
const gchar *title;
const gchar *orientation;
const gchar *copyright;
@@ -233,23 +234,6 @@ extract_jpeg (const gchar *uri,
id = g_new0 (TrackerIptcData, 1);
}
- /* Don't merge if the make is in the model */
- if ((xd->make == NULL || xd->model == NULL) ||
- (xd->make && xd->model && strstr (xd->model, xd->make) == NULL)) {
- md.camera = tracker_merge_const (" ", 2, xd->make, xd->model);
- } else {
- md.camera = g_strdup (xd->model);
- }
-
- if (!md.camera) {
- if ((ed->make == NULL || ed->model == NULL) ||
- (ed->make && ed->model && strstr (ed->model, ed->make) == NULL)) {
- md.camera = tracker_merge_const (" ", 2, ed->make, ed->model);
- } else {
- md.camera = g_strdup (ed->model);
- }
- }
-
md.title = tracker_coalesce_strip (4, xd->title, ed->document_name, xd->title2, xd->pdf_title);
md.orientation = tracker_coalesce_strip (3, xd->orientation, ed->orientation, id->image_orientation);
md.copyright = tracker_coalesce_strip (4, xd->copyright, xd->rights, ed->copyright, id->copyright_notice);
@@ -269,6 +253,8 @@ extract_jpeg (const gchar *uri,
md.country = tracker_coalesce_strip (2, xd->country, id->country_name);
md.creator = tracker_coalesce_strip (3, xd->creator, id->byline, id->credit);
md.comment = tracker_coalesce_strip (2, comment, ed->user_comment);
+ md.make = tracker_coalesce_strip (2, xd->make, ed->make);
+ md.model = tracker_coalesce_strip (2, xd->model, ed->model);
/* Prioritize on native dimention in all cases */
tracker_sparql_builder_predicate (metadata, "nfo:width");
@@ -391,9 +377,20 @@ extract_jpeg (const gchar *uri,
}
g_ptr_array_free (keywords, TRUE);
- if (md.camera) {
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, md.camera);
+ if (md.make || md.model) {
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (md.model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, md.model);
+ }
+ if (md.make) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, md.make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
if (md.title) {
@@ -598,8 +595,6 @@ extract_jpeg (const gchar *uri,
jpeg_destroy_decompress (&cinfo);
- g_free (md.camera);
-
tracker_exif_free (ed);
tracker_xmp_free (xd);
tracker_iptc_free (id);
diff --git a/src/tracker-extract/tracker-extract-pdf.cpp b/src/tracker-extract/tracker-extract-pdf.cpp
index 908243e..c36a306 100644
--- a/src/tracker-extract/tracker-extract-pdf.cpp
+++ b/src/tracker-extract/tracker-extract-pdf.cpp
@@ -637,18 +637,19 @@ extract_pdf (const gchar *uri,
}
if (xd->make || xd->model) {
- gchar *camera;
-
- if ((xd->make == NULL || xd->model == NULL) ||
- (xd->make && xd->model && strstr (xd->model, xd->make) == NULL)) {
- camera = tracker_merge_const (" ", 2, xd->make, xd->model);
- } else {
- camera = g_strdup (xd->model);
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (xd->model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, xd->model);
}
-
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, camera);
- g_free (camera);
+ if (xd->make) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, xd->make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
if (xd->orientation) {
diff --git a/src/tracker-extract/tracker-extract-png.c b/src/tracker-extract/tracker-extract-png.c
index 25159ce..b73fb47 100644
--- a/src/tracker-extract/tracker-extract-png.c
+++ b/src/tracker-extract/tracker-extract-png.c
@@ -40,7 +40,8 @@ typedef struct {
const gchar *date;
const gchar *license;
const gchar *artist;
- gchar *camera;
+ const gchar *make;
+ const gchar *model;
const gchar *orientation;
const gchar *white_balance;
const gchar *fnumber;
@@ -189,23 +190,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
xd = g_new0 (TrackerXmpData, 1);
}
- /* Don't merge if the make is in the model */
- if ((xd->make == NULL || xd->model == NULL) ||
- (xd->make && xd->model && strstr (xd->model, xd->make) == NULL)) {
- md.camera = tracker_merge_const (" ", 2, xd->make, xd->model);
- } else {
- md.camera = g_strdup (xd->model);
- }
-
- if (!md.camera) {
- if ((ed->make == NULL || ed->model == NULL) ||
- (ed->make && ed->model && strstr (ed->model, ed->make) == NULL)) {
- md.camera = tracker_merge_const (" ", 2, ed->make, ed->model);
- } else {
- md.camera = g_strdup (ed->model);
- }
- }
-
md.creator = tracker_coalesce_strip (3, xd->creator, pd.creator, pd.author);
md.title = tracker_coalesce_strip (5, xd->title, pd.title, ed->document_name, xd->title2, xd->pdf_title);
md.copyright = tracker_coalesce_strip (3, xd->rights, pd.copyright, ed->copyright);
@@ -222,6 +206,8 @@ read_metadata (TrackerSparqlBuilder *preupdate,
md.focal_length = tracker_coalesce_strip (2, xd->focal_length, ed->focal_length);
md.metering_mode = tracker_coalesce_strip (2, xd->metering_mode, ed->metering_mode);
md.white_balance = tracker_coalesce_strip (2, xd->white_balance, ed->white_balance);
+ md.make = tracker_coalesce_strip (2, xd->make, ed->make);
+ md.model = tracker_coalesce_strip (2, xd->model, ed->model);
keywords = g_ptr_array_new ();
@@ -274,9 +260,20 @@ read_metadata (TrackerSparqlBuilder *preupdate,
tracker_sparql_builder_object_unvalidated (metadata, md.title);
}
- if (md.camera) {
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, md.camera);
+ if (md.make || md.model) {
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (md.model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, md.model);
+ }
+ if (md.make) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, md.make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
if (md.artist) {
@@ -470,7 +467,6 @@ read_metadata (TrackerSparqlBuilder *preupdate,
tracker_exif_free (ed);
tracker_xmp_free (xd);
g_free (pd.creation_time);
- g_free (md.camera);
}
static void
diff --git a/src/tracker-extract/tracker-extract-tiff.c b/src/tracker-extract/tracker-extract-tiff.c
index c7dcab5..7872178 100644
--- a/src/tracker-extract/tracker-extract-tiff.c
+++ b/src/tracker-extract/tracker-extract-tiff.c
@@ -38,7 +38,8 @@ typedef enum {
} TagType;
typedef struct {
- gchar *camera;
+ const gchar *make;
+ const gchar *model;
const gchar *title;
const gchar *orientation;
const gchar *copyright;
@@ -354,16 +355,6 @@ extract_tiff (const gchar *uri,
TIFFClose (image);
g_free (filename);
- md.camera = tracker_merge_const (" ", 2, xd->make, xd->model);
-
- if (!md.camera) {
- md.camera = tracker_merge_const (" ", 2, td.make, td.model);
-
- if (!md.camera) {
- md.camera = tracker_merge_const (" ", 2, ed->make, ed->model);
- }
- }
-
md.title = tracker_coalesce_strip (5, xd->title, xd->pdf_title, td.title, ed->document_name, xd->title2);
md.orientation = tracker_coalesce_strip (4, xd->orientation, td.orientation, ed->orientation, id->image_orientation);
md.copyright = tracker_coalesce_strip (4, xd->rights, td.copyright, ed->copyright, id->copyright_notice);
@@ -384,6 +375,8 @@ extract_tiff (const gchar *uri,
md.creator = tracker_coalesce_strip (3, xd->creator, id->byline, id->credit);
md.x_dimension = tracker_coalesce_strip (2, td.width, ed->x_dimension);
md.y_dimension = tracker_coalesce_strip (2, td.length, ed->y_dimension);
+ md.make = tracker_coalesce_strip (3, xd->make, td.make, ed->make);
+ md.model = tracker_coalesce_strip (3, xd->model, td.model, ed->model);
keywords = g_ptr_array_new ();
@@ -542,9 +535,20 @@ extract_tiff (const gchar *uri,
}
g_ptr_array_free (keywords, TRUE);
- if (md.camera) {
- tracker_sparql_builder_predicate (metadata, "nfo:device");
- tracker_sparql_builder_object_unvalidated (metadata, md.camera);
+ if (md.make || md.model) {
+ tracker_sparql_builder_predicate (metadata, "nfo:equipment");
+ tracker_sparql_builder_object_blank_open (metadata);
+ tracker_sparql_builder_predicate (metadata, "a");
+ tracker_sparql_builder_object (metadata, "nco:Equipment");
+ if (md.model) {
+ tracker_sparql_builder_predicate (metadata, "nco:model");
+ tracker_sparql_builder_object_unvalidated (metadata, md.model);
+ }
+ if (md.make) {
+ tracker_sparql_builder_predicate (metadata, "nco:make");
+ tracker_sparql_builder_object_unvalidated (metadata, md.make);
+ }
+ tracker_sparql_builder_object_blank_close (metadata);
}
if (md.title) {
@@ -678,7 +682,6 @@ extract_tiff (const gchar *uri,
tracker_sparql_builder_object_double (metadata, value);
}
- g_free (md.camera);
tiff_data_free (&td);
tracker_exif_free (ed);
tracker_xmp_free (xd);
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index a4ab962..7a31302 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -360,6 +360,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
}
+ /* Totally deprecated: this uses nfo:Equipment nowadays */
if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "camera") == 0) {
gchar *work_on = g_strdup (row[3]);
gchar *ptr = strchr (work_on, ' ');
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]