Otherwise the miner doesn't correct it after extracting.
This fixed DLNA requirement 7.3.128.7
private const string TEMP_ID = "x";
private const string QUERY_ID = "_:" + TEMP_ID;
+ // We need to add the size in the miner's graph so that the miner will
+ // update it and correct a (possibly wrong) size we got via CreateItem
+ // (DLNA requirement 7.3.128.7)
+ // FIXME: Use constant from libtracker-miner once we port to
+ // libtracker-sparql
+ private const string MINER_GRAPH =
+ "urn:uuid:472ed0cc-40ff-4e37-9c0c-062d78656540";
+
public string id;
public InsertionQuery (MediaItem item, string category) {
triplets.add (new QueryTriplet (QUERY_ID,
"nie:url",
"\"" + item.uris[0] + "\""));
- if (item.size > 0) {
- triplets.add (new QueryTriplet
- (QUERY_ID,
- "nie:byteSize",
- "\"" + item.size.to_string () + "\""));
- }
-
var now = TimeVal ();
var date = now.to_iso8601 ();
triplets.add (new QueryTriplet (QUERY_ID,
"nie:contentCreated",
"\"" + date + "\""));
+ if (item.size > 0) {
+ triplets.add (new QueryTriplet.with_graph
+ (MINER_GRAPH,
+ QUERY_ID,
+ "nie:byteSize",
+ "\"" + item.size.to_string () + "\""));
+ }
+
base (triplets);
}
* Represents SPARQL Triplet
*/
public class Rygel.Tracker.QueryTriplet {
+ public string graph;
public string subject;
public string predicate;
public string obj;
public QueryTriplet next;
public QueryTriplet (string subject, string predicate, string obj) {
+ this.graph = null;
this.subject = subject;
this.predicate = predicate;
this.obj = obj;
}
+ public QueryTriplet.with_graph (string graph,
+ string subject,
+ string predicate,
+ string object) {
+ this.graph = graph;
+ this.subject = subject;
+ this.predicate = predicate;
+ this.obj = object;
+ }
+
public QueryTriplet.chain (string subject,
string predicate,
QueryTriplet next) {
public string to_string (bool include_subject = true) {
string str = "";
+ if (graph != null) {
+ str += "GRAPH <%s> {".printf (this.graph);
+ }
+
if (include_subject) {
str += " " + subject;
}
str += " " + this.obj;
}
+ if (graph != null) {
+ str += "}";
+ }
+
return str;
}
}
str += this[i].to_string (include_subject);
if (i < this.size - 1) {
- include_subject = this[i].subject != this[i + 1].subject;
+ include_subject = this[i].subject != this[i + 1].subject ||
+ this.check_graph_change (i);
if (include_subject) {
str += " . ";
this.add (triplet);
}
}
+
+ private bool check_graph_change (int i) {
+ return (this[i].graph == null && this[i + 1].graph != null) ||
+ (this[i].graph != null && this[i + 1].graph == null) ||
+ (this[i].graph != this[i + 1].graph);
+ }
}