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



commit bec7e950422ed2ed0671e4183c9df1f8a194d8cd
Author: Umang Jain <mailumangjain gmail com>
Date:   Sat Aug 27 04:10:24 2016 +0530

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

 src/photos-query-builder.c |   52 ++++++++++++++++++++++++++++++++++++++++++++
 src/photos-query-builder.h |   13 +++++++++++
 2 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index a16bc8e..3e691bc 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -348,6 +348,58 @@ photos_query_builder_update_mtime_query (PhotosSearchContextState *state, const
 }
 
 
+PhotosQuery *
+photos_query_builder_get_equipment_query (PhotosSearchContextState *state, const gchar *resource)
+{
+  gchar *sparql;
+
+  sparql = g_strdup_printf ("SELECT nfo:equipment(<%s>) WHERE {}", resource);
+
+  return photos_query_new (state, sparql);
+}
+
+
+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..c24a2d7 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -62,6 +62,19 @@ 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);
+
+PhotosQuery *photos_query_builder_get_equipment_query (PhotosSearchContextState *state, const gchar 
*resource);
+
 G_END_DECLS
 
 #endif /* PHOTOS_QUERY_BUILDER */


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