Skip to content

Commit ea7744f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into removecommonslogging
* upstream/master: Extend RIS import with multiple fields (#3642) Fix ICAR fetcher test which resulted in build failure (#3654)
2 parents eff166b + 733da31 commit ea7744f

File tree

13 files changed

+75
-31
lines changed

13 files changed

+75
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ For more details refer to the [field mapping help page](http://help.jabref.org/e
2424
### Fixed
2525
- We fixed the missing dot in the name of an exported file. [#3576](https://github.com/JabRef/jabref/issues/3576)
2626
- Autocompletion in the search bar can now be disabled via the preferences. [#3598](https://github.com/JabRef/jabref/issues/3598)
27+
- We fixed and extended the RIS import functionality to cover more fields. [#3634](https://github.com/JabRef/jabref/issues/3634) [#2607](https://github.com/JabRef/jabref/issues/2607)
2728

2829
### Removed
2930
- We removed the [Look and Feels from JGoodies](http://www.jgoodies.com/freeware/libraries/looks/), because the open source version is not compatible with Java 9.

src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919
import org.jabref.model.entry.FieldName;
2020
import org.jabref.model.entry.Month;
2121

22-
/**
23-
* Imports a Biblioscape Tag File. The format is described on
24-
* http://www.biblioscape.com/manual_bsp/Biblioscape_Tag_File.htm
25-
* Several Biblioscape field types are ignored. Others are only included in the BibTeX
26-
* field "comment".
27-
*/
2822
public class RisImporter extends Importer {
2923

3024
private static final Pattern RECOGNIZED_FORMAT_PATTERN = Pattern.compile("TY - .*");
@@ -129,21 +123,21 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
129123
fields.put(FieldName.TITLE, fields.get(FieldName.TITLE).replaceAll("\\s+", " ")); // Normalize whitespaces
130124
} else if ("BT".equals(tag)) {
131125
fields.put(FieldName.BOOKTITLE, value);
132-
} else if ("T2".equals(tag) && (fields.get(FieldName.JOURNAL) == null || "".equals(fields.get(FieldName.JOURNAL)))) {
126+
} else if (("T2".equals(tag) || "J2".equals(tag) || "JA".equals(tag)) && (fields.get(FieldName.JOURNAL) == null || "".equals(fields.get(FieldName.JOURNAL)))) {
133127
//if there is no journal title, then put second title as journal title
134128
fields.put(FieldName.JOURNAL, value);
135-
} else if ("JO".equals(tag)) {
129+
} else if ("JO".equals(tag) || "J1".equals(tag) || "JF".equals(tag)) {
136130
//if this field appears then this should be the journal title
137131
fields.put(FieldName.JOURNAL, value);
138132
} else if ("T3".equals(tag)) {
139133
fields.put(FieldName.SERIES, value);
140-
} else if ("AU".equals(tag) || "A1".equals(tag)) {
134+
} else if ("AU".equals(tag) || "A1".equals(tag) || "A2".equals(tag) || "A3".equals(tag) || "A4".equals(tag)) {
141135
if ("".equals(author)) {
142136
author = value;
143137
} else {
144138
author += " and " + value;
145139
}
146-
} else if ("A2".equals(tag) || "A3".equals(tag) || "A4".equals(tag)) {
140+
} else if ("ED".equals(tag)) {
147141
if (editor.isEmpty()) {
148142
editor = value;
149143
} else {
@@ -161,7 +155,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
161155
fields.put("caption", value);
162156
} else if ("DB".equals(tag)) {
163157
fields.put("database", value);
164-
} else if ("IS".equals(tag)) {
158+
} else if ("IS".equals(tag) || "AN".equals(tag) || "C7".equals(tag) || "M1".equals(tag)) {
165159
fields.put(FieldName.NUMBER, value);
166160
} else if ("SP".equals(tag)) {
167161
startPage = value;
@@ -171,7 +165,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
171165
} else {
172166
fields.put(FieldName.PUBLISHER, value);
173167
}
174-
} else if ("AD".equals(tag) || "CY".equals(tag)) {
168+
} else if ("AD".equals(tag) || "CY".equals(tag) || "PP".equals(tag)) {
175169
fields.put(FieldName.ADDRESS, value);
176170
} else if ("EP".equals(tag)) {
177171
endPage = value;
@@ -191,9 +185,9 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
191185
} else {
192186
fields.put(FieldName.ABSTRACT, oldAb + OS.NEWLINE + value);
193187
}
194-
} else if ("UR".equals(tag)) {
188+
} else if ("UR".equals(tag) || "L2".equals(tag) || "LK".equals(tag)) {
195189
fields.put(FieldName.URL, value);
196-
} else if (("Y1".equals(tag) || "PY".equals(tag) || "DA".equals(tag)) && (value.length() >= 4)) {
190+
} else if (("Y1".equals(tag) || "Y2".equals(tag) || "PY".equals(tag) || "DA".equals(tag)) && (value.length() >= 4)) {
197191
fields.put(FieldName.YEAR, value.substring(0, 4));
198192
String[] parts = value.split("/");
199193
if ((parts.length > 1) && !parts[1].isEmpty()) {
@@ -216,12 +210,39 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException {
216210
comment = comment + " ";
217211
}
218212
comment = comment + value;
213+
} else if ("M3".equals(tag) || "DO".equals(tag)) {
214+
addDoi(fields, value);
215+
} else if ("C3".equals(tag)) {
216+
fields.put(FieldName.EVENTTITLE, value);
217+
} else if ("N1".equals(tag) || "RN".equals(tag)) {
218+
fields.put(FieldName.NOTE, value);
219+
} else if ("ST".equals(tag)) {
220+
fields.put(FieldName.SHORTTITLE, value);
221+
} else if ("C2".equals(tag)) {
222+
fields.put(FieldName.EPRINT, value);
223+
fields.put(FieldName.EPRINTTYPE, "pubmed");
224+
} else if ("TA".equals(tag)) {
225+
fields.put(FieldName.TRANSLATOR, value);
219226
}
220-
// Added ID import 2005.12.01, Morten Alver:
221-
else if ("ID".equals(tag)) {
227+
// fields for which there is no direct mapping in the bibtext standard
228+
else if ("AV".equals(tag)) {
229+
fields.put("archive_location", value);
230+
} else if ("CN".equals(tag) || "VO".equals(tag)) {
231+
fields.put("call-number", value);
232+
} else if ("DB".equals(tag)) {
233+
fields.put("archive", value);
234+
} else if ("NV".equals(tag)) {
235+
fields.put("number-of-volumes", value);
236+
} else if ("OP".equals(tag)) {
237+
fields.put("original-title", value);
238+
} else if ("RI".equals(tag)) {
239+
fields.put("reviewed-title", value);
240+
} else if ("RP".equals(tag)) {
241+
fields.put("status", value);
242+
} else if ("SE".equals(tag)) {
243+
fields.put("section", value);
244+
} else if ("ID".equals(tag)) {
222245
fields.put("refid", value);
223-
} else if ("M3".equals(tag) || "DO".equals(tag)) {
224-
addDoi(fields, value);
225246
}
226247
}
227248
// fix authors
@@ -245,11 +266,11 @@ else if ("ID".equals(tag)) {
245266

246267
// create one here
247268
// type is set in the loop above
248-
BibEntry b = new BibEntry(type);
249-
b.setField(fields);
269+
BibEntry entry = new BibEntry(type);
270+
entry.setField(fields);
250271
// month has a special treatment as we use the separate method "setMonth" of BibEntry instead of directly setting the value
251-
month.ifPresent(parsedMonth -> b.setMonth(parsedMonth));
252-
bibitems.add(b);
272+
month.ifPresent(parsedMonth -> entry.setMonth(parsedMonth));
273+
bibitems.add(entry);
253274

254275
}
255276
return new ParserResult(bibitems);

src/main/java/org/jabref/model/entry/FieldName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public class FieldName {
110110
public static final String SERIES = "series";
111111
public static final String SHORTAUTHOR = "shortauthor";
112112
public static final String SHORTEDITOR = "shorteditor";
113+
public static final String SHORTTITLE = "shorttitle";
113114
public static final String SORTNAME = "sortname";
114115
public static final String SUBTITLE = "subtitle";
115116
public static final String TITLE = "title";

src/test/java/org/jabref/logic/importer/fetcher/IacrEprintFetcherTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ public void setUp() {
7171
delgado2017.setField("bibtexkey", "cryptoeprint:2017:1095");
7272
delgado2017.setField(FieldName.ABSTRACT, "dummy");
7373
delgado2017.setField(FieldName.AUTHOR, "Sergi Delgado-Segura and Cristina Pérez-Solà and Guillermo Navarro-Arribas and Jordi Herrera-Joancomartí");
74-
delgado2017.setField(FieldName.DATE, "2017-11-10");
74+
delgado2017.setField(FieldName.DATE, "2018-01-19");
7575
delgado2017.setField(FieldName.HOWPUBLISHED, "Cryptology ePrint Archive, Report 2017/1095");
7676
delgado2017.setField(FieldName.NOTE, "\\url{https://eprint.iacr.org/2017/1095}");
7777
delgado2017.setField(FieldName.TITLE, "Analysis of the Bitcoin UTXO set");
78-
delgado2017.setField(FieldName.URL, "https://eprint.iacr.org/2017/1095/20171110:183926");
79-
delgado2017.setField(FieldName.VERSION, "20171110:183926");
78+
delgado2017.setField(FieldName.URL, "https://eprint.iacr.org/2017/1095/20180119:113352");
79+
delgado2017.setField(FieldName.VERSION, "20180119:113352");
8080
delgado2017.setField(FieldName.YEAR, "2017");
8181
}
8282

src/test/java/org/jabref/logic/importer/fileformat/RISImporterTestFiles.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void setUp() throws URISyntaxException {
4040
@Parameters(name = "{0}")
4141
public static Collection<String> fileNames() {
4242
return Arrays.asList("RisImporterTest1", "RisImporterTest3", "RisImporterTest4a", "RisImporterTest4b",
43-
"RisImporterTest4c", "RisImporterTest5a", "RisImporterTest5b", "RisImporterTest6",
43+
"RisImporterTest4c", "RisImporterTest5a", "RisImporterTest5b", "RisImporterTest6", "RisImporterTest7",
4444
"RisImporterTestDoiAndJournalTitle", "RisImporterTestScopus", "RisImporterTestScience");
4545
}
4646

src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest1.bib

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ @phdthesis{
22
abstract = {abstract0
33
abstract1},
44
address = {32 peralta avenue los gatos ca},
5-
author = {Cocke and Harrison, Warren Levenshtein Morris},
6-
booktitle = {kmptnz},
5+
author = {Cocke and Harrison, Warren Levenshtein Morris and Rives and Kasami},
6+
booktitle = {kmptne},
77
comment = {comment0
88
comment1
99
comment2},
1010
doi = {whatever},
11-
editor = {Rives and Kasami},
1211
issn = {kmptns},
1312
journal = {kmptnd},
1413
keywords = {keyword0, keyword1},

src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest3.bib

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ @incollection{
44
doi = {10.1201/b19107-2},
55
issn = {978-1-4822-5326-9},
66
journal = {Dermoscopy Image Analysis},
7-
month = {#sep#},
7+
month = {#nov#},
8+
number = {0},
89
pages = {1-22},
910
publisher = {CRC Press},
1011
series = {Digital Imaging and Computer Vision},

src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest4b.bib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@book{,
22
address = {Cambridge},
3+
editor = {Robinson, W. F. and Huxtable, C. R. R.},
34
publisher = {Cambridge University Press},
45
refid = {robinson},
56
title = {Clinicopathologic Principles For Veterinary Medicine},

src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest5a.bib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ @article{
55
issn = {0032-5910},
66
journal = {Powder Technology},
77
keywords = {ibuprofen beta cyclodextrin inclusion complex tablet},
8+
number = {Copyright (C) 2016 American Chemical Society (ACS). All Rights Reserved.},
89
pages = {245--251},
910
publisher = {Elsevier B.V.},
1011
title = {Release profile of ibuprofen in β-cyclodextrin complexes from two different solid dosage forms.},

src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest6.bib

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ @article{
55
issn = {1537-744X},
66
journal = {The Scientific World Journal},
77
month = {#mar#},
8+
number = {PMC3654245},
89
pages = {219840},
910
publisher = {Hindawi Publishing Corporation},
1011
title = {Chelation: Harnessing and Enhancing Heavy Metal Detoxification--A Review},

0 commit comments

Comments
 (0)