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

Export translator field to msoffice 2007 xml #3632

Merged
merged 6 commits into from
Jan 14, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We now show a small notification icon in the entry editor when we detect data inconsistency or other problems. [#3145](https://github.com/JabRef/jabref/issues/3145)
- We added [oaDOI](https://oadoi.org/) as a fulltext provider, so that JabRef is now able to provide fulltexts for more than 90 million open-access articles.
- We changed one default of [Cleanup entries dialog](http://help.jabref.org/en/CleanupEntries): Per default, the PDF are not moved to the default file directory anymore. [#3619](https://github.com/JabRef/jabref/issues/3619)
- We added the export of the the `translator` field to the according MS-Office XML field. [#1750, comment](https://github.com/JabRef/jabref/issues/1750#issuecomment-357350986)
- We changed the import of the MS-Office XML fields `bookauthor` and `translator`. Both are now imported to their corresponding bibtex/biblatex fields.

### Fixed
- We fixed the missing dot in the name of an exported file. [#3576](https://github.com/JabRef/jabref/issues/3576)
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/gui/importer/ImportFormats.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public void actionPerformed(ActionEvent e) {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder()
.addExtensionFilter(allImports)
.addExtensionFilters(extensions)
.withDefaultExtension(allImports)
.withInitialDirectory(Globals.prefs.get(JabRefPreferences.IMPORT_WORKING_DIRECTORY))
.build();
DialogService dialogService = new FXDialogService();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/util/FileFilterConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static FileChooser.ExtensionFilter toExtensionFilter(String description,
}

public static Optional<Importer> getImporter(FileChooser.ExtensionFilter extensionFilter, Collection<Importer> importers) {
return importers.stream().filter(importer -> importer.getDescription().equals(extensionFilter.getDescription())).findFirst();
return importers.stream().filter(importer -> importer.getFileType().getDescription().equals(extensionFilter.getDescription())).findFirst();
}

public static Optional<Exporter> getExporter(FileChooser.ExtensionFilter extensionFilter, Collection<Exporter> exporters) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/logic/msbib/BibTeXConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public static BibEntry convert(MSBibEntry entry) {
}

addAuthor(fieldValues, FieldName.AUTHOR, entry.authors);
addAuthor(fieldValues, MSBIB_PREFIX + FieldName.BOOKAUTHOR, entry.bookAuthors);
addAuthor(fieldValues, FieldName.BOOKAUTHOR, entry.bookAuthors);
addAuthor(fieldValues, FieldName.EDITOR, entry.editors);
addAuthor(fieldValues, MSBIB_PREFIX + FieldName.TRANSLATOR, entry.translators);
addAuthor(fieldValues, FieldName.TRANSLATOR, entry.translators);
addAuthor(fieldValues, MSBIB_PREFIX + "producername", entry.producerNames);
addAuthor(fieldValues, MSBIB_PREFIX + "composer", entry.composers);
addAuthor(fieldValues, MSBIB_PREFIX + "conductor", entry.conductors);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/jabref/logic/msbib/MSBibConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static MSBibEntry convert(BibEntry entry) {

entry.getField(FieldName.AUTHOR).ifPresent(authors -> result.authors = getAuthors(authors));
entry.getField(FieldName.EDITOR).ifPresent(editors -> result.editors = getAuthors(editors));
entry.getField(FieldName.TRANSLATOR).ifPresent(translator -> result.translators = getAuthors(translator));

return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
@RunWith(Parameterized.class)
public class MsBibImporterTestFiles {

@Parameter
public String fileName;
@Parameter public String fileName;
public Path resourceDir;

private MsBibImporter testImporter;

@Before
public void setUp() throws Exception {
resourceDir = Paths.get(MsBibImporterTestFiles.class.getResource("").toURI());
testImporter = new MsBibImporter();
}

@Parameters(name = "{0}")
Expand All @@ -45,18 +45,14 @@ public static Collection<String> fileNames() throws IOException, URISyntaxExcept

@Test
public final void testIsRecognizedFormat() throws Exception {
MsBibImporter testImporter = new MsBibImporter();
Path xmlFile = resourceDir.resolve(fileName);

Assert.assertTrue(testImporter.isRecognizedFormat(xmlFile, StandardCharsets.UTF_8));
}

@Test
public void testImportEntries() throws Exception {

String bibFileName = fileName.replace(".xml", ".bib");
MsBibImporter testImporter = new MsBibImporter();

Path xmlFile = resourceDir.resolve(fileName);

List<BibEntry> result = testImporter.importDatabase(xmlFile, StandardCharsets.UTF_8).getDatabase().getEntries();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
% Encoding: UTF-8

@Misc{2016,
title = {MeinArtikel},
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't look like the bibtex version of the xml file below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for noticing. But shouldn't travis normally have noticed this?

year = {2016},
month = jul,
journal = {MeineZeitung},
msbib-accessed = {2018-07-01},
msbib-day = {1},
pages = {17},
timestamp = {2018-01-12},
translator = {TestÜbersetzer},
}

@Comment{jabref-meta: databaseType:biblatex;}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<b:Sources xmlns:b="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" xmlns="http://schemas.openxmlformats.org/officeDocument/2006/bibliography" SelectedStyle="">
<b:Source>
<b:Volume>130</b:Volume>
<b:BIBTEX_Entry>article</b:BIBTEX_Entry>
<b:SourceType>JournalArticle</b:SourceType>
<b:Title>La doctrine médicale des Indo-Européens</b:Title>
<b:Tag>benv-doct</b:Tag>
<b:BIBTEX_KeyWords>medicine, agni and soma</b:BIBTEX_KeyWords>
<b:Author>
<b:Author>
<b:NameList>
<b:Person>
<b:Last>Benveniste</b:Last>
<b:First>{\'E}mile</b:First>
</b:Person>
</b:NameList>
</b:Author>
<b:Translator>
<b:NameList>
<b:Person>
<b:Last>Übersetzer</b:Last>
<b:Middle>Test</b:Middle>
<b:First>Mein</b:First>
</b:Person>
</b:NameList>
</b:Translator>
</b:Author>
<b:Pages>5-12</b:Pages>
<b:Year>1945</b:Year>
<b:JournalName>Revue de l'Histoire des Religions</b:JournalName>
</b:Source>
</b:Sources>