Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
Update BfArM Antigentest list (#232)
Browse files Browse the repository at this point in the history
* Update BfArM Antigentest list

* - change parser to skip 2 lines (csv headers)
- fix sonar findings
  • Loading branch information
bergmann-dierk authored Mar 8, 2022
1 parent b0e9738 commit 8fb482c
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -51,7 +49,8 @@
@RequiredArgsConstructor
public class AntigenTestService {

private List<AntigenTest> antigenTests = new ArrayList();
private List<AntigenTest> antigenTests = new ArrayList<>();

@Getter
private LocalDateTime lastUpdate = Utilities.getCurrentLocalDateTimeUtc();

Expand Down Expand Up @@ -91,22 +90,19 @@ protected void setAntigenTests(InputStream inputStreamCsv) {
}

private void init() {
InputStream inputStreamCsv = loadAntigenTestsFromBfArM();
if (inputStreamCsv == null) {
final ClassPathResource classPathResource = new ClassPathResource("antigentests.csv");
inputStreamCsv = (Objects.requireNonNull(
Objects.requireNonNull(classPathResource.getClassLoader())
.getResourceAsStream("antigentests.csv")));
}
final ClassPathResource classPathResource = new ClassPathResource("antigentests.csv");
InputStream inputStreamCsv = (Objects.requireNonNull(
Objects.requireNonNull(classPathResource.getClassLoader())
.getResourceAsStream("antigentests.csv")));
setAntigenTests(inputStreamCsv);
}

private List<AntigenTest> mapToAntigenTest(List<List<String>> rawAntigenTests) {
List<AntigenTest> antigenTests = new ArrayList();
List<AntigenTest> mappedAntigenTests = new ArrayList<>();
for (List<String> row : rawAntigenTests) {
antigenTests.add(new AntigenTest(row.get(0), row.get(1)));
mappedAntigenTests.add(new AntigenTest(row.get(0), row.get(1)));
}
return antigenTests;
return mappedAntigenTests;
}

private List<List<String>> filterAntigenTests(List<List<String>> unFilteredAntigentest) {
Expand All @@ -122,7 +118,7 @@ private List<List<String>> createAntigenTestListFromCsvInputStream(InputStream i
.withIgnoreQuotations(true)
.build();
CSVReader csvReader = new CSVReaderBuilder(new InputStreamReader(inputStreamCsv, "windows-1252"))
.withSkipLines(1)
.withSkipLines(2)
.withCSVParser(parser)
.build();
String[] values;
Expand All @@ -136,9 +132,4 @@ private List<List<String>> createAntigenTestListFromCsvInputStream(InputStream i
}
return rawAntigenTests;
}

private InputStream loadAntigenTestsFromBfArM() {
// TODO impl
return null;
}
}
Loading

0 comments on commit 8fb482c

Please sign in to comment.