From 318cf3194f4104f70f0affb4e2eb06400708522f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 8 Aug 2006 23:08:52 +0000 Subject: [PATCH] Addresses #171, Add more conditions to advanced search architecture Added conditions 'tagID', 'tag' (text), 'creator' (concats first and last before comparing), and 'note' --- .../content/scholar/xpcom/search.js | 70 ++++++++++++++++++- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/search.js b/chrome/chromeFiles/content/scholar/xpcom/search.js index 85f419dbda..a3e3a4ef44 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/search.js +++ b/chrome/chromeFiles/content/scholar/xpcom/search.js @@ -273,7 +273,9 @@ Scholar.Search.prototype._buildQuery = function(){ for (i in tables){ for (var j in tables[i]){ + // // Special table handling + // switch (i){ case 'items': break; @@ -282,10 +284,28 @@ Scholar.Search.prototype._buildQuery = function(){ var openParens = 2; } + + // + // Special field handling + // + // For itemData fields, include fieldID - if (tables[i][j]['name']=='field'){ - sql += 'fieldID=? AND '; - sqlParams.push(Scholar.ItemFields.getID(tables[i][j]['alias'])); + switch (tables[i][j]['name']){ + case 'field': + sql += 'fieldID=? AND '; + sqlParams.push( + Scholar.ItemFields.getID(tables[i][j]['alias']) + ); + break; + case 'tag': + sql += "tagID IN (SELECT tagID FROM tags WHERE "; + openParens++; + break; + case 'creator': + sql += "creatorID IN (SELECT creatorID FROM creators " + + "WHERE "; + openParens++; + break; } sql += tables[i][j]['field']; @@ -486,6 +506,50 @@ Scholar.SearchConditions = new function(){ field: 'itemTypeID' }, + { + name: 'tagID', + operators: { + is: true, + isNot: true + }, + table: 'itemTags', + field: 'tagID' + }, + + { + name: 'tag', + operators: { + is: true, + isNot: true, + contains: true, + doesNotContain: true + }, + table: 'itemTags', + field: 'tag' + }, + + { + name: 'note', + operators: { + contains: true, + doesNotContain: true + }, + table: 'itemNotes', + field: 'note' + }, + + { + name: 'creator', + operators: { + is: true, + isNot: true, + contains: true, + doesNotContain: true + }, + table: 'itemCreators', + field: "firstName || ' ' || lastName" + }, + { name: 'field', operators: {