[gnome-photos/wip/uajain/de_dup: 2/5] Add insert or replace



commit f8adb4bf12c7740b06d6ebd9bbde5461b7fd337b
Author: Umang Jain <mailumangjain gmail com>
Date:   Fri Aug 26 02:24:51 2016 +0530

    Add insert or replace

 src/photos-query-builder.c |   18 +++++++++++++++---
 src/photos-query-builder.h |    7 ++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/src/photos-query-builder.c b/src/photos-query-builder.c
index 39c9c55..eb15dc3 100644
--- a/src/photos-query-builder.c
+++ b/src/photos-query-builder.c
@@ -349,6 +349,20 @@ 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 *obj1, const gchar *obj2)
 {
   gchar *sparql;
@@ -360,16 +374,14 @@ photos_query_builder_relate_objects (PhotosSearchContextState *state, const gcha
 
 
 PhotosQuery *
-photos_query_builder_insert_remote_object (PhotosSearchContextState *state, const gchar *title, const gchar 
*id)
+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 ; "
-                            "nie:title '%s' ; "
                             "nao:identifier '%s' }",
-                            title,
                             identifier);
   g_free (identifier);
 
diff --git a/src/photos-query-builder.h b/src/photos-query-builder.h
index a0a3c51..79f62d9 100644
--- a/src/photos-query-builder.h
+++ b/src/photos-query-builder.h
@@ -62,7 +62,12 @@ PhotosQuery  *photos_query_builder_update_mtime_query (PhotosSearchContextState
 
 gchar        *photos_query_builder_filter_local        (void);
 
-PhotosQuery  *photos_query_builder_insert_remote_object (PhotosSearchContextState *state, const gchar 
*title, const gchar *id);
+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 *obj1, 
const gchar *obj2);
 


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