2 * Copyright (C) 20010 Nokia Corporation.
4 * Author: Zeeshan Ali <zeenix@gmail.com>
6 * This file is part of Rygel.
8 * Rygel is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * Rygel is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26 * Represents Tracker SPARQL Insertion query
28 public class Rygel.Tracker.InsertionQuery : Query {
29 private const string TEMP_ID = "x";
30 private const string QUERY_ID = "_:" + TEMP_ID;
34 public InsertionQuery (MediaItem item, string category) {
35 var triplets = new QueryTriplets ();
36 triplets.add (new QueryTriplet (QUERY_ID, "a", category));
37 triplets.add (new QueryTriplet (QUERY_ID, "a", "nie:DataObject"));
38 triplets.add (new QueryTriplet (QUERY_ID, "a", "nfo:FileDataObject"));
39 triplets.add (new QueryTriplet (QUERY_ID,
41 "\"" + item.mime_type + "\""));
42 if (item.dlna_profile != null) {
43 triplets.add (new QueryTriplet (QUERY_ID,
45 "\"" + item.dlna_profile + "\""));
47 triplets.add (new QueryTriplet (QUERY_ID,
49 "\"" + item.uris[0] + "\""));
50 triplets.add (new QueryTriplet (QUERY_ID,
52 "\"" + item.size.to_string () + "\""));
55 triplets.add (new QueryTriplet (QUERY_ID,
56 "nfo:fileLastModified",
57 "\"" + now.to_iso8601 () + "\""));
62 public override async void execute (ResourcesIface resources)
64 var str = this.to_string ();
66 debug ("Executing SPARQL query: %s", str);
68 var result = yield resources.sparql_update_blank (str);
70 this.id = result[0,0].lookup (TEMP_ID);
72 debug ("Created item in Tracker store with ID '%s'", this.id);
75 public override string to_string () {
76 return "INSERT { " + base.to_string () + " }";