Skip to content

Commit 49757c8

Browse files
committed
Merge remote-tracking branch 'upstream/main' into jdk17
* 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) ...
2 parents c25f8e8 + a01754c commit 49757c8

File tree

98 files changed

+3084
-1261
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+3084
-1261
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
1414
- We added a progress counter to the title bar in Possible Duplicates dialog window. [#7366](https://github.com/JabRef/jabref/issues/7366)
1515
- 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)
1616
- 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)
17+
- We showed to the find Unlinked Files Dialog the date of the files' most recent modification. [#4652](https://github.com/JabRef/jabref/issues/4652)
18+
- 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)
19+
- 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)
1720
- 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)
1821
- 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)
1922
- We added some symbols and keybindings to the context menu in the entry editor. [#7268](https://github.com/JabRef/jabref/pull/7268)
@@ -28,9 +31,11 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
2831
- We added a select all button for the library import function. [#7786](https://github.com/JabRef/jabref/issues/7786)
2932
- We added a search feature for journal abbreviations. [#7804](https://github.com/JabRef/jabref/pull/7804)
3033
- We added auto-key-generation progress to the background task list. [#7267](https://github.com/JabRef/jabref/issues/72)
34+
- We added the option to write XMP metadata to pdfs from the CLI. [7814](https://github.com/JabRef/jabref/pull/7814)
3135

3236
### Changed
3337

38+
- 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)
3439
- 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)
3540
- The keywords added via "Manage content selectors" are now displayed in alphabetical order. [#3791](https://github.com/JabRef/jabref/issues/3791)
3641
- We improved the "Find unlinked files" dialog to show import results for each file. [#7209](https://github.com/JabRef/jabref/pull/7209)
@@ -53,6 +58,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
5358

5459
### Fixed
5560

61+
- We fixed an isuse where some texts (e.g. descriptionss) in dialogs could not be translated [#7854](https://github.com/JabRef/jabref/issues/7854)
5662
- We fixed an issue where import hangs for ris files with "ER - " [#7737](https://github.com/JabRef/jabref/issues/7737)
5763
- 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)
5864
- We fixed an issue where importing entries would not respect the library mode (BibTeX/biblatex)[#1018](https://github.com/JabRef/jabref/issues/1018)
@@ -109,6 +115,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
109115
- We fixed an issue where the RFC fetcher is not compatible with the draft [7305](https://github.com/JabRef/jabref/issues/7305)
110116
- 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)
111117
- 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)
118+
- We fixed an issue where editing "Custom preview style" triggers exception. [#7526](https://github.com/JabRef/jabref/issues/7526)
112119
- 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)
113120
- 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)
114121
- 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)

build.gradle

+8-8
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ dependencies {
130130

131131
implementation 'commons-cli:commons-cli:1.4'
132132

133-
implementation 'org.libreoffice:libreoffice:7.1.3'
134-
implementation 'org.libreoffice:unoloader:7.1.3'
133+
implementation 'org.libreoffice:libreoffice:7.1.4'
134+
implementation 'org.libreoffice:unoloader:7.1.4'
135135

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

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

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

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

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

156-
implementation 'org.postgresql:postgresql:42.2.21'
156+
implementation 'org.postgresql:postgresql:42.2.22'
157157

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

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

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

docs/adr/0013-add-native-support-biblatex-software.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ With citing software becoming fairly common, native support is helpful.
1616
## Considered Options
1717

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

2222
## Decision Outcome
2323

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

2626
### Positive Consequences
2727

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

3434
## Pros and Cons of the Options
3535

36-
### Adding the new entry types to the existing biblatex types
36+
### Add the new entry types to the existing biblatex types
3737

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

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

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

44-
### Support via customized entry types
44+
45+
### Support via customized entry types: A user can load a customized bib file
4546

4647
* Good, because no code needs to be changed
4748
* Bad, because documentation is needed

docs/adr/0018-use-regular-expression-to-split-multiple-sentence-titles.md

-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,3 @@ Chosen option: "Regular expression", because we can use Java internal classes (P
2323
### Negative Consequences
2424

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

docs/adr/0019-implement-special-fields-as-seperate-fields.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ keywords = {prio1, printed, read}
4949

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

@@ -61,7 +61,7 @@ Example:
6161
jabrefspecial = {prio1, printed, red}
6262
```
6363

64-
* Good, because typing effort
64+
* Good, because typing effort
6565
* Bad, because handling in table gets complicated → one field is now multiple columns
6666

6767
### Special fields as sub-feature of groups

docs/adr/0021-keep-study-as-a-dto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Chosen option: "Keep study as DTO and use transformators", because comes out bes
1616

1717
## Pros and Cons of the Options
1818

19-
### Keep study as DTO and use transformators
19+
### Keep study as DTO and use transformers
2020

2121
* Good, because no need for custom serialization
2222
* Good, because deactivated fetchers can be documented (important for traceable Searching (SLRs))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Remove stop words during query transformation
2+
3+
## Context and Problem Statement
4+
5+
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.
6+
7+
## Decision Drivers
8+
9+
* Consistent to the Google search engine
10+
* Allow reproducible searches
11+
* Avoid WTFs on the user's side
12+
13+
## Considered Options
14+
15+
* Remove stop words from the query
16+
* Automatically enclose in quotes if no Boolean operator is contained
17+
18+
## Decision Outcome
19+
20+
Chosen option: "Remove stop words from the query", because comes out best.
21+
22+
## Pros and Cons of the Options
23+
24+
### Remove stop words from the query
25+
26+
* Good, because Good search results if no Boolean operators are used
27+
* Bad, because When using complex queries and stop words are used alone, they are silently removed
28+
29+
### Automatically enclose in quotes if no Boolean operator is contained
30+
31+
* Good, because Good search results if no Boolean operators are used
32+
* Bad, because Silently leads to different results
33+
* Bad, because Inconsistent to Google behavior

eclipse.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ eclipse {
4040
}
4141
}
4242

43-
defaultOutputDir = file('build')
43+
defaultOutputDir = file('bin/main')
4444
downloadSources = true
4545
downloadJavadoc = true
4646
}

mlc_config.json

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"ignorePatterns": [
3+
{
4+
"pattern": "baeldung.com"
5+
},
36
{
47
"pattern": "^CONTRIBUTING\\.md"
58
},
@@ -21,6 +24,9 @@
2124
{
2225
"pattern": "^http://purl\\.org/net/bibteXMP"
2326
},
27+
{
28+
"pattern": "tldrlegal.com"
29+
},
2430
{
2531
"pattern": "^https://www\\.slant\\.co/"
2632
},

src/main/java/org/jabref/cli/ArgumentProcessor.java

+95
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.nio.charset.Charset;
6+
import java.nio.file.Files;
57
import java.nio.file.Path;
68
import java.util.ArrayList;
9+
import java.util.Arrays;
710
import java.util.Collections;
811
import java.util.List;
912
import java.util.Locale;
1013
import java.util.Optional;
1114
import java.util.Set;
15+
import java.util.Vector;
1216
import java.util.prefs.BackingStoreException;
1317

1418
import org.jabref.gui.Globals;
@@ -24,6 +28,7 @@
2428
import org.jabref.logic.exporter.ExporterFactory;
2529
import org.jabref.logic.exporter.SavePreferences;
2630
import org.jabref.logic.exporter.TemplateExporter;
31+
import org.jabref.logic.exporter.XmpPdfExporter;
2732
import org.jabref.logic.importer.FetcherException;
2833
import org.jabref.logic.importer.ImportException;
2934
import org.jabref.logic.importer.ImportFormatReader;
@@ -49,6 +54,8 @@
4954
import org.jabref.model.entry.BibEntry;
5055
import org.jabref.model.strings.StringUtil;
5156
import org.jabref.model.util.DummyFileUpdateMonitor;
57+
import org.jabref.model.util.FileHelper;
58+
import org.jabref.preferences.FilePreferences;
5259
import org.jabref.preferences.SearchPreferences;
5360

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

225+
if (cli.isWriteXMPtoPdf()) {
226+
if (!loaded.isEmpty()) {
227+
writeXMPtoPdf(loaded, cli.getWriteXMPtoPdf(), Globals.prefs.getDefaultEncoding(), Globals.prefs.getXmpPreferences(), Globals.prefs.getFilePreferences());
228+
}
229+
}
230+
218231
if (cli.isFileExport()) {
219232
if (!loaded.isEmpty()) {
220233
exportFile(loaded, cli.getFileExport().split(","));
@@ -239,6 +252,88 @@ private List<ParserResult> processArguments() {
239252
return loaded;
240253
}
241254

255+
private void writeXMPtoPdf(List<ParserResult> loaded, String filesAndCitekeys, Charset encoding, XmpPreferences xmpPreferences, FilePreferences filePreferences) {
256+
if (loaded.isEmpty()) {
257+
LOGGER.error("The write xmp option depends on a valid import option.");
258+
return;
259+
}
260+
ParserResult pr = loaded.get(loaded.size() - 1);
261+
BibDatabaseContext databaseContext = pr.getDatabaseContext();
262+
BibDatabase dataBase = pr.getDatabase();
263+
264+
XmpPdfExporter xmpPdfExporter = new XmpPdfExporter(xmpPreferences);
265+
266+
if ("all".equals(filesAndCitekeys)) {
267+
for (BibEntry entry : dataBase.getEntries()) {
268+
writeXMPtoPDFsOfEntry(databaseContext, entry.getCitationKey().orElse("<no cite key defined>"), entry, encoding, filePreferences, xmpPdfExporter);
269+
}
270+
return;
271+
}
272+
273+
Vector<String> citeKeys = new Vector<>();
274+
Vector<String> pdfs = new Vector<>();
275+
for (String fileOrCiteKey : filesAndCitekeys.split(",")) {
276+
if (fileOrCiteKey.toLowerCase(Locale.ROOT).endsWith(".pdf")) {
277+
pdfs.add(fileOrCiteKey);
278+
} else {
279+
citeKeys.add(fileOrCiteKey);
280+
}
281+
}
282+
283+
writeXMPtoPdfByCitekey(databaseContext, dataBase, citeKeys, encoding, filePreferences, xmpPdfExporter);
284+
writeXMPtoPdfByFileNames(databaseContext, dataBase, pdfs, encoding, filePreferences, xmpPdfExporter);
285+
286+
}
287+
288+
private void writeXMPtoPDFsOfEntry(BibDatabaseContext databaseContext, String citeKey, BibEntry entry, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
289+
try {
290+
if (xmpPdfExporter.exportToAllFilesOfEntry(databaseContext, encoding, filePreferences, entry, Arrays.asList(entry))) {
291+
LOGGER.info(String.format("Successfully written XMP metadata on at least one linked file of %s", citeKey));
292+
} else {
293+
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));
294+
}
295+
} catch (Exception e) {
296+
LOGGER.error(String.format("Failed writing XMP metadata on a linked file of %s.", citeKey));
297+
}
298+
}
299+
300+
private void writeXMPtoPdfByCitekey(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> citeKeys, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
301+
for (String citeKey : citeKeys) {
302+
List<BibEntry> bibEntryList = dataBase.getEntriesByCitationKey(citeKey);
303+
if (bibEntryList.isEmpty()) {
304+
LOGGER.error(String.format("Skipped - Cannot find %s in library.", citeKey));
305+
continue;
306+
}
307+
for (BibEntry entry : bibEntryList) {
308+
writeXMPtoPDFsOfEntry(databaseContext, citeKey, entry, encoding, filePreferences, xmpPdfExporter);
309+
}
310+
}
311+
}
312+
313+
private void writeXMPtoPdfByFileNames(BibDatabaseContext databaseContext, BibDatabase dataBase, Vector<String> fileNames, Charset encoding, FilePreferences filePreferences, XmpPdfExporter xmpPdfExporter) {
314+
for (String fileName : fileNames) {
315+
Path filePath = Path.of(fileName);
316+
if (!filePath.isAbsolute()) {
317+
filePath = FileHelper.find(fileName, databaseContext.getFileDirectories(filePreferences)).orElse(FileHelper.find(fileName, Arrays.asList(Path.of("").toAbsolutePath())).orElse(filePath));
318+
}
319+
if (Files.exists(filePath)) {
320+
try {
321+
if (xmpPdfExporter.exportToFileByPath(databaseContext, dataBase, encoding, filePreferences, filePath)) {
322+
LOGGER.info(String.format("Successfully written XMP metadata of at least one entry to %s", fileName));
323+
} else {
324+
LOGGER.error(String.format("File %s is not linked to any entry in database.", fileName));
325+
}
326+
} catch (IOException e) {
327+
LOGGER.error("Error accessing files.", fileName);
328+
} catch (Exception e) {
329+
LOGGER.error(String.format("Error writing entry to %s.", fileName));
330+
}
331+
} else {
332+
LOGGER.error(String.format("Skipped - PDF %s does not exist", fileName));
333+
}
334+
}
335+
}
336+
242337
private boolean exportMatches(List<ParserResult> loaded) {
243338
String[] data = cli.getExportMatches().split(",");
244339
String searchTerm = data[0].replace("\\$", " "); // enables blanks within the search term:

src/main/java/org/jabref/cli/JabRefCLI.java

+16
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ public boolean isAutomaticallySetFileLinks() {
147147
return cl.hasOption("automaticallySetFileLinks");
148148
}
149149

150+
public boolean isWriteXMPtoPdf() {
151+
return cl.hasOption("writeXMPtoPdf");
152+
}
153+
154+
public String getWriteXMPtoPdf() {
155+
return cl.getOptionValue("writeXMPtoPdf");
156+
}
157+
150158
private static Options getOptions() {
151159
Options options = new Options();
152160

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

253+
options.addOption(Option
254+
.builder("w")
255+
.longOpt("writeXMPtoPdf")
256+
.desc(String.format("%s: '%s'", Localization.lang("Write BibTeXEntry as XMP metadata to PDF."), "-w pathToMyOwnPaper.pdf"))
257+
.hasArg()
258+
.argName("CITEKEY1[,CITEKEY2][,CITEKEYn] | PDF1[,PDF2][,PDFn] | all")
259+
.build());
260+
245261
return options;
246262
}
247263

src/main/java/org/jabref/gui/Base.css

+4
Original file line numberDiff line numberDiff line change
@@ -1236,3 +1236,7 @@ TextFlow * {
12361236
.fontsizeSpinner{
12371237
-fx-pref-width: 5em;
12381238
}
1239+
1240+
.text-field:invalid {
1241+
-fx-background-color: rgba(240, 128, 128, 0.5);
1242+
}

0 commit comments

Comments
 (0)