diff --git a/CHANGELOG.md b/CHANGELOG.md index 29e50ecd0b7..c89c2daf5f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,10 +13,16 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv ### Changed +- We improved the offline parsing of BibTeX data from PDF-documents. [#12278](https://github.com/JabRef/jabref/issues/12278) + ### Fixed +- We fixed an issue where a bib file with UFF-8 charset was wrongly loaded with a different charset [forum#5369](https://discourse.jabref.org/t/jabref-5-15-opens-bib-files-with-shift-jis-encoding-instead-of-utf-8/5369/) + ### Removed +- "Web of Science" [journal abbreviation list](https://docs.jabref.org/advanced/journalabbreviations) was removed. [abbrv.jabref.org#176](https://github.com/JabRef/abbrv.jabref.org/issues/176) + ## [6.0-alpha] – 2024-12-23 ### Added diff --git a/build.gradle b/build.gradle index 87767e41711..55f50444170 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ plugins { id 'org.openjfx.javafxplugin' version '0.1.0' - id 'org.beryx.jlink' version '3.1.0-rc-1' + id 'org.beryx.jlink' version '3.1.1' // nicer test outputs during running and completion // Homepage: https://github.com/radarsh/gradle-test-logger-plugin @@ -29,7 +29,7 @@ plugins { id 'idea' - id 'org.openrewrite.rewrite' version '6.29.0' + id 'org.openrewrite.rewrite' version '6.29.3' id "org.itsallcode.openfasttrace" version "3.0.1" } @@ -211,7 +211,7 @@ dependencies { implementation 'com.fasterxml:aalto-xml:1.3.3' - implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.9' + implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.12' implementation 'org.postgresql:postgresql:42.7.4' @@ -243,8 +243,8 @@ dependencies { exclude group: 'org.openjfx' } implementation 'org.fxmisc.flowless:flowless:0.7.3' - implementation 'org.fxmisc.richtext:richtextfx:0.11.3' - implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.80.0') { + implementation 'org.fxmisc.richtext:richtextfx:0.11.4' + implementation (group: 'com.dlsc.gemsfx', name: 'gemsfx', version: '2.81.0') { exclude module: 'javax.inject' // Split package, use only jakarta.inject exclude module: 'commons-lang3' exclude group: 'org.apache.commons.validator' @@ -256,7 +256,7 @@ dependencies { exclude group: 'tech.units' } // Required by gemsfx - implementation 'tech.units:indriya:2.2.1' + implementation 'tech.units:indriya:2.2.2' // Required by gemsfx and langchain4j implementation ('com.squareup.retrofit2:retrofit:2.11.0') { exclude group: 'com.squareup.okhttp3' @@ -281,7 +281,7 @@ dependencies { // route all requests to log4j to SLF4J implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.24.3' - implementation('de.undercouch:citeproc-java:3.1.0') { + implementation('de.undercouch:citeproc-java:3.2.0') { exclude group: 'org.antlr' } @@ -358,7 +358,7 @@ dependencies { } implementation 'org.apache.velocity:velocity-engine-core:2.4.1' - implementation platform('ai.djl:bom:0.30.0') + implementation platform('ai.djl:bom:0.31.1') implementation 'ai.djl:api' implementation 'ai.djl.huggingface:tokenizers' implementation 'ai.djl.pytorch:pytorch-model-zoo' @@ -383,7 +383,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4' testImplementation 'org.junit.platform:junit-platform-launcher:1.11.4' - testImplementation 'org.mockito:mockito-core:5.14.2' + testImplementation 'org.mockito:mockito-core:5.15.2' testImplementation 'org.xmlunit:xmlunit-core:2.10.0' testImplementation 'org.xmlunit:xmlunit-matchers:2.10.0' testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:1.3.0' @@ -396,12 +396,12 @@ dependencies { // recommended by https://github.com/wiremock/wiremock/issues/2149#issuecomment-1835775954 testImplementation 'org.wiremock:wiremock-standalone:3.10.0' - checkstyle 'com.puppycrawl.tools:checkstyle:10.21.0' + checkstyle 'com.puppycrawl.tools:checkstyle:10.21.1' // xjc needs the runtime as well for the ant task, otherwise it fails xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '3.0.2' xjc group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '3.0.2' - rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.22.0")) + rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.23.2")) rewrite("org.openrewrite.recipe:rewrite-static-analysis") rewrite("org.openrewrite.recipe:rewrite-logging-frameworks") rewrite("org.openrewrite.recipe:rewrite-testing-frameworks") diff --git a/buildres/abbrv.jabref.org b/buildres/abbrv.jabref.org index 78e1b08f044..93a2cad5148 160000 --- a/buildres/abbrv.jabref.org +++ b/buildres/abbrv.jabref.org @@ -1 +1 @@ -Subproject commit 78e1b08f04405c376ae65488a1b268ee938750ce +Subproject commit 93a2cad5148805b4a32c37cdb8cb4412cd71e216 diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java index 1c234329b76..11e16797446 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanel.java @@ -124,7 +124,7 @@ public void updateItem(CitationKeyPatternsPanelItemModel item, boolean empty) { setStyle(""); } else if (isSelected()) { setStyle("-fx-background-color: -fx-selection-bar"); - } else if (item.getEntryType().getName().equals(CitationKeyPatternsPanelViewModel.ENTRY_TYPE_DEFAULT_NAME)) { + } else if (CitationKeyPatternsPanelViewModel.ENTRY_TYPE_DEFAULT_NAME.equals(item.getEntryType().getName())) { setStyle("-fx-background-color: -fx-default-button"); } else { setStyle(""); diff --git a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java index 7a0c98f4cd8..78df89b5ba7 100644 --- a/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java +++ b/src/main/java/org/jabref/gui/commonfxcontrols/CitationKeyPatternsPanelViewModel.java @@ -26,9 +26,9 @@ public class CitationKeyPatternsPanelViewModel { if (itemOneName.equals(itemTwoName)) { return 0; - } else if (itemOneName.equals(ENTRY_TYPE_DEFAULT_NAME)) { + } else if (ENTRY_TYPE_DEFAULT_NAME.equals(itemOneName)) { return -1; - } else if (itemTwoName.equals(ENTRY_TYPE_DEFAULT_NAME)) { + } else if (ENTRY_TYPE_DEFAULT_NAME.equals(itemTwoName)) { return 1; } diff --git a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java index 4a79e57b45c..6946b5997ee 100644 --- a/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java +++ b/src/main/java/org/jabref/gui/externalfiletype/ExternalFileTypes.java @@ -205,7 +205,7 @@ public static Set fromString(String storedFileTypes) { // Read the prefs information for file types: String[][] vals = StringUtil.decodeStringDoubleArray(storedFileTypes); for (String[] val : vals) { - if ((val.length == 2) && val[1].equals(FILE_TYPE_REMOVED_FLAG)) { + if ((val.length == 2) && FILE_TYPE_REMOVED_FLAG.equals(val[1])) { // This entry indicates that a default entry type should be removed: ExternalFileType toRemove = null; for (ExternalFileType type : types) { diff --git a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java index 33640a4d1a7..dd8ef20c091 100644 --- a/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupDialogViewModel.java @@ -403,7 +403,7 @@ public void setValues() { if (parentNode != null) { parentNode.getGroup() .getIconName() - .filter(iconName -> !iconName.equals(DefaultGroupsFactory.ALL_ENTRIES_GROUP_DEFAULT_ICON)) + .filter(iconName -> !DefaultGroupsFactory.ALL_ENTRIES_GROUP_DEFAULT_ICON.equals(iconName)) .ifPresent(iconProperty::setValue); parentNode.getGroup().getColor().ifPresent(color -> colorUseProperty.setValue(true)); } diff --git a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java index 06907a2bcb8..46183d7f62b 100644 --- a/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java +++ b/src/main/java/org/jabref/gui/preferences/websearch/WebSearchTabViewModel.java @@ -147,7 +147,7 @@ public void setValues() { catalogs.addAll(WebFetchers.getSearchBasedFetchers(importFormatPreferences, importerPreferences) .stream() .map(SearchBasedFetcher::getName) - .filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME)) + .filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name)) .map(name -> { boolean enabled = importerPreferences.getCatalogs().contains(name); return new StudyCatalogItem(name, enabled); diff --git a/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java b/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java index 8080c64990a..c1dade283be 100644 --- a/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java +++ b/src/main/java/org/jabref/gui/slr/ManageStudyDefinitionViewModel.java @@ -75,7 +75,7 @@ public ManageStudyDefinitionViewModel(ImportFormatPreferences importFormatPrefer .map(SearchBasedFetcher::getName) // The user wants to select specific fetchers // The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR) - .filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME)) + .filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name)) .map(name -> { boolean enabled = DEFAULT_SELECTION.contains(name); return new StudyCatalogItem(name, enabled); @@ -108,7 +108,7 @@ public ManageStudyDefinitionViewModel(Study study, .map(SearchBasedFetcher::getName) // The user wants to select specific fetchers // The fetcher summarizing ALL fetchers can be emulated by selecting ALL fetchers (which happens rarely when doing an SLR) - .filter(name -> !name.equals(CompositeSearchBasedFetcher.FETCHER_NAME)) + .filter(name -> !CompositeSearchBasedFetcher.FETCHER_NAME.equals(name)) .map(name -> { boolean enabled = studyDatabases.contains(new StudyDatabase(name, true)); return new StudyCatalogItem(name, enabled); diff --git a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java index 85a4ecfd8e0..f9755996beb 100644 --- a/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java +++ b/src/main/java/org/jabref/logic/exporter/MetaDataSerializer.java @@ -98,7 +98,7 @@ private static Map serializeMetaData(Map> s continue; } - boolean isSaveActions = metaItem.getKey().equals(MetaData.SAVE_ACTIONS); + boolean isSaveActions = MetaData.SAVE_ACTIONS.equals(metaItem.getKey()); // The last "MetaData.SEPARATOR_STRING" adds compatibility to JabRef v5.9 and earlier StringJoiner joiner = new StringJoiner(MetaData.SEPARATOR_STRING, "", MetaData.SEPARATOR_STRING); boolean lastWasSaveActionsEnablement = false; diff --git a/src/main/java/org/jabref/logic/exporter/XmpExporter.java b/src/main/java/org/jabref/logic/exporter/XmpExporter.java index 23730852ee0..3cb88848a06 100644 --- a/src/main/java/org/jabref/logic/exporter/XmpExporter.java +++ b/src/main/java/org/jabref/logic/exporter/XmpExporter.java @@ -47,7 +47,7 @@ public void export(BibDatabaseContext databaseContext, Path file, List // This is a distinction between writing all entries from the supplied list to a single .xmp file, // or write every entry to a separate file. - if (file.getFileName().toString().trim().equals(XMP_SPLIT_DIRECTORY_INDICATOR)) { + if (XMP_SPLIT_DIRECTORY_INDICATOR.equals(file.getFileName().toString().trim())) { for (BibEntry entry : entries) { // Avoid situations, where two citation keys are null Path entryFile; diff --git a/src/main/java/org/jabref/logic/importer/Importer.java b/src/main/java/org/jabref/logic/importer/Importer.java index d991b087d3b..7f465176eea 100644 --- a/src/main/java/org/jabref/logic/importer/Importer.java +++ b/src/main/java/org/jabref/logic/importer/Importer.java @@ -121,7 +121,8 @@ protected static Charset getCharset(BufferedInputStream bufferedInputStream) { return defaultCharSet; } - if (Arrays.stream(matches).anyMatch(charset -> "ASCII".equals(charset.getName()))) { + // if we have utf8 with 100 confidence we assume that the file is in utf8, more likely + if (Arrays.stream(matches).anyMatch(charset -> "ASCII".equals(charset.getName()) || ("UTF-8".equals(charset.getName()) && charset.getConfidence() == 100))) { return defaultCharSet; } diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java index 2aa9305a869..b06068169ad 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java @@ -244,6 +244,6 @@ private boolean isAPSJournal(BibEntry entry, String doiAsString) { } String suffix = doiAsString.substring(doiAsString.lastIndexOf('/') + 1); String organizationId = doiAsString.substring(doiAsString.indexOf('.') + 1, doiAsString.indexOf('/')); - return organizationId.equals(APS_JOURNAL_ORG_DOI_ID) && APS_SUFFIX_PATTERN.matcher(suffix).matches(); + return APS_JOURNAL_ORG_DOI_ID.equals(organizationId) && APS_SUFFIX_PATTERN.matcher(suffix).matches(); } } 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 ebb1282a787..adf2f95ef77 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java @@ -212,7 +212,7 @@ private void parseDatabaseID() throws IOException { skipWhitespace(); String label = parseTextToken().trim(); - if (label.equals(BibtexDatabaseWriter.DATABASE_ID_PREFIX)) { + if (BibtexDatabaseWriter.DATABASE_ID_PREFIX.equals(label)) { skipWhitespace(); database.setSharedDatabaseID(parseTextToken().trim()); } @@ -354,7 +354,7 @@ 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 (comment.substring(0, Math.min(comment.length(), MetaData.META_FLAG.length())).equals(MetaData.META_FLAG)) { + 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()); @@ -367,8 +367,8 @@ private void parseJabRefComment(Map meta) { dumpTextReadSoFarToString(); } } - } else if (comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())) - .equals(MetaData.ENTRYTYPE_FLAG)) { + } else if (MetaData.ENTRYTYPE_FLAG + .equals(comment.substring(0, Math.min(comment.length(), MetaData.ENTRYTYPE_FLAG.length())))) { // A custom entry type can also be stored in a // "@comment" Optional typ = MetaDataParser.parseCustomEntryType(comment); diff --git a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java index 2c9c94a4745..14a5b1e6c21 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/PdfContentImporter.java @@ -243,11 +243,13 @@ protected void writeString(String text, List textPositions) { } private boolean isFarAway(TextPosition previous, TextPosition current) { - float XspaceThreshold = 3.0F; - float YspaceThreshold = previous.getFontSizeInPt() * 1.5F; + float XspaceThreshold = previous.getFontSizeInPt() * 3.0F; + float YspaceThreshold = previous.getFontSizeInPt() * 3.0F; float Xgap = current.getXDirAdj() - (previous.getXDirAdj() + previous.getWidthDirAdj()); - float Ygap = current.getYDirAdj() - (previous.getYDirAdj() - previous.getHeightDir()); - return Xgap > XspaceThreshold && Ygap > YspaceThreshold; + float Ygap = current.getYDirAdj() - previous.getYDirAdj(); + // For cases like paper titles spanning two or more lines, both X and Y gaps must exceed thresholds, + // so "&&" is used instead of "||". + return Math.abs(Xgap) > XspaceThreshold && Math.abs(Ygap) > YspaceThreshold; } private boolean isUnwantedText(TextPosition previousTextPosition, TextPosition textPosition) { @@ -258,28 +260,27 @@ private boolean isUnwantedText(TextPosition previousTextPosition, TextPosition t return true; } // The title usually don't in the bottom 10% of a page. - if ((textPosition.getPageHeight() - textPosition.getYDirAdj()) - < (textPosition.getPageHeight() * 0.1)) { - return true; - } - // The title character usually stay together. - return isFarAway(previousTextPosition, textPosition); + return (textPosition.getPageHeight() - textPosition.getYDirAdj()) + < (textPosition.getPageHeight() * 0.1); } private Optional findLargestFontText(List textPositions) { Map fontSizeTextMap = new TreeMap<>(Collections.reverseOrder()); + Map lastPositionMap = new TreeMap<>(Collections.reverseOrder()); TextPosition previousTextPosition = null; for (TextPosition textPosition : textPositions) { + float fontSize = textPosition.getFontSizeInPt(); // Exclude unwanted text based on heuristics - if (isUnwantedText(previousTextPosition, textPosition)) { + if (isUnwantedText(previousTextPosition, textPosition) || + (lastPositionMap.containsKey(fontSize) && isFarAway(lastPositionMap.get(fontSize), textPosition))) { continue; } - float fontSize = textPosition.getFontSizeInPt(); fontSizeTextMap.putIfAbsent(fontSize, new StringBuilder()); if (previousTextPosition != null && isThereSpace(previousTextPosition, textPosition)) { fontSizeTextMap.get(fontSize).append(" "); } fontSizeTextMap.get(fontSize).append(textPosition.getUnicode()); + lastPositionMap.put(fontSize, textPosition); previousTextPosition = textPosition; } for (Map.Entry entry : fontSizeTextMap.entrySet()) { diff --git a/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java b/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java index d1e66146412..d6bd258d283 100644 --- a/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java +++ b/src/main/java/org/jabref/logic/importer/util/MetaDataParser.java @@ -119,7 +119,7 @@ public MetaData parse(MetaData metaData, Map data, Character key } else if (entry.getKey().startsWith(MetaData.SELECTOR_META_PREFIX)) { // edge case, it might be one special field e.g. article from biblatex-apa, but we can't distinguish this from any other field and rather prefer to handle it as UnknownField metaData.addContentSelector(ContentSelectors.parse(FieldFactory.parseField(entry.getKey().substring(MetaData.SELECTOR_META_PREFIX.length())), StringUtil.unquote(entry.getValue(), MetaData.ESCAPE_CHARACTER))); - } else if (entry.getKey().equals(MetaData.FILE_DIRECTORY)) { + } else if (MetaData.FILE_DIRECTORY.equals(entry.getKey())) { metaData.setLibrarySpecificFileDirectory(parseDirectory(entry.getValue())); } else if (entry.getKey().startsWith(MetaData.FILE_DIRECTORY + '-')) { // The user name starts directly after FILE_DIRECTORY + '-' @@ -130,26 +130,26 @@ public MetaData parse(MetaData metaData, Map data, Character key String user = entry.getKey().substring(MetaData.FILE_DIRECTORY_LATEX.length() + 1); Path path = Path.of(parseDirectory(entry.getValue())).normalize(); metaData.setLatexFileDirectory(user, path); - } else if (entry.getKey().equals(MetaData.SAVE_ACTIONS)) { + } else if (MetaData.SAVE_ACTIONS.equals(entry.getKey())) { metaData.setSaveActions(fieldFormatterCleanupsParse(values)); - } else if (entry.getKey().equals(MetaData.DATABASE_TYPE)) { + } else if (MetaData.DATABASE_TYPE.equals(entry.getKey())) { metaData.setMode(BibDatabaseMode.parse(getSingleItem(values))); - } else if (entry.getKey().equals(MetaData.KEYPATTERNDEFAULT)) { + } else if (MetaData.KEYPATTERNDEFAULT.equals(entry.getKey())) { defaultCiteKeyPattern = new CitationKeyPattern(getSingleItem(values)); - } else if (entry.getKey().equals(MetaData.PROTECTED_FLAG_META)) { + } else if (MetaData.PROTECTED_FLAG_META.equals(entry.getKey())) { if (Boolean.parseBoolean(getSingleItem(values))) { metaData.markAsProtected(); } else { metaData.markAsNotProtected(); } - } else if (entry.getKey().equals(MetaData.SAVE_ORDER_CONFIG)) { + } else if (MetaData.SAVE_ORDER_CONFIG.equals(entry.getKey())) { metaData.setSaveOrder(SaveOrder.parse(values)); - } else if (entry.getKey().equals(MetaData.GROUPSTREE) || entry.getKey().equals(MetaData.GROUPSTREE_LEGACY)) { + } else if (MetaData.GROUPSTREE.equals(entry.getKey()) || MetaData.GROUPSTREE_LEGACY.equals(entry.getKey())) { metaData.setGroups(GroupsParser.importGroups(values, keywordSeparator, fileMonitor, metaData)); - } else if (entry.getKey().equals(MetaData.GROUPS_SEARCH_SYNTAX_VERSION)) { + } else if (MetaData.GROUPS_SEARCH_SYNTAX_VERSION.equals(entry.getKey())) { Version version = Version.parse(getSingleItem(values)); metaData.setGroupSearchSyntaxVersion(version); - } else if (entry.getKey().equals(MetaData.VERSION_DB_STRUCT)) { + } else if (MetaData.VERSION_DB_STRUCT.equals(entry.getKey())) { metaData.setVersionDBStructure(getSingleItem(values)); } else { // Keep meta data items that we do not know in the file diff --git a/src/main/java/org/jabref/logic/integrity/EditionChecker.java b/src/main/java/org/jabref/logic/integrity/EditionChecker.java index 697ca38e85c..3fb6ec5b89b 100644 --- a/src/main/java/org/jabref/logic/integrity/EditionChecker.java +++ b/src/main/java/org/jabref/logic/integrity/EditionChecker.java @@ -40,7 +40,7 @@ public Optional checkValue(String value) { return Optional.empty(); } - if (value.equals(FIRST_EDITION)) { + if (FIRST_EDITION.equals(value)) { return Optional.of(Localization.lang("edition of book reported as just 1")); } diff --git a/src/main/java/org/jabref/logic/layout/Layout.java b/src/main/java/org/jabref/logic/layout/Layout.java index 65587b1f81b..8af843a1865 100644 --- a/src/main/java/org/jabref/logic/layout/Layout.java +++ b/src/main/java/org/jabref/logic/layout/Layout.java @@ -57,7 +57,7 @@ public Layout(List parsedEntries, tmpEntries.add(le); blockEntries = null; } else { - LOGGER.debug(blockStart + '\n' + parsedEntry.s); + LOGGER.debug("{}\n{}", blockStart, parsedEntry.s); LOGGER.warn("Nested field/group entries are not implemented!"); Thread.dumpStack(); } diff --git a/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java b/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java index 9d9d8819445..0c6db429622 100644 --- a/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java +++ b/src/main/java/org/jabref/logic/shared/listener/PostgresSQLNotificationListener.java @@ -36,7 +36,7 @@ public void run() { if (notifications != null) { for (PGNotification notification : notifications) { - if (!notification.getName().equals(DBMSProcessor.PROCESSOR_ID)) { + if (!DBMSProcessor.PROCESSOR_ID.equals(notification.getName())) { dbmsSynchronizer.pullChanges(); } } diff --git a/src/main/java/org/jabref/logic/util/Version.java b/src/main/java/org/jabref/logic/util/Version.java index 1380c90e109..245ee21031f 100644 --- a/src/main/java/org/jabref/logic/util/Version.java +++ b/src/main/java/org/jabref/logic/util/Version.java @@ -57,7 +57,7 @@ private static Logger getLogger() { * @return the parsed version or {@link Version#UNKNOWN_VERSION} if an error occurred */ public static Version parse(String version) { - if ((version == null) || version.isEmpty() || version.equals(BuildInfo.UNKNOWN_VERSION) + if ((version == null) || version.isEmpty() || BuildInfo.UNKNOWN_VERSION.equals(version) || "${version}".equals(version)) { return UNKNOWN_VERSION; } @@ -127,9 +127,9 @@ public boolean isNewerThan(Version otherVersion) { Objects.requireNonNull(otherVersion); if (Objects.equals(this, otherVersion)) { return false; - } else if (this.getFullVersion().equals(BuildInfo.UNKNOWN_VERSION)) { + } else if (BuildInfo.UNKNOWN_VERSION.equals(this.getFullVersion())) { return false; - } else if (otherVersion.getFullVersion().equals(BuildInfo.UNKNOWN_VERSION)) { + } else if (BuildInfo.UNKNOWN_VERSION.equals(otherVersion.getFullVersion())) { return false; } diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index b5a2ba9bbad..10d0eb4e30f 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -516,9 +516,9 @@ private static void upgradeCleanups(JabRefCliPreferences prefs) { List formatterCleanups = List.of(StringUtil.unifyLineBreaks(prefs.get(V5_8_CLEANUP_FIELD_FORMATTERS), "\n") .split("\n")); if (formatterCleanups.size() >= 2 - && (formatterCleanups.getFirst().equals(FieldFormatterCleanups.ENABLED) - || formatterCleanups.getFirst().equals(FieldFormatterCleanups.DISABLED))) { - prefs.putBoolean(V6_0_CLEANUP_FIELD_FORMATTERS_ENABLED, formatterCleanups.getFirst().equals(FieldFormatterCleanups.ENABLED) + && (FieldFormatterCleanups.ENABLED.equals(formatterCleanups.getFirst()) + || FieldFormatterCleanups.DISABLED.equals(formatterCleanups.getFirst()))) { + prefs.putBoolean(V6_0_CLEANUP_FIELD_FORMATTERS_ENABLED, FieldFormatterCleanups.ENABLED.equals(formatterCleanups.getFirst()) ? Boolean.TRUE : Boolean.FALSE); diff --git a/src/main/java/org/jabref/model/database/BibDatabaseContext.java b/src/main/java/org/jabref/model/database/BibDatabaseContext.java index f90a7c64fbd..2efba5d6c65 100644 --- a/src/main/java/org/jabref/model/database/BibDatabaseContext.java +++ b/src/main/java/org/jabref/model/database/BibDatabaseContext.java @@ -133,7 +133,7 @@ public boolean isBiblatexMode() { */ public boolean isStudy() { return this.getDatabasePath() - .map(path -> path.getFileName().toString().equals(Crawler.FILENAME_STUDY_RESULT_BIB) && + .map(path -> Crawler.FILENAME_STUDY_RESULT_BIB.equals(path.getFileName().toString()) && Files.exists(path.resolveSibling(StudyRepository.STUDY_DEFINITION_FILE_NAME))) .orElse(false); } diff --git a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java index 43a551a8634..80d6c6cf092 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/PdfContentImporterTest.java @@ -150,7 +150,8 @@ private static Stream providePdfData() { Arguments.of("On the impact of service-oriented patterns on software evolvability: a controlled experiment and metric-based analysis", "/pdfs/PdfContentImporter/Bogner2019.pdf"), Arguments.of("Pandemic programming", "/pdfs/PdfContentImporter/Ralph2020.pdf"), Arguments.of("Do RESTful API design rules have an impact on the understandability of Web APIs?", "/pdfs/PdfContentImporter/Bogner2023.pdf"), - Arguments.of("Adopting microservices and DevOps in the cyber-physical systems domain: A rapid review and case study", "/pdfs/PdfContentImporter/Fritzsch2022.pdf") + Arguments.of("Adopting microservices and DevOps in the cyber-physical systems domain: A rapid review and case study", "/pdfs/PdfContentImporter/Fritzsch2022.pdf"), + Arguments.of("OPIUM: Optimal Package Install/Uninstall Manager", "/pdfs/PdfContentImporter/opium.pdf") ); } } diff --git a/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java b/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java index dc43b0d26cb..02cd04e72ca 100644 --- a/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java +++ b/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java @@ -197,7 +197,7 @@ static Stream ooHTMLTransformFromRawBibliography() { // Small-caps Arguments.of( - " Smith, B., Jones, B., Williams, J. (2016) Title of the test entry Taylor, P. (ed.). BibTeX Journal, 34(3), pp. 45–67.

", + " Smith, B., Jones, B. and Williams, J. (2016) Title of the test entry Taylor, P. (ed.). BibTeX Journal, 34(3), pp. 45–67.

", STYLE_LIST.stream().filter(e -> "De Montfort University - Harvard".equals(e.getTitle())).findAny().get() ), @@ -305,12 +305,12 @@ static Stream ooHTMLTransformFromCitationWithSingleEntry() { ), Arguments.of( - "(Smith, Jones, Williams, 2016)", + "(Smith, Jones and Williams, 2016)", STYLE_LIST.stream().filter(e -> "De Montfort University - Harvard".equals(e.getTitle())).findAny().get() ), Arguments.of( - "(Smith, Jones, & Williams)", + "(Smith, Jones, & Williams, “Title of the test entry”)", STYLE_LIST.stream().filter(e -> "Modern Language Association 7th edition (underline)".equals(e.getTitle())).findAny().get() ), @@ -429,12 +429,12 @@ static Stream ooHTMLTransformFromCitationWithMultipleEntries() { ), Arguments.of( - "(Garcia, Lee, 2021; Smith, Johnson, 2020)", + "(Garcia and Lee, 2021; Smith and Johnson, 2020)", STYLE_LIST.stream().filter(e -> "De Montfort University - Harvard".equals(e.getTitle())).findAny().get() ), Arguments.of( - "(Garcia & Lee; Smith & Johnson)", + "(Garcia & Lee, “Quantum Entanglement in Superconductors”; Smith & Johnson, “A Study on Machine Learning Algorithms”)", STYLE_LIST.stream().filter(e -> "Modern Language Association 7th edition (underline)".equals(e.getTitle())).findAny().get() ), diff --git a/src/test/resources/pdfs/PdfContentImporter/opium.pdf b/src/test/resources/pdfs/PdfContentImporter/opium.pdf new file mode 100644 index 00000000000..b34c19a48a5 Binary files /dev/null and b/src/test/resources/pdfs/PdfContentImporter/opium.pdf differ