Skip to content

Commit d303aff

Browse files
FrequinzyannamaartenssonTian0602LottaJohnssonFilippa Nilsson
authored
Importing of BibDesk Groups and Linked Files (#10968)
* Add test to check parsing of BibDesk Static Groups * Add test to check parsing of BibDesk Static Groups * Change isExpanded attribute to false in expected groups * remove extra blank line * Add tests to check parsing of BibDesk Smart and mixed groups * Add parsing of BibDesk Files * Attempts at plist * Now parses bdsk-file and shows it as a file in JabRef * Add test for parsing a bdsk-file field * Fix formatting * Add dd-plist library to documentation --------- Co-authored-by: Tian0602 <[email protected]> * Add creation of static JabRef group from a BibDesk file * Creates an empty ExplicitGroup from BibDesk comment * Adds citations to new groups modifies group creations to support multiple groups in the same BibDeskFile * Fix requested changes Refactor imports since they did not match with main Add safety check in addBibDeskGroupEntriesToJabRefGroups --------- Co-authored-by: Filippa Nilsson <[email protected]> * Refactor newline to match main branch Co-authored-by: Filippa Nilsson <[email protected]> * Add changes to CHANGELOG.md * Reformat indentation to match previous * Revert external libraries Adjust groups serializing * checkstyle and optional magic * fix * fix tests * fix * fix dangling do * better group tree metadata setting * merge group trees, prevent duplicate group assignment in entry Add new BibDesk group Fix IOB for change listeing * fix tests, and extract constant * return early * fixtest and checkstyle --------- Co-authored-by: Anna Maartensson <[email protected]> Co-authored-by: Tian0602 <[email protected]> Co-authored-by: LottaJohnsson <[email protected]> Co-authored-by: Filippa Nilsson <[email protected]> Co-authored-by: Filippa Nilsson <[email protected]> Co-authored-by: Oliver Kopp <[email protected]> Co-authored-by: Siedlerchr <[email protected]>
1 parent f5f92f9 commit d303aff

File tree

11 files changed

+561
-38
lines changed

11 files changed

+561
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv
2424
- When pasting HTML into the abstract or a comment field, the hypertext is automatically converted to Markdown. [#10558](https://github.com/JabRef/jabref/issues/10558)
2525
- We added the possibility to redownload files that had been present but are no longer in the specified location. [#10848](https://github.com/JabRef/jabref/issues/10848)
2626
- We added the citation key pattern `[camelN]`. Equivalent to the first N words of the `[camel]` pattern.
27+
- We added importing of static groups and linked files from BibDesk .bib files. [#10381](https://github.com/JabRef/jabref/issues/10381)
2728
- We added ability to export in CFF (Citation File Format) [#10661](https://github.com/JabRef/jabref/issues/10661).
2829
- We added ability to push entries to TeXworks. [#3197](https://github.com/JabRef/jabref/issues/3197)
2930
- We added the ability to zoom in and out in the document viewer using <kbd>Ctrl</kbd> + <kbd>Scroll</kbd>. [#10964](https://github.com/JabRef/jabref/pull/10964)

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ dependencies {
242242
// Because of GraalVM quirks, we need to ship that. See https://github.com/jspecify/jspecify/issues/389#issuecomment-1661130973 for details
243243
implementation 'org.jspecify:jspecify:0.3.0'
244244

245+
// parse plist files
246+
implementation 'com.googlecode.plist:dd-plist:1.23'
247+
245248
testImplementation 'io.github.classgraph:classgraph:4.8.168'
246249
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
247250
testImplementation 'org.junit.platform:junit-platform-launcher:1.10.2'
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
dd-plist - An open source library to parse and generate property lists
2+
Copyright (C) 2016 Daniel Dreibrodt
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
SOFTWARE.

src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,5 @@
144144
requires org.libreoffice.uno;
145145
requires de.saxsys.mvvmfx.validation;
146146
requires com.jthemedetector;
147+
requires dd.plist;
147148
}

src/main/java/org/jabref/logic/bibtex/comparator/BibDatabaseDiff.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ private static EntryComparator getEntryComparator() {
4949
private static List<BibEntryDiff> compareEntries(List<BibEntry> originalEntries, List<BibEntry> newEntries, BibDatabaseMode mode) {
5050
List<BibEntryDiff> differences = new ArrayList<>();
5151

52+
// Prevent IndexOutOfBoundException
53+
if (newEntries.isEmpty()) {
54+
return differences;
55+
}
56+
5257
// Create a HashSet where we can put references to entries in the new
5358
// database that we have matched. This is to avoid matching them twice.
5459
Set<Integer> used = new HashSet<>(newEntries.size());
@@ -88,7 +93,6 @@ private static List<BibEntryDiff> compareEntries(List<BibEntry> originalEntries,
8893
}
8994
}
9095
}
91-
9296
BibEntry bestEntry = newEntries.get(bestMatchIndex);
9397
if (bestMatch > MATCH_THRESHOLD
9498
|| hasEqualCitationKey(originalEntry, bestEntry)

src/main/java/org/jabref/logic/importer/fileformat/BibtexParser.java

Lines changed: 161 additions & 34 deletions
Large diffs are not rendered by default.

src/main/java/org/jabref/logic/util/MetadataSerializationConfiguration.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public class MetadataSerializationConfiguration {
1818
*/
1919
public static final char GROUP_QUOTE_CHAR = '\\';
2020

21+
/**
22+
* Group Type suffix (part of the GroupType)
23+
*/
24+
public static final String GROUP_TYPE_SUFFIX = ":";
25+
2126
/**
2227
* For separating units (e.g. name and hierarchic context) in the string representation
2328
*/

src/main/java/org/jabref/model/groups/AllEntriesGroup.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ public boolean equals(Object o) {
2323
return o instanceof AllEntriesGroup aeg && Objects.equals(aeg.getName(), getName());
2424
}
2525

26+
/**
27+
* Always returns true for any BibEntry!
28+
*
29+
* @param entry The @{@link BibEntry} to check
30+
* @return Always returns true
31+
*/
2632
@Override
2733
public boolean contains(BibEntry entry) {
2834
return true;

src/main/java/org/jabref/model/groups/GroupTreeNode.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ public int hashCode() {
135135
return Objects.hash(group);
136136
}
137137

138+
/**
139+
* Get only groups containing all the entries or just groups containing any of the
140+
*
141+
* @param entries List of {@link BibEntry} to search for
142+
* @param requireAll Whether to return only groups that must contain all entries
143+
* @return List of {@link GroupTreeNode} containing the matches. {@link AllEntriesGroup} is always contained}
144+
*/
138145
public List<GroupTreeNode> getContainingGroups(List<BibEntry> entries, boolean requireAll) {
139146
List<GroupTreeNode> groups = new ArrayList<>();
140147

@@ -197,6 +204,11 @@ public List<BibEntry> getEntriesInGroup(List<BibEntry> entries) {
197204
return result;
198205
}
199206

207+
/**
208+
* Get the name of the underlying group
209+
*
210+
* @return String the name of the group
211+
*/
200212
public String getName() {
201213
return group.getName();
202214
}

src/main/java/org/jabref/model/metadata/MetaData.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class MetaData {
4848
public static final String FILE_DIRECTORY_LATEX = "fileDirectoryLatex";
4949
public static final String PROTECTED_FLAG_META = "protectedFlag";
5050
public static final String SELECTOR_META_PREFIX = "selector_";
51+
public static final String BIBDESK_STATIC_FLAG = "BibDesk Static Groups";
5152

5253
public static final char ESCAPE_CHARACTER = '\\';
5354
public static final char SEPARATOR_CHARACTER = ';';

0 commit comments

Comments
 (0)