Skip to content

Commit

Permalink
Fix for #8788 JabRef not showing contents of shared database library (#…
Browse files Browse the repository at this point in the history
…8793)

Co-authored-by: christian.bley <christian.bley@tu-braunschweig.de>
Co-authored-by: Christoph <siedlerkiller@gmail.com>
  • Loading branch information
3 people authored May 15, 2022
1 parent 065b05f commit a90ee23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where the content of a big shared database library is not shown [#8788](https://github.com/JabRef/jabref/issues/8788)
- We fixed the unnecessary horizontal scroll bar in group panel [#8467](https://github.com/JabRef/jabref/issues/8467)
- We fixed an issue where the notification bar message, icon and actions appeared to be invisible. [#8761](https://github.com/JabRef/jabref/issues/8761)
- We fixed an issue where deprecated fields tab is shown when the fields don't contain any values. [#8396](https://github.com/JabRef/jabref/issues/8396)
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/org/jabref/logic/shared/DBMSProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jabref.model.entry.field.FieldFactory;
import org.jabref.model.entry.types.EntryTypeFactory;

import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -477,6 +478,22 @@ public Optional<BibEntry> getSharedEntry(int sharedID) {
}
}

/**
* Queries the database for shared entries in 500 element batches.
* Optionally, they are filtered by the given list of sharedIds
*
* @param sharedIDs the list of Ids to filter. If list is empty, then no filter is applied
*/
public List<BibEntry> partitionAndGetSharedEntries(List<Integer> sharedIDs) {
List<List<Integer>> partitions = Lists.partition(sharedIDs, 500);
List<BibEntry> result = new ArrayList<>();

for (List<Integer> sublist : partitions) {
result.addAll(getSharedEntries(sublist));
}
return result;
}

/**
* Queries the database for shared entries. Optionally, they are filtered by the given list of sharedIds
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public void synchronizeLocalDatabase() {

if (!entriesToInsertIntoLocalDatabase.isEmpty()) {
// in case entries should be added into the local database, insert them
bibDatabase.insertEntries(dbmsProcessor.getSharedEntries(entriesToInsertIntoLocalDatabase), EntriesEventSource.SHARED);
bibDatabase.insertEntries(dbmsProcessor.partitionAndGetSharedEntries(entriesToInsertIntoLocalDatabase), EntriesEventSource.SHARED);
}
}

Expand Down

0 comments on commit a90ee23

Please sign in to comment.