[rygel] tracker: Fix query builder for graphed statements



commit 80f1eb0a31b91e1a31d834b91e397188ad21c602
Author: Jens Georg <mail jensge org>
Date:   Thu Oct 20 11:49:55 2011 +0200

    tracker: Fix query builder for graphed statements

 .../tracker/rygel-tracker-query-triplet.vala       |   12 +++---------
 .../tracker/rygel-tracker-query-triplets.vala      |   13 +++++++++++++
 2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-query-triplet.vala b/src/plugins/tracker/rygel-tracker-query-triplet.vala
index d81041e..fa7d477 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplet.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplet.vala
@@ -59,6 +59,7 @@ public class Rygel.Tracker.QueryTriplet {
     }
 
     public QueryTriplet.clone (QueryTriplet triplet) {
+        this.graph = triplet.graph;
         this.subject = triplet.subject;
         this.predicate = triplet.predicate;
 
@@ -78,7 +79,8 @@ public class Rygel.Tracker.QueryTriplet {
             chain_equal = a.next == b.next;
         }
 
-        return a.subject == b.subject &&
+        return a.graph == b.graph &&
+               a.subject == b.subject &&
                a.obj == b.obj &&
                a.predicate == b.predicate &&
                chain_equal;
@@ -87,10 +89,6 @@ public class Rygel.Tracker.QueryTriplet {
     public string to_string (bool include_subject = true) {
         string str = "";
 
-        if (graph != null) {
-            str += "GRAPH <%s> {".printf (this.graph);
-        }
-
         if (include_subject) {
             str += " " + subject;
         }
@@ -103,10 +101,6 @@ public class Rygel.Tracker.QueryTriplet {
             str += " " + this.obj;
         }
 
-        if (graph != null) {
-            str += "}";
-        }
-
         return str;
     }
 }
diff --git a/src/plugins/tracker/rygel-tracker-query-triplets.vala b/src/plugins/tracker/rygel-tracker-query-triplets.vala
index 587919e..e8192ac 100644
--- a/src/plugins/tracker/rygel-tracker-query-triplets.vala
+++ b/src/plugins/tracker/rygel-tracker-query-triplets.vala
@@ -43,6 +43,10 @@ public class Rygel.Tracker.QueryTriplets : ArrayList<QueryTriplet> {
         var include_subject = true;
 
         for (int i = 0; i < this.size; i++) {
+            if (this[i].graph != null && include_subject) {
+                str += "GRAPH <%s> {".printf (this[i].graph);
+            }
+
             str += this[i].to_string (include_subject);
 
             if (i < this.size - 1) {
@@ -51,9 +55,18 @@ public class Rygel.Tracker.QueryTriplets : ArrayList<QueryTriplet> {
 
                 if (include_subject) {
                     str += " . ";
+                    // close the graph if we change the subject
+                    if (this[i].graph != null) {
+                        str += "} ";
+                    }
                 } else {
                     str += " ; ";
                 }
+            } else {
+                // need to explicitly close the graph for the last triplet
+                if (this[i].graph != null) {
+                    str += " . } ";
+                }
             }
         }
 



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