[tracker/wip/sam/resource: 17/18] tracker-extract: Use TrackerResource SPARQL generation for cmdline
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/sam/resource: 17/18] tracker-extract: Use TrackerResource SPARQL generation for cmdline
- Date: Sun, 10 Apr 2016 21:43:32 +0000 (UTC)
commit 408ea1f6dd9471f0cf7764a7daf222c81af850a9
Author: Sam Thursfield <sam afuera me uk>
Date: Fri Apr 8 15:51:24 2016 +0100
tracker-extract: Use TrackerResource SPARQL generation for cmdline
src/tracker-extract/tracker-extract.c | 61 ++++++++++++---------------------
1 files changed, 22 insertions(+), 39 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index d420d7d..bb7a525 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -795,53 +795,36 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
while (task->cur_func) {
if (!filter_module (object, task->cur_module) &&
get_file_metadata (task, &info)) {
+ GList *resources = tracker_extract_info_get_resources (info);
+ GError *error = NULL;
+
no_data_or_modules = FALSE;
- /* This will break in one case or the other depending on what extractor was used...
FIXME */
+ /* This only works for extractors using TrackerResource, not all do yet... FIXME */
+
if (output_format == TRACKER_SERIALIZATION_FORMAT_SPARQL) {
- /* Only works for old-style extractors using TrackerSparqlBuilder */
- const gchar *preupdate_str, *postupdate_str, *statements_str, *where;
TrackerSparqlBuilder *builder;
+ const char *text;
- preupdate_str = statements_str = postupdate_str = NULL;
-
- builder = tracker_extract_info_get_metadata_builder (info);
-
- if (tracker_sparql_builder_get_length (builder) > 0) {
- statements_str = tracker_sparql_builder_get_result (builder);
- }
-
- builder = tracker_extract_info_get_preupdate_builder (info);
-
- if (tracker_sparql_builder_get_length (builder) > 0) {
- preupdate_str = tracker_sparql_builder_get_result (builder);
- }
+ builder = tracker_sparql_builder_new_update ();
- builder = tracker_extract_info_get_postupdate_builder (info);
+ for (GList *l = resources; l; l = l->next) {
+ /* If this was going into the tracker-store we'd generate a unique ID
+ * here, so that the data persisted across file renames.
+ */
+ tracker_resource_set_identifier (TRACKER_RESOURCE (l->data), uri);
- if (tracker_sparql_builder_get_length (builder) > 0) {
- postupdate_str = tracker_sparql_builder_get_result (builder);
+ tracker_resource_generate_sparql_update (TRACKER_RESOURCE (l->data),
+ builder,
+
tracker_namespace_manager_get_default (),
+ NULL,
+ &error);
}
- where = tracker_extract_info_get_where_clause (info);
-
- g_print ("\n");
-
- g_print ("SPARQL pre-update:\n--\n%s--\n\n",
- preupdate_str ? preupdate_str : "");
- g_print ("SPARQL item:\n--\n%s--\n\n",
- statements_str ? statements_str : "");
- g_print ("SPARQL where clause:\n--\n%s--\n\n",
- where ? where : "");
- g_print ("SPARQL post-update:\n--\n%s--\n\n",
- postupdate_str ? postupdate_str : "");
+ text = tracker_sparql_builder_get_result (builder);
- tracker_extract_info_unref (info);
- break;
+ g_print ("%s\n", text);
} else {
- /* For experimental new TrackerResource extractors */
- GList *resources = tracker_extract_info_get_resources (info);
- GError *error = NULL;
/* FIXME: we should return a JSON-LD @graph if there are multiple resources,
* not a sequence of JSON documents!!!
*/
@@ -862,10 +845,10 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
g_error_free (error);
}
}
-
- tracker_extract_info_unref (info);
- break;
}
+
+ tracker_extract_info_unref (info);
+ break;
} else {
if (!tracker_mimetype_info_iter_next (task->mimetype_handlers)) {
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]