commit 6c88563ded7ca45f8d3ac5940bef00e48dcbca5a
parent 7328a3eab37410119a175254ee5ece31799958b3
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 29 Jun 2006 07:58:50 +0000
Changed translators.type column to INT and added index
Updated scraper updated mechanism to handle new translator schema, roughly
Diffstat:
2 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/chrome/chromeFiles/content/scholar/xpcom/schema.js b/chrome/chromeFiles/content/scholar/xpcom/schema.js
@@ -289,7 +289,7 @@ Scholar.Schema = new function(){
var currentTime = xmlhttp.responseXML.
getElementsByTagName('currentTime')[0].firstChild.nodeValue;
- var updates = xmlhttp.responseXML.getElementsByTagName('scraper');
+ var updates = xmlhttp.responseXML.getElementsByTagName('translator');
Scholar.DB.beginTransaction();
@@ -361,19 +361,24 @@ Scholar.Schema = new function(){
function _scraperXMLToDBQuery(xmlnode){
var sqlValues = [
{'string':xmlnode.getAttribute('id')},
- {'string':centralLastUpdated = xmlnode.getAttribute('lastUpdated')},
+ {'string':xmlnode.getAttribute('lastUpdated')},
+ {'string':xmlnode.getAttribute('type')},
{'string':xmlnode.getElementsByTagName('label')[0].firstChild.nodeValue},
{'string':xmlnode.getElementsByTagName('creator')[0].firstChild.nodeValue},
- {'string':xmlnode.getElementsByTagName('urlPattern')[0].firstChild.nodeValue},
- // scraperDetectCode can not exist or be empty
- (xmlnode.getElementsByTagName('scraperDetectCode').item(0) &&
- xmlnode.getElementsByTagName('scraperDetectCode')[0].firstChild)
- ? {'string':xmlnode.getElementsByTagName('scraperDetectCode')[0].firstChild.nodeValue}
+ // target
+ (xmlnode.getElementsByTagName('target').item(0) &&
+ xmlnode.getElementsByTagName('target')[0].firstChild)
+ ? {'string':xmlnode.getElementsByTagName('target')[0].firstChild.nodeValue}
: {'null':true},
- {'string':xmlnode.getElementsByTagName('scraperJavaScript')[0].firstChild.nodeValue}
+ // detectCode can not exist or be empty
+ (xmlnode.getElementsByTagName('detectCode').item(0) &&
+ xmlnode.getElementsByTagName('detectCode')[0].firstChild)
+ ? {'string':xmlnode.getElementsByTagName('detectCode')[0].firstChild.nodeValue}
+ : {'null':true},
+ {'string':xmlnode.getElementsByTagName('code')[0].firstChild.nodeValue}
]
- var sql = "REPLACE INTO scrapers VALUES (?,?,?,?,?,?,?)";
+ var sql = "REPLACE INTO translators VALUES (?,?,?,?,?,?,?,?)";
return Scholar.DB.query(sql, sqlValues);
}
@@ -385,7 +390,7 @@ Scholar.Schema = new function(){
//
// Change this value to match the schema version
//
- var toVersion = 28;
+ var toVersion = 29;
if (toVersion != _getSchemaSQLVersion()){
throw('Schema version does not match version in _migrateSchema()');
@@ -399,8 +404,8 @@ Scholar.Schema = new function(){
//
// Each block performs the changes necessary to move from the
// previous revision to that one.
- for (var i=parseInt(fromVersion) + 1; i<=toVersion; i++){
- if (i==28){
+ for (var i=fromVersion + 1; i<=toVersion; i++){
+ if (i==29){
Scholar.DB.query("DROP TABLE IF EXISTS keywords");
Scholar.DB.query("DROP TABLE IF EXISTS itemKeywords");
Scholar.DB.query("DROP TABLE IF EXISTS scrapers");
diff --git a/schema.sql b/schema.sql
@@ -1,4 +1,4 @@
--- 28
+-- 29
DROP TABLE IF EXISTS version;
CREATE TABLE version (
@@ -151,13 +151,15 @@
CREATE TABLE translators (
translatorID TEXT PRIMARY KEY,
lastUpdated DATETIME,
- type TEXT,
+ type INT,
label TEXT,
creator TEXT,
target TEXT,
detectCode TEXT,
code TEXT
);
+ DROP INDEX IF EXISTS translators_type;
+ CREATE INDEX translators_type ON translators(type);
DROP TABLE IF EXISTS transactionSets;
CREATE TABLE transactionSets (