[gnome-documents/wip/skydrive: 4/18] miner: move tracker_sparql_connection_set_triple to libgdminer
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/skydrive: 4/18] miner: move tracker_sparql_connection_set_triple to libgdminer
- Date: Wed, 30 May 2012 16:44:44 +0000 (UTC)
commit f7a036deb25205877aa0a0fd9c5616e5821881f4
Author: Debarshi Ray <debarshir gnome org>
Date: Wed May 23 21:03:22 2012 +0200
miner: move tracker_sparql_connection_set_triple to libgdminer
Fixes: https://bugzilla.gnome.org/666535
src/miner/gd-gdata-miner.c | 94 ++++--------------------------------------
src/miner/gd-miner-tracker.c | 76 ++++++++++++++++++++++++++++++++++
src/miner/gd-miner-tracker.h | 16 +++++++
3 files changed, 101 insertions(+), 85 deletions(-)
---
diff --git a/src/miner/gd-gdata-miner.c b/src/miner/gd-gdata-miner.c
index bba7442..51982e6 100644
--- a/src/miner/gd-gdata-miner.c
+++ b/src/miner/gd-gdata-miner.c
@@ -86,82 +86,6 @@ _tracker_sparql_connection_toggle_favorite (TrackerSparqlConnection *connection,
return retval;
}
-static gboolean
-_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection *connection,
- GCancellable *cancellable,
- GError **error,
- const gchar *graph,
- const gchar *resource,
- const gchar *property_name,
- const gchar *property_value)
-{
- GString *insert;
- gchar *graph_str;
- gboolean retval = TRUE;
-
- graph_str = _tracker_utils_format_into_graph (graph);
-
- insert = g_string_new (NULL);
- g_string_append_printf
- (insert,
- "INSERT OR REPLACE %s { <%s> a nie:InformationElement ; %s \"%s\" }",
- graph_str, resource, property_name, property_value);
-
- g_debug ("Insert or replace triple: query %s", insert->str);
-
- tracker_sparql_connection_update (connection, insert->str,
- G_PRIORITY_DEFAULT, cancellable,
- error);
-
- g_string_free (insert, TRUE);
-
- if (*error != NULL)
- retval = FALSE;
-
- g_free (graph_str);
-
- return retval;
-}
-
-static gboolean
-_tracker_sparql_connection_set_triple (TrackerSparqlConnection *connection,
- GCancellable *cancellable,
- GError **error,
- const gchar *graph,
- const gchar *resource,
- const gchar *property_name,
- const gchar *property_value)
-{
- GString *delete;
- gboolean retval = TRUE;
-
- delete = g_string_new (NULL);
- g_string_append_printf
- (delete,
- "DELETE { <%s> %s ?val } WHERE { <%s> %s ?val }", resource,
- property_name, resource, property_name);
-
- tracker_sparql_connection_update (connection, delete->str,
- G_PRIORITY_DEFAULT, cancellable,
- error);
-
- g_string_free (delete, TRUE);
- if (*error != NULL)
- {
- retval = FALSE;
- goto out;
- }
-
- retval =
- _tracker_sparql_connection_insert_or_replace_triple (connection,
- cancellable, error,
- graph, resource,
- property_name, property_value);
-
- out:
- return retval;
-}
-
static gchar*
_tracker_utils_ensure_contact_resource (TrackerSparqlConnection *connection,
GCancellable *cancellable,
@@ -428,7 +352,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
datasource_urn = g_strdup_printf ("gd:goa-account:%s",
goa_account_get_id (job->account));
- _tracker_sparql_connection_set_triple
+ gd_miner_tracker_sparql_connection_set_triple
(job->connection, job->cancellable, error,
identifier, resource,
"nie:dataSource", datasource_urn);
@@ -441,7 +365,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
alternate = gdata_entry_look_up_link (entry, GDATA_LINK_ALTERNATE);
alternate_uri = gdata_link_get_uri (alternate);
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -468,7 +392,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
if (*error != NULL)
goto out;
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -498,7 +422,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
if (*error != NULL)
goto out;
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -507,7 +431,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
if (*error != NULL)
goto out;
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -531,7 +455,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
if (*error != NULL)
goto out;
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -573,7 +497,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
scope_value,
"");
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -586,7 +510,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
}
date = gd_iso8601_from_timestamp (gdata_entry_get_published (entry));
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
@@ -597,7 +521,7 @@ account_miner_job_process_entry (AccountMinerJob *job,
goto out;
date = gd_iso8601_from_timestamp (gdata_entry_get_updated (entry));
- _tracker_sparql_connection_insert_or_replace_triple
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple
(job->connection,
job->cancellable, error,
identifier, resource,
diff --git a/src/miner/gd-miner-tracker.c b/src/miner/gd-miner-tracker.c
index dffd942..7d2e305 100644
--- a/src/miner/gd-miner-tracker.c
+++ b/src/miner/gd-miner-tracker.c
@@ -130,3 +130,79 @@ gd_miner_tracker_sparql_connection_ensure_resource (TrackerSparqlConnection *con
g_clear_object (&cursor);
return retval;
}
+
+gboolean
+gd_miner_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection *connection,
+ GCancellable *cancellable,
+ GError **error,
+ const gchar *graph,
+ const gchar *resource,
+ const gchar *property_name,
+ const gchar *property_value)
+{
+ GString *insert;
+ gchar *graph_str;
+ gboolean retval = TRUE;
+
+ graph_str = _tracker_utils_format_into_graph (graph);
+
+ insert = g_string_new (NULL);
+ g_string_append_printf
+ (insert,
+ "INSERT OR REPLACE %s { <%s> a nie:InformationElement ; %s \"%s\" }",
+ graph_str, resource, property_name, property_value);
+
+ g_debug ("Insert or replace triple: query %s", insert->str);
+
+ tracker_sparql_connection_update (connection, insert->str,
+ G_PRIORITY_DEFAULT, cancellable,
+ error);
+
+ g_string_free (insert, TRUE);
+
+ if (*error != NULL)
+ retval = FALSE;
+
+ g_free (graph_str);
+
+ return retval;
+}
+
+gboolean
+gd_miner_tracker_sparql_connection_set_triple (TrackerSparqlConnection *connection,
+ GCancellable *cancellable,
+ GError **error,
+ const gchar *graph,
+ const gchar *resource,
+ const gchar *property_name,
+ const gchar *property_value)
+{
+ GString *delete;
+ gboolean retval = TRUE;
+
+ delete = g_string_new (NULL);
+ g_string_append_printf
+ (delete,
+ "DELETE { <%s> %s ?val } WHERE { <%s> %s ?val }", resource,
+ property_name, resource, property_name);
+
+ tracker_sparql_connection_update (connection, delete->str,
+ G_PRIORITY_DEFAULT, cancellable,
+ error);
+
+ g_string_free (delete, TRUE);
+ if (*error != NULL)
+ {
+ retval = FALSE;
+ goto out;
+ }
+
+ retval =
+ gd_miner_tracker_sparql_connection_insert_or_replace_triple (connection,
+ cancellable, error,
+ graph, resource,
+ property_name, property_value);
+
+ out:
+ return retval;
+}
diff --git a/src/miner/gd-miner-tracker.h b/src/miner/gd-miner-tracker.h
index 85dcbfd..362caad 100644
--- a/src/miner/gd-miner-tracker.h
+++ b/src/miner/gd-miner-tracker.h
@@ -35,6 +35,22 @@ gchar *gd_miner_tracker_sparql_connection_ensure_resource (TrackerSparqlConnecti
const gchar *class,
...);
+gboolean gd_miner_tracker_sparql_connection_insert_or_replace_triple (TrackerSparqlConnection *connection,
+ GCancellable *cancellable,
+ GError **error,
+ const gchar *graph,
+ const gchar *resource,
+ const gchar *property_name,
+ const gchar *property_value);
+
+gboolean gd_miner_tracker_sparql_connection_set_triple (TrackerSparqlConnection *connection,
+ GCancellable *cancellable,
+ GError **error,
+ const gchar *graph,
+ const gchar *resource,
+ const gchar *property_name,
+ const gchar *property_value);
+
G_END_DECLS
#endif /* __GD_MINER_TRACKER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]