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

Fix XMP Exctrator not returning empty optional #6578

Merged
merged 3 commits into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where the "Attach file" dialog, in the right-click menu for an entry, started on the working directory instead of the user's main directory. [#4995](https://github.com/JabRef/jabref/issues/4995)
- We fixed an issue where the JabRef Icon in the macOS launchpad was not displayed correctly [#5003](https://github.com/JabRef/jabref/issues/5003)
- We fixed an issue where the "Search for unlinked local files" would throw an exception when parsing the content of a PDF-file with missing "series" information [#5128](https://github.com/JabRef/jabref/issues/5128)
- We fixed an issue where the XMP Importer would incorrectly return an empty default entry when importing pdfs [#6577](https://github.com/JabRef/jabref/issues/6577)

### Removed

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/jabref/logic/xmp/DublinCoreExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void extractEditor() {
private void extractAuthor() {
List<String> creators = dcSchema.getCreators();
if ((creators != null) && !creators.isEmpty()) {
bibEntry.setField(StandardField.AUTHOR, String.join(" and ", creators));
bibEntry.setField(StandardField.AUTHOR, String.join(" and ", creators));
}
}

Expand Down Expand Up @@ -242,10 +242,10 @@ public Optional<BibEntry> extractBibtexEntry() {
this.extractTitle();
this.extractType();

if (bibEntry.getType() == null) {
bibEntry.setType(BibEntry.DEFAULT_TYPE);
// we pass a new BibEntry in the constructor which is never empty as it already consists of "@misc"
if (bibEntry.equals(new BibEntry())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, adding a isEmpty method in BibEntry might lead to more readable code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, your hint gave me the idea to check if the entry has any fields

return Optional.empty();
}

return Optional.of(bibEntry);
}

Expand Down