Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Noname690/jabref into Non…
Browse files Browse the repository at this point in the history
…ame690-master

* 'master' of https://github.com/Noname690/jabref:
  add a test
  add a test for #7737
  fix RIS importer
  fix the ris importer
  • Loading branch information
Siedlerchr committed May 29, 2021
2 parents 7a374ad + 6887cfa commit c7fc828
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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", "--")
.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 - "));
}
}


}

0 comments on commit c7fc828

Please sign in to comment.