[rygel] tracker: Separate class for list of triplets
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] tracker: Separate class for list of triplets
- Date: Sat, 5 Dec 2009 01:19:48 +0000 (UTC)
commit a7dc2bc93cc16515b5e97e48faa4f624de30c78d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Mon Nov 30 15:48:45 2009 +0200
tracker: Separate class for list of triplets
.../tracker/rygel-tracker-metadata-values.vala | 2 +-
src/plugins/tracker/rygel-tracker-query.vala | 27 +++++++++------
.../tracker/rygel-tracker-search-container.vala | 33 +++++++++++---------
3 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-metadata-values.vala b/src/plugins/tracker/rygel-tracker-metadata-values.vala
index 1b3bb0b..921173e 100644
--- a/src/plugins/tracker/rygel-tracker-metadata-values.vala
+++ b/src/plugins/tracker/rygel-tracker-metadata-values.vala
@@ -67,7 +67,7 @@ public class Rygel.TrackerMetadataValues : Rygel.SimpleContainer {
private async void fetch_metadata_values () {
int i;
- var mandatory = new ArrayList<TrackerQueryTriplet> ();
+ var mandatory = new TrackerQueryTriplets ();
// All variables used in the query
var num_keys = this.key_chain.length - 1;
diff --git a/src/plugins/tracker/rygel-tracker-query.vala b/src/plugins/tracker/rygel-tracker-query.vala
index 35709cb..66e6a04 100644
--- a/src/plugins/tracker/rygel-tracker-query.vala
+++ b/src/plugins/tracker/rygel-tracker-query.vala
@@ -26,8 +26,8 @@ using Gee;
* Represents Tracker SPARQL query
*/
public class Rygel.TrackerQuery {
- public ArrayList<TrackerQueryTriplet> mandatory;
- public ArrayList<TrackerQueryTriplet> optional;
+ public TrackerQueryTriplets mandatory;
+ public TrackerQueryTriplets optional;
public ArrayList<string> variables;
public ArrayList<string> filters;
@@ -36,20 +36,20 @@ public class Rygel.TrackerQuery {
public int offset;
public int max_count;
- public TrackerQuery (ArrayList<string> variables,
- ArrayList<TrackerQueryTriplet> mandatory,
- ArrayList<TrackerQueryTriplet>? optional,
- ArrayList<string>? filters,
- string? order_by = null,
- int offset = 0,
- int max_count = -1) {
+ public TrackerQuery (ArrayList<string> variables,
+ TrackerQueryTriplets mandatory,
+ TrackerQueryTriplets? optional,
+ ArrayList<string>? filters,
+ string? order_by = null,
+ int offset = 0,
+ int max_count = -1) {
this.variables = variables;
this.mandatory = mandatory;
if (optional != null) {
this.optional = optional;
} else {
- this.optional = new ArrayList<TrackerQueryTriplet> ();
+ this.optional = new TrackerQueryTriplets ();
}
if (filters != null) {
@@ -105,7 +105,7 @@ public class Rygel.TrackerQuery {
return query;
}
- private string serialize_triplets (Gee.List<TrackerQueryTriplet> triplets) {
+ private string serialize_triplets (TrackerQueryTriplets triplets) {
string str = "";
for (int i = 0; i < triplets.size; i++) {
@@ -166,3 +166,8 @@ public class Rygel.TrackerQueryTriplet {
return str;
}
}
+
+/**
+ * Represents a list of SPARQL Triplet
+ */
+public class Rygel.TrackerQueryTriplets : ArrayList<TrackerQueryTriplet> {}
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 45799b4..3971fe1 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -40,14 +40,12 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
private TrackerResourcesIface resources;
- public TrackerSearchContainer (string id,
- MediaContainer parent,
- string title,
- string category,
- ArrayList<TrackerQueryTriplet> mandatory =
- new ArrayList<TrackerQueryTriplet> (),
- ArrayList<string>? filters =
- null) {
+ public TrackerSearchContainer (string id,
+ MediaContainer parent,
+ string title,
+ string category,
+ TrackerQueryTriplets? mandatory = null,
+ ArrayList<string>? filters = null) {
base (id, parent, title, 0);
this.category = category;
@@ -55,12 +53,17 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
var variables = new ArrayList<string> ();
variables.add (ITEM_VARIABLE);
- mandatory.add (new TrackerQueryTriplet (ITEM_VARIABLE,
- "a",
- category,
- false));
+ var our_mandatory = new TrackerQueryTriplets ();
+ if (mandatory != null) {
+ our_mandatory.add_all (mandatory);
+ }
+
+ our_mandatory.add (new TrackerQueryTriplet (ITEM_VARIABLE,
+ "a",
+ category,
+ false));
- var optional = new ArrayList<TrackerQueryTriplet> ();
+ var optional = new TrackerQueryTriplets ();
foreach (var key in TrackerItem.get_metadata_keys ()) {
var variable = "?" + key.replace (":", "_");
@@ -73,7 +76,7 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
}
this.query = new TrackerQuery (variables,
- mandatory,
+ our_mandatory,
optional,
filters,
ITEM_VARIABLE);
@@ -96,7 +99,7 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
query.variables = new ArrayList<string> ();
query.variables.add ("COUNT(" + ITEM_VARIABLE + ") AS x");
- query.optional = new ArrayList<TrackerQueryTriplet> ();
+ query.optional = new TrackerQueryTriplets ();
var query_str = query.to_string ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]