From 1ad836c63fd87079a87c6009fbe0a35353475547 Mon Sep 17 00:00:00 2001 From: Dennis Tschechlov Date: Thu, 2 Feb 2017 11:27:06 +0100 Subject: [PATCH 1/2] fix journal title --- .../importer/fileformat/RisImporter.java | 6 ++++- .../fileformat/RISImporterTestFiles.java | 2 +- .../fileformat/RisImporterTestScience.bib | 13 ++++++++++ .../fileformat/RisImporterTestScience.ris | 25 +++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.bib create mode 100644 src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.ris diff --git a/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java b/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java index 3196596c815..eb737680c1a 100644 --- a/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java +++ b/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java @@ -129,7 +129,11 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { fields.put(FieldName.TITLE, fields.get(FieldName.TITLE).replaceAll("\\s+", " ")); // Normalize whitespaces } else if ("BT".equals(tag)) { fields.put(FieldName.BOOKTITLE, value); - } else if ("T2".equals(tag) || "JO".equals(tag)) { + } else if ("T2".equals(tag)&&(fields.get(FieldName.JOURNAL) == null || "".equals(fields.get(FieldName.JOURNAL)))){ + //if there is no journal title, then put second title as journal title + fields.put(FieldName.JOURNAL, value); + } else if ("JO".equals(tag)) { + //if this field appears then this should be the journal title fields.put(FieldName.JOURNAL, value); } else if ("T3".equals(tag)) { fields.put(FieldName.SERIES, value); diff --git a/src/test/java/net/sf/jabref/logic/importer/fileformat/RISImporterTestFiles.java b/src/test/java/net/sf/jabref/logic/importer/fileformat/RISImporterTestFiles.java index af84c5e2ec4..f8dd081f8bc 100644 --- a/src/test/java/net/sf/jabref/logic/importer/fileformat/RISImporterTestFiles.java +++ b/src/test/java/net/sf/jabref/logic/importer/fileformat/RISImporterTestFiles.java @@ -41,7 +41,7 @@ public void setUp() throws URISyntaxException { public static Collection fileNames() { return Arrays.asList("RisImporterTest1", "RisImporterTest3", "RisImporterTest4a", "RisImporterTest4b", "RisImporterTest4c", "RisImporterTest5a", "RisImporterTest5b", "RisImporterTest6", - "RisImporterTestDoiAndJournalTitle", "RisImporterTestScopus"); + "RisImporterTestDoiAndJournalTitle", "RisImporterTestScopus", "RisImporterTestScience"); } @Test diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.bib b/src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.bib new file mode 100644 index 00000000000..faed9ca343d --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.bib @@ -0,0 +1,13 @@ +@Article{, + author = {Ghosh, Chanchal and Basu, Joysurya and Ramachandran, Divakar and Mohandas, E.}, + title = {Phase separation and ω transformation in binary V-Ti and ternary V-Ti-Cr alloys}, + journal = {Acta Materialia}, + year = {2016}, + volume = {121}, + pages = {310--324}, + month = dec, + issn = {1359-6454}, + abstract = {Abstract}, + keywords = {V-Ti-Cr alloys, Spinodal decomposition, ω phase transformation, High-resolution electron microscopy, Energy-filtered transmission microscopy}, + url = {//www.sciencedirect.com/science/article/pii/S1359645416307273}, +} diff --git a/src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.ris b/src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.ris new file mode 100644 index 00000000000..247f2cf9b14 --- /dev/null +++ b/src/test/resources/net/sf/jabref/logic/importer/fileformat/RisImporterTestScience.ris @@ -0,0 +1,25 @@ +TY - JOUR +T1 - Phase separation and ω transformation in binary V-Ti and ternary V-Ti-Cr alloys +JO - Acta Materialia +VL - 121 +IS - +SP - 310 +EP - 324 +PY - 2016/12// +T2 - +AU - Ghosh, Chanchal +AU - Basu, Joysurya +AU - Ramachandran, Divakar +AU - Mohandas, E. +SN - 1359-6454 +DO - http://dx.doi.org/10.1016/j.actamat.2016.09.028 +UR - //www.sciencedirect.com/science/article/pii/S1359645416307273 +KW - V-Ti-Cr alloys +KW - Spinodal decomposition +KW - ω phase transformation +KW - High-resolution electron microscopy +KW - Energy-filtered transmission microscopy +AB - Abstract +ER - + + From c3f03ad1ef217083d79d9239ac371fb0c542f518 Mon Sep 17 00:00:00 2001 From: Dennis Tschechlov Date: Thu, 2 Feb 2017 18:11:34 +0100 Subject: [PATCH 2/2] add changelog entry and fix formatting --- CHANGELOG.md | 1 + .../net/sf/jabref/logic/importer/fileformat/RisImporter.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e00d5525c21..f15df6a0082 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Fixed - Repairs the handling of apostrophes in the LaTeX to unicode conversion. [#2500](https://github.com/JabRef/jabref/issues/2500) + - Fix import of journal title in ris format. [#2506](https://github.com/JabRef/jabref/issues/2506) ### Removed diff --git a/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java b/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java index eb737680c1a..eb74651b709 100644 --- a/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java +++ b/src/main/java/net/sf/jabref/logic/importer/fileformat/RisImporter.java @@ -129,7 +129,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { fields.put(FieldName.TITLE, fields.get(FieldName.TITLE).replaceAll("\\s+", " ")); // Normalize whitespaces } else if ("BT".equals(tag)) { fields.put(FieldName.BOOKTITLE, value); - } else if ("T2".equals(tag)&&(fields.get(FieldName.JOURNAL) == null || "".equals(fields.get(FieldName.JOURNAL)))){ + } else if ("T2".equals(tag) && (fields.get(FieldName.JOURNAL) == null || "".equals(fields.get(FieldName.JOURNAL)))) { //if there is no journal title, then put second title as journal title fields.put(FieldName.JOURNAL, value); } else if ("JO".equals(tag)) {