[grilo-plugins] tracker: map key names to SPARQL variables
- From: Victor Toso de Carvalho <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] tracker: map key names to SPARQL variables
- Date: Sat, 27 Feb 2016 13:27:38 +0000 (UTC)
commit 6027a46574f6b3954d3bec62098555d44e9f6981
Author: fosero <fosero users noreply github com>
Date: Wed Jan 27 11:06:38 2016 +0100
tracker: map key names to SPARQL variables
The Grilo tracker plugin maps grilo key names to SPARQL variables. Key
names can contains dashes for multipart key names, SPARQL variables
cannot. This adds an extra mapping to the key lookup that converts the
dashes to underscores that can be used as SPARQL variable names.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=761168.
src/tracker/grl-tracker-utils.c | 23 +++++++++++++++++------
src/tracker/grl-tracker-utils.h | 1 +
2 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/tracker/grl-tracker-utils.c b/src/tracker/grl-tracker-utils.c
index 87cfe30..47dff05 100644
--- a/src/tracker/grl-tracker-utils.c
+++ b/src/tracker/grl-tracker-utils.c
@@ -126,12 +126,13 @@ insert_key_mapping (GrlKeyID grl_key,
GRLKEYID_TO_POINTER (grl_key));
gchar *canon_name = g_strdup (GRL_METADATA_KEY_GET_NAME (grl_key));
- assoc->grl_key = grl_key;
- assoc->sparql_key_name = build_flavored_key (canon_name,
- sparql_key_flavor);
- assoc->sparql_key_attr = sparql_key_attr;
- assoc->sparql_key_attr_call = sparql_key_attr_call;
- assoc->sparql_key_flavor = sparql_key_flavor;
+ assoc->grl_key = grl_key;
+ assoc->sparql_key_name = build_flavored_key (canon_name,
+ sparql_key_flavor);
+ assoc->sparql_key_name_canon = g_strdup (canon_name);
+ assoc->sparql_key_attr = sparql_key_attr;
+ assoc->sparql_key_attr_call = sparql_key_attr_call;
+ assoc->sparql_key_flavor = sparql_key_flavor;
assoc_list = g_list_append (assoc_list, assoc);
@@ -145,6 +146,16 @@ insert_key_mapping (GrlKeyID grl_key,
(gpointer) GRL_METADATA_KEY_GET_NAME (grl_key),
assoc);
+ /* Grilo maps key names to SPARQL variables. Key names can contain dashes,
+ * however SPARQL does not allow dashes in variable names. So use the to
+ * underscores converted canon_name as additional mapping.
+ */
+ if (g_strrstr (assoc->sparql_key_name_canon, "_")) {
+ g_hash_table_insert (sparql_to_grl_mapping,
+ (gpointer) assoc->sparql_key_name_canon,
+ assoc);
+ }
+
g_free (canon_name);
return assoc;
diff --git a/src/tracker/grl-tracker-utils.h b/src/tracker/grl-tracker-utils.h
index 430be88..41bd232 100644
--- a/src/tracker/grl-tracker-utils.h
+++ b/src/tracker/grl-tracker-utils.h
@@ -53,6 +53,7 @@ typedef void (*tracker_grl_sparql_setter_cb_t) (TrackerSparqlCursor *cursor,
typedef struct {
GrlKeyID grl_key;
const gchar *sparql_key_name;
+ const gchar *sparql_key_name_canon;
const gchar *sparql_key_attr;
const gchar *sparql_key_attr_call;
const gchar *sparql_key_flavor;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]