Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Citation keys are always overwritten when importing through web search #7420

Closed
1 task done
k3KAW8Pnf7mkmdSMPHz27 opened this issue Feb 3, 2021 · 7 comments · Fixed by #7443
Closed
1 task done
Labels
fetcher good first issue An issue intended for project-newcomers. Varies in difficulty. import keygenerator preferences

Comments

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member

k3KAW8Pnf7mkmdSMPHz27 commented Feb 3, 2021

The citation key generator never preserves citation keys while importing from sites such as INSPIRE HEP. The citation keys are overwritten even if "Overwrite existing keys" is disabled in preferences and always without warning.

JabRef version

JabRef 5.3--2021-02-03--242a494
Mac OS X 10.15.7 x86_64 
Java 15.0.2 
JavaFX 15.0.1+1

Relevant links

  1. JabRef renaming keys?! (I don't think these options exist anymore)
  2. InspireHEP and SAO/NASA ADS Bibtex Key Catch (feature request)
  3. Can I use Inspire citation keys when importing via jabref?
  4. There is a mention of unwanted key formatting in Issue with INSPIRE web search #7274

Temporary workaround

It is possible to keep citation keys by using the citation key pattern [CITATIONKEY] during the import.
: must also be removed from the "Remove the following characters" field in preferences.
It should be possible to use the regexp in #7111 (comment) to create a workaround where a different pattern is used when there is no citation key in the imported entry. (If someone manages with this approach, feel free to add a comment and perhaps others will also find it useful)

Steps to reproduce the behavior:

  1. Unmark "Overwrite existing keys" Skärmavbild 2021-02-03 kl  15 41 33
  2. Make a web-search on INSPIRE and import any entry Skärmavbild 2021-02-03 kl  15 43 47
  3. Note that the citation key is overwritten

Skärmavbild 2021-02-03 kl  15 47 36

@k3KAW8Pnf7mkmdSMPHz27 k3KAW8Pnf7mkmdSMPHz27 added fetcher import keygenerator preferences bug Confirmed bugs or reports that are very likely to be bugs and removed bug Confirmed bugs or reports that are very likely to be bugs labels Feb 3, 2021
@bulmust
Copy link

bulmust commented Feb 3, 2021

Same issue for me. I always manually rewrite bibtex-key which i fetch from inspire or ads

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

@bulmust, the workaround(s) work for now?

@bulmust
Copy link

bulmust commented Feb 5, 2021

No, still problematic. Bibtex-key is not fetched from Inspire.
1

My configs and version are:
2

@k3KAW8Pnf7mkmdSMPHz27
Copy link
Member Author

k3KAW8Pnf7mkmdSMPHz27 commented Feb 5, 2021

I meant using the citation key pattern [BIBTEXKEY] or [CITATIONKEY] while importing. (discussed here on discourse)
However, that might not be convenient for you unless you always want to keep the imported keys.

@Siedlerchr
Copy link
Member

I debugged a bit and the problem seems to be that this import handler doesn't check the preferences if the key should be overwritten or not. And further down there isn't any check either.

So the solution would be to add a check for the setting from the CitationKeyPrefereces.

/**
* Generate keys for given entries.
*
* @param entries entries to generate keys for
*/
private void generateKeys(List<BibEntry> entries) {
CitationKeyGenerator keyGenerator = new CitationKeyGenerator(
bibdatabase.getMetaData().getCiteKeyPattern(preferencesService.getCitationKeyPatternPreferences()
.getKeyPattern()),
bibdatabase.getDatabase(),
preferencesService.getCitationKeyPatternPreferences());
for (BibEntry entry : entries) {
keyGenerator.generateAndSetKey(entry);
}

@Siedlerchr Siedlerchr added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Feb 5, 2021
@bulmust
Copy link

bulmust commented Feb 6, 2021

I meant using the citation key pattern [BIBTEXKEY] or [CITATIONKEY] while importing. (discussed here on discourse)
However, that might not be convenient for you unless you always want to keep the imported keys.

Thank you. It is solved.

Before Jabref 5.x versions, this option was default. Solution is following:

Peek 2021-02-06 19-02

LucasF-42 added a commit to LucasF-42/jabref that referenced this issue Feb 13, 2021
Fixes JabRef#7420
If 'Overwrite existing keys' in 'Preferences' > 'Citation key patterns' is unchecked, 'CitatonKeyGenerator' only overwrites the default citationKey if it is blank. If it is not blank, the default citationKey is not overwritten.
@LucasF-42
Copy link
Contributor

Hey, I've (possibly) been able to fix this, but I'm not sure if it's according to JabRefs intended behaviour for this feature (more details on that can be found in the Pull Request).

Siedlerchr added a commit that referenced this issue Mar 26, 2021
* Fix citation keys unintentionally being overwritten on import
Fixes #7420
If 'Overwrite existing keys' in 'Preferences' > 'Citation key patterns' is unchecked, 'CitatonKeyGenerator' only overwrites the default citationKey if it is blank. If it is not blank, the default citationKey is not overwritten.

* WIP add import preferences tab, checkbox for setting
Commit does not work as intended yet (is buggy)

Co-authored-by: Christoph <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fetcher good first issue An issue intended for project-newcomers. Varies in difficulty. import keygenerator preferences
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants