Skip to content

Commit

Permalink
Merge branch 'upgrade-dependencies'
Browse files Browse the repository at this point in the history
  • Loading branch information
jpschewe committed Jun 14, 2020
2 parents 8a6c306 + ca1be8a commit d03fa4e
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 122 deletions.
171 changes: 84 additions & 87 deletions build.gradle

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
Expand Down Expand Up @@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi

# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
# For Cygwin or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
Expand Down
2 changes: 1 addition & 1 deletion src/integrationTest/java/fll/web/IntegrationTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
import fll.util.FLLInternalException;
import fll.web.api.TournamentsServlet;
import fll.xml.BracketSortType;
import io.github.bonigarcia.wdm.DriverManagerType;
import io.github.bonigarcia.wdm.WebDriverManager;
import io.github.bonigarcia.wdm.config.DriverManagerType;
import net.mtu.eggplant.xml.XMLUtils;

/**
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/fll/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvValidationException;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import fll.db.ImportDB;
Expand Down Expand Up @@ -233,7 +234,8 @@ public static void loadCSVFile(final Connection connection,
}
prep.executeUpdate();
}

} catch (final CsvValidationException e) {
throw new IOException("Error reading line of file", e);
} finally {
SQLFunctions.close(stmt);
SQLFunctions.close(prep);
Expand Down
31 changes: 18 additions & 13 deletions src/main/java/fll/db/ImportDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.w3c.dom.Document;

import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvValidationException;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import fll.Team;
Expand Down Expand Up @@ -299,22 +300,26 @@ private static void createTournament(final Tournament sourceTournament,
* @return key is column name, value is type
*/
public static Map<String, String> loadTypeInfo(final Reader reader) throws IOException {
final CSVReader csvreader = new CSVReader(reader);
final Map<String, String> columnTypes = new HashMap<>();
try {
final CSVReader csvreader = new CSVReader(reader);
final Map<String, String> columnTypes = new HashMap<>();

String[] line;
while (null != (line = csvreader.readNext())) {
if (line.length != 2) {
throw new RuntimeException("Typeinfo file has incorrect number of columns, should be 2");
}
if ("character".equalsIgnoreCase(line[1])) {
// handle broken dumps from version 7.0
columnTypes.put(line[0].toLowerCase(), "character(64)");
} else {
columnTypes.put(line[0].toLowerCase(), line[1]);
String[] line;
while (null != (line = csvreader.readNext())) {
if (line.length != 2) {
throw new RuntimeException("Typeinfo file has incorrect number of columns, should be 2");
}
if ("character".equalsIgnoreCase(line[1])) {
// handle broken dumps from version 7.0
columnTypes.put(line[0].toLowerCase(), "character(64)");
} else {
columnTypes.put(line[0].toLowerCase(), line[1]);
}
}
return columnTypes;
} catch (final CsvValidationException e) {
throw new IOException("Error parsing line", e);
}
return columnTypes;
}

/**
Expand Down
22 changes: 14 additions & 8 deletions src/main/java/fll/util/CSVCellReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.opencsv.CSVParserBuilder;
import com.opencsv.CSVReader;
import com.opencsv.CSVReaderBuilder;
import com.opencsv.exceptions.CsvValidationException;

import fll.Utilities;

Expand All @@ -35,7 +36,9 @@ public CSVCellReader(final File file) throws IOException {
}

/**
* @throws IOException
* @param file the file to read
* @param separator the column separator
* @throws IOException if there is an error opening the file
*/
public CSVCellReader(final Path file,
final char separator)
Expand All @@ -46,25 +49,28 @@ public CSVCellReader(final Path file,
}

/**
* @throws IOException
* @param file the file to read
* @throws IOException if there is an error opening the file
*/
public CSVCellReader(final Path file) throws IOException {
delegate = new CSVReaderBuilder(Files.newBufferedReader(file, Utilities.DEFAULT_CHARSET)).build();
}

/**
* @see fll.util.CellFileReader#getLineNumber()
*/
@Override
public long getLineNumber() {
return delegate.getLinesRead();
}

/**
* @throws IOException
* @see fll.util.CellFileReader#readNext()
* @throws IOException if there is an error reading from the file
*/
@Override
public String[] readNext() throws IOException {
return delegate.readNext();
try {
return delegate.readNext();
} catch (final CsvValidationException e) {
throw new IOException("Invalid line in CSV file", e);
}
}

public void close() throws IOException {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/fll/util/CellFileReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class CellFileReader implements Closeable {
public abstract long getLineNumber();

/**
* Read the next line
* Read the next line.
*
* @return the line as an array of Strings
* @throws IOException
Expand All @@ -59,7 +59,7 @@ public static CellFileReader createCellReader(final File file,
}

/**
* Read either an Excel file or a CSV file
* Read either an Excel file or a CSV file.
*
* @param file the file to read
* @param sheetName the sheet in an Excel file to read, null if reading a CSV
Expand All @@ -72,7 +72,7 @@ public static CellFileReader createCellReader(final Path file,
final String sheetName)
throws InvalidFormatException, IOException {
if (ExcelCellReader.isExcelFile(file)) {
try (final InputStream fis = Files.newInputStream(file)) {
try (InputStream fis = Files.newInputStream(file)) {
Objects.requireNonNull(sheetName, "Sheet name cannot be null when reading an Excel file");

return new ExcelCellReader(fis, sheetName);
Expand All @@ -81,7 +81,7 @@ public static CellFileReader createCellReader(final Path file,
// determine if the file is tab separated or comma separated, check the
// first line for tabs and if they aren't found, assume it's comma
// separated
try (final BufferedReader breader = Files.newBufferedReader(file, Utilities.DEFAULT_CHARSET)) {
try (BufferedReader breader = Files.newBufferedReader(file, Utilities.DEFAULT_CHARSET)) {
final String firstLine = breader.readLine();
if (null == firstLine) {
LOGGER.warn("Empty file");
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fll/util/ExcelCellReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import java.util.List;
import java.util.Objects;

import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Row.MissingCellPolicy;
Expand Down Expand Up @@ -214,9 +214,9 @@ public String[] readNext() throws IOException {
if (CellType.NUMERIC.equals(cell.getCellType())) {
final double d = cell.getNumericCellValue();
// test if a date!
if (HSSFDateUtil.isCellDateFormatted(cell)) {
if (DateUtil.isCellDateFormatted(cell)) {
// make sure to format times like we expect them
final Date date = HSSFDateUtil.getJavaDate(d);
final Date date = DateUtil.getJavaDate(d);
str = DATE_FORMAT_AM_PM_SS.get().format(date);
} else {
// check for integer
Expand Down

0 comments on commit d03fa4e

Please sign in to comment.