From b4c48efa769b6ec92dfeb8dd4cd1a9288fb1ede8 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 5 Feb 2025 22:52:52 +0100 Subject: [PATCH 1/4] Fix BibTexStrings not included in backup file (#12464) * Fix BibTexStrings not included in backup file Fixes https://github.com/JabRef/jabref/issues/12462 * fix checkstyle --- CHANGELOG.md | 1 + .../gui/autosaveandbackup/BackupManager.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9ecede44ef..bccf8db02be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where removing the sort from the table did not restore the original order. [#12371](https://github.com/JabRef/jabref/pull/12371) - We fixed an issue where JabRef icon merges with dark background [#7771](https://github.com/JabRef/jabref/issues/7771) - We fixed an issue where an entry's group was no longer highlighted on selection [#12413](https://github.com/JabRef/jabref/issues/12413) +- We fixed an issue where BibTeX Strings were not included in the backup file [#12462](https://github.com/JabRef/jabref/issues/12462) ### Removed diff --git a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java index acae02c01c8..6ef3e41970c 100644 --- a/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/gui/autosaveandbackup/BackupManager.java @@ -38,6 +38,7 @@ import org.jabref.model.database.event.BibDatabaseContextChangedEvent; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.BibEntryTypesManager; +import org.jabref.model.entry.BibtexString; import org.jabref.model.metadata.SaveOrder; import org.jabref.model.metadata.SelfContainedSaveOrder; @@ -59,7 +60,7 @@ public class BackupManager { private static final int DELAY_BETWEEN_BACKUP_ATTEMPTS_IN_SECONDS = 19; - private static Set runningInstances = new HashSet<>(); + private static final Set RUNNING_INSTANCES = new HashSet<>(); private final BibDatabaseContext bibDatabaseContext; private final CliPreferences preferences; @@ -109,7 +110,7 @@ static Optional getLatestBackupPath(Path originalPath, Path backupDir) { public static BackupManager start(LibraryTab libraryTab, BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, CliPreferences preferences) { BackupManager backupManager = new BackupManager(libraryTab, bibDatabaseContext, entryTypesManager, preferences); backupManager.startBackupTask(preferences.getFilePreferences().getBackupDirectory()); - runningInstances.add(backupManager); + RUNNING_INSTANCES.add(backupManager); return backupManager; } @@ -119,7 +120,7 @@ public static BackupManager start(LibraryTab libraryTab, BibDatabaseContext bibD * @param bibDatabaseContext Associated {@link BibDatabaseContext} */ public static void discardBackup(BibDatabaseContext bibDatabaseContext, Path backupDir) { - runningInstances.stream().filter(instance -> instance.bibDatabaseContext == bibDatabaseContext).forEach(backupManager -> backupManager.discardBackup(backupDir)); + RUNNING_INSTANCES.stream().filter(instance -> instance.bibDatabaseContext == bibDatabaseContext).forEach(backupManager -> backupManager.discardBackup(backupDir)); } /** @@ -130,8 +131,8 @@ public static void discardBackup(BibDatabaseContext bibDatabaseContext, Path bac * @param backupDir The path to the backup directory */ public static void shutdown(BibDatabaseContext bibDatabaseContext, Path backupDir, boolean createBackup) { - runningInstances.stream().filter(instance -> instance.bibDatabaseContext == bibDatabaseContext).forEach(backupManager -> backupManager.shutdown(backupDir, createBackup)); - runningInstances.removeIf(instance -> instance.bibDatabaseContext == bibDatabaseContext); + RUNNING_INSTANCES.stream().filter(instance -> instance.bibDatabaseContext == bibDatabaseContext).forEach(backupManager -> backupManager.shutdown(backupDir, createBackup)); + RUNNING_INSTANCES.removeIf(instance -> instance.bibDatabaseContext == bibDatabaseContext); } /** @@ -268,6 +269,9 @@ void performBackup(Path backupPath) { .map(BibEntry.class::cast) .toList(); BibDatabase bibDatabaseClone = new BibDatabase(list); + bibDatabaseContext.getDatabase().getStringValues().stream().map(BibtexString::clone) + .map(BibtexString.class::cast) + .forEach(bibDatabaseClone::addString); BibDatabaseContext bibDatabaseContextClone = new BibDatabaseContext(bibDatabaseClone, bibDatabaseContext.getMetaData()); Charset encoding = bibDatabaseContext.getMetaData().getEncoding().orElse(StandardCharsets.UTF_8); From 1a9af9a00d74307af9b9897ec1a994b47e130f0c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Feb 2025 22:28:42 +0000 Subject: [PATCH 2/4] Bump org.openrewrite.rewrite from 7.0.0 to 7.0.5 (#12451) * Bump org.openrewrite.rewrite from 7.0.0 to 7.0.5 Bumps org.openrewrite.rewrite from 7.0.0 to 7.0.5. --- updated-dependencies: - dependency-name: org.openrewrite.rewrite dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Fix OpenRewriteIssue --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Oliver Kopp --- build.gradle | 2 +- .../java/org/jabref/logic/ai/chatting/model/Gpt4AllModel.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ee48989d2d7..ddc48cbe429 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,7 @@ plugins { id 'idea' - id 'org.openrewrite.rewrite' version '7.0.0' + id 'org.openrewrite.rewrite' version '7.0.5' id "org.itsallcode.openfasttrace" version "3.0.1" } diff --git a/src/main/java/org/jabref/logic/ai/chatting/model/Gpt4AllModel.java b/src/main/java/org/jabref/logic/ai/chatting/model/Gpt4AllModel.java index d83a31210a5..8bfc5a0835b 100644 --- a/src/main/java/org/jabref/logic/ai/chatting/model/Gpt4AllModel.java +++ b/src/main/java/org/jabref/logic/ai/chatting/model/Gpt4AllModel.java @@ -65,7 +65,7 @@ public Response generate(List list) { .uri(URLUtil.createUri(fullUrl)) .header("Content-Type", "application/json") .POST(HttpRequest.BodyPublishers.ofString(requestBody)) - .timeout(Duration.ofSeconds(60)) + .timeout(Duration.ofMinutes(1)) .build(); HttpResponse response = httpClient.send(httpRequest, HttpResponse.BodyHandlers.ofString()); From 9e9b9619ab52e847dfbf311d8801223965d4b497 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 6 Feb 2025 13:07:06 +0100 Subject: [PATCH 3/4] Improve condition (#12469) --- .../importer/fileformat/BibtexParser.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java index adf2f95ef77..5d3cf9d0d33 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -354,21 +354,18 @@ private void parseJabRefComment(Map meta) { // We remove all line breaks in the metadata // These have been inserted to prevent too long lines when the file was saved, and are not part of the data. String comment = buffer.toString().replaceAll("[\\x0d\\x0a]", ""); - if (MetaData.META_FLAG.equals(comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())))) { - if (comment.startsWith(MetaData.META_FLAG)) { - String rest = comment.substring(MetaData.META_FLAG.length()); + if (comment.startsWith(MetaData.META_FLAG)) { + String rest = comment.substring(MetaData.META_FLAG.length()); - int pos = rest.indexOf(':'); + int pos = rest.indexOf(':'); - if (pos > 0) { - meta.put(rest.substring(0, pos), rest.substring(pos + 1)); + if (pos > 0) { + meta.put(rest.substring(0, pos), rest.substring(pos + 1)); - // meta comments are always re-written by JabRef and not stored in the file - dumpTextReadSoFarToString(); - } + // meta comments are always re-written by JabRef and not stored in the file + dumpTextReadSoFarToString(); } - } else if (MetaData.ENTRYTYPE_FLAG - .equals(comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())))) { + } else if (comment.startsWith(MetaData.ENTRYTYPE_FLAG)) { // A custom entry type can also be stored in a // "@comment" Optional typ = MetaDataParser.parseCustomEntryType(comment); From 4c9c821e675dea3befec34162fac8bc4ccaf21ab Mon Sep 17 00:00:00 2001 From: Priyanshu Gupta Date: Fri, 7 Feb 2025 01:28:24 +0530 Subject: [PATCH 4/4] Move generate key option to citation key preference tab (#12436) * Move 'Generate key on import' option from WebSearch tab to CitationKeyTab * Takes preferences as arguments * Add correct comment * Fix javadoc link, shift `importerPreferences` declaration below --------- Co-authored-by: Subhramit Basu Bhowmick --- CHANGELOG.md | 1 + .../gui/externalfiles/ImportHandler.java | 2 +- .../CitationKeyPatternTab.fxml | 1 + .../CitationKeyPatternTab.java | 4 +++- .../CitationKeyPatternTabViewModel.java | 19 ++++++++++++++++++- .../preferences/websearch/WebSearchTab.fxml | 1 - .../preferences/websearch/WebSearchTab.java | 2 -- .../websearch/WebSearchTabViewModel.java | 7 ------- .../logic/importer/ImporterPreferences.java | 2 +- .../CitationsRelationsTabViewModelTest.java | 2 +- 10 files changed, 26 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bccf8db02be..a61f39170fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ### Changed +- We moved the "Generate a new key for imported entries" option from the "Web search" tab to the "Citation key generator" tab in preferences. [#12436](https://github.com/JabRef/jabref/pull/12436) - We improved the offline parsing of BibTeX data from PDF-documents. [#12278](https://github.com/JabRef/jabref/issues/12278) - The tab bar is now hidden when only one library is open. [#9971](https://github.com/JabRef/jabref/issues/9971) diff --git a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java index 58a4f4eabe8..5555ef03fda 100644 --- a/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java +++ b/src/main/java/org/jabref/gui/externalfiles/ImportHandler.java @@ -351,7 +351,7 @@ private void addToGroups(List entries, Collection group * @param entries entries to generate keys for */ private void generateKeys(List entries) { - if (!preferences.getImporterPreferences().isGenerateNewKeyOnImport()) { + if (!preferences.getImporterPreferences().shouldGenerateNewKeyOnImport()) { return; } CitationKeyGenerator keyGenerator = new CitationKeyGenerator( diff --git a/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.fxml b/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.fxml index 3b2a5bb0103..adc13ae7070 100644 --- a/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.fxml +++ b/src/main/java/org/jabref/gui/preferences/citationkeypattern/CitationKeyPatternTab.fxml @@ -27,6 +27,7 @@ +