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

If user moved file, it should simply be relinked #9798

Open
koppor opened this issue Apr 25, 2023 · 33 comments · May be fixed by #12110
Open

If user moved file, it should simply be relinked #9798

koppor opened this issue Apr 25, 2023 · 33 comments · May be fixed by #12110
Assignees
Labels
FirstTimeCodeContribution Triggers GitHub Greeter Workflow good first issue An issue intended for project-newcomers. Varies in difficulty.

Comments

@koppor
Copy link
Member

koppor commented Apr 25, 2023

Start:

@misc{test,
  file = {a.pdf}
}

File a.pdf exists

User moves a.pdf into folder-a.

When "Find unlinked files" is started, JabRef should

  • Recognize that a.pdf of test is missing
  • folder-a/a.pdf does not belong to any entry
  • Rewrite the link of test from a.pdf to folder-a/a.pdf

If a.pdf exists multiple times, no rewrite should be done.

First implementation

The functionality should be in "Automatically set file links" (Quality -> Automatically set file links). In case it is absolutely sure that the file was moved (i.e., no two files with the same name), they should be moved.

image

Current output:

image

Follow-up implementation

The "Search for unlinked files" (Lookup -> Find unlinked files) dialog should get two columns as search result. Currently 1.

  • column 1: file x@folder y (as it is currently; with checkmarks)
  • column 2: candidate entry (citation key. If clicked, main table jumps to that entry)

In case no candidate entry exists, "" is put in. In case two (or more) candidate entries exist, the cell turns into a dropdown. The jump link is next to the drop down.

image


Update 2024-01-09: Testing effort high is serious. Crafting test cases for different scenarios is necessary. See especially the comment at #9798 (comment).

Update 2024-03-05: Testing effort high is really serious. A single test case is not enough. The PR #10526 showed an initial test case. -- One could think of using https://github.com/google/jimfs for more advanced tests. However @TempDir with some files should be enough.

@Alexandra-Stath
Copy link
Contributor

Hello my name is Alexandra Stathopoulou and i am an academic student in a greek University. For my semester course I have been asked to contribute in an open source software project and i would like to take on this issue.
Could I be assigned on this?

@ThiloteE ThiloteE moved this from Free to take to Reserved in Candidates for University Projects Apr 25, 2023
@ThiloteE ThiloteE moved this from Free to take to Reserved in Good First Issues Apr 25, 2023
@ThiloteE ThiloteE added the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Apr 25, 2023
@github-actions
Copy link
Contributor

As a general advice for newcomers: check out Contributing for a start. Also, guidelines for setting up a local workspace is worth having a look at.

Feel free to ask here at GitHub, if you have any issue related questions. If you have questions about how to setup your workspace use JabRef's Gitter chat. Try to open a (draft) pull-request early on, so that people can see you are working on the issue and so that they can see the direction the pull request is heading towards. This way, you will likely receive valuable feedback.

@claell
Copy link
Contributor

claell commented Apr 25, 2023

Would be great to see this! Only question is, should this be always done automatically? Especially for some cases this might create wrong links (before two files "a.pdf" exist at different places; user deletes one; now the other "a.pdf" gets linked, although it's possibly different).

@koppor
Copy link
Member Author

koppor commented Apr 26, 2023

@claell The "First Implementation" is fully automatic. The second one has a user check build in.

May I ask if your described case is an edge case? OK, there could be "download.pdf" being linked. Howver, JabRef supports one with renaming files to a pattern. The default is even CitationKey - Title. I doubt that it often happens that two files following that pattern are semantically different. -- Maybe, you bring up another description, saying that having duplicate files in differnt folders happens often?

@claell
Copy link
Contributor

claell commented Apr 27, 2023

In addition to the proposed implementations, I suggest a button here in case the file wasn't found. Right now the UX isn't great, the user only sees the file wasn't found and there is no action to try to solve that.

grafik

@claell
Copy link
Contributor

claell commented Apr 27, 2023

Regarding the described case: Yes, this is an edge case, but robust implementations should cover such edge cases to not create wrong data.
Personally, I don't use that feature with renaming files to a pattern (yet). If I would, I might not even have this issue, as the current file searching implementations that JabRef has all rely on such renamed files. So this issue here is especially relevant for people who don't use the pattern named files. The function described in this issue would have been very useful to me after importing a .bib file from Citavi which had the file names, but not the correct directory included. At this stage, there are no pattern named files, as they haven't been opened in JabRef before.

@Alexandra-Stath
Copy link
Contributor

Alexandra-Stath commented Apr 28, 2023

Hello there,

I have been looking through the issue for the first implementation and this is the solution I have come up with:

First, when the Search for unlinked local files is initiated, the program should first review all the entries of the current library where the file input is filled. For those entries, the program should check if the file name and the full path are valid (exists and matches to some file in the local folders). If either of these do not exist then the entry name (entry ID) should be kept in an array, as well as the file’s name.
Then, the Search for unlinked local files begins in the local machine as it is done currently. The filename saved as mentioned above shall be searched for locally. If found the path of this unlinked file should be added to the previous array as a new addition.

If (a) the file is not found, or (b) the path is not recognized and a file with the same name is found in a different folder the user should be informed with the display of the right message. Also, the user should be advised to (a) delete the file input or (b) change the file path.

If this is the case, a fitting message shall appear on the screen informing the user that:
a) The file path or name of an entry is not found or matched to a local file.

b) The file path of an entry is not matched and a file with the specific name is found in the local folder.

For example, as mentioned in the issue the message shall be:

a) Entry: test, file: a.pdf
File name or path not found or matched to a local file.
You are advised to delete the file input as it is not valid.

b) Entry: test, file: a.pdf
Invalid file path. File named: a.pdf found on local folder: folder-a.
You can automatically change file path by selecting entry and using the “Automatically set file links” key (F7).

Lastly, when the Automatically set files link key is pressed the program shall change the file path to the new full path of the file with the same name found unless more than one file has the same name.

Please inform me about your thoughts on this approach.

Kind regards,
Alexandra Stathopoulou

@koppor
Copy link
Member Author

koppor commented Apr 28, 2023

The function described in this issue would have been very useful to me after importing a .bib file from Citavi which had the file names

Can you describe how citavi names the files?

We surely could make a notification listing all entries having non-existant files, but other entries with the same filename. (In the case for auto linking). Then, the user can manually investigate.

@koppor
Copy link
Member Author

koppor commented Apr 28, 2023

In addition to the proposed implementations, I suggest a button here in case the file wasn't found. Right now the UX isn't great, the user only sees the file wasn't found and there is no action to try to solve that.

grafik

Yeah! Currently, JabRef tries magically to resolve the file link, which causes confusion sometimes: #9800

@koppor
Copy link
Member Author

koppor commented Apr 28, 2023

Your description starts well.

Then, I have some comments:

[...] ]f either of these do not exist then the entry name (entry ID) should be kept in an array, as well as the file’s name.

You do not need an ordering (which an array provides). It should be another data structure. Maybe Map<String,BibEntry>, where String is the filename. -

Then, the Search for unlinked local files begins in the local machine as it is done currently. The filename saved as mentioned above shall be searched for locally. If found the path of this unlinked file should be added to the previous array as a new addition.

The array contains files not existing any more, now you add existing files?

If (a) the file is not found, or (b) the path is not recognized and a file with the same name is found in a different folder the user should be informed with the display of the right message. Also, the user should be advised to (a) delete the file input or (b) change the file path.

Nothing with prompts please. JabRef should do "magic" here (because it is "automatically set file links). Prompts should be done in the second option ("Follow-up implementation"). The second one is "Files -> Find unlinked files" with a UI.

a) Entry: test, file: a.pdf File name or path not found or matched to a local file. You are advised to delete the file input as it is not valid.

A user put the file into the library folder, because he wants to collect it as reference. Deletion would remove the file from the references. It should be added. --> The user can use the "Find unlinked files" functionality for that.

b) Entry: test, file: a.pdf Invalid file path. File named: a.pdf found on local folder: folder-a. You can automatically change file path by selecting entry and using the “Automatically set file links” key (F7).

The automatically set file links should work perfectly when selecting all entries of the library.

Lastly, when the Automatically set files link key is pressed the program shall change the file path to the new full path of the file with the same name found unless more than one file has the same name.

This is the intention. Building a data structure based on the existing entries and the file system is necessary for it.

@claell
Copy link
Contributor

claell commented May 30, 2023

The function described in this issue would have been very useful to me after importing a .bib file from Citavi which had the file names

Can you describe how citavi names the files?

We surely could make a notification listing all entries having non-existant files, but other entries with the same filename. (In the case for auto linking). Then, the user can manually investigate.

That would be great (also for other use cases). I don't exactly remember right now; will investigate.

@claell
Copy link
Contributor

claell commented May 30, 2023

Here is an example from a .bib export from Citavi (the colons seem to be Citavi specific?):

@misc{Glinz.2020,
 author = {Glinz, Martin and {van Loenhoud}, Hans and Staal, Stefan and Bühne, Stan},
 date = {2020},
 title = {Handbuch für das CPRE Foundation Level nach dem IREB-Standard: Aus- und Weiterbildung zum Certified Professional for Requirements Engineering (CPRE) Foundation Level},
 url = {https://www.ireb.org/content/downloads/5-cpre-foundation-level-handbook/cpre_foundationlevel_handbook_de_v1.0.pdf},
 institution = {{International Requirements Engineering Board (IREB) e.V.}},
 file = {CPRE Foundation Level - Handbuch (2020):Attachments/CPRE Foundation Level - Handbuch (2020).pdf:application/pdf}
}

The name is from the file that I added as attachment directly in Citavi. However, I also have that file stored separately on my drive with that name. If deemed sensible, I can open a new issue for Citavi, as it might require treating this specific export format.

@claell
Copy link
Contributor

claell commented May 30, 2023

In addition to the proposed implementations, I suggest a button here in case the file wasn't found. Right now the UX isn't great, the user only sees the file wasn't found and there is no action to try to solve that.
grafik

Yeah! Currently, JabRef tries magically to resolve the file link, which causes confusion sometimes: #9800

I like that behavior, just that it doesn't give options there when it cannot find the file. But that might need general consideration of UX, considering that the whole behavior might get changed a bit with the idea in this issue.

@koppor
Copy link
Member Author

koppor commented Jun 7, 2023

@Alexandra-Stath Will you continue working on this or will you focus on other issues?

@Alexandra-Stath
Copy link
Contributor

@koppor
No, since I worked on URLCleanup issue.

@Alexandra-Stath Alexandra-Stath removed their assignment Jun 15, 2023
@mkumar09
Copy link

mkumar09 commented Jun 16, 2023

Hi @koppor, I worked on Linked identifier for ISBNs issue recently. I want to take this up. Shall I ?

Copy link
Contributor

As a general advice for newcomers: check out Contributing for a start. Also, guidelines for setting up a local workspace is worth having a look at.

Feel free to ask here at GitHub, if you have any issue related questions. If you have questions about how to setup your workspace use JabRef's Gitter chat. Try to open a (draft) pull-request early on, so that people can see you are working on the issue and so that they can see the direction the pull request is heading towards. This way, you will likely receive valuable feedback.

@koppor koppor moved this from In Progress to Reserved in Good First Issues Feb 23, 2024
@koppor
Copy link
Member Author

koppor commented Feb 23, 2024

@Maja-Larsson Sure thing! I assigned you only, because GitHub allows only to assign commenters of an issue.

Note that this issue is more about requirements engineering and developing test cases than the actual implementation. Thus, use this as chance to learn about JUnit and test-driven development. In practice, this means: Write tests, use the "Debug" button to execute the tests and let the IDE suspend on breakpoints. See how the code behaves. Adapt it. Re-run. Until the test is green. Then, the next test.

akshu-dh pushed a commit to akshu-dh/jabref that referenced this issue Feb 23, 2024
RiLoGosh added a commit to RiLoGosh/jabref that referenced this issue Mar 1, 2024
We added file relinking functionality after a file is moved when clicking the "Automatically set file links" button. Implementation based and improved upon work done in closed issue [JabRef#10526]. [JabRef#9798]
@RiLoGosh
Copy link

RiLoGosh commented Mar 1, 2024

Hi! Our group (assigned to Maja-Larsson ) made a version of the First implementation based on the work done previously by u74981018 in issue #10526 . The relevant work you can see done in the pull request above. Would love to hear feedback and receive further insight! Thank you!

@Maja-Larsson
Copy link

Our course have unfortunately ended and we will not be able to continue working on this issue. I will unassign me from this and I hope we have contributed to the issue in some way! Thanks for all the feedback!

@Maja-Larsson Maja-Larsson removed their assignment Mar 5, 2024
@koppor koppor moved this from Reserved to Free to take in Candidates for University Projects Mar 5, 2024
@koppor koppor moved this from Reserved to Free to take in Good First Issues Mar 5, 2024
@koppor koppor removed the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Jul 3, 2024
@amilcarjose9
Copy link

Hi, I'm working with a group of 2 other CS students from Florida International University. We are part of the Tech Talent Academy program where we are required to join an open source project and make a contribution. We were wondering if we could tackle this issue.

@Siedlerchr
Copy link
Member

I assigned you to the other issue already

@u7754676
Copy link

u7754676 commented Oct 12, 2024

Hello! I'm a university student who is interested in working on this issue as part of a school assignment. Is it still available? If it is, could I please have it assigned to me? This would be my first time contributing to an open source project. Thank you!

@LoayGhreeb LoayGhreeb moved this from Free to take to Assigned in Good First Issues Oct 12, 2024
@LoayGhreeb LoayGhreeb moved this from Free to take to Assigned in Candidates for University Projects Oct 12, 2024
@LoayGhreeb LoayGhreeb added the FirstTimeCodeContribution Triggers GitHub Greeter Workflow label Oct 12, 2024
Copy link
Contributor

Welcome to the vibrant world of open-source development with JabRef!

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

Happy coding! 🚀

Le-Chat-BottE pushed a commit to arshchawla21/jabref that referenced this issue Oct 27, 2024
Le-Chat-BottE pushed a commit to arshchawla21/jabref that referenced this issue Oct 27, 2024
…s improvement, automatically relink a file if it is moved. On issue [JabRef#9798](JabRef#9798)
@github-project-automation github-project-automation bot moved this to Normal priority in Prioritization Nov 13, 2024
@calixtus calixtus moved this from Normal priority to Low priority in Prioritization Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FirstTimeCodeContribution Triggers GitHub Greeter Workflow good first issue An issue intended for project-newcomers. Varies in difficulty.
Projects
Status: In Progress
Status: In Progress
Status: Low priority