Automatically created groups with Field to group by as entrytype (#4539)#4555
Conversation
Siedlerchr
left a comment
There was a problem hiding this comment.
Thank you very much for your contribution! In general lgtm, just a minor improvement
| 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.
I think you can move the EntryType.get... Before the loop
There was a problem hiding this comment.
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.
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?
Siedlerchr
left a comment
There was a problem hiding this comment.
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?
tobiasdiez
left a comment
There was a problem hiding this comment.
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.
| 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.
As above, entryType = EntryTypes.getType(entry.getType(), BibDatabaseMode.BIBLATEX).orElse(entry.getType()) is slightly better.
There was a problem hiding this comment.
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.
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.
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.
Your solution sounds reasoable, I would let it as is.
Siedlerchr
left a comment
There was a problem hiding this comment.
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! |
tobiasdiez
left a comment
There was a problem hiding this comment.
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:
BibEntryto see if 'searchField' matches TYPE_HEADER - "entrytype"WordKeywordGroupto collect entries for the entrytype groups