From 72789baef6dac8d86f905e2f1cdea5de62a8b505 Mon Sep 17 00:00:00 2001 From: aurimasv Date: Sat, 12 May 2012 05:25:13 -0500 Subject: [PATCH 1/2] Minor RDF tweaks --- chrome/content/zotero/xpcom/rdf/identity.js | 17 +++++++---------- chrome/content/zotero/xpcom/rdf/init.js | 16 +++++++--------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/chrome/content/zotero/xpcom/rdf/identity.js b/chrome/content/zotero/xpcom/rdf/identity.js index 66c3dd77f7..454ffdd22e 100644 --- a/chrome/content/zotero/xpcom/rdf/identity.js +++ b/chrome/content/zotero/xpcom/rdf/identity.js @@ -202,7 +202,7 @@ We replace the bigger with the smaller. moveIndex(this.classActions); moveIndex(this.propertyActions); - tabulator.log.debug("Equate done. "+big+" now links to "+small) + $rdf.log.debug("Equate done. "+big+" now links to "+small) return true; // true means the statement does not need to be put in }; @@ -250,9 +250,7 @@ We replace the bigger with the smaller. return new $rdf.Literal(val); // @@ differet types if(typeof val == 'boolean') return new $rdf.Literal(val ? "1" : "0", undefined, $rdf.Symbol.prototype.XSDboolean); - else if(typeof val == 'number') - return new $rdf.Literal('' + val); // @@ datatypes - else if(typeof val == 'undefined') + if(typeof val == 'undefined') return undefined; else // @@ add converting of dates and numbers throw "Can't make Term from " + val + " of type " + typeof val; @@ -390,12 +388,11 @@ We replace the bigger with the smaller. break; } } - if(st != null) results.push(st); - } - - if(justOne) { - if(results.length > 1) - results = results.slice(0, 1); + if(st != null) { + results.push(st); + if(justOne) + break; + } } return results; }; // statementsMatching diff --git a/chrome/content/zotero/xpcom/rdf/init.js b/chrome/content/zotero/xpcom/rdf/init.js index fc310ec7ff..1a5ca0ccca 100644 --- a/chrome/content/zotero/xpcom/rdf/init.js +++ b/chrome/content/zotero/xpcom/rdf/init.js @@ -19,7 +19,11 @@ var $rdf = { } throw "RDFArrayRemove: Array did not contain " + x; }, - } + }, + log: { + debug: Zotero.debug, + warn: Zotero.debug + } }; if(Zotero.RDF) { @@ -28,11 +32,5 @@ if(Zotero.RDF) { Zotero.RDF = {AJAW:$rdf}; } -var tabulator = { - log: { - debug: Zotero.debug, - warn: Zotero.debug - } -}; - -var alert = Zotero.debug; \ No newline at end of file +var tabulator = {log: $rdf.log}; +var alert = $rdf.log.warn; \ No newline at end of file From f112b0f9c28d468d9fa3a06fac8ea316ad1213fc Mon Sep 17 00:00:00 2001 From: aurimasv Date: Sat, 12 May 2012 05:25:41 -0500 Subject: [PATCH 2/2] Expose RDF.serialize() to translators to assist with debugging. --- chrome/content/zotero/xpcom/translation/translate.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index a12c9e63be..e3e4e9b6d6 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -2285,7 +2285,8 @@ Zotero.Translate.IO._RDFSandbox.prototype = { "getArcsOut":"r", "getSources":"r", "getTargets":"r", - "getStatementsMatching":"r" + "getStatementsMatching":"r", + "serialize":"r" }, /**