mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-19 02:29:58 +00:00
starting to understand IRMs/MaxPointsReason codes in Barbados result format
This commit is contained in:
1 parent
64a800317c
commit
98d8e655c8
3 files changed
+21
-9
No files matched your search
Binary file not shown.
+8
-7
@@ -29,6 +29,7 @@ public class BarbadosResultImportTest {
|
||||
private static final String SAMPLE_INPUT_NAME_EMPTY_RESULTS = "RESULTS-505Barbados.xlsx";
|
||||
private static final String RESOURCES = "resources/";
|
||||
private BarbadosResultSpreadsheet spreadsheet;
|
||||
private ScoreCorrectionProviderImpl scp;
|
||||
|
||||
private InputStream getInputStream(String filename) throws FileNotFoundException, IOException {
|
||||
return new FileInputStream(getFile(filename));
|
||||
@@ -41,6 +42,13 @@ public class BarbadosResultImportTest {
|
||||
@Before
|
||||
public void setUp() throws FileNotFoundException, IOException, Exception {
|
||||
spreadsheet = new BarbadosResultSpreadsheet(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS));
|
||||
scp = new ScoreCorrectionProviderImpl(new ResultDocumentProvider() {
|
||||
@Override
|
||||
public Iterable<Triple<InputStream, String, TimePoint>> getDocumentsAndNamesAndLastModified() throws IOException {
|
||||
return Collections.singleton(new Triple<InputStream, String, TimePoint>(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS),
|
||||
SAMPLE_INPUT_NAME_EMPTY_RESULTS, MillisecondsTimePoint.now()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -53,13 +61,6 @@ public class BarbadosResultImportTest {
|
||||
|
||||
@Test
|
||||
public void testResultsThroughScoreCorrectionProvider() throws Exception {
|
||||
ScoreCorrectionProviderImpl scp = new ScoreCorrectionProviderImpl(new ResultDocumentProvider() {
|
||||
@Override
|
||||
public Iterable<Triple<InputStream, String, TimePoint>> getDocumentsAndNamesAndLastModified() throws IOException {
|
||||
return Collections.singleton(new Triple<InputStream, String, TimePoint>(getInputStream(SAMPLE_INPUT_NAME_EMPTY_RESULTS),
|
||||
SAMPLE_INPUT_NAME_EMPTY_RESULTS, MillisecondsTimePoint.now()));
|
||||
}
|
||||
});
|
||||
Map<String, Set<Pair<String, TimePoint>>> hasResultsFor = scp.getHasResultsForBoatClassFromDateByEventName();
|
||||
assertNotNull(hasResultsFor);
|
||||
assertEquals(1, hasResultsFor.size());
|
||||
|
||||
+13
-2
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
@@ -56,11 +57,21 @@ public class BarbadosResultSpreadsheet {
|
||||
double netPointsBeforeDiscarding = row.getCell(columnNumberOfNetScore).getNumericCellValue();
|
||||
List<CompetitorEntry> rankAndMaxPointsReasonAndPointsAndDiscarded = new ArrayList<>();
|
||||
for (int raceNumber=0; raceNumber<numberOfRaces; raceNumber++) {
|
||||
int rank = (int) row.getCell(COLUMN_NUMBER_OF_FIRST_RACE_RANK+raceNumber).getNumericCellValue();
|
||||
final Cell rankOrMaxPointReasonCell = row.getCell(COLUMN_NUMBER_OF_FIRST_RACE_RANK+raceNumber);
|
||||
Integer rank;
|
||||
String maxPointsReason;
|
||||
try {
|
||||
rank = (int) rankOrMaxPointReasonCell.getNumericCellValue();
|
||||
maxPointsReason = null;
|
||||
} catch (IllegalStateException e) {
|
||||
// not a numeric value; try to parse text / IRM / MaxPointsReason
|
||||
rank = null;
|
||||
maxPointsReason = rankOrMaxPointReasonCell.getStringCellValue();
|
||||
}
|
||||
double score = row.getCell(columnNumberOfFirstRaceScore+raceNumber).getNumericCellValue();
|
||||
if (score != 0.0) {
|
||||
CompetitorEntry entry = new DefaultCompetitorEntryImpl(rank,
|
||||
/* maxPointsReason */ null, score, /* discarded */ false);
|
||||
maxPointsReason, score, /* discarded */ false);
|
||||
rankAndMaxPointsReasonAndPointsAndDiscarded.add(entry);
|
||||
} else {
|
||||
rankAndMaxPointsReasonAndPointsAndDiscarded.add(null);
|
||||
|
||||
Reference in new issue
Block a user