[tracker/wip/sam/resource: 17/17] 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/17] tracker-extract: Use TrackerResource SPARQL generation for cmdline
- Date: Fri, 8 Apr 2016 16:17:25 +0000 (UTC)
commit 1801aec6941f9f650e14ac5c0a174231426c737c
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 | 65 +++++++++++++--------------------
1 files changed, 25 insertions(+), 40 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index c62c2b2..090ed8f 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -795,53 +795,38 @@ 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_extract_info_get_postupdate_builder (info);
+ builder = tracker_sparql_builder_new_update ();
- if (tracker_sparql_builder_get_length (builder) > 0) {
- postupdate_str = tracker_sparql_builder_get_result (builder);
+ for (GList *l = resources; l; l = l->next) {
+ /* Normally the extractor*/
+ GValue value = G_VALUE_INIT;
+ TrackerResource *resource = TRACKER_RESOURCE (l->data);
+ g_value_init (&value, G_TYPE_STRING);
+ g_value_set_string (&value, uri);
+ g_object_set_property (G_OBJECT (resource), "identifier", &value);
+ g_value_unset (&value);
+
+ tracker_resource_generate_sparql_update (resource,
+ builder,
+ 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!!!
*/
@@ -855,10 +840,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]