Skip to content
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

Merged
merged 4 commits into from
Feb 9, 2019

Conversation

shubhamatlani
Copy link
Contributor

Potential solution for #4539:

  • Made "entrytype" as a valid keyword for automatically created groups.
  • Added check in BibEntry to see if 'searchField' matches TYPE_HEADER - "entrytype"
  • Made change in WordKeywordGroup to collect entries for the entrytype groups
  • Screenshots reflecting the change attached -
  1. All entries -

all_entries_ss1

  1. Automatically create groups. Field to group by is "entrytype" -

create_group_ss2

  1. Result -

group_view_ss3


  • Change in CHANGELOG.md described
  • Tests created for changes
  • Manually tested changed features in running JabRef
  • Screenshots added in PR description (for bigger UI changes)
  • Ensured that the git commit message is a good one
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)

Copy link
Member

@Siedlerchr Siedlerchr left a 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);
Copy link
Member

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

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

@Siedlerchr Siedlerchr left a 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?

Copy link
Member

@tobiasdiez tobiasdiez left a 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.

src/main/java/org/jabref/model/entry/BibEntry.java Outdated Show resolved Hide resolved
@@ -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()) {
Copy link
Member

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.

Copy link
Contributor Author

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());
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

@Siedlerchr Siedlerchr left a 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!

@shubhamatlani
Copy link
Contributor Author

Hi, is there anything else that needs to be done here before this PR can be merged with master ?

@Siedlerchr
Copy link
Member

if @tobiasdiez is fine with the change, we can merge!

Copy link
Member

@tobiasdiez tobiasdiez left a 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.

@tobiasdiez tobiasdiez merged commit 8e7b1f9 into JabRef:master Feb 9, 2019
Siedlerchr added a commit that referenced this pull request Feb 15, 2019
* 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
Siedlerchr added a commit that referenced this pull request Feb 18, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants