diff --git a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java index 0f673938c9af..81c4fe316d9b 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/EndnoteXmlImporter.java @@ -260,10 +260,32 @@ private Optional getUrl(Record record) { } private Optional getUrlValue(Url url) { - return Optional.ofNullable(url) - .map(Url::getStyle) - .map(Style::getContent) - .map(this::clean); + Optional> urlContent = Optional.ofNullable(url).map(Url::getContent); + List list = urlContent.orElse(null); + Optional ret; + if (list==null || list.size() == 0) { + return Optional.empty(); + } + else { + boolean isStyleExist = false; + int style_index = -1; + for(int i =0 ; i < list.size(); i++) { + if(list.get(i) instanceof Style){ + isStyleExist = true; + style_index = i; + } + } + if (!isStyleExist) { + ret = Optional.ofNullable((String) list.get(0)) + .map(this::clean); + } + else { + ret = Optional.ofNullable((Style)list.get(style_index)) + .map(Style::getContent) + .map(this::clean); + } + } + return ret; } private List getKeywords(Record record) { diff --git a/src/main/resources/xjc/endnote/endnote.xsd b/src/main/resources/xjc/endnote/endnote.xsd index 5cfbe1893ca8..a446559044df 100644 --- a/src/main/resources/xjc/endnote/endnote.xsd +++ b/src/main/resources/xjc/endnote/endnote.xsd @@ -668,7 +668,7 @@ - + diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.bib b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.bib new file mode 100644 index 000000000000..f93199db1afb --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.bib @@ -0,0 +1,16 @@ +@article{, + abstract = {test abstract}, + author = {Ahmad, AS and Ormiston-Smith, N and Sasieni, PD}, + doi = {10.1038/bjc.2014.606}, + file = {:file\://localhost/Users/user/Documents/Bookends/Attachments/Ahmad%20et%20al%202015.pdf:PDF}, + isbn = {1532-1827 (Electronic) 0007-0920 (Linking)}, + keywords = {Age Factors; Aged; Aged, 80 and over; Female; Great Britain/epidemiology; Humans; Male; Middle Aged; Models, Statistical; Neoplasms/*epidemiology; Risk Assessment; Risk Factors; Sex Characteristics}, + number = {5}, + pages = {943-7}, + title = {Trends in the lifetime risk of developing cancer in Great Britain: comparison of risk for those born from 1930 to 1960}, + volume = {112}, + year = {2015}, + journal = {Br J Cancer}, + note = {some notes}, + url = {http://www.ncbi.nlm.nih.gov/pubmed/25647015}, +} diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.xml b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.xml new file mode 100644 index 000000000000..768ba5af3915 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle.xml @@ -0,0 +1,129 @@ + + + + + Library1.bdb + Bookends + 2954 + 17 + + + + + + + + + + + + + + + + + + + <style face="normal" size="100%">Trends in the lifetime risk of developing cancer in Great Britain: + comparison of risk for those born from 1930 to 1960 + </style> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://localhost/Users/user/Documents/Bookends/Attachments/Ahmad%20et%20al%202015.pdf + + + + + + + + + + + + + + + diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.bib b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.bib new file mode 100644 index 000000000000..a7293b79f142 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.bib @@ -0,0 +1,24 @@ +@article{, + author = {Chapman, A. G.}, + isbn = {0012-9658}, + number = {1}, + pages = {93-105}, + title = {An ecological basis for reforestation of submariginal lands in the Central Hardwood Region}, + volume = {18}, + year = {1937}, + journal = {Ecology}, + note = {some notes}, + url = {://000200148800007} +} +@book{, + author = {Strohecker, H. F.}, + isbn = {0012-9658}, + number = {1}, + journal = {Ecology}, + note = {some other notes}, + pages = {162-168}, + title = {A survey of soil temperatures in the Chicago area}, + volume = {18}, + url = {://000200148800014}, + year = {1937} +} diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.xml b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.xml new file mode 100644 index 000000000000..1050edd3f0f6 --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/EndnoteXmlImporterTest_WithoutUrlStyle2.xml @@ -0,0 +1,184 @@ + + + + + EndNote + Ecology.enl + + EndNote + 13264 + + 13264 + + 17 + + + + + + + + + + + + + <style face="normal" font="default" size="100%">An ecological basis for reforestation of + submariginal lands in the Central Hardwood Region + </style> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <Go to ISI>://000200148800007 + + + + + + + + + EndNote + Ecology.enl + + EndNote + 13265 + + 13265 + + 6 + + + + + + + + + + + + + <style face="normal" font="default" size="100%">A survey of soil temperatures in the Chicago area + </style> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <Go to ISI>://000200148800014 + + + + + + + + +