Skip to content

Commit

Permalink
Add mappings on ModsImporter.java (#9193)
Browse files Browse the repository at this point in the history
  • Loading branch information
berry120 authored Oct 2, 2022
1 parent 4f8dc06 commit 1797af8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Changed

- Genres are now mapped correctly to entry types when importing MODS files. [#9185](https://github.com/JabRef/jabref/issues/9185)
- We improved the Citavi Importer to also import so called Knowledge-items into the field `comment` of the corresponding entry [#9025](https://github.com/JabRef/jabref/issues/9025)
- We removed wrapping of string constants when writing to a `.bib` file.
- We call backup files `.bak` and temporary writing files now `.sav`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -167,7 +168,7 @@ private void parseModsGroup(Map<Field, String> fields, List<Object> modsGroup, B
abstractDefinition
.ifPresent(abstractDef -> putIfValueNotNull(fields, StandardField.ABSTRACT, abstractDef.getValue()));

genreDefinition.ifPresent(genre -> entry.setType(EntryTypeFactory.parse(genre.getValue())));
genreDefinition.ifPresent(genre -> entry.setType(EntryTypeFactory.parse(mapGenre(genre.getValue()))));

languageDefinition.ifPresent(
languageDef -> languageDef.getLanguageTerm().stream().map(LanguageTermDefinition::getValue)
Expand Down Expand Up @@ -203,6 +204,16 @@ private void parseModsGroup(Map<Field, String> fields, List<Object> modsGroup, B
putIfListIsNotEmpty(fields, notes, StandardField.NOTE, ", ");
}

private String mapGenre(String genre) {
return switch (genre.toLowerCase(Locale.ROOT)) {
case "conference publication" -> "proceedings";
case "database" -> "dataset";
case "yearbook", "handbook" -> "book";
case "law report or digest", "technical report", "reporting" -> "report";
default -> genre;
};
}

private void parseTitle(Map<Field, String> fields, List<Object> titleOrSubTitleOrPartNumber) {
for (Object object : titleOrSubTitleOrPartNumber) {
if (object instanceof JAXBElement) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@proceedings{TestPublication,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<modsCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.loc.gov/mods/v3"
xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd">
<mods version="3.3">
<genre authority="gmgpc">Conference Publication</genre>
<identifier type="citekey">TestPublication</identifier>
</mods>
</modsCollection>

0 comments on commit 1797af8

Please sign in to comment.