Enable Merging of BibDatabases#6689
Conversation
tobiasdiez
left a comment
There was a problem hiding this comment.
Good that you have a look at the merge functionality as well.
We already have two merge methods:
jabref/src/main/java/org/jabref/gui/importer/ImportEntriesViewModel.java
Lines 106 to 195 in 7cc5747
jabref/src/main/java/org/jabref/gui/importer/ImportAction.java
Lines 129 to 189 in 7cc5747
It would be good to refactor and combine them (with your newly added method as well).
Side remark: depending on your envisioned applications, the ImportEntriesDialog might be helpful.
8523018 to
278a5f7
Compare
|
The linked code refs #6488 Currently, I understand the new code better than the looong linked code. We also have |
|
We merged the merge methods at the cose of "some" undo/redo (at the whole import 😟) undo/redo refs https://github.com/koppor/jabref/issues/453 |
7ca130e to
760498b
Compare
Signed-off-by: Dominik Voigt <dominik.ingo.voigt@gmail.com>
760498b to
000d773
Compare
tobiasdiez
left a comment
There was a problem hiding this comment.
Thanks. The code looks mostly good to me. I've a few comments and suggestions for improvement.
| @@ -0,0 +1,65 @@ | |||
| package org.jabref.logic.bibtex; | |||
There was a problem hiding this comment.
Since this is not related to writing bibtex (as the rest of the package), I suggest to move it together with the duplication check to a new logic.database package in parallel to the existing model.database. @JabRef/developers opinions?
There was a problem hiding this comment.
I moved it to the recommended package :).
| void mergeAddsNonDuplicateEntries() { | ||
| // Entries 2 and 3 are identical | ||
| BibEntry entry1 = new BibEntry() | ||
| .withField(StandardField.AUTHOR, "Stephen Blaha") |
There was a problem hiding this comment.
Please reduce these examples to a minimum. I don't think you need to have 4 entries with full information
There was a problem hiding this comment.
I reduced the number of entries and their information content.
| * @param otherFilename the filename of the other library. Pass "unknown" if not known. | ||
| * @param allOtherEntries list of all other entries | ||
| */ | ||
| public void merge(MetaData other, String otherFilename, List<BibEntry> allOtherEntries) { |
There was a problem hiding this comment.
Please move these merge metadata methods to the database merger class. There you can also add a merge method operating on BibDatabaseContext objects, to have an easy way to merge two databases including all their metadata.
| .collect(Collectors.toList()); | ||
|
|
||
| assertEquals(List.of(targetString1.toString(), targetString2.toString()), resultStringsSorted); | ||
| } |
There was a problem hiding this comment.
Please also include tests for the merged groups.
Signed-off-by: Dominik Voigt <dominik.ingo.voigt@gmail.com>
Add DatabaseContext merging capability to DatabaseMerger Signed-off-by: Dominik Voigt <dominik.ingo.voigt@gmail.com>
Signed-off-by: Dominik Voigt <dominik.ingo.voigt@gmail.com>
Signed-off-by: Dominik Voigt <dominik.ingo.voigt@gmail.com>
Signed-off-by: Dominik Voigt <dominik.ingo.voigt@gmail.com>
|
Thanks for your comments :). I implemented the requested changes! |
This PR adds a method to the BibDatabases that allows instances to be merged with other instances.
This merging will not introduce duplicates if an entry is contained in both databases.