use of org.onebusaway.admin.model.BundleValidationParseError in project onebusaway-application-modules by camsys.
the class BundleCheckParserServiceImpl method parseRecord.
private BundleValidationParseResults parseRecord(CSVRecord record, BundleValidationParseResults parseResults) {
// Verify that second field contains a valid test.
if (record.size() < 2 || !validTests.contains(record.get(1).toLowerCase())) {
BundleValidationParseError parseError = new BundleValidationParseError();
parseError.setLinenum((int) record.getRecordNumber());
parseError.setErrorMessage(PARSE_ERROR);
parseError.setOffendingLine(record.toString());
parseResults.getParseErrors().add(parseError);
return parseResults;
}
ParsedBundleValidationCheck parsedCheck = new ParsedBundleValidationCheck();
parsedCheck.setLinenum((int) record.getRecordNumber());
parsedCheck.setAgencyId(record.get(0));
parsedCheck.setSpecificTest(record.get(1));
if (record.get(2) != null) {
parsedCheck.setRouteName(record.get(2));
}
if (record.get(3) != null) {
parsedCheck.setRouteId(record.get(3));
}
if (record.get(4) != null) {
parsedCheck.setStopName(record.get(4));
}
if (record.get(5) != null) {
parsedCheck.setStopId(record.get(5));
}
if (record.get(6) != null) {
parsedCheck.setDate(record.get(6));
}
if (record.get(7) != null) {
parsedCheck.setDepartureTime(record.get(7));
}
parseResults.getParsedBundleChecks().add(parsedCheck);
return parseResults;
}
use of org.onebusaway.admin.model.BundleValidationParseError in project onebusaway-application-modules by camsys.
the class BundleCheckParserServiceImpl method parseBundleChecksFile.
@Override
public BundleValidationParseResults parseBundleChecksFile(Reader csvDataFile) {
// Create set of valid tests
List<ParsedBundleValidationCheck> parsedChecks = new ArrayList<ParsedBundleValidationCheck>();
List<BundleValidationParseError> parseErrors = new ArrayList<BundleValidationParseError>();
BundleValidationParseResults parseResults = new BundleValidationParseResults();
parseResults.setParsedBundleChecks(parsedChecks);
parseResults.setParseErrors(parseErrors);
try {
int linenum = 0;
for (CSVRecord record : CSVFormat.DEFAULT.parse(csvDataFile)) {
++linenum;
parseResults = parseRecord(record, parseResults);
}
} catch (FileNotFoundException e) {
_log.info("Exception parsing csv file ", e);
e.printStackTrace();
} catch (IOException e) {
_log.info("Exception parsing csv file ", e);
e.printStackTrace();
}
return parseResults;
}
Aggregations