[gnome-documents] query: apply filters as usual when doing a single element query
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents] query: apply filters as usual when doing a single element query
- Date: Thu, 15 Sep 2011 23:41:36 +0000 (UTC)
commit f50e07a43bff352abec24241d50ce7bb69d5d42c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Sep 15 18:30:00 2011 -0400
query: apply filters as usual when doing a single element query
Single element queries are done in respose to changes in the tracker DB,
both when an element changes or when a new one is added.
We need to use the same filters we would use for an "overview" query in
this case too, otherwise a document not matching the current filters
could be added to the filtered view.
We also need to move the filter-by-type function from WHERE to
FILTER, as UNION doesn't seem to work with a specified resource value.
src/query.js | 35 +++++++++++++++++------------------
1 files changed, 17 insertions(+), 18 deletions(-)
---
diff --git a/src/query.js b/src/query.js
index 1a0abf7..ea35895 100644
--- a/src/query.js
+++ b/src/query.js
@@ -104,6 +104,15 @@ QueryBuilder.prototype = {
return filter;
},
+ _buildFilterType: function() {
+ let filter =
+ '(fn:contains(rdf:type(?urn), \"nfo#PaginatedTextDocument\") ||'
+ + 'fn:contains(rdf:type(?urn), \"nfo#Spreadsheet\") ||'
+ + 'fn:contains(rdf:type(?urn), \"nfo#Presentation\"))';
+
+ return filter;
+ },
+
_buildFilterString: function() {
let sparql = 'FILTER (';
@@ -112,23 +121,14 @@ QueryBuilder.prototype = {
sparql += '(' + Global.sourceManager.getActiveSourceFilter() + ')';
sparql += ' && ';
sparql += '(' + Global.categoryManager.getActiveCategoryFilter() + ')';
+ sparql += ' && ';
+ sparql += '(' + this._buildFilterType() + ')';
sparql += ')';
return sparql;
},
- _buildTypeFilter: function() {
- let sparql =
- '{ ?urn a nfo:PaginatedTextDocument } ' +
- 'UNION ' +
- '{ ?urn a nfo:Spreadsheet } ' +
- 'UNION ' +
- '{ ?urn a nfo:Presentation } ';
-
- return sparql;
- },
-
_buildOptional: function() {
let sparql =
'OPTIONAL { ?urn nco:creator ?creator . } ' +
@@ -139,19 +139,19 @@ QueryBuilder.prototype = {
_buildQueryInternal: function(global) {
let globalSparql =
- 'WHERE { ' + this._buildOptional() + '}';
+ 'WHERE { ?urn a rdfs:Resource ' +
+ this._buildOptional();
if (global) {
- globalSparql =
- ('WHERE { ' +
- this._buildTypeFilter() +
- this._buildOptional() +
- Global.categoryManager.getActiveCategoryWhere() +
+ globalSparql +=
+ (Global.categoryManager.getActiveCategoryWhere() +
this._buildFilterString() +
' } ' +
'ORDER BY DESC (?mtime)' +
'LIMIT %d OFFSET %d').format(Global.offsetController.getOffsetStep(),
Global.offsetController.getOffset());
+ } else {
+ globalSparql += this._buildFilterString() + ' }';
}
let sparql =
@@ -184,7 +184,6 @@ QueryBuilder.prototype = {
buildCountQuery: function() {
let sparql =
'SELECT DISTINCT COUNT(?urn) WHERE { ' +
- this._buildTypeFilter() +
this._buildOptional() +
this._buildFilterString() +
'}';
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]