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) {
|
||||
let { fields } = Zotero.Utilities.Internal.extractExtraFields(json.extra);
|
||||
let extraField = fields.get('DOI');
|
||||
if (extraField && extraField.value) {
|
||||
doi = extraField.value;
|
||||
if (extraField) {
|
||||
doi = extraField;
|
||||
}
|
||||
}
|
||||
if (doi) {
|
||||
|
@ -675,7 +675,7 @@ Zotero.Retractions = {
|
|||
},
|
||||
|
||||
_getItemDOI: function (item) {
|
||||
var itemDOI = item.getField('DOI') || item.getExtraField('doi');
|
||||
var itemDOI = item.getField('DOI') || item.getExtraField('DOI');
|
||||
if (itemDOI) {
|
||||
itemDOI = Zotero.Utilities.cleanDOI(itemDOI);
|
||||
}
|
||||
|
@ -772,9 +772,9 @@ Zotero.Retractions = {
|
|||
rows = await Zotero.DB.queryAsync(sql, Zotero.ItemFields.getID('extra'));
|
||||
for (let row of rows) {
|
||||
let { fields } = Zotero.Utilities.Internal.extractExtraFields(row.value);
|
||||
let doi = fields.get('doi');
|
||||
if (!doi || !doi.value) continue;
|
||||
let value = Zotero.Utilities.cleanDOI(doi.value);
|
||||
let doi = fields.get('DOI');
|
||||
if (!doi) continue;
|
||||
let value = Zotero.Utilities.cleanDOI(doi);
|
||||
if (!value) continue;
|
||||
this._addItemKeyMapping(this.TYPE_DOI, value, row.id);
|
||||
}
|
||||
|
@ -791,8 +791,8 @@ Zotero.Retractions = {
|
|||
/*
|
||||
let { fields } = Zotero.Utilities.Internal.extractExtraFields(row.value);
|
||||
let pmid = fields.get('pmid') || fields.get('pubmedID');
|
||||
if (!pmid || !pmid.value) continue;
|
||||
this._addItemKeyMapping(this.TYPE_PMID, pmid.value, row.id);
|
||||
if (!pmid) continue;
|
||||
this._addItemKeyMapping(this.TYPE_PMID, pmid, row.id);
|
||||
*/
|
||||
let pmid = this._extractPMID(row.value);
|
||||
if (!pmid) continue;
|
||||
|
|
|
@ -48,7 +48,30 @@ describe("Retractions", function() {
|
|||
Object.assign(o, options);
|
||||
var item = createUnsavedDataObject('item', o);
|
||||
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();
|
||||
}
|
||||
else {
|
||||
|
@ -219,6 +242,18 @@ describe("Retractions", function() {
|
|||
|
||||
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());
|
||||
});
|
||||
|
||||
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 () {
|
||||
var item = await createRetractedItem({ deleted: true });
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue