Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where import hangs for ris files with "ER - " failed [#7737](https://github.com/JabRef/jabref/issues/7737)
- We fixed an issue where getting bibliograhpic data from DOI or another identifer did not respect the library mode (BibTeX/biblatex)[#1018](https://github.com/JabRef/jabref/issues/6267)
- We fixed an issue where importing entries would not respect the library mode (BibTeX/biblatex)[#1018](https://github.com/JabRef/jabref/issues/1018)
- We fixed an issue where an exception occured when importing entries from a web search [#7606](https://github.com/JabRef/jabref/issues/7606)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class RisImporter extends Importer {

private static final Pattern RECOGNIZED_FORMAT_PATTERN = Pattern.compile("TY - .*");
private static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy");
private static String[] entries;

@Override
public String getName() {
Expand All @@ -54,15 +55,19 @@ public boolean isRecognizedFormat(BufferedReader reader) throws IOException {
return reader.lines().anyMatch(line -> RECOGNIZED_FORMAT_PATTERN.matcher(line).find());
}

public String[] getEntries() {
return entries;
}

@Override
public ParserResult importDatabase(BufferedReader reader) throws IOException {
List<BibEntry> bibitems = new ArrayList<>();

// use optional here, so that no exception will be thrown if the file is empty
String linesAsString = reader.lines().reduce((line, nextline) -> line + "\n" + nextline).orElse("");

String[] entries = linesAsString.replace("\u2013", "-").replace("\u2014", "--").replace("\u2015", "--")
.split("ER -.*\\n");
entries = linesAsString.replace("\u2013", "-").replace("\u2014", "--").replace("\u2015", "--")
Copy link
Member

Choose a reason for hiding this comment

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

This is not what I meant with tests. Have a look at the RISImporterTestFiles class.
It searches for test files in /src/test/resources/org/jabref/logic/importer/fileformat that ar named with RISImporterTest....ris
and have a corresponding .bib file with the same name

So you create a minimal RIS file with the ER at the end and a corresponding bib files
This way you can test that the import succeeds without errors

.split("ER -.*(\\n)*");

// stores all the date tags from highest to lowest priority
List<String> dateTags = Arrays.asList("Y1", "PY", "DA", "Y2");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,14 @@ public void testIfNotRecognizedFormat() throws IOException, URISyntaxException {
Path file = Path.of(RISImporterTest.class.getResource("RisImporterCorrupted.ris").toURI());
assertFalse(importer.isRecognizedFormat(file, StandardCharsets.UTF_8));
}

@Test
public void testIfSplitCorrect(){
String[] entries = importer.gerEntries;
for (String entry : entries) {
assertFalse(entry.equals("ER - "));
}
}


}