-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Restructure importers #1207
Restructure importers #1207
Conversation
Any comments or can I rebase and merge? |
@Override | ||
public String getCLIId() { | ||
return "ris"; | ||
public List<String> getExtensions() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why return null here (and in similar places)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I have no idea for which extensions these importers support.
See above:
Remark: The methods getExtension and getDescription are not implemented by almost any importer. This should be done. Maybe this is something for the stupro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, OK. Tired... Somehow, the questions was also, why not an empty list?
I do not fully understand why the getCLIId method is removed? How is the importer selected from CLI now? Also, since there is a method setCliId, maybe that should change name as well (as it appears as getCLIId is sometimes replaces with getId, somehow, it seems like getCLIId is a better name, but no strong opinions). Many changes are related to imports and replacing extension strings with a list of extension strings, right? |
Now I think I understand why. However, I think that getCLIId and getFormatName in general should return different things... |
Well, maybe I do not understand the code fully (again, tired), but what I was worried about with getId doesn't seem to the case, so to me this looks good! |
There is a method getId (previously getCLIID) in ImportFormat which constructs the id based on the name of the formatter. Thus some of the hand-coded ids in the specific importers could be removed. I couldn't find the method |
I saw 👍 |
Waiting for the last #547 to be merged - then, this PR can clean up all the importer code uniformly. |
This is unblocked now. Go 4 it. :) |
# Conflicts: # src/main/java/net/sf/jabref/Globals.java # src/main/java/net/sf/jabref/JabRef.java # src/main/java/net/sf/jabref/exporter/SaveDatabaseAction.java # src/main/java/net/sf/jabref/external/ExternalFileTypeEntryEditor.java # src/main/java/net/sf/jabref/external/MoveFileAction.java # src/main/java/net/sf/jabref/gui/BasePanel.java # src/main/java/net/sf/jabref/gui/FileDialogs.java # src/main/java/net/sf/jabref/gui/FileListEntryEditor.java # src/main/java/net/sf/jabref/gui/actions/BrowseAction.java # src/main/java/net/sf/jabref/gui/journals/ManageJournalsPanel.java # src/main/java/net/sf/jabref/gui/plaintextimport/TextInputDialog.java # src/main/java/net/sf/jabref/importer/ImportFormatReader.java # src/main/java/net/sf/jabref/importer/OpenDatabaseAction.java # src/main/java/net/sf/jabref/importer/fetcher/DOItoBibTeXFetcher.java # src/main/java/net/sf/jabref/importer/fetcher/MedlineFetcher.java # src/main/java/net/sf/jabref/importer/fileformat/BiblioscapeImporter.java # src/main/java/net/sf/jabref/importer/fileformat/FreeCiteImporter.java # src/main/java/net/sf/jabref/importer/fileformat/InspecImporter.java # src/main/java/net/sf/jabref/importer/fileformat/IsiImporter.java # src/main/java/net/sf/jabref/importer/fileformat/MedlineImporter.java # src/main/java/net/sf/jabref/importer/fileformat/MedlinePlainImporter.java # src/main/java/net/sf/jabref/importer/fileformat/MsBibImporter.java # src/main/java/net/sf/jabref/importer/fileformat/OvidImporter.java # src/main/java/net/sf/jabref/importer/fileformat/PdfContentImporter.java # src/main/java/net/sf/jabref/importer/fileformat/PdfXmpImporter.java # src/main/java/net/sf/jabref/importer/fileformat/RepecNepImporter.java # src/main/java/net/sf/jabref/importer/fileformat/RisImporter.java # src/main/java/net/sf/jabref/importer/fileformat/SilverPlatterImporter.java # src/main/java/net/sf/jabref/logic/msbib/MSBibDatabase.java # src/main/java/net/sf/jabref/logic/xmp/XMPUtil.java # src/main/java/net/sf/jabref/pdfimport/PdfImporter.java # src/test/java/net/sf/jabref/exporter/BibDatabaseWriterTest.java # src/test/java/net/sf/jabref/importer/ImportFormatReaderIntegrationTest.java # src/test/java/net/sf/jabref/importer/fileformat/BiblioscapeImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/BiblioscapeImporterTestFiles.java # src/test/java/net/sf/jabref/importer/fileformat/BiblioscapeImporterTestTypes.java # src/test/java/net/sf/jabref/importer/fileformat/CopacImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/EndnoteImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/InspecImportTest.java # src/test/java/net/sf/jabref/importer/fileformat/IsiImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/MedlinePlainImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/MsBibImporterTestfiles.java # src/test/java/net/sf/jabref/importer/fileformat/OvidImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/PdfContentImporterTestFiles.java # src/test/java/net/sf/jabref/importer/fileformat/PdfXmpImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/RISImporterTestFiles.java # src/test/java/net/sf/jabref/importer/fileformat/RepecNepImporterTest.java # src/test/java/net/sf/jabref/importer/fileformat/SilverPlatterImporterTest.java # src/test/java/net/sf/jabref/logic/openoffice/OOBibStyleTest.java
The aim of this PR is to reduce the overlap between the Importer package and some code in GUI (in particular, the class OpenDatabaseAction).
Moreover, #1080 and #1153 are fixed.
In detail, the following things were changed:
ImportFormat
class is almost completely rewritten. Please have a look at this class. Almost all other changes are a direct consequence of the edits made to the ImportFormat class. The biggest change is that the import method returns aParserResult
instead of a list of entries (in this way, metadata can also be imported and error messages are communicated more effectively instead of throwing IOExceptions). Moreover, the import method operates on a reader instead of an input stream in order to reduce some common code in all importers.importDatabase(Path file, Charset encoding)
to the importer interface which opens the file and passes the stream to the other import method.OpenDatabaseAction.loadDatabase
to determine the encoding of the bib file.Remark: The methods getExtension and getDescription are not implemented by almost any importer. This should be done. Maybe this is something for the stupro?
(Will add the changelog entry and add a few tests later)