Commit bc104c20 authored by Matija Obreza's avatar Matija Obreza
Browse files

Fix: opencsv obsolete methods

parent 10a6fdaf
......@@ -28,7 +28,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.vividsolutions.jts.geom.Coordinate;
/**
......@@ -48,13 +50,13 @@ public class CountryProcessServiceImpl implements ProcessService {
return execute(reader, separator, quoteChar, escapeChar, decimalMark);
}
private List<String[]> execute(final Reader readerr, final char separatorChar, final char quoteChar, final char escapeChar, final Character decimalMark) throws IOException {
private List<String[]> execute(final Reader reader, final char separatorChar, final char quoteChar, final char escapeChar, final Character decimalMark) throws IOException {
final List<String[]> lines = Collections.synchronizedList(new LinkedList<>());
try (CSVReader reader = new CSVReader(readerr, separatorChar, quoteChar, escapeChar, 0, false)) {
try (CSVReader csv = new CSVReaderBuilder(reader).withCSVParser(new CSVParserBuilder().withSeparator(separatorChar).withQuoteChar(quoteChar).withEscapeChar(escapeChar).build()).build()) {
final String[] headers = reader.readNext();
final String[] headers = csv.readNext();
LOG.debug("Input CSV headers: {}", Arrays.toString(headers));
HeaderUtils.throwIfHeaderFound(headers, new String[] { ApplicationUtils.HEADER_ORIGCTY_CHECK });
......@@ -132,7 +134,7 @@ public class CountryProcessServiceImpl implements ProcessService {
final ArrayList<String[]> inputs = new ArrayList<>();
for (int j = 0; j < 100; j++) {
final String[] nextLine = reader.readNext();
final String[] nextLine = csv.readNext();
if (nextLine == null) {
LOG.info("No input");
......
......@@ -28,7 +28,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
/**
* @author Andrey Lugovskoy.
......@@ -52,14 +54,14 @@ public class LandOrSeaProcessServiceImpl implements ProcessService {
* @see org.genesys.geotools.cli.GeoTool#execute(java.io.InputStream,
* java.io.OutputStream, char, char, char)
*/
public List<String[]> execute(final Reader readerr, final char separatorChar, final char quoteChar, final char escapeChar, final char decimalMark) throws IOException {
public List<String[]> execute(final Reader reader, final char separatorChar, final char quoteChar, final char escapeChar, final char decimalMark) throws IOException {
final List<String[]> lines = Collections.synchronizedList(new LinkedList<>());
try (CSVReader reader = new CSVReader(readerr, separatorChar, quoteChar, escapeChar, 0, false)) {
try (CSVReader csv = new CSVReaderBuilder(reader).withCSVParser(new CSVParserBuilder().withSeparator(separatorChar).withQuoteChar(quoteChar).withEscapeChar(escapeChar).build()).build()) {
// Scan for headers
final String[] headers = reader.readNext();
final String[] headers = csv.readNext();
LOG.debug("Input CSV headers: {}", Arrays.toString(headers));
HeaderUtils.throwIfHeaderFound(headers, new String[] { ApplicationUtils.HEADER_LANDORSEA_CHECK });
......@@ -115,7 +117,7 @@ public class LandOrSeaProcessServiceImpl implements ProcessService {
final ArrayList<String[]> inputs = new ArrayList<>();
for (int j = 0; j < 100; j++) {
final String[] nextLine = reader.readNext();
final String[] nextLine = csv.readNext();
if (nextLine == null) {
LOG.info("No input");
break;
......
......@@ -46,7 +46,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
/**
* The Class ProcessServiceImpl.
......@@ -133,9 +135,9 @@ public class TaxonomyProcessServiceImpl implements ProcessService {
taxonomyChecker.setTaxonomyDatabase(taxonomyDatabase);
LOG.info("Running the validation against {}", taxonomyDatabase);
try (CSVReader csvReader = new CSVReader(reader, separator, quoteChar, escapeChar, 0, false, true, false)) {
try (CSVReader csv = new CSVReaderBuilder(reader).withCSVParser(new CSVParserBuilder().withSeparator(separator).withQuoteChar(quoteChar).withEscapeChar(escapeChar).build()).build()) {
final String[] headers = csvReader.readNext();
final String[] headers = csv.readNext();
LOG.debug("Input CSV headers: {}", Arrays.toString(headers));
{
......@@ -224,7 +226,7 @@ public class TaxonomyProcessServiceImpl implements ProcessService {
String[] sourceLine;
while ((sourceLine = csvReader.readNext()) != null) {
while ((sourceLine = csv.readNext()) != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("\n\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment