-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically created groups with Field to group by as entrytype (#4539) #4555
Changes from 3 commits
2fa906b
4a8b3c8
ae16446
fdbfdb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,15 @@ | |
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jabref.model.EntryTypes; | ||
import org.jabref.model.FieldChange; | ||
import org.jabref.model.database.BibDatabaseMode; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.EntryType; | ||
import org.jabref.model.entry.KeywordList; | ||
import org.jabref.model.strings.StringUtil; | ||
|
||
|
@@ -113,6 +118,12 @@ public boolean contains(BibEntry entry) { | |
|
||
private Set<String> getFieldContentAsWords(BibEntry entry) { | ||
if (onlySplitWordsAtSeparator) { | ||
if (BibEntry.TYPE_HEADER.equals(searchField)) { | ||
Optional<EntryType> entryType = EntryTypes.getType(entry.getType(), BibDatabaseMode.BIBLATEX); | ||
if (entryType.isPresent()) { | ||
return searchWords.stream().filter(sw -> entryType.get().getName().equals(sw)).collect(Collectors.toSet()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the reason for filtering the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Please suggest. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your solution sounds reasoable, I would let it as is. |
||
} | ||
} | ||
return entry.getField(searchField) | ||
.map(content -> KeywordList.parse(content, keywordSeparator).toStringList()) | ||
.orElse(Collections.emptySet()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above,
entryType = EntryTypes.getType(entry.getType(), BibDatabaseMode.BIBLATEX).orElse(entry.getType())
is slightly better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type mismatch occurs.
entry.getType()
isString
while we are assigning value forOptional<EntryType>
here