[tracker/anonymous-file-nodes: 1/8] Add API to TrackerSparqlBuilder to allow embedded insertions.



commit a224e7887b209e109670632c3f0291954f981e14
Author: Carlos Garnacho <carlos lanedo com>
Date:   Tue Jan 26 11:58:14 2010 +0100

    Add API to TrackerSparqlBuilder to allow embedded insertions.
    
    Embedded insertions may take triples so data taken from tracker-extract
    can be afterwards inserted together with the rest of the data in the
    miner.

 src/libtracker-common/tracker-sparql-builder.vala |   21 +++++++++++++++++----
 1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-common/tracker-sparql-builder.vala b/src/libtracker-common/tracker-sparql-builder.vala
index c0d5e6d..4705e29 100644
--- a/src/libtracker-common/tracker-sparql-builder.vala
+++ b/src/libtracker-common/tracker-sparql-builder.vala
@@ -25,7 +25,8 @@ public class Tracker.SparqlBuilder : Object {
 		SUBJECT,
 		PREDICATE,
 		OBJECT,
-		BLANK
+		BLANK,
+		EMBEDDED_INSERT
 	}
 
 	public string result {
@@ -48,6 +49,11 @@ public class Tracker.SparqlBuilder : Object {
 		states += State.UPDATE;
 	}
 
+	public SparqlBuilder.embedded_insert () {
+		states += State.EMBEDDED_INSERT;
+		states += State.INSERT;
+	}
+
 	public void drop_graph (string iri)
 		requires (state == State.UPDATE)
 	{
@@ -72,7 +78,10 @@ public class Tracker.SparqlBuilder : Object {
 			states.length -= 3;
 		}
 		states.length--;
-		str.append ("}\n");
+
+		if (state != State.EMBEDDED_INSERT) {
+			str.append ("}\n");
+		}
 	}
 
 	public void subject_iri (string iri) {
@@ -80,7 +89,7 @@ public class Tracker.SparqlBuilder : Object {
 	}
 
 	public void subject (string s)
-		requires (state == State.INSERT || state == State.OBJECT)
+		requires (state == State.INSERT || state == State.OBJECT || state == State.EMBEDDED_INSERT)
 	{
 		if (state == State.OBJECT) {
 			str.append (" .\n");
@@ -208,8 +217,12 @@ public class Tracker.SparqlBuilder : Object {
 	}
 
 	public void append (string raw)
-		requires (states.length == 1)
 	{
+		if (state == State.OBJECT) {
+			str.append (" .\n");
+			states.length -= 3;
+		}
+
 		str.append (raw);
 	}
 }



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