use of org.onebusaway.admin.model.BundleValidateQuery in project onebusaway-application-modules by camsys.
the class BuildBundleQueriesServiceImpl method buildQueries.
@Override
public List<BundleValidateQuery> buildQueries(List<ParsedBundleValidationCheck> parsedChecks, String checkEnvironment) {
if (queryBuilders == null) {
initQueryBuilders();
}
List<BundleValidateQuery> queries = new ArrayList<BundleValidateQuery>();
String envURI = "";
if (checkEnvironment.equals(PRODUCTION_ENV)) {
envURI = getConfigValue("apiProd");
} else {
envURI = getConfigValue("apiStaging");
}
String apiKey = getConfigValue("apiKey");
String apiQuery = getConfigValue("apiQuery");
String siriQuery = getConfigValue("siriQuery");
for (ParsedBundleValidationCheck check : parsedChecks) {
BundleValidateQuery validationQuery = new BundleValidateQuery();
String specificTest = check.getSpecificTest().toLowerCase();
String query = queryBuilders.get(specificTest) == null ? "" : queryBuilders.get(specificTest).buildQuery(envURI, apiKey, apiQuery, siriQuery, check);
validationQuery.setLinenum(check.getLinenum());
validationQuery.setSpecificTest(check.getSpecificTest());
validationQuery.setRouteOrStop(check.getRouteName());
validationQuery.setRouteId(check.getRouteId());
validationQuery.setStopId(check.getStopId());
validationQuery.setServiceDate(check.getDate());
validationQuery.setDepartureTime(check.getDepartureTime());
validationQuery.setQuery(query);
if (query.isEmpty()) {
continue;
} else {
queries.add(validationQuery);
}
}
return queries;
}
use of org.onebusaway.admin.model.BundleValidateQuery in project onebusaway-application-modules by camsys.
the class ValidateBundleAction method checkResults.
public List<BundleValidationCheckResult> checkResults(List<BundleValidateQuery> queryResults) {
List<BundleValidationCheckResult> testResults = new ArrayList<BundleValidationCheckResult>();
int linenum = 1;
for (BundleValidateQuery query : queryResults) {
QueryResultChecker resultChecker = getResultChecker(query.getSpecificTest().toLowerCase());
BundleValidationCheckResult checkResult = resultChecker.checkResults(query);
checkResult.setLinenum(linenum);
checkResult.setCsvLinenum(query.getLinenum());
checkResult.setSpecificTest(query.getSpecificTest());
checkResult.setTestQuery(query.getQuery());
testResults.add(checkResult);
++linenum;
}
return testResults;
}
use of org.onebusaway.admin.model.BundleValidateQuery 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";
}
Aggregations