From 40dd0250bfb3195642fab3effb90095ec248d294 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 13 Nov 2022 16:44:01 +0100 Subject: [PATCH 01/66] Fix typographic error --- .../guidelines-for-setting-up-a-local-workspace.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md index f765ab2ac7a..d81feebffa4 100644 --- a/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md +++ b/docs/getting-into-the-code/guidelines-for-setting-up-a-local-workspace.md @@ -74,7 +74,7 @@ This section explains how you get the JabRef code onto your machine in a form al 1. Log into your GitHub account 2. Go to [https://github.com/JabRef/jabref](https://github.com/JabRef/jabref) 3. Create a fork by clicking at fork button on the right top corner -4. A fork repository will be created under your account `https://github.com/YOUR\_USERNAME/jabref`. +4. A fork repository will be created under your account `https://github.com/YOUR_USERNAME/jabref`. ### Clone your forked repository on your local machine From f7bf767b982a8740ffaca19f4a4a76ab19d799ee Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 13 Nov 2022 20:50:21 +0100 Subject: [PATCH 02/66] Replace net.sf with org.jabref in l10n path --- docs/contributing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contributing.md b/docs/contributing.md index 8e2e5d9f5f9..f1aad6b7670 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -76,7 +76,7 @@ Actual :[Opens\ JabRef's\ Twitter\ page (src\main\java\org\jabref\gui\JabRefFr Add the above snippet to the English translation file located at `src/main/resources/l10n/JabRef_en.properties`. [Crowdin](https://crowdin.com/project/jabref) will automatically pick up the new string and add it to the other translations. -You can also directly run the specific test in your IDE. The test "LocalizationConsistencyTest" is placed under `src/test/java/net.sf.jabref.logic.l10n/LocalizationConsistencyTest.java`. Find more information in the [JabRef developer docs](https://devdocs.jabref.org/getting-into-the-code/code-howtos#using-localization-correctly). +You can also directly run the specific test in your IDE. The test "LocalizationConsistencyTest" is placed under `src/test/java/org.jabref.logic.l10n/LocalizationConsistencyTest.java`. Find more information in the [JabRef developer docs](https://devdocs.jabref.org/getting-into-the-code/code-howtos#using-localization-correctly). #### When adding a library From 8ddb2df184fbe8c4edaf6f59d20b4bdee0184838 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:53:10 +0100 Subject: [PATCH 03/66] Bump richtextfx from 0.10.9 to 0.11.0 (#9375) Bumps [richtextfx](https://github.com/FXMisc/RichTextFX) from 0.10.9 to 0.11.0. - [Release notes](https://github.com/FXMisc/RichTextFX/releases) - [Changelog](https://github.com/FXMisc/RichTextFX/blob/master/CHANGELOG.md) - [Commits](https://github.com/FXMisc/RichTextFX/compare/v0.10.9...v0.11.0) --- updated-dependencies: - dependency-name: org.fxmisc.richtext:richtextfx dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index b40d37f27ca..70924139fba 100644 --- a/build.gradle +++ b/build.gradle @@ -171,7 +171,7 @@ dependencies { implementation 'de.saxsys:mvvmfx:1.8.0' implementation 'com.tobiasdiez:easybind:2.2.1-SNAPSHOT' implementation 'org.fxmisc.flowless:flowless:0.6.10' - implementation 'org.fxmisc.richtext:richtextfx:0.10.9' + implementation 'org.fxmisc.richtext:richtextfx:0.11.0' implementation 'com.jfoenix:jfoenix:9.0.10' implementation 'org.controlsfx:controlsfx:11.1.2' From e4a6fe90fbe212fcff05cc5f47d4996a0fccc6e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:54:34 +0100 Subject: [PATCH 04/66] Bump mariadb-java-client from 2.7.6 to 2.7.7 (#9374) Bumps [mariadb-java-client](https://github.com/mariadb-corporation/mariadb-connector-j) from 2.7.6 to 2.7.7. - [Release notes](https://github.com/mariadb-corporation/mariadb-connector-j/releases) - [Changelog](https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/CHANGELOG.md) - [Commits](https://github.com/mariadb-corporation/mariadb-connector-j/compare/2.7.6...2.7.7) --- updated-dependencies: - dependency-name: org.mariadb.jdbc:mariadb-java-client dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 70924139fba..7b0c972b58d 100644 --- a/build.gradle +++ b/build.gradle @@ -146,7 +146,7 @@ dependencies { implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.14.0' implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.14.0' - implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.6' + implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.7' implementation 'org.postgresql:postgresql:42.5.0' From 07ea998517e49630118971df34b8890572f0c2d9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Nov 2022 16:54:45 +0100 Subject: [PATCH 05/66] Bump flowless from 0.6.10 to 0.7.0 (#9373) Bumps [flowless](https://github.com/FXMisc/Flowless) from 0.6.10 to 0.7.0. - [Release notes](https://github.com/FXMisc/Flowless/releases) - [Changelog](https://github.com/FXMisc/Flowless/blob/master/CHANGELOG.md) - [Commits](https://github.com/FXMisc/Flowless/compare/v0.6.10...v0.7.0) --- updated-dependencies: - dependency-name: org.fxmisc.flowless:flowless dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 7b0c972b58d..4c1634d8c3d 100644 --- a/build.gradle +++ b/build.gradle @@ -170,7 +170,7 @@ dependencies { implementation 'com.github.sialcasa.mvvmFX:mvvmfx-validation:f195849ca9' //jitpack implementation 'de.saxsys:mvvmfx:1.8.0' implementation 'com.tobiasdiez:easybind:2.2.1-SNAPSHOT' - implementation 'org.fxmisc.flowless:flowless:0.6.10' + implementation 'org.fxmisc.flowless:flowless:0.7.0' implementation 'org.fxmisc.richtext:richtextfx:0.11.0' implementation 'com.jfoenix:jfoenix:9.0.10' implementation 'org.controlsfx:controlsfx:11.1.2' From 951c108648fe335f2cde9b64cb267a1fb84f1b73 Mon Sep 17 00:00:00 2001 From: github actions Date: Tue, 15 Nov 2022 02:40:04 +0000 Subject: [PATCH 06/66] Squashed 'buildres/csl/csl-styles/' changes from 13fd98e2c8..7a10e3f659 7a10e3f659 Bluebook: Remove small-caps for case short & legislation (#6305) ca4a92bf63 Merge pull request #6244 from POBrien333/patch-1107 12743ad620 Create social-science-history.csl (#6233) f7c1d57f17 Update american-chemical-society.csl (#6231) aca6b23a96 ready: Update oil-shale.csl (#6225) aadae55cf8 Create pallas.csl (#6204) cc7d016ca2 Merge pull request #6253 from nschneid/patch-1 77fab39552 Merge pull request #6282 from POBrien333/patch-1119 e2668ebcfb Merge pull request #6263 from POBrien333/patch-1113 7f3244dd9d move style to dependent folder 85849934c4 Create development-growth-differentiation.csl (#6226) dfe71ff926 Create biotechnology-and-bioprocess-engineering.csl (#6227) 0d91742a04 Create sn-computer-science.csl (#6228) a0d09b4007 Create mots.csl (#6205) 47665e53fe Update review-of-international-studies.csl d573b8b205 Create computer-supported-cooperative-work.csl cebec0e186 ACL: check if edition is ordinal before printing the word "edition" 03a0a39739 Re-indent CSL styles 3c64906775 fix self link 479c0615e7 fix small issues after visual inspection a356e725c6 Create gnosis-journal-of-gnostic-studies.csl git-subtree-dir: buildres/csl/csl-styles git-subtree-split: 7a10e3f6591cf9549de37893a0b344a6b761bf1c --- american-chemical-society.csl | 41 +- association-for-computational-linguistics.csl | 13 +- biotechnology-and-bioprocess-engineering.csl | 237 +++++++ bluebook-law-review.csl | 21 +- computer-supported-cooperative-work.csl | 621 ++++++++++++++++++ .../development-growth-differentiation.csl | 17 + gnosis-journal-of-gnostic-studies.csl | 153 +++++ mots.csl | 259 ++++++++ oil-shale.csl | 500 +++++++------- pallas.csl | 252 +++++++ review-of-international-studies.csl | 6 +- sn-computer-science.csl | 169 +++++ social-science-history.csl | 598 +++++++++++++++++ 13 files changed, 2591 insertions(+), 296 deletions(-) create mode 100644 biotechnology-and-bioprocess-engineering.csl create mode 100644 computer-supported-cooperative-work.csl create mode 100644 dependent/development-growth-differentiation.csl create mode 100644 gnosis-journal-of-gnostic-studies.csl create mode 100644 mots.csl create mode 100644 pallas.csl create mode 100644 sn-computer-science.csl create mode 100644 social-science-history.csl diff --git a/american-chemical-society.csl b/american-chemical-society.csl index b7d421858bd..c3b618341fb 100644 --- a/american-chemical-society.csl +++ b/american-chemical-society.csl @@ -18,10 +18,13 @@ Sebastian Karcher + + Patrick O'Brien + The American Chemical Society style - 2021-05-22T12:00:00+00:00 + 2022-09-19T18:32:56+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -138,6 +141,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -249,18 +276,10 @@ - + - - - - - - - - @@ -277,7 +296,7 @@ - + diff --git a/association-for-computational-linguistics.csl b/association-for-computational-linguistics.csl index ec95b2a95b5..0fd76b842e5 100644 --- a/association-for-computational-linguistics.csl +++ b/association-for-computational-linguistics.csl @@ -68,8 +68,17 @@ - - + + + + + + + + + + + diff --git a/biotechnology-and-bioprocess-engineering.csl b/biotechnology-and-bioprocess-engineering.csl new file mode 100644 index 00000000000..75cab4f5718 --- /dev/null +++ b/biotechnology-and-bioprocess-engineering.csl @@ -0,0 +1,237 @@ + + diff --git a/bluebook-law-review.csl b/bluebook-law-review.csl index 5ce50f1f0ab..7525b6b182e 100644 --- a/bluebook-law-review.csl +++ b/bluebook-law-review.csl @@ -40,9 +40,22 @@ - - + + + + + + + + + + + + + + + @@ -59,10 +72,10 @@ - + - + diff --git a/computer-supported-cooperative-work.csl b/computer-supported-cooperative-work.csl new file mode 100644 index 00000000000..7bd3f33c829 --- /dev/null +++ b/computer-supported-cooperative-work.csl @@ -0,0 +1,621 @@ + + diff --git a/dependent/development-growth-differentiation.csl b/dependent/development-growth-differentiation.csl new file mode 100644 index 00000000000..f11d24bc750 --- /dev/null +++ b/dependent/development-growth-differentiation.csl @@ -0,0 +1,17 @@ + + diff --git a/gnosis-journal-of-gnostic-studies.csl b/gnosis-journal-of-gnostic-studies.csl new file mode 100644 index 00000000000..93f292d5faa --- /dev/null +++ b/gnosis-journal-of-gnostic-studies.csl @@ -0,0 +1,153 @@ + + diff --git a/mots.csl b/mots.csl new file mode 100644 index 00000000000..f6a0b1f2ad4 --- /dev/null +++ b/mots.csl @@ -0,0 +1,259 @@ + + + diff --git a/oil-shale.csl b/oil-shale.csl index 4d0d9c08619..6b7da61f500 100644 --- a/oil-shale.csl +++ b/oil-shale.csl @@ -1,338 +1,286 @@ - diff --git a/pallas.csl b/pallas.csl new file mode 100644 index 00000000000..dfe83e5541d --- /dev/null +++ b/pallas.csl @@ -0,0 +1,252 @@ + + + diff --git a/review-of-international-studies.csl b/review-of-international-studies.csl index 19fed42975c..2fea05e8949 100644 --- a/review-of-international-studies.csl +++ b/review-of-international-studies.csl @@ -14,7 +14,7 @@ 0260-2105 1469-9044 - 2018-03-29T14:20:30+00:00 + 2022-10-24T16:26:57+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -131,9 +131,9 @@ - + - + - + diff --git a/buildres/csl/csl-styles/iawa-journal.csl b/buildres/csl/csl-styles/iawa-journal.csl index da0b9ed086d..97443927d13 100644 --- a/buildres/csl/csl-styles/iawa-journal.csl +++ b/buildres/csl/csl-styles/iawa-journal.csl @@ -130,11 +130,11 @@ - + - + @@ -160,7 +160,7 @@ - + @@ -170,24 +170,24 @@ - + - + - - + + - + - + - + @@ -196,9 +196,9 @@ - - - + + + diff --git a/buildres/csl/csl-styles/les-mondes-du-travail.csl b/buildres/csl/csl-styles/les-mondes-du-travail.csl new file mode 100644 index 00000000000..ba6774b283e --- /dev/null +++ b/buildres/csl/csl-styles/les-mondes-du-travail.csl @@ -0,0 +1,280 @@ + + diff --git a/buildres/csl/csl-styles/triangle.csl b/buildres/csl/csl-styles/triangle.csl index eefba067154..79e0953412a 100644 --- a/buildres/csl/csl-styles/triangle.csl +++ b/buildres/csl/csl-styles/triangle.csl @@ -20,7 +20,7 @@ Derived from Style EHESS-histoire, available at http://www.boiteaoutils.info/2011/06/styles-francais-de-citation-sous-zotero.html First version online in november 2012. Changes made to cover more documents types and to lighten URLS display. Should preferably be used ticking the quoting option (preferences/citer/styles): include URLs addresses in references. - 2021-04-07T01:50:30+00:00 + 2022-09-29T01:50:30+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -62,27 +62,27 @@ - + - + - + - + diff --git a/buildres/csl/csl-styles/emerald-harvard.csl b/buildres/csl/csl-styles/emerald-harvard.csl index 3b4a484c002..ead41080a33 100644 --- a/buildres/csl/csl-styles/emerald-harvard.csl +++ b/buildres/csl/csl-styles/emerald-harvard.csl @@ -30,7 +30,7 @@ - 2020-08-26T12:00:00+00:00 + 2022-12-12T18:17:18+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -108,28 +108,23 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + diff --git a/buildres/csl/csl-styles/interpreting.csl b/buildres/csl/csl-styles/interpreting.csl new file mode 100644 index 00000000000..848f09e24bd --- /dev/null +++ b/buildres/csl/csl-styles/interpreting.csl @@ -0,0 +1,406 @@ + + diff --git a/buildres/csl/csl-styles/journal-of-the-american-college-of-cardiology.csl b/buildres/csl/csl-styles/journal-of-the-american-college-of-cardiology.csl index 49b9a5c56fd..eb47b7cb49b 100644 --- a/buildres/csl/csl-styles/journal-of-the-american-college-of-cardiology.csl +++ b/buildres/csl/csl-styles/journal-of-the-american-college-of-cardiology.csl @@ -6,7 +6,8 @@ http://www.zotero.org/styles/journal-of-the-american-college-of-cardiology - + + Julian Onions julian.onions@gmail.com @@ -19,9 +20,14 @@ 0735-1097 1558-3597 Journal of the American College of Cardiology - 2012-09-27T22:06:38+00:00 + 2022-12-09T09:35:42+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License + + + published online + + @@ -45,24 +51,34 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + @@ -92,11 +108,11 @@ - + - + @@ -108,7 +124,7 @@ - + @@ -120,7 +136,7 @@ - + @@ -136,21 +152,21 @@ - - - - - - - - - - - + + + + + + + + + + + + - diff --git a/buildres/csl/csl-styles/lund-university-school-of-economics-and-management.csl b/buildres/csl/csl-styles/lund-university-school-of-economics-and-management.csl index 8a7984a43ed..8f87d987152 100644 --- a/buildres/csl/csl-styles/lund-university-school-of-economics-and-management.csl +++ b/buildres/csl/csl-styles/lund-university-school-of-economics-and-management.csl @@ -364,7 +364,7 @@ - + diff --git a/buildres/csl/csl-styles/medizinische-hochschule-hannover.csl b/buildres/csl/csl-styles/medizinische-hochschule-hannover.csl index d4988b5f214..9c63592e170 100644 --- a/buildres/csl/csl-styles/medizinische-hochschule-hannover.csl +++ b/buildres/csl/csl-styles/medizinische-hochschule-hannover.csl @@ -13,12 +13,16 @@ Style for MHH based on the guidelines from 02.12.2020. - 2022-05-12T08:17:27+00:00 + 2022-12-07T11:41:15+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License + @@ -29,8 +33,24 @@ + + + + + + + + + + + + + @@ -44,8 +64,8 @@ - - @@ -53,6 +73,19 @@ + + + + + + + + + + + + + @@ -84,28 +117,54 @@ - + - - - - - - - - + + + + + + + + + + + + + - - + + + + + diff --git a/buildres/csl/csl-styles/royal-society-of-chemistry.csl b/buildres/csl/csl-styles/royal-society-of-chemistry.csl index 0f9cebdbb0c..b13885f3257 100644 --- a/buildres/csl/csl-styles/royal-society-of-chemistry.csl +++ b/buildres/csl/csl-styles/royal-society-of-chemistry.csl @@ -14,10 +14,14 @@ Ivan Bushmarinov ib@ineos.ac.ru + + Steven R. Kirk + steven.kirk@cantab.net + The Royal Society of Chemistry journal style. - 2018-12-26T22:22:35+00:00 + 2022-12-05T05:15:00+00:00 This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License @@ -176,6 +180,31 @@ + + + + + + + + + + + + + + + + + + + + + + + From 55a819fb7ef62b7b67734d217a0550ec8f7113d1 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 15 Dec 2022 17:10:32 -0500 Subject: [PATCH 65/66] Fixing journal abbreviation roundtrip (#9453) * checking for dot-less/medline abbreviations * fixed regex * fixed indentation * Move code for checking dot-less abbreviations into separate method * Add checks for dot-less abbreviations * Add test case for dot-less abbreviations * Update CHANGELOG.md * Add new static class variable for Pattern * Add checks for "?" journal names * Add check requiring abbreviation be more than 2 words --- CHANGELOG.md | 1 + .../JournalAbbreviationRepository.java | 57 ++++++++++++++++++- .../JournalAbbreviationRepositoryTest.java | 15 +++++ 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d80e8c19482..0f4b4029f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,6 +95,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where font size preferences did not apply correctly to preference dialog window and the menu bar. [#8386](https://github.com/JabRef/jabref/issues/8386) and [#9279](https://github.com/JabRef/jabref/issues/9279) - We fixed an issue that JabRef displayed the wrong group tree after loading. [koppor#637](https://github.com/koppor/jabref/issues/637) - We fixed an issue when using an unsafe character in the citation key, the auto-linking feature fails to link files. [#9267](https://github.com/JabRef/jabref/issues/9267) +- We fixed an issue where a known journal's medline/dot-less abbreviation does not switch to the full name. [#9370](https://github.com/JabRef/jabref/issues/9370) ### Removed diff --git a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java index 825bd706e27..0437e1ae2ae 100644 --- a/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java +++ b/src/main/java/org/jabref/logic/journals/JournalAbbreviationRepository.java @@ -8,6 +8,7 @@ import java.util.Optional; import java.util.Set; import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import org.h2.mvstore.MVMap; @@ -17,6 +18,8 @@ * A repository for all journal abbreviations, including add and find methods. */ public class JournalAbbreviationRepository { + static final Pattern DOT = Pattern.compile("\\."); + static final Pattern QUESTION_MARK = Pattern.compile("\\?"); private final MVMap fullToAbbreviation; private final MVMap abbreviationToFull; @@ -49,6 +52,11 @@ private static boolean isMatchedAbbreviated(String name, Abbreviation abbreviati * Letters) or its abbreviated form (e.g. Phys. Rev. Lett.). */ public boolean isKnownName(String journalName) { + // check for at least one "?" + if (QUESTION_MARK.matcher(journalName).find()) { + return false; + } + String journal = journalName.trim().replaceAll(Matcher.quoteReplacement("\\&"), "&"); boolean isKnown = customAbbreviations.stream().anyMatch(abbreviation -> isMatched(journal, abbreviation)); @@ -56,7 +64,8 @@ public boolean isKnownName(String journalName) { return true; } - return fullToAbbreviation.containsKey(journal) || abbreviationToFull.containsKey(journal); + return fullToAbbreviation.containsKey(journal) || abbreviationToFull.containsKey(journal) + || findDottedAbbrFromDotless(journal).length() > 0; } /** @@ -66,8 +75,40 @@ public boolean isKnownName(String journalName) { public boolean isAbbreviatedName(String journalName) { String journal = journalName.trim(); + // journal abbreviation must be at least 2 words + boolean isMoreThanTwoWords = journalName.split(" ").length >= 2; + return customAbbreviations.stream().anyMatch(abbreviation -> isMatchedAbbreviated(journal, abbreviation)) - || abbreviationToFull.containsKey(journal); + || abbreviationToFull.containsKey(journal) + || (isMoreThanTwoWords && findDottedAbbrFromDotless(journal).length() > 0); + } + + public String findDottedAbbrFromDotless(String journalName) { + // check for at least one "?" + if (QUESTION_MARK.matcher(journalName).find()) { + return "UNKNOWN"; + } + + String foundKey = ""; + + // check for a dot-less abbreviation + if (!DOT.matcher(journalName).find()) { + // use dot-less abbr to find full name using regex + String[] journalSplit = journalName.split(" "); + + for (int i = 0; i < journalSplit.length; i++) { + String word = journalSplit[i] + "[\\.\\s]*"; + journalSplit[i] = word; + } + + String joined = String.join("", journalSplit); + + foundKey = abbreviationToFull.keySet().stream() + .filter(s -> Pattern.compile(joined).matcher(s).find()) + .collect(Collectors.joining()); + } + + return foundKey; } /** @@ -87,7 +128,17 @@ public Optional get(String input) { return Optional.ofNullable(fullToAbbreviation.get(journal)) .map(abbreviation -> new Abbreviation(journal, abbreviation)) - .or(() -> Optional.ofNullable(abbreviationToFull.get(journal)).map(fullName -> new Abbreviation(fullName, journal))); + .or(() -> { + String abbr = ""; + + // check for dot-less abbr + if (isKnownName(journal) && isAbbreviatedName(journal)) { + abbr = findDottedAbbrFromDotless(journal); + } + + return Optional.ofNullable(abbreviationToFull.get(abbr.equals("") ? journal : abbr)) + .map(fullName -> new Abbreviation(fullName, journal)); + }); } public void addCustomAbbreviation(Abbreviation abbreviation) { diff --git a/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java b/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java index fe724edc847..66f8567709b 100644 --- a/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java +++ b/src/test/java/org/jabref/logic/journals/JournalAbbreviationRepositoryTest.java @@ -252,4 +252,19 @@ void testUnabbreviateWithJournalExistsAndFJournalExists() { .withField(StandardField.JOURNAL, "ACS Applied Materials & Interfaces"); assertEquals(expectedAbbreviatedJournalEntry, abbreviatedJournalEntry); } + + @Test + void testJournalDotlessAbbreviation() { + BibDatabase bibDatabase = new BibDatabase(); + JournalAbbreviationRepository journalAbbreviationRepository = JournalAbbreviationLoader.loadBuiltInRepository(); + UndoableUnabbreviator undoableUnabbreviator = new UndoableUnabbreviator(journalAbbreviationRepository); + + BibEntry abbreviatedJournalEntry = new BibEntry(StandardEntryType.Article); + abbreviatedJournalEntry.setField(StandardField.JOURNAL, "ACS Appl Mater Interfaces"); + + undoableUnabbreviator.unabbreviate(bibDatabase, abbreviatedJournalEntry, StandardField.JOURNAL, new CompoundEdit()); + BibEntry expectedAbbreviatedJournalEntry = new BibEntry(StandardEntryType.Article) + .withField(StandardField.JOURNAL, "ACS Applied Materials & Interfaces"); + assertEquals(expectedAbbreviatedJournalEntry, abbreviatedJournalEntry); + } } From c02d75b9fb8025de5dc461033fb4276c964dd519 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Fri, 16 Dec 2022 01:40:56 +0100 Subject: [PATCH 66/66] Add "discarded" flag to backups (#9458) Co-authored-by: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Co-authored-by: Christoph --- CHANGELOG.md | 3 +- src/main/java/org/jabref/gui/JabRefFrame.java | 30 +++-- .../autosaveandbackup/BackupManager.java | 53 ++++++++- .../java/org/jabref/logic/util/BuildInfo.java | 2 +- .../jabref/logic/util/io/BackupFileUtil.java | 2 + .../BackupManagerTestDiscarded.java | 109 ++++++++++++++++++ .../org/jabref/logic/util/BuildInfoTest.java | 2 +- 7 files changed, 186 insertions(+), 15 deletions(-) create mode 100644 src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTestDiscarded.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f4b4029f60..e9f6a3a3d73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,7 +62,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Fixed - We fixed an issue where importing from XMP would fail for certain PDFs [#9383](https://github.com/JabRef/jabref/issues/9383) -- We fixed the readability of the file field in the dark dark theme [#9340](https://github.com/JabRef/jabref/issues/9340) +- We fixed the readability of the file field in the dark theme [#9340](https://github.com/JabRef/jabref/issues/9340) - We fixed that sorting of entries in the maintable by special fields is updated immediately [#9334](https://github.com/JabRef/jabref/issues/9334) - We fixed the Cleanup entries dialog is partially visible [#9223](https://github.com/JabRef/jabref/issues/9223) - We fixed the display of the "Customize Entry Types" dialogue title [#9198](https://github.com/JabRef/jabref/issues/9198) @@ -93,6 +93,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where editing entry's "date" field in library mode "biblatex" causes an uncaught exception. [#8747](https://github.com/JabRef/jabref/issues/8747) - We fixed an issue where journal abbreviations would not abbreviate journal titles with escaped ampersands (\\&). [#8948](https://github.com/JabRef/jabref/issues/8948) - We fixed an issue where font size preferences did not apply correctly to preference dialog window and the menu bar. [#8386](https://github.com/JabRef/jabref/issues/8386) and [#9279](https://github.com/JabRef/jabref/issues/9279) +- We fixed the behavior of "Discard changes" when reopening a modified library. [#9361](https://github.com/JabRef/jabref/issues/9361) - We fixed an issue that JabRef displayed the wrong group tree after loading. [koppor#637](https://github.com/koppor/jabref/issues/637) - We fixed an issue when using an unsafe character in the citation key, the auto-linking feature fails to link files. [#9267](https://github.com/JabRef/jabref/issues/9267) - We fixed an issue where a known journal's medline/dot-less abbreviation does not switch to the full name. [#9370](https://github.com/JabRef/jabref/issues/9370) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index f3ca8c90ed2..5b979bd2049 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -1160,9 +1160,10 @@ public FileHistoryMenu getFileHistory() { } /** - * Ask if the user really wants to close the given database + * Ask if the user really wants to close the given database. + * Offers to save or discard the changes -- or return to the library * - * @return true if the user choose to close the database + * @return true if the user choose to close the database */ private boolean confirmClose(LibraryTab libraryTab) { String filename = libraryTab.getBibDatabaseContext() @@ -1173,15 +1174,24 @@ private boolean confirmClose(LibraryTab libraryTab) { ButtonType saveChanges = new ButtonType(Localization.lang("Save changes"), ButtonBar.ButtonData.YES); ButtonType discardChanges = new ButtonType(Localization.lang("Discard changes"), ButtonBar.ButtonData.NO); - ButtonType cancel = new ButtonType(Localization.lang("Return to library"), ButtonBar.ButtonData.CANCEL_CLOSE); + ButtonType returnToLibrary = new ButtonType(Localization.lang("Return to library"), ButtonBar.ButtonData.CANCEL_CLOSE); Optional response = dialogService.showCustomButtonDialogAndWait(Alert.AlertType.CONFIRMATION, Localization.lang("Save before closing"), Localization.lang("Library '%0' has changed.", filename), - saveChanges, discardChanges, cancel); + saveChanges, discardChanges, returnToLibrary); + + if (response.isEmpty()) { + return true; + } + + ButtonType buttonType = response.get(); + + if (buttonType.equals(returnToLibrary)) { + return false; + } - if (response.isPresent() && response.get().equals(saveChanges)) { - // The user wants to save. + if (buttonType.equals(saveChanges)) { try { SaveDatabaseAction saveAction = new SaveDatabaseAction(libraryTab, prefs, Globals.entryTypesManager); if (saveAction.save()) { @@ -1196,7 +1206,13 @@ private boolean confirmClose(LibraryTab libraryTab) { // Save was cancelled or an error occurred. return false; } - return response.isEmpty() || !response.get().equals(cancel); + + if (buttonType.equals(discardChanges)) { + BackupManager.discardBackup(libraryTab.getBibDatabaseContext()); + return true; + } + + return false; } /** diff --git a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java index 11228558c48..c88930619dd 100644 --- a/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java +++ b/src/main/java/org/jabref/logic/autosaveandbackup/BackupManager.java @@ -66,7 +66,7 @@ public class BackupManager { private boolean needsBackup = true; - private BackupManager(BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService preferences) { + BackupManager(BibDatabaseContext bibDatabaseContext, BibEntryTypesManager entryTypesManager, PreferencesService preferences) { this.bibDatabaseContext = bibDatabaseContext; this.entryTypesManager = entryTypesManager; this.preferences = preferences; @@ -105,6 +105,16 @@ public static BackupManager start(BibDatabaseContext bibDatabaseContext, BibEntr return backupManager; } + /** + * Marks the backup as discarded at the library which is associated with the given {@link BibDatabaseContext}. + * + * @param bibDatabaseContext Associated {@link BibDatabaseContext} + */ + public static void discardBackup(BibDatabaseContext bibDatabaseContext) { + runningInstances.stream().filter(instance -> instance.bibDatabaseContext == bibDatabaseContext).forEach( + BackupManager::discardBackup); + } + /** * Shuts down the BackupManager which is associated with the given {@link BibDatabaseContext}. * @@ -120,13 +130,25 @@ public static void shutdown(BibDatabaseContext bibDatabaseContext) { * Checks whether a backup file exists for the given database file. If it exists, it is checked whether it is * newer and different from the original. * + * In case a discarded file is present, the method also returns false, See also {@link #discardBackup()}. + * * @param originalPath Path to the file a backup should be checked for. Example: jabref.bib. * * @return true if backup file exists AND differs from originalPath. false is the - * "default" return value in the good case. In the case of an exception true is returned to ensure that - * the user checks the output. + * "default" return value in the good case. In case a discarded file exists, false is returned, too. + * In the case of an exception true is returned to ensure that the user checks the output. */ public static boolean backupFileDiffers(Path originalPath) { + Path discardedFile = determineDiscardedFile(originalPath); + if (Files.exists(discardedFile)) { + try { + Files.delete(discardedFile); + } catch (IOException e) { + LOGGER.error("Could not remove discarded file {}", discardedFile, e); + return true; + } + return false; + } return getLatestBackupPath(originalPath).map(latestBackupPath -> { FileTime latestBackupFileLastModifiedTime; try { @@ -177,7 +199,7 @@ public static void restoreBackup(Path originalPath) { } } - private Optional determineBackupPathForNewBackup() { + Optional determineBackupPathForNewBackup() { return bibDatabaseContext.getDatabasePath().map(BackupManager::getBackupPathForNewBackup); } @@ -188,7 +210,7 @@ private Optional determineBackupPathForNewBackup() { * * @param backupPath the path where the library should be backed up to */ - private void performBackup(Path backupPath) { + void performBackup(Path backupPath) { if (!needsBackup) { return; } @@ -226,6 +248,27 @@ private void performBackup(Path backupPath) { } } + private static Path determineDiscardedFile(Path file) { + return BackupFileUtil.getAppDataBackupDir().resolve( + BackupFileUtil.getUniqueFilePrefix(file) + "--" + file.getFileName() + "--discarded" + ); + } + + /** + * Marks the backups as discarded. + * + * We do not delete any files, because the user might want to recover old backup files. + * Therefore, we mark discarded backups by a --discarded file. + */ + public void discardBackup() { + Path path = determineDiscardedFile(bibDatabaseContext.getDatabasePath().get()); + try { + Files.createFile(path); + } catch (IOException e) { + LOGGER.info("Could not create backup file {}", path, e); + } + } + private void logIfCritical(Path backupPath, IOException e) { Throwable innermostCause = e; while (innermostCause.getCause() != null) { diff --git a/src/main/java/org/jabref/logic/util/BuildInfo.java b/src/main/java/org/jabref/logic/util/BuildInfo.java index 375fc0d0bdb..930357b3ab7 100644 --- a/src/main/java/org/jabref/logic/util/BuildInfo.java +++ b/src/main/java/org/jabref/logic/util/BuildInfo.java @@ -10,7 +10,7 @@ public final class BuildInfo { - public static final String UNKNOWN_VERSION = "*unknown*"; + public static final String UNKNOWN_VERSION = "UNKNOWN"; public static final String OS = System.getProperty("os.name", UNKNOWN_VERSION); public static final String OS_VERSION = System.getProperty("os.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT); diff --git a/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java b/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java index 34fd3810990..f669f2ee567 100644 --- a/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java +++ b/src/main/java/org/jabref/logic/util/io/BackupFileUtil.java @@ -69,6 +69,8 @@ public static Path getPathForNewBackupFileAndCreateDirectory(Path targetFile, Ba /** * Finds the latest backup (.sav). If it does not exist, an empty optional is returned + * + * @param targetFile the full path of the file to backup */ public static Optional getPathOfLatestExisingBackupFile(Path targetFile, BackupFileType fileType) { // The code is similar to "getPathForNewBackupFileAndCreateDirectory" diff --git a/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTestDiscarded.java b/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTestDiscarded.java new file mode 100644 index 00000000000..63c3a8d2b2b --- /dev/null +++ b/src/test/java/org/jabref/logic/autosaveandbackup/BackupManagerTestDiscarded.java @@ -0,0 +1,109 @@ +package org.jabref.logic.autosaveandbackup; + +import java.io.IOException; +import java.io.Writer; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.jabref.logic.exporter.AtomicFileWriter; +import org.jabref.logic.exporter.BibWriter; +import org.jabref.logic.exporter.BibtexDatabaseWriter; +import org.jabref.logic.exporter.SavePreferences; +import org.jabref.model.database.BibDatabase; +import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.BibEntryTypesManager; +import org.jabref.model.entry.field.StandardField; +import org.jabref.model.metadata.SaveOrderConfig; +import org.jabref.preferences.PreferencesService; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.Answers; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +/** + * Test for "discarded" flag + */ +class BackupManagerTestDiscarded { + + private BibDatabaseContext bibDatabaseContext; + private BackupManager backupManager; + private Path testBib; + private SavePreferences savePreferences; + private PreferencesService preferencesService; + private BibEntryTypesManager bibEntryTypesManager; + + @BeforeEach + public void setup(@TempDir Path tempDir) throws Exception { + Path backupDir = tempDir.resolve("backups"); + Files.createDirectories(backupDir); + + testBib = tempDir.resolve("test.bib"); + + bibDatabaseContext = new BibDatabaseContext(new BibDatabase()); + bibDatabaseContext.setDatabasePath(testBib); + + bibEntryTypesManager = new BibEntryTypesManager(); + + savePreferences = mock(SavePreferences.class, Answers.RETURNS_DEEP_STUBS); + when(savePreferences.shouldMakeBackup()).thenReturn(false); + when(savePreferences.getSaveOrder()).thenReturn(new SaveOrderConfig()); + when(savePreferences.withMakeBackup(anyBoolean())).thenReturn(savePreferences); + when(savePreferences.shouldSaveInOriginalOrder()).thenReturn(true); + + preferencesService = mock(PreferencesService.class, Answers.RETURNS_DEEP_STUBS); + when(preferencesService.getSavePreferences()).thenReturn(savePreferences); + + saveDatabase(); + + backupManager = new BackupManager(bibDatabaseContext, bibEntryTypesManager, preferencesService); + makeBackup(); + } + + private void saveDatabase() throws IOException { + try (Writer writer = new AtomicFileWriter(testBib, StandardCharsets.UTF_8, false)) { + BibWriter bibWriter = new BibWriter(writer, bibDatabaseContext.getDatabase().getNewLineSeparator()); + new BibtexDatabaseWriter(bibWriter, preferencesService.getGeneralPreferences(), savePreferences, bibEntryTypesManager) + .saveDatabase(bibDatabaseContext); + } + } + + private void databaseModification() { + bibDatabaseContext.getDatabase().insertEntry(new BibEntry().withField(StandardField.NOTE, "test")); + } + + private void makeBackup() { + backupManager.determineBackupPathForNewBackup().ifPresent(backupManager::performBackup); + } + + @Test + public void noDiscardingAChangeLeadsToNewerBackupBeReported() throws Exception { + databaseModification(); + makeBackup(); + assertTrue(BackupManager.backupFileDiffers(testBib)); + } + + @Test + public void noDiscardingASavedChange() throws Exception { + databaseModification(); + makeBackup(); + saveDatabase(); + assertFalse(BackupManager.backupFileDiffers(testBib)); + } + + @Test + public void discardingAChangeLeadsToNewerBackupToBeIgnored() throws Exception { + databaseModification(); + makeBackup(); + backupManager.discardBackup(); + assertFalse(BackupManager.backupFileDiffers(testBib)); + } +} diff --git a/src/test/java/org/jabref/logic/util/BuildInfoTest.java b/src/test/java/org/jabref/logic/util/BuildInfoTest.java index eea2bb1e4b8..ed057a09344 100644 --- a/src/test/java/org/jabref/logic/util/BuildInfoTest.java +++ b/src/test/java/org/jabref/logic/util/BuildInfoTest.java @@ -10,7 +10,7 @@ public class BuildInfoTest { @Test public void testDefaults() { BuildInfo buildInfo = new BuildInfo("asdf"); - assertEquals("*unknown*", buildInfo.version.getFullVersion()); + assertEquals("UNKNOWN", buildInfo.version.getFullVersion()); } @Test