diegodlh / zotero-cita

Cita: a Wikidata addon for Zotero with citations metadata support
GNU General Public License v3.0
222 stars 10 forks source link

Update Zotero relationships upon adding citations to source items #157

Open diegodlh opened 2 years ago

diegodlh commented 2 years ago

As described here, there may be cases where a Citation is linked to a Zotero item without using the Citation's linkToZoteroItem method. In these cases, the citing and cited items may not be marked as related in Zotero. To fix this change the SourceItemWrapper's addCitations method to:

  1. create a temporary array of Zotero keys in the Citation objects being added, and
  2. use these keys collected to mark citing and cited items as related (if not yet marked so).
Dominic-DallOsto commented 2 years ago

If we resolve #156 by requiring a source item in the constructor of a citation, I think this issue is easier to solve? But this isn't the only solution. Let me know what you think.

diegodlh commented 2 years ago

I have just added some comments to #156: I think we could avoid using the Citation constructor directly, and using a source item's addCitation method instead.

My proposal above (having the source item's addCitations method update the source item relationships) was wrong, because whereas it does cover (1) the case where a zotero key is given to new Citation() (without using the citation's linkToZoteroItem), it doesn't cover (2) the (unlikely) case where a zotero key is manually added to the note attachment (because addCitations is not called by loadCitations).

Provided you agree with my comments in #156, for (1) we could just use the citation's linkToZoteroItem method if a zotero key was provided to the addCitation method proposed in #156.

For (2), inside the source item's loadCitations method we could make sure that all cited items with a zotero key are already marked as related to the source/citing item. Otherwise, write pending relationships altogether. Beware this may conflict with #18.

I think we could solve (1) for now, and leave (2) for later (and change the issue's title accordingly).