use of org.onebusaway.admin.model.BundleValidationParseResults in project onebusaway-application-modules by camsys.
the class ValidateBundleAction method runValidateBundle.
/**
* Uploads the bundle validate checks and uses them to test the validity of the bundle
*/
public String runValidateBundle() {
File inputFile;
Path csvTarget = null;
Reader csvInputFile = null;
if (wikiUrl.length() > 0) {
URL wikiInputUrl;
try {
wikiInputUrl = new URL(wikiUrl);
csvInputFile = new BufferedReader(new InputStreamReader(wikiInputUrl.openStream()));
} catch (MalformedURLException e) {
return "bundleValidationResults";
} catch (IOException e) {
e.printStackTrace();
return "bundleValidationResults";
}
} else if (csvFile.length() > 0) {
csvTarget = uploadCsvFile(csvFile);
inputFile = csvTarget.toFile();
try {
csvInputFile = new FileReader(inputFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
return "bundleValidationResults";
}
} else {
return "bundleValidationResults";
}
BundleValidationParseResults parseResults = _bundleCheckParserService.parseBundleChecksFile(csvInputFile);
List<BundleValidateQuery> queryResults = _buildBundleQueriesService.buildQueries(parseResults.getParsedBundleChecks(), checkEnvironment);
for (BundleValidateQuery query : queryResults) {
String queryResult = getQueryResult(query);
query.setQueryResult(queryResult);
}
List<BundleValidationCheckResult> checkResults = checkResults(queryResults);
if (csvTarget != null) {
try {
Files.delete(csvTarget);
} catch (IOException e) {
_log.error("Exception while trying to delete temp .csv file");
e.printStackTrace();
}
}
bundleValidationResults = checkResults;
return "bundleValidationResults";
}
use of org.onebusaway.admin.model.BundleValidationParseResults 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