[rygel] tracker: Refactor create_query_from_expression()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [rygel] tracker: Refactor create_query_from_expression()
- Date: Mon, 16 Nov 2009 23:19:15 +0000 (UTC)
commit edf74256cd866bc4c498dcc05e7d187eb1795d74
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Nov 12 18:31:06 2009 +0200
tracker: Refactor create_query_from_expression()
.../tracker/rygel-tracker-search-container.vala | 90 +++++++++++---------
1 files changed, 49 insertions(+), 41 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 321a613..49c5e23 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -212,47 +212,7 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
var query_op = this.get_op_for_expression (rel_expression);
if (rel_expression.operand1 == "@id" && query_op != null) {
- string parent_id;
- string service;
-
- var path = this.get_item_info (rel_expression.operand2,
- out parent_id,
- out service);
- if (path != null && parent_id != null && parent_id == this.id) {
- var dir = Path.get_dirname (path);
- var basename = Path.get_basename (path);
-
- var search_condition =
- "<rdfq:and>\n" +
- "<" + query_op + ">\n" +
- "<rdfq:Property " +
- "name=\"File:Path\" />\n" +
- "<rdf:String>" +
- dir +
- "</rdf:String>\n" +
- "</" + query_op + ">\n" +
- "<" + query_op + ">\n" +
- "<rdfq:Property " +
- "name=\"File:Name\" />\n" +
- "<rdf:String>" +
- basename +
- "</rdf:String>\n" +
- "</" + query_op + ">\n" +
- "</rdfq:and>\n";
-
- if (this.query_condition != "") {
- query = "<rdfq:Condition>\n" +
- "<rdfq:and>\n" +
- search_condition +
- this.query_condition +
- "</rdfq:and>\n" +
- "</rdfq:Condition>";
- } else {
- query = "<rdfq:Condition>\n" +
- search_condition +
- "</rdfq:Condition>";
- }
- }
+ query = create_query_for_id (rel_expression, query_op);
} else if (rel_expression.operand1 == "@parentID" &&
rel_expression.compare_string (this.id)) {
if (this.query_condition != "") {
@@ -267,6 +227,54 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
return query;
}
+ private string? create_query_for_id (RelationalExpression expression,
+ string query_op) {
+ string query = null;
+ string parent_id;
+ string service;
+
+ var path = this.get_item_info (expression.operand2,
+ out parent_id,
+ out service);
+
+ if (path != null && parent_id != null && parent_id == this.id) {
+ var dir = Path.get_dirname (path);
+ var basename = Path.get_basename (path);
+
+ var search_condition = "<rdfq:and>\n" +
+ "<" + query_op + ">\n" +
+ "<rdfq:Property " +
+ "name=\"File:Path\" />\n" +
+ "<rdf:String>" +
+ dir +
+ "</rdf:String>\n" +
+ "</" + query_op + ">\n" +
+ "<" + query_op + ">\n" +
+ "<rdfq:Property " +
+ "name=\"File:Name\" />\n" +
+ "<rdf:String>" +
+ basename +
+ "</rdf:String>\n" +
+ "</" + query_op + ">\n" +
+ "</rdfq:and>\n";
+
+ if (this.query_condition != "") {
+ query = "<rdfq:Condition>\n" +
+ "<rdfq:and>\n" +
+ search_condition +
+ this.query_condition +
+ "</rdfq:and>\n" +
+ "</rdfq:Condition>";
+ } else {
+ query = "<rdfq:Condition>\n" +
+ search_condition +
+ "</rdfq:Condition>";
+ }
+ }
+
+ return query;
+ }
+
private string? get_op_for_expression (RelationalExpression expression) {
switch (expression.op) {
case SearchCriteriaOp.EQ:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]