-
-
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
Auto relativize PDF file paths when selecting "Search for unlinked local files" #12088
Conversation
@@ -118,7 +118,7 @@ public List<ImportFilesResultItemViewModel> call() { | |||
|
|||
try { | |||
if (FileUtil.isPDFFile(file)) { | |||
var pdfImporterResult = contentImporter.importPDFContent(file); | |||
var pdfImporterResult = contentImporter.importPDFContent(file, bibDatabaseContext, filePreferences); |
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.
Can you change this to the strict returned type here?
* @param context Everything related to the BIB file | ||
* @param preferences Preferences for linked files |
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.
146 - To be more precise, context is the metadata for the library. However, it's a common JabRef parameter, so can remove it.
147 - Can remove as well, as the type of the parameter makes the description redundant.
// Set up results | ||
List<BibEntry> result = importer.importDatabase(file, database, preferences).getDatabase().getEntries(); | ||
|
||
// Set up expected value | ||
BibEntry expected = new BibEntry(StandardEntryType.InProceedings) |
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.
Remove these two comments (redundant).
I have just added a commit that follows up on all of the requested changes so far. |
Removes unnecessary comments
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.
Tried it out. Works.
Small naming comment - otherwise code looks good. No need for additional tests. - Code is pretty similar with #10582 - which we also reviewed back then. - The PR was abandoned, thank you for porting it to the most recent version of JabRef.
Please add CHANGELOG.md entry and then it should be good to go!
@@ -17,9 +19,9 @@ public ExternalFilesContentImporter(ImportFormatPreferences importFormatPreferen | |||
this.importFormatPreferences = importFormatPreferences; | |||
} | |||
|
|||
public ParserResult importPDFContent(Path file) { | |||
public ParserResult importPDFContent(Path file, BibDatabaseContext context, FilePreferences preferences) { |
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.
Name the preferences
variable filePreferences
- also in the method importDatabase
It now correctly states which function is called to produce the return value
Head branch was pushed to by a user without write access
@u7676493 I already added it to the merge queue. You updated. Do you want to do any more changes? |
List<Path> directories = context.getFileDirectories(filePreferences); | ||
|
||
if (!directories.isEmpty()) { | ||
filePath = FileUtil.relativize(filePath, directories); |
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.
Doesn't that method also have a check for emptyness? Then, this call can be moved out of the if and the jf be removed.
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.
I have just added a commit that does that
Removed unnecessary if statement
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.
Looks good. Adding back to merge queue.
Fixes koppor#549
It updates the functionality of the "Search for unlinked local files" import option - it now automatically relativizes the file paths for PDF files.
List of changes
ImportHandler
to use different arguments forimportPDFContent()
, accounting for the changes made toExternalFilesContentImporter
ImportHandler
starts the execution of the logic of importing a PDF file.ExternalFilesContentImporter
to include imports forBibDatabaseContext
andFilePreferences
classes as well as different arguments forimportPDFContent()
andimportDatabase()
, both related to the changes made toPdfMergeMetadataImporter
PdfMergeMetadataImporter
to add an alternateimportDatabase()
function with different arguments, using theBibDatabaseContext.getFileDirectories(FilePreferences)
function to get all file directories and relativize the file path using theFileUtil.relativize(Path, List<Path>)
function, before passing it into the default override of theimportDatabase(Path)
function from theImporter
class.PdfMergeMetadataImporter
handles all of the actual logic relating to importing a PDF file.The new
importDatabase()
function has three arguments:(Path file, BibDatabaseContext context, FilePreferences preferences)
PdfMergeMetadataImporter
Please provide me with any feedback you can! I haven't included any changes in documentation yet because this is still a WIP.
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if applicable)