Remove a couple redundant lines in Extra on RDF import
`publicationTitle`/`reporter` (and fields mapped to `publicationTitle`) and `meetingName`/`conferenceName` I assume these should just be base-field mappings, but since they're not, they're not automatically deduplicated in `fromJSON()` and need to be handled separately. https://groups.google.com/d/msgid/zotero-dev/806a22e3-3d6a-4d86-8747-10c787291a93%40googlegroups.com
This commit is contained in:
parent
91ca6d2ba6
commit
0e3d707576
2 changed files with 60 additions and 7 deletions
|
@ -4425,12 +4425,35 @@ Zotero.Item.prototype.fromJSON = function (json, options = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Remove "Version Number" if "Edition" is set, since as of 3/2020 the RDF translator
|
||||
// assigns it
|
||||
if (extraFields.has('versionNumber') && setFields.has('edition')
|
||||
&& extraFields.get('versionNumber') == this.getField('edition')) {
|
||||
extraFields.delete('versionNumber');
|
||||
invalidFieldLogLines.delete('versionNumber');
|
||||
// Remove Extra lines created by double assignments in the RDF translator for fields that
|
||||
// aren't base-field mappings (which are deduped above). These should probably just become
|
||||
// base-field mappings, at which point this could be removed.
|
||||
var temporaryRDFFixes = [
|
||||
['versionNumber', 'edition'],
|
||||
|
||||
['conferenceName', 'meetingName'],
|
||||
|
||||
['publicationTitle', 'reporter'],
|
||||
['bookTitle', 'reporter'],
|
||||
['blogTitle', 'reporter'],
|
||||
['dictionaryTitle', 'reporter'],
|
||||
['encyclopediaTitle', 'reporter'],
|
||||
['forumTitle', 'reporter'],
|
||||
['proceedingsTitle', 'reporter'],
|
||||
['programTitle', 'reporter'],
|
||||
['websiteTitle', 'reporter'],
|
||||
];
|
||||
for (let x of temporaryRDFFixes) {
|
||||
if (extraFields.has(x[0]) && setFields.has(x[1])
|
||||
&& extraFields.get(x[0]) == this.getField(x[1])) {
|
||||
extraFields.delete(x[0]);
|
||||
invalidFieldLogLines.delete(x[0]);
|
||||
}
|
||||
if (extraFields.has(x[1]) && setFields.has(x[0])
|
||||
&& extraFields.get(x[1]) == this.getField(x[0])) {
|
||||
extraFields.delete(x[1]);
|
||||
invalidFieldLogLines.delete(x[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1914,7 +1914,7 @@ describe("Zotero.Item", function () {
|
|||
assert.equal(item.getField('extra'), '');
|
||||
});
|
||||
|
||||
it("should ignore versionNumber for books", async function () {
|
||||
it("should ignore some redundant fields from RDF translator (temporary)", function () {
|
||||
var json = {
|
||||
itemType: "book",
|
||||
edition: "1",
|
||||
|
@ -1924,6 +1924,36 @@ describe("Zotero.Item", function () {
|
|||
item.fromJSON(json);
|
||||
assert.equal(item.getField('edition'), "1");
|
||||
assert.equal(item.getField('extra'), '');
|
||||
|
||||
json = {
|
||||
itemType: "presentation",
|
||||
meetingName: "Foo",
|
||||
conferenceName: "Foo"
|
||||
};
|
||||
var item = new Zotero.Item;
|
||||
item.fromJSON(json);
|
||||
assert.equal(item.getField('meetingName'), "Foo");
|
||||
assert.equal(item.getField('extra'), '');
|
||||
|
||||
json = {
|
||||
itemType: "journalArticle",
|
||||
publicationTitle: "Foo",
|
||||
reporter: "Foo"
|
||||
};
|
||||
var item = new Zotero.Item;
|
||||
item.fromJSON(json);
|
||||
assert.equal(item.getField('publicationTitle'), "Foo");
|
||||
assert.equal(item.getField('extra'), '');
|
||||
|
||||
json = {
|
||||
itemType: "conferencePaper",
|
||||
proceedingsTitle: "Foo",
|
||||
reporter: "Foo"
|
||||
};
|
||||
var item = new Zotero.Item;
|
||||
item.fromJSON(json);
|
||||
assert.equal(item.getField('proceedingsTitle'), "Foo");
|
||||
assert.equal(item.getField('extra'), '');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue