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

Duplicate check on importing in find unlinked files #12076

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

R-Zhou4
Copy link

@R-Zhou4 R-Zhou4 commented Oct 24, 2024

This PR resolves the issue of duplicate entries being imported when clicking the "Import" button multiple times by refining the import process.
"Closes koppor#551".

Key Changes:

UnlinkedFilesDialogViewModel Class:

  • edit startImport Method:

    • Import Logic: Uses the ImportHandler.getEntriesToImport method to retrieve a list of entries.
    • Deduplication Logic: Prevents duplicate entries from being imported by using the importHandler.findDuplicate method.
  • add getFilePathFromEntry Method:

    • Extracts the correct file path from BibEntry.
    • Returns a valid path, or an empty path if no valid fields are found.

ImportHandler Class:

  • add getEntriesToImport Method:
    • Processes the incoming list of files and extracts importable BibEntry objects.
    • Handles different file types (e.g., PDF and BibTeX) and returns unique entries.
    • Maintains import integrity by creating empty entries for unsupported file types.

BibEntry Class:

  • add getCiteKey Method:
    • Adds a method for retrieving the citation key to support duplicate entry detection.

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@Siedlerchr Siedlerchr changed the title Fix for issue 551 Duplicate check on importing Oct 24, 2024
@Siedlerchr Siedlerchr changed the title Duplicate check on importing Duplicate check on importing in find unlinked files Oct 24, 2024
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.

Small initial comment while on the road.

@@ -1052,6 +1052,10 @@ public KeywordList getFieldAsKeywords(Field field, Character keywordSeparator) {
return keywords;
}

public Optional<String> getCiteKey() {
Copy link
Member

Choose a reason for hiding this comment

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

Remove. Use

public Optional<String> getCitationKey() {

Move method below up, too.

Copy link
Author

Choose a reason for hiding this comment

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

Updated: getCiteKey() has been removed.

@@ -166,10 +188,49 @@ public void startImport() {
progressTextProperty.unbind();
taskActiveProperty.setValue(false);
})
.onSuccess(resultList::addAll);
.onSuccess(new Consumer<List<ImportFilesResultItemViewModel>>() {
@Override
Copy link
Member

@Siedlerchr Siedlerchr Oct 24, 2024

Choose a reason for hiding this comment

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

You can use a lambda here directly no need for anonymous method, Intellij should offer you that already

Copy link
Author

Choose a reason for hiding this comment

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

Replaced with a lambda now

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.

Import at "Find Unlinked Files" should not re-add an identical entry
4 participants