Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into jdk17
Browse files Browse the repository at this point in the history
* upstream/main: (26 commits)
  Add unit test to four test classes (#7651)
  Fix IEEE test (#7852)
  New Crowdin updates (#7859)
  Fix markdown syntax of ADRs
  add missing l10n (#7857)
  New Crowdin updates (#7847)
  Bump mockito-core from 3.11.1 to 3.11.2 (#7856)
  Bump checkstyle from 8.43 to 8.44 (#7855)
  Fix for issue #4652: Add Find Unlinked Files Filter based on Date (#7846)
  Fix for entering a backslash in the custom entry preview dialog (#7851)
  Fixed INSPIREFetcherTest
  Fixed TitleFetcherTest
  Ignore baeldung.com and tldrlegal.com from out link checks
  New Crowdin updates (#7845)
  New Crowdin updates (#7843)
  Refactoring and addition of unit tests (#7597)
  CLI option to write XMP metadata to pdfs (#7814)
  Add query validation for web search (#7809)
  change eclipse default output dir (#7842)
  Bump lucene-queryparser from 8.8.2 to 8.9.0 (#7835)
  ...
  • Loading branch information
Siedlerchr committed Jun 30, 2021
2 parents c25f8e8 + a01754c commit 49757c8
Show file tree
Hide file tree
Showing 98 changed files with 3,084 additions and 1,261 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added a progress counter to the title bar in Possible Duplicates dialog window. [#7366](https://github.com/JabRef/jabref/issues/7366)
- We added new "Customization" tab to the preferences which includes option to choose a custom address for DOI access. [#7337](https://github.com/JabRef/jabref/issues/7337)
- We added zbmath to the public databases from which the bibliographic information of an existing entry can be updated. [#7437](https://github.com/JabRef/jabref/issues/7437)
- We showed to the find Unlinked Files Dialog the date of the files' most recent modification. [#4652](https://github.com/JabRef/jabref/issues/4652)
- We added to the find Unlinked Files function a filter to show only files based on date of last modification (Last Year, Last Month, Last Week, Last Day). [#4652](https://github.com/JabRef/jabref/issues/4652)
- We added to the find Unlinked Files function a filter that sorts the files based on the date of last modification(Sort by Newest, Sort by Oldest First). [#4652](https://github.com/JabRef/jabref/issues/4652)
- We added the possibility to add a new entry via its zbMath ID (zbMATH can be chosen as ID type in the "Select entry type" window). [#7202](https://github.com/JabRef/jabref/issues/7202)
- We added the extension support and the external application support (For Texshow, Texmaker and LyX) to the flatpak [#7248](https://github.com/JabRef/jabref/pull/7248)
- We added some symbols and keybindings to the context menu in the entry editor. [#7268](https://github.com/JabRef/jabref/pull/7268)
Expand All @@ -28,9 +31,11 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added a select all button for the library import function. [#7786](https://github.com/JabRef/jabref/issues/7786)
- We added a search feature for journal abbreviations. [#7804](https://github.com/JabRef/jabref/pull/7804)
- We added auto-key-generation progress to the background task list. [#7267](https://github.com/JabRef/jabref/issues/72)
- We added the option to write XMP metadata to pdfs from the CLI. [7814](https://github.com/JabRef/jabref/pull/7814)

### Changed

- The export to MS Office XML now exports the author field as `Inventor` if the bibtex entry type is `patent` [#7830](https://github.com/JabRef/jabref/issues/7830)
- We changed the EndNote importer to import the field `label` to the corresponding bibtex field `endnote-label` [forum#2734](https://discourse.jabref.org/t/importing-endnote-label-field-to-jabref-from-xml-file/2734)
- The keywords added via "Manage content selectors" are now displayed in alphabetical order. [#3791](https://github.com/JabRef/jabref/issues/3791)
- We improved the "Find unlinked files" dialog to show import results for each file. [#7209](https://github.com/JabRef/jabref/pull/7209)
Expand All @@ -53,6 +58,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an isuse where some texts (e.g. descriptionss) in dialogs could not be translated [#7854](https://github.com/JabRef/jabref/issues/7854)
- We fixed an issue where import hangs for ris files with "ER - " [#7737](https://github.com/JabRef/jabref/issues/7737)
- We fixed an issue where getting bibliograhpic data from DOI or another identifer did not respect the library mode (BibTeX/biblatex)[#1018](https://github.com/JabRef/jabref/issues/6267)
- We fixed an issue where importing entries would not respect the library mode (BibTeX/biblatex)[#1018](https://github.com/JabRef/jabref/issues/1018)
Expand Down Expand Up @@ -109,6 +115,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the RFC fetcher is not compatible with the draft [7305](https://github.com/JabRef/jabref/issues/7305)
- We fixed an issue where duplicate files (both file names and contents are the same) is downloaded and add to linked files [#6197](https://github.com/JabRef/jabref/issues/6197)
- We fixed an issue where changing the appearance of the preview tab did not trigger a restart warning. [#5464](https://github.com/JabRef/jabref/issues/5464)
- We fixed an issue where editing "Custom preview style" triggers exception. [#7526](https://github.com/JabRef/jabref/issues/7526)
- We fixed an issue where a title with multiple applied formattings in EndNote was not imported correctly [forum#2734](https://discourse.jabref.org/t/importing-endnote-label-field-to-jabref-from-xml-file/2734)
- We fixed an issue where a `report` in EndNote was imported as `article` [forum#2734](https://discourse.jabref.org/t/importing-endnote-label-field-to-jabref-from-xml-file/2734)
- We fixed an issue where the field `publisher` in EndNote was not imported in JabRef [forum#2734](https://discourse.jabref.org/t/importing-endnote-label-field-to-jabref-from-xml-file/2734)
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ dependencies {

implementation 'commons-cli:commons-cli:1.4'

implementation 'org.libreoffice:libreoffice:7.1.3'
implementation 'org.libreoffice:unoloader:7.1.3'
implementation 'org.libreoffice:libreoffice:7.1.4'
implementation 'org.libreoffice:unoloader:7.1.4'

implementation 'io.github.java-diff-utils:java-diff-utils:4.10'
implementation 'info.debatty:java-string-similarity:2.0.0'
Expand All @@ -142,18 +142,18 @@ dependencies {
antlr4 'org.antlr:antlr4:4.9.2'
implementation 'org.antlr:antlr4-runtime:4.9.2'

implementation (group: 'org.apache.lucene', name: 'lucene-queryparser', version: '8.8.2') {
implementation (group: 'org.apache.lucene', name: 'lucene-queryparser', version: '8.9.0') {
exclude group: 'org.apache.lucene', module: 'lucene-sandbox'
}

implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.11.1.202105131744-r'
implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '5.12.0.202106070339-r'

implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.12.3'
implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.12.3'

implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.3'

implementation 'org.postgresql:postgresql:42.2.21'
implementation 'org.postgresql:postgresql:42.2.22'

implementation ('com.oracle.ojdbc:ojdbc10:19.3.0.0') {
// causing module issues
Expand Down Expand Up @@ -214,10 +214,10 @@ dependencies {
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.2'
testImplementation 'org.junit.platform:junit-platform-launcher:1.7.2'

testImplementation 'net.bytebuddy:byte-buddy-parent:1.11.2'
testImplementation 'net.bytebuddy:byte-buddy-parent:1.11.5'
testRuntimeOnly group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT'
testRuntimeOnly group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '3.0.0-SNAPSHOT'
testImplementation 'org.mockito:mockito-core:3.11.1'
testImplementation 'org.mockito:mockito-core:3.11.2'
testImplementation 'org.xmlunit:xmlunit-core:2.8.2'
testImplementation 'org.xmlunit:xmlunit-matchers:2.8.2'
testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:0.19.0'
Expand All @@ -226,7 +226,7 @@ dependencies {
testImplementation "org.testfx:testfx-junit5:4.0.17-alpha-SNAPSHOT"
testImplementation "org.hamcrest:hamcrest-library:2.2"

checkstyle 'com.puppycrawl.tools:checkstyle:8.43'
checkstyle 'com.puppycrawl.tools:checkstyle:8.44'
xjc group: 'org.glassfish.jaxb', name: 'jaxb-xjc', version: '2.3.3'
}

Expand Down
13 changes: 7 additions & 6 deletions docs/adr/0013-add-native-support-biblatex-software.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ With citing software becoming fairly common, native support is helpful.
## Considered Options

* Add the new entry types to the existing biblatex types
* Add a divider with label Biblatex-Software under which the new entries are listed : Native support for Biblatex-Software
* Support via customized entry types : A user can load a customized bib file
* Add a divider with label Biblatex-Software under which the new entries are listed: Native support for Biblatex-Software
* Support via customized entry types: A user can load a customized bib file

## Decision Outcome

Chosen option: Add a new divider, because comes out best (see below).
Chosen option: "Add a new divider", because comes out best (see below).

### Positive Consequences

Expand All @@ -33,15 +33,16 @@ Chosen option: Add a new divider, because comes out best (see below).

## Pros and Cons of the Options

### Adding the new entry types to the existing biblatex types
### Add the new entry types to the existing biblatex types

* Good, because there is no need for a new category in the add entry pane

### Add a divider with label Biblatex-Software with relevant types
### Add a divider with label Biblatex-Software under which the new entries are listed: Native support for Biblatex-Software

* Good, since this gives the user a bit more clarity

### Support via customized entry types

### Support via customized entry types: A user can load a customized bib file

* Good, because no code needs to be changed
* Bad, because documentation is needed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ Chosen option: "Regular expression", because we can use Java internal classes (P
### Negative Consequences

* Regular expressions can never cover every case, therefore, splitting may not be accurate for every title

4 changes: 2 additions & 2 deletions docs/adr/0019-implement-special-fields-as-seperate-fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ keywords = {prio1, printed, read}

* Good, because does not bloat the BibTeX file. Typically, 50% of the lines are special fields
* Good, because the user can easily assign a special field. E.g, typing “, prio1” into keywords instead of “\n priority = {prio1},”
* Bad, because they need to be synchronized to fields (because otherwise, the maintable cannot render it)
* Bad, because they need to be synchronized to fields (because otherwise, the maintable cannot render it)
* Bad, because keywords are related to the actual content
* Bad, because some users want to keep publisher keywords

Expand All @@ -61,7 +61,7 @@ Example:
jabrefspecial = {prio1, printed, red}
```

* Good, because typing effort
* Good, because typing effort
* Bad, because handling in table gets complicated → one field is now multiple columns

### Special fields as sub-feature of groups
Expand Down
2 changes: 1 addition & 1 deletion docs/adr/0021-keep-study-as-a-dto.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Chosen option: "Keep study as DTO and use transformators", because comes out bes

## Pros and Cons of the Options

### Keep study as DTO and use transformators
### Keep study as DTO and use transformers

* Good, because no need for custom serialization
* Good, because deactivated fetchers can be documented (important for traceable Searching (SLRs))
Expand Down
33 changes: 33 additions & 0 deletions docs/adr/0022-remove-stop-words-during-query-transformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Remove stop words during query transformation

## Context and Problem Statement

When quering for a title of a paper, the title might contain stop words such as "a", "for", "and". Some data providers return 0 results when querying for a stop word. When transforming a query to the lucene syntax, the default Boolean operator `and` is used. When using IEEE, this often leads to zero search results.

## Decision Drivers

* Consistent to the Google search engine
* Allow reproducible searches
* Avoid WTFs on the user's side

## Considered Options

* Remove stop words from the query
* Automatically enclose in quotes if no Boolean operator is contained

## Decision Outcome

Chosen option: "Remove stop words from the query", because comes out best.

## Pros and Cons of the Options

### Remove stop words from the query

* Good, because Good search results if no Boolean operators are used
* Bad, because When using complex queries and stop words are used alone, they are silently removed

### Automatically enclose in quotes if no Boolean operator is contained

* Good, because Good search results if no Boolean operators are used
* Bad, because Silently leads to different results
* Bad, because Inconsistent to Google behavior
2 changes: 1 addition & 1 deletion eclipse.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ eclipse {
}
}

defaultOutputDir = file('build')
defaultOutputDir = file('bin/main')
downloadSources = true
downloadJavadoc = true
}
Expand Down
6 changes: 6 additions & 0 deletions mlc_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"ignorePatterns": [
{
"pattern": "baeldung.com"
},
{
"pattern": "^CONTRIBUTING\\.md"
},
Expand All @@ -21,6 +24,9 @@
{
"pattern": "^http://purl\\.org/net/bibteXMP"
},
{
"pattern": "tldrlegal.com"
},
{
"pattern": "^https://www\\.slant\\.co/"
},
Expand Down
95 changes: 95 additions & 0 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.Set;
import java.util.Vector;
import java.util.prefs.BackingStoreException;

import org.jabref.gui.Globals;
Expand All @@ -24,6 +28,7 @@
import org.jabref.logic.exporter.ExporterFactory;
import org.jabref.logic.exporter.SavePreferences;
import org.jabref.logic.exporter.TemplateExporter;
import org.jabref.logic.exporter.XmpPdfExporter;
import org.jabref.logic.importer.FetcherException;
import org.jabref.logic.importer.ImportException;
import org.jabref.logic.importer.ImportFormatReader;
Expand All @@ -49,6 +54,8 @@
import org.jabref.model.entry.BibEntry;
import org.jabref.model.strings.StringUtil;
import org.jabref.model.util.DummyFileUpdateMonitor;
import org.jabref.model.util.FileHelper;
import org.jabref.preferences.FilePreferences;
import org.jabref.preferences.SearchPreferences;

import com.google.common.base.Throwables;
Expand Down Expand Up @@ -215,6 +222,12 @@ private List<ParserResult> processArguments() {
automaticallySetFileLinks(loaded);
}

if (cli.isWriteXMPtoPdf()) {
if (!loaded.isEmpty()) {
writeXMPtoPdf(loaded, cli.getWriteXMPtoPdf(), Globals.prefs.getDefaultEncoding(), Globals.prefs.getXmpPreferences(), Globals.prefs.getFilePreferences());
}
}

if (cli.isFileExport()) {
if (!loaded.isEmpty()) {
exportFile(loaded, cli.getFileExport().split(","));
Expand All @@ -239,6 +252,88 @@ private List<ParserResult> processArguments() {
return loaded;
}

private void writeXMPtoPdf(List<ParserResult> loaded, String filesAndCitekeys, Charset encoding, XmpPreferences xmpPreferences, FilePreferences filePreferences) {
if (loaded.isEmpty()) {
LOGGER.error("The write xmp option depends on a valid import option.");
return;
}
ParserResult pr = loaded.get(loaded.size() - 1);
BibDatabaseContext databaseContext = pr.getDatabaseContext();
BibDatabase dataBase = pr.getDatabase();

XmpPdfExporter xmpPdfExporter = new XmpPdfExporter(xmpPreferences);

if ("all".equals(filesAndCitekeys)) {
for (BibEntry entry : dataBase.getEntries()) {
writeXMPtoPDFsOfEntry(databaseContext, entry.getCitationKey().orElse("<no cite key defined>"), entry, encoding, filePreferences, xmpPdfExporter);
}
return;
}

Vector<String> citeKeys = new Vector<>();
Vector<String> pdfs = new Vector<>();
for (String fileOrCiteKey : filesAndCitekeys.split(",")) {
if (fileOrCiteKey.toLowerCase(Locale.ROOT).endsWith(".pdf")) {
pdfs.add(fileOrCiteKey);
} else {
citeKeys.add(fileOrCiteKey);
}
}

writeXMPtoPdfByCitekey(databaseContext, dataBase, citeKeys, encoding, filePreferences, xmpPdfExporter);
writeXMPtoPdfByFileNames(databaseContext, dataBase, pdfs, encoding, filePreferences, xmpPdfExporter);

}

private void writeXMPtoPDFsOfEntry(BibDatabaseContext databaseContext, String citeKey, BibEntry entry, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
try {
if (xmpPdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, Arrays.asList(entry))) {
LOGGER.info(String.format("Successfully written XMP metadata on at least one linked file of %s", citeKey));
} else {
LOGGER.error(String.format("Cannot write XMP metadata on any linked files of %s. Make sure there is at least one linked file and the path is correct.", citeKey));
}
} catch (Exception e) {
LOGGER.error(String.format("Failed writing XMP metadata on a linked file of %s.", citeKey));
}
}

private void writeXMPtoPdfByCitekey(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> citeKeys, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
for (String citeKey : citeKeys) {
List<BibEntry> bibEntryList = dataBase.getEntriesByCitationKey(citeKey);
if (bibEntryList.isEmpty()) {
LOGGER.error(String.format("Skipped - Cannot find %s in library.", citeKey));
continue;
}
for (BibEntry entry : bibEntryList) {
writeXMPtoPDFsOfEntry(databaseContext, citeKey, entry, encoding, filePreferences, xmpPdfExporter);
}
}
}

private void writeXMPtoPdfByFileNames(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> fileNames, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
for (String fileName : fileNames) {
Path filePath = Path.of(fileName);
if (!filePath.isAbsolute()) {
filePath = FileHelper.find(fileName, databaseContext.getFileDirectories(filePreferences)).orElse(FileHelper.find(fileName, Arrays.asList(Path.of("").toAbsolutePath())).orElse(filePath));
}
if (Files.exists(filePath)) {
try {
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
LOGGER.info(String.format("Successfully written XMP metadata of at least one entry to %s", fileName));
} else {
LOGGER.error(String.format("File %s is not linked to any entry in database.", fileName));
}
} catch (IOException e) {
LOGGER.error("Error accessing files.", fileName);
} catch (Exception e) {
LOGGER.error(String.format("Error writing entry to %s.", fileName));
}
} else {
LOGGER.error(String.format("Skipped - PDF %s does not exist", fileName));
}
}
}

private boolean exportMatches(List<ParserResult> loaded) {
String[] data = cli.getExportMatches().split(",");
String searchTerm = data[0].replace("\\$", " "); // enables blanks within the search term:
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ public boolean isAutomaticallySetFileLinks() {
return cl.hasOption("automaticallySetFileLinks");
}

public boolean isWriteXMPtoPdf() {
return cl.hasOption("writeXMPtoPdf");
}

public String getWriteXMPtoPdf() {
return cl.getOptionValue("writeXMPtoPdf");
}

private static Options getOptions() {
Options options = new Options();

Expand Down Expand Up @@ -242,6 +250,14 @@ private static Options getOptions() {
.argName("KEY1[,KEY2][,KEYn] | all")
.build());

options.addOption(Option
.builder("w")
.longOpt("writeXMPtoPdf")
.desc(String.format("%s: '%s'", Localization.lang("Write BibTeXEntry as XMP metadata to PDF."), "-w pathToMyOwnPaper.pdf"))
.hasArg()
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
.build());

return options;
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/gui/Base.css
Original file line number Diff line number Diff line change
Expand Up @@ -1236,3 +1236,7 @@ TextFlow * {
.fontsizeSpinner{
-fx-pref-width: 5em;
}

.text-field:invalid {
-fx-background-color: rgba(240, 128, 128, 0.5);
}

0 comments on commit 49757c8

Please sign in to comment.