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

Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 #5755

Closed
wants to merge 4 commits into from
Closed

Conversation

CarodePourtales
Copy link

@CarodePourtales CarodePourtales commented Dec 16, 2019

Creation of a button which opens a dialog.
Only one textfield for an id
Regex on the id to know the fetcher
3 buttons : cancel, look the source and generate
#4183 #550
-->

CarodePourtales and others added 4 commits December 11, 2019 14:11
…e un dialog avec un textfield pour un id dont le Fetcher est trouvé par Regex.
Travail sur l'issue #4183 et #550 pour implémenter un bouton qui ouvr…
avancée issue 4183 : reste travail sur pattern, beauté affichage
@koppor koppor changed the title #4183 #550 Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 Dec 17, 2019
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some first comments.

Could you please provide screenshots so that there is no need to run JabRef locally to provide a timely feedback?

@@ -12,35 +12,43 @@
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this reformatting in the file? Can't the file be kept as is?


final BibEntry entry = result.get();

String entryString = "Found with : \n" + fetcherName + "\n\n with ID : \n" + entry.getId() + "\n\n Title : \n" + entry.getTitle() + "\n\n Publication date : \n" + entry.getPublicationDate();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please localize that. I think, wrapping in Localizaion.lang is the thing you are searching for.

Please no spaces before the :.

import org.jabref.logic.importer.IdBasedFetcher;
import org.jabref.logic.importer.NoFetcherFoundException;
import org.jabref.logic.importer.WebFetchers;
import org.jabref.logic.importer.fetcher.*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your workspace doesn't seem to be fully setup according to https://github.com/JabRef/jabref/wiki/Guidelines-for-setting-up-a-local-workspace

We don't have imports with *. Please ensure that you followed all steps given there.

}
} else {
// Regenerate CiteKey of imported BibEntry
new BibtexKeyGenerator(basePanel.getBibDatabaseContext(), prefs.getBibtexKeyPatternPreferences()).generateAndSetKey(entry);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup for the bibtex key should be used here - don't we have such a cleanupper? (Reason: consistency with other JAbRef Code).

}
}

private class FetcherWorker extends Task<Optional<BibEntry>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't JabRef have an infrastructure for background tasks somehow? Maybe, this is a TODO. The current code here feels a bit quickly hacked. At least, this nested class should be factored out to a separate class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BackgroundTask class is perfectly made for such cases.

} else {
EntryTypeView typeChoiceDialog = new EntryTypeView(jabRefFrame.getCurrentBasePanel(), dialogService, preferences);
EntryType selectedType = typeChoiceDialog.showAndWait().orElse(null);
if (fromID){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean parameters should not be used. This smells for a second method (or enums - see http://media.pragprog.com/titles/javacomp/split.pdf)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should actually be a completely new class.

@@ -91,6 +91,8 @@ Automatically\ remove\ exact\ duplicates=Supprimer automatiquement les doublons

AUX\ file\ import=Importation de fichier AUX

author= Auteur
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thin, "author" is not used in the code. This string is obsolete.

Please translate full sentences instead of part of sentences.

@@ -1258,6 +1269,7 @@ Your\ style\ file\ specifies\ the\ character\ format\ '%0',\ which\ is\ undefine
Your\ style\ file\ specifies\ the\ paragraph\ format\ '%0',\ which\ is\ undefined\ in\ your\ current\ OpenOffice/LibreOffice\ document.=Your style file specifies the paragraph format '%0', which is undefined in your current OpenOffice/LibreOffice document.

Searching...=Searching...
Adding...= Adding ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not have spaces before/after a translation.

Adding...=Adding...

@@ -394,6 +396,8 @@ Formatter\ name=Nom de formateur

found\ in\ AUX\ file=trouvées dans le fichier AUX

FromID= Entrez l'identifiant comme un ISBN, DOI, ou Arxiv dans le champ ci-dessous
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key has to be the full sentence in English.

@@ -259,6 +260,7 @@ private void setupActions() {

actions.put(Actions.SAVE_SELECTED_AS_PLAIN, saveAction::saveSelectedAsPlain);


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please not two empty lines between statements.

@koppor koppor changed the title Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 [WIP] Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 Dec 20, 2019
Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution. The code looks already pretty good. I've some suggestions concerning the general architecture.

}
}

private class FetcherWorker extends Task<Optional<BibEntry>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BackgroundTask class is perfectly made for such cases.

} else {
EntryTypeView typeChoiceDialog = new EntryTypeView(jabRefFrame.getCurrentBasePanel(), dialogService, preferences);
EntryType selectedType = typeChoiceDialog.showAndWait().orElse(null);
if (fromID){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should actually be a completely new class.


import org.jabref.JabRefException;

public class NoFetcherFoundException extends RuntimeException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this really needs an exception. Normally, you don't want to use an exception to control the flow of the execution and "No fetcher found" doesn't sound like an abnormal situation but more like a special situation in a normal workflow.

*/
public static HashMap<Predicate<String>,IdBasedFetcher> getHashMapPredicateIdBasedFetchers(ImportFormatPreferences importFormatPreferences) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better if the IdBasedFetcher interface is extended by a method boolean matchIdentifier(string identifier), which then is implemented by each fetcher. In this way, the fetcher itself is responsible to decide which identifier it is able to match.

@koppor
Copy link
Member

koppor commented Feb 28, 2020

@CarodePourtales May I ask whether you find time to complete this pull request? We would really like to include that feature in JabRef. Is there something that we can do to support you to adress the comments?

@koppor koppor force-pushed the master branch 5 times, most recently from b8ef7b7 to 21c6e5e Compare March 4, 2020 17:02
@koppor koppor assigned Siedlerchr and unassigned CarodePourtales Mar 31, 2020
@tobiasdiez
Copy link
Member

@CarodePourtales any update on this? It would be sad if your good work would be lost. Since only a few polishing changes are required, this shouldn't take long. Thanks!

@tobiasdiez tobiasdiez marked this pull request as draft April 17, 2020 15:58
@koppor koppor changed the title [WIP] Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 Allow addition of an entry by its Id (e.g., DOI, ISBN) - fixes #4183 #550 Apr 23, 2020
@koppor
Copy link
Member

koppor commented Aug 31, 2020

On JabCon 2020, we decided to freeze this PR and focus on the other opened PRs. We will come back to this issue as soon as our resources are free for it.

@koppor koppor closed this Aug 31, 2020
koppor pushed a commit that referenced this pull request Dec 15, 2021
60bf7d5 Add encyclopedia type to wikipedia-templates.csl (#5778)
031afe1 Update and rename dependent/organization-studies.csl to organization-… (#5779)
7ed71e7 Update harvard-newcastle-university.csl (#5765)
46bab91 Update annals-of-oncology.csl (#5760)
6158ae6 Create research-in-plant-disease.csl (#5738)
04422a8 Create chemmedchem.csl (#5753)
7c11521 Create clinical-kidney-journal.csl (#5749)
e7ee983 Create kit-karlsruher-institut-fur-technologie-germanistik-ndl-neuere… (#5729)
96a1106 Update article format for STM journal (#5755)
a4ca057 Update historia-scribere.csl (#5748)

git-subtree-dir: buildres/csl/csl-styles
git-subtree-split: 60bf7d5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants