[gnome-photos/wip/uajain/de_dup: 1/3] query-builder: Add remote object queries



commit 6c407f8eaa361380cc5fe85b1cfcf184f482d2dd
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Aug 26 05:45:18 2016 +0530

    query-builder: Add remote object queries
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770267

 src/photos-query-builder.c |   41 +++++++++++++++++++++++++++++++++++++++++
 src/photos-query-builder.h |   11 +++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index a16bc8e..50e1d7f 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -348,6 +348,47 @@ photos_query_builder_update_mtime_query (PhotosSearchContextState *state, const
 }
 
 
+PhotosQuery *
+photos_query_builder_insert_or_replace (PhotosSearchContextState *state,
+                                       const gchar *resource,
+                                       const gchar *property_name,
+                                       const gchar *property_value)
+{
+  gchar *sparql;
+
+  sparql = g_strdup_printf ("INSERT OR REPLACE { <%s> %s '%s' }", resource, property_name, property_value);
+
+  return photos_query_new (state, sparql);
+}
+
+
+PhotosQuery *
+photos_query_builder_relate_objects (PhotosSearchContextState *state, const gchar *domain_urn, const gchar 
*range_urn)
+{
+  gchar *sparql;
+
+  sparql = g_strdup_printf ("INSERT OR REPLACE { <%s> nie:relatedTo '%s' }", domain_urn, range_urn);
+
+  return photos_query_new (state, sparql);
+}
+
+
+PhotosQuery *
+photos_query_builder_insert_remote_object (PhotosSearchContextState *state, const gchar *id)
+{
+  gchar *identifier;
+  gchar *sparql;
+
+  identifier = g_strconcat ("google:picasaweb:", id, NULL);
+  sparql = g_strdup_printf ("INSERT { _:res a nfo:RemoteDataObject; a nmm:Photo ; "
+                            "nao:identifier '%s' }",
+                            identifier);
+  g_free (identifier);
+
+  return photos_query_new (state, sparql);
+}
+
+
 gchar *
 photos_query_builder_filter_local (void)
 {
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
index 30c9693..e365ebe 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -62,6 +62,17 @@ PhotosQuery  *photos_query_builder_update_mtime_query (PhotosSearchContextState
 
 gchar        *photos_query_builder_filter_local        (void);
 
+PhotosQuery  *photos_query_builder_insert_or_replace (PhotosSearchContextState *state,
+                                                     const gchar *resource,
+                                                     const gchar *property_name,
+                                                     const gchar *property_value);
+
+PhotosQuery  *photos_query_builder_insert_remote_object (PhotosSearchContextState *state, const gchar *id);
+
+PhotosQuery  *photos_query_builder_relate_objects       (PhotosSearchContextState *state,
+                                                        const gchar *domain_urn,
+                                                        const gchar *range_urn);
+
 G_END_DECLS
 
 #endif /* PHOTOS_QUERY_BUILDER */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]