Fix detection of retractions for items with DOI in Extra
Affected items should be detected on the next retraction updates check
This commit is contained in:
parent
6bbb7ddc09
commit
7422c50076
2 changed files with 53 additions and 9 deletions
|
@ -189,8 +189,8 @@ Zotero.Retractions = {
|
||||||
else if (json.extra) {
|
else if (json.extra) {
|
||||||
let { fields } = Zotero.Utilities.Internal.extractExtraFields(json.extra);
|
let { fields } = Zotero.Utilities.Internal.extractExtraFields(json.extra);
|
||||||
let extraField = fields.get('DOI');
|
let extraField = fields.get('DOI');
|
||||||
if (extraField && extraField.value) {
|
if (extraField) {
|
||||||
doi = extraField.value;
|
doi = extraField;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (doi) {
|
if (doi) {
|
||||||
|
@ -675,7 +675,7 @@ Zotero.Retractions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_getItemDOI: function (item) {
|
_getItemDOI: function (item) {
|
||||||
var itemDOI = item.getField('DOI') || item.getExtraField('doi');
|
var itemDOI = item.getField('DOI') || item.getExtraField('DOI');
|
||||||
if (itemDOI) {
|
if (itemDOI) {
|
||||||
itemDOI = Zotero.Utilities.cleanDOI(itemDOI);
|
itemDOI = Zotero.Utilities.cleanDOI(itemDOI);
|
||||||
}
|
}
|
||||||
|
@ -772,9 +772,9 @@ Zotero.Retractions = {
|
||||||
rows = await Zotero.DB.queryAsync(sql, Zotero.ItemFields.getID('extra'));
|
rows = await Zotero.DB.queryAsync(sql, Zotero.ItemFields.getID('extra'));
|
||||||
for (let row of rows) {
|
for (let row of rows) {
|
||||||
let { fields } = Zotero.Utilities.Internal.extractExtraFields(row.value);
|
let { fields } = Zotero.Utilities.Internal.extractExtraFields(row.value);
|
||||||
let doi = fields.get('doi');
|
let doi = fields.get('DOI');
|
||||||
if (!doi || !doi.value) continue;
|
if (!doi) continue;
|
||||||
let value = Zotero.Utilities.cleanDOI(doi.value);
|
let value = Zotero.Utilities.cleanDOI(doi);
|
||||||
if (!value) continue;
|
if (!value) continue;
|
||||||
this._addItemKeyMapping(this.TYPE_DOI, value, row.id);
|
this._addItemKeyMapping(this.TYPE_DOI, value, row.id);
|
||||||
}
|
}
|
||||||
|
@ -791,8 +791,8 @@ Zotero.Retractions = {
|
||||||
/*
|
/*
|
||||||
let { fields } = Zotero.Utilities.Internal.extractExtraFields(row.value);
|
let { fields } = Zotero.Utilities.Internal.extractExtraFields(row.value);
|
||||||
let pmid = fields.get('pmid') || fields.get('pubmedID');
|
let pmid = fields.get('pmid') || fields.get('pubmedID');
|
||||||
if (!pmid || !pmid.value) continue;
|
if (!pmid) continue;
|
||||||
this._addItemKeyMapping(this.TYPE_PMID, pmid.value, row.id);
|
this._addItemKeyMapping(this.TYPE_PMID, pmid, row.id);
|
||||||
*/
|
*/
|
||||||
let pmid = this._extractPMID(row.value);
|
let pmid = this._extractPMID(row.value);
|
||||||
if (!pmid) continue;
|
if (!pmid) continue;
|
||||||
|
|
|
@ -48,7 +48,30 @@ describe("Retractions", function() {
|
||||||
Object.assign(o, options);
|
Object.assign(o, options);
|
||||||
var item = createUnsavedDataObject('item', o);
|
var item = createUnsavedDataObject('item', o);
|
||||||
item.setField('DOI', retractedDOI);
|
item.setField('DOI', retractedDOI);
|
||||||
if (Zotero.DB.inTransaction) {
|
if (Zotero.DB.inTransaction()) {
|
||||||
|
await item.save();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await item.saveTx();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!checkQueueItemsStub.called) {
|
||||||
|
await Zotero.Promise.delay(50);
|
||||||
|
}
|
||||||
|
await checkQueueItemsStub.returnValues[0];
|
||||||
|
checkQueueItemsStub.resetHistory();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createRetractedItemWithExtraDOI(options = {}) {
|
||||||
|
var o = {
|
||||||
|
itemType: 'journalArticle'
|
||||||
|
};
|
||||||
|
Object.assign(o, options);
|
||||||
|
var item = createUnsavedDataObject('item', o);
|
||||||
|
item.setField('extra', 'DOI: ' + retractedDOI);
|
||||||
|
if (Zotero.DB.inTransaction()) {
|
||||||
await item.save();
|
await item.save();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -219,6 +242,18 @@ describe("Retractions", function() {
|
||||||
|
|
||||||
spy.restore();
|
spy.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
it("should identify object with retracted DOI in Extra", async function () {
|
||||||
|
var json = [
|
||||||
|
{
|
||||||
|
extra: `DOI: ${retractedDOI}`
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
var indexes = await Zotero.Retractions.getRetractionsFromJSON(json);
|
||||||
|
assert.sameMembers(indexes, [0]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,6 +267,15 @@ describe("Retractions", function() {
|
||||||
assert.isTrue(bannerShown());
|
assert.isTrue(bannerShown());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should show banner when retracted item with DOI in Extra is added", async function () {
|
||||||
|
var banner = win.document.getElementById('retracted-items-container');
|
||||||
|
assert.isFalse(bannerShown());
|
||||||
|
|
||||||
|
await createRetractedItemWithExtraDOI();
|
||||||
|
|
||||||
|
assert.isTrue(bannerShown());
|
||||||
|
});
|
||||||
|
|
||||||
it("shouldn't show banner when item in trash is added", async function () {
|
it("shouldn't show banner when item in trash is added", async function () {
|
||||||
var item = await createRetractedItem({ deleted: true });
|
var item = await createRetractedItem({ deleted: true });
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue