-
-
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
Conversation
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.
Thank you very much for your contribution! In general lgtm, just a minor improvement
@@ -113,6 +118,14 @@ public boolean contains(BibEntry entry) { | |||
|
|||
private Set<String> getFieldContentAsWords(BibEntry entry) { | |||
if (onlySplitWordsAtSeparator) { | |||
if (BibEntry.TYPE_HEADER.equals(searchField)) { | |||
for (String searchWord : searchWords) { | |||
Optional<EntryType> entryType = EntryTypes.getType(entry.getType(), BibDatabaseMode.BIBLATEX); |
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.
I think you can move the EntryType.get... Before the loop
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.
Then you could implement the for loop as stream with filter and in the end you can use map / and collectors.toSet
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.
Thanks. I have a question - While fetching entryType, how do I decide which BibDatabaseMode to pass? BIBTEX or BIBLATEX? In both the committed files I have used BIBLATEX. Is that correct?
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.
Biblatex is s superset of bibtex, has more and other fields the newer standard.
I am unsure if you need the actual mode,
There is a method get Bib database mode (sorry, I'm on mobile only)
Could you please test if that works also for custom entry types?
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.
Thanks a lot for your contribution. The changes look good to me and I've only a minor suggestion concerning the case when the entry type is unknown.
@@ -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()) { |
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()
is String
while we are assigning value for Optional<EntryType>
here
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 comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for filtering the searchWords
list? I think you can safely return the value of entryType
(as a 1-item list).
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.
searchWords
is a 1-item set. Filter method lets me compare the content of this set with the entry type. Example, searchWord can be 'Book' but the entry type can be 'Article' and hence, this entry won't fall under Book subgroup. Other approach that I could think of -
if (entryType.isPresent() && searchWords.iterator().next().equals(entryType.get().getName())) {
return searchWords;
}
Please suggest.
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.
Your solution sounds reasoable, I would let it as is.
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.
From my point of view this looks good now!
Hi, is there anything else that needs to be done here before this PR can be merged with master ? |
if @tobiasdiez is fine with the change, we can merge! |
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.
Sorry, that somehow disappeared from my radar.
The changes look good to me, so I'll merge now. Thanks again for your contribution.
* upstream/master: (21 commits) Bump applicationinsights-core from 2.3.0 to 2.3.1 (#4656) Bump applicationinsights-logging-log4j2 from 2.3.0 to 2.3.1 (#4657) Bump bcprov-jdk15on from 1.60 to 1.61 (#4653) Bump log4j-jcl from 2.11.1 to 2.11.2 (#4646) Bump log4j-api from 2.11.1 to 2.11.2 (#4650) Bump assertj-swing-junit from 3.8.0 to 3.9.2 (#4647) Bump log4j-jul from 2.11.1 to 2.11.2 (#4648) Bump log4j-slf4j18-impl from 2.11.1 to 2.11.2 (#4649) Bump log4j-core from 2.11.1 to 2.11.2 (#4651) Remove old code for PDF import (#4634) Reorder conditional checks Automatically created groups with Field to group by as entrytype (#4539) (#4555) Fix for issue 4641: Remove usage of TempDirectory extension from junit-pioneer (#4644) Edit localization file Add Integrity check for books with edition reported as 1 Use 'junit-jupiter' aggregator module (#4640) Bump junit-jupiter-params from 5.3.2 to 5.4.0 (#4638) Bump junit-vintage-engine from 5.3.2 to 5.4.0 (#4637) Bump junit-platform-launcher from 1.3.2 to 1.4.0 (#4636) Bump junit-jupiter-api from 5.3.2 to 5.4.0 (#4639) ... # Conflicts: # src/main/resources/l10n/JabRef_en.properties
…tofx * upstream/master: (30 commits) Bump applicationinsights-core from 2.3.0 to 2.3.1 (#4656) Bump applicationinsights-logging-log4j2 from 2.3.0 to 2.3.1 (#4657) Bump bcprov-jdk15on from 1.60 to 1.61 (#4653) Bump log4j-jcl from 2.11.1 to 2.11.2 (#4646) Bump log4j-api from 2.11.1 to 2.11.2 (#4650) Bump assertj-swing-junit from 3.8.0 to 3.9.2 (#4647) Bump log4j-jul from 2.11.1 to 2.11.2 (#4648) Bump log4j-slf4j18-impl from 2.11.1 to 2.11.2 (#4649) Bump log4j-core from 2.11.1 to 2.11.2 (#4651) Remove old code for PDF import (#4634) Reorder conditional checks Automatically created groups with Field to group by as entrytype (#4539) (#4555) Fix for issue 4641: Remove usage of TempDirectory extension from junit-pioneer (#4644) Edit localization file Add Integrity check for books with edition reported as 1 Use 'junit-jupiter' aggregator module (#4640) Bump junit-jupiter-params from 5.3.2 to 5.4.0 (#4638) Bump junit-vintage-engine from 5.3.2 to 5.4.0 (#4637) Bump junit-platform-launcher from 1.3.2 to 1.4.0 (#4636) Bump junit-jupiter-api from 5.3.2 to 5.4.0 (#4639) ... # Conflicts: # src/main/java/org/jabref/preferences/PreferencesService.java
Potential solution for #4539:
BibEntry
to see if 'searchField' matches TYPE_HEADER - "entrytype"WordKeywordGroup
to collect entries for the entrytype groups