Skip to content

Copy linked files on entry transfer#13535

Merged
koppor merged 175 commits intoJabRef:mainfrom
UmutAkbayin:fix/copy-linked-files-on-entry-transfer
Nov 25, 2025
Merged

Copy linked files on entry transfer#13535
koppor merged 175 commits intoJabRef:mainfrom
UmutAkbayin:fix/copy-linked-files-on-entry-transfer

Conversation

@UmutAkbayin
Copy link
Copy Markdown
Contributor

@UmutAkbayin UmutAkbayin commented Jul 13, 2025

Closes #12267

Adds a requirements specification file files.md documenting the linked file transfer logic between BibTeX entries in JabRef.
The document captures three key scenarios for when linked files are reachable or not in the target context and the expected behavior regarding path adjustment and file copying.

This improves traceability by formally specifying requirements that are linked to implementation and tests via OpenFastTrace.

Steps to test

  • Verify that the new requirements specification file docs/requirements/files.md is present, properly formatted, and follows JabRef conventions.

  • Run all existing and new unit tests in LinkedFileTransferHelperTest to ensure the linked file transfer logic behaves correctly across all covered scenarios.

  • Manually verify the business logic in JabRef, especially for the scenario where the linked file is not reachable and a nested directory structure must be created. Reviewers should confirm that the path adjustments and file copying behavior conform to the requirements.

  • Provide feedback if the handling of the last case (unreachable file with differing paths) aligns with project expectations.

CopyFileOption

Mandatory checks

Comment thread jabgui/src/main/java/org/jabref/gui/LibraryTab.java Outdated
Comment thread jabgui/src/main/java/org/jabref/gui/LibraryTab.java Outdated
FilePreferences filePreferences
) {

Set<BibEntry> modifiedEntries = new HashSet<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using constructor for HashSet instead of modern Java collection factory method Set.of(). Modern Java practices recommend using factory methods for cleaner and more maintainable code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

could not find a quick solution. would have to refactor the logic then.


for (BibEntry entry : targetContext.getEntries()) {
boolean entryChanged = false;
List<LinkedFile> linkedFiles = new ArrayList<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using ArrayList constructor instead of modern Java collection factory methods. Should use List.of() for empty list initialization following JabRef's conventions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

could not find a quick solution. would have to refactor the logic then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

TracBot is wrong here 😅

@koppor
Copy link
Copy Markdown
Member

koppor commented Jul 23, 2025

@UmutAkbayin Please read the bot comment - one week old

Fix the tests

image

@koppor koppor marked this pull request as draft July 23, 2025 19:18
@koppor
Copy link
Copy Markdown
Member

koppor commented Jul 23, 2025

I converted the PR to draft, because a) merge conflicts b) tests failing.

@koppor
Copy link
Copy Markdown
Member

koppor commented Jul 23, 2025

"Steps to test" seems to be AI generated. It is not a step-by-step guide. Please refine.

@UmutAkbayin
Copy link
Copy Markdown
Contributor Author

I noticed that one unit test is affected by the changes in LibraryTab#pasteEntry. I’ll look into it tomorrow or over the weekend. I’ll also review the other things like code style.

@UmutAkbayin UmutAkbayin force-pushed the fix/copy-linked-files-on-entry-transfer branch from 3f155a7 to 3ee3b08 Compare August 1, 2025 19:38
Umut Akbayin added 15 commits August 1, 2025 21:55
Allows tracking the source BibDatabaseContext for later use in pasteEntry()
…er and setter

Enables tracking the source database context for use in pasteEntry()
… CopyTo#copyEntriesWithFeedback and LibraryTab#pasteEntry
Add filePreferences parameter to CopyTo.java to enable
LinkedFile#findIn functionality
…sferHelperTest#isReachableFromPrimaryDirectory method
Cloning the BibEntry in importEntryWithDuplicateCheck to ensure that
any file path adjustments during the copy/paste process do not affect
the original entry in the source database.

This avoids side effects when imported entries are modified (e.g. file links),
especially when the same BibEntry instance is shared between databases.
…ls in LibraryTab and CopyTo to align with new method signature
@koppor
Copy link
Copy Markdown
Member

koppor commented Nov 19, 2025

Log output of current version:

2025-11-19 13:16:43 [JavaFX Application Thread] org.jabref.gui.JabRefDialogService.notify()
INFO: Cut 1 entry(s)
2025-11-19 13:16:50 [JavaFX Application Thread] org.jabref.logic.externalfiles.LinkedFileTransferHelper.adjustLinkedFilesForTarget()
DEBUG: Handling LunaOstos2024 - Luna Ostos, Roche, Coroama and Finkbeiner: "Social life cycle assessment in the chocolate industry: A Colombian case study with Luker Chocolate" (2024)
2025-11-19 13:16:50 [JavaFX Application Thread] org.jabref.logic.externalfiles.LinkedFileTransferHelper.adjustLinkedFilesForTarget()
DEBUG: Handling file ParsedFileField{description='', link='LunaOstos_2024 - Social Life Cycle Assessment in the Chocolate Industry - A Colombian Case Study with Luker Chocolate.pdf', fileType='PDF', sourceUrl='https://link.springer.com/content/pdf/10.1007/s11367-023-02261-y.pdf'}
2025-11-19 13:16:50 [JavaFX Application Thread] org.jabref.logic.externalfiles.LinkedFileTransferHelper.adjustLinkedFilesForTarget()
DEBUG: Moving file from C:\git-repositories\jabref-all\jabref-demonstration-libraries\chocolate\pdfs\LunaOstos_2024 - Social Life Cycle Assessment in the Chocolate Industry - A Colombian Case Study with Luker Chocolate.pdf to C:\git-repositories\jabref-all\tmp-test\LunaOstos_2024 - Social Life Cycle Assessment in the Chocolate Industry - A Colombian Case Study with Luker Chocolate.pdf
2025-11-19 13:16:50 [JavaFX Application Thread] org.jabref.gui.JabRefDialogService.notify()
INFO: Pasted 1 entry(s) to tmp-test.bib

@koppor
Copy link
Copy Markdown
Member

koppor commented Nov 19, 2025

Settings

grafik

@koppor
Copy link
Copy Markdown
Member

koppor commented Nov 19, 2025

Default settings BTW

grafik

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Nov 19, 2025
@koppor koppor marked this pull request as ready for review November 19, 2025 12:25
Comment thread jabgui/src/main/java/org/jabref/gui/clipboard/JabRefClipboardData.java Outdated
@Siedlerchr
Copy link
Copy Markdown
Member

jackson.databind is not visible
import tools.jackson.databind.ObjectMapper;
^
(package tools.jackson.databind is declared in module tools.jackson.databind, but module org.jabref does not read it)
1 error

@koppor koppor dismissed Siedlerchr’s stale review November 25, 2025 18:35

Adressed comments

@koppor koppor enabled auto-merge November 25, 2025 18:35
@koppor koppor added this pull request to the merge queue Nov 25, 2025
Merged via the queue into JabRef:main with commit 17c0eb2 Nov 25, 2025
52 checks passed
@koppor koppor mentioned this pull request Feb 12, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When copying and pasting an entry to another bib file - all attached files should also be copied

4 participants