use of org.asqatasun.webapp.presentation.data.TestResult in project Asqatasun by Asqatasun.
the class TestResultFactory method getTestResultListFromTest.
/**
*
* @param webresource
* @param test
* @return the test result list without user filter (used for the export
* function)
*/
public Map<Theme, List<TestResult>> getTestResultListFromTest(WebResource webresource, Test test) {
// Map that associates a list of results with a theme
List<TestResult> testResultList = new LinkedList();
List<ProcessResult> netResultList = (List<ProcessResult>) processResultDataService.getProcessResultListByWebResourceAndTest(webresource, test);
Collection testList = new ArrayList();
testList.add(test);
netResultList.addAll(addNotTestedProcessResult(testList, test.getCriterion().getTheme().getCode(), netResultList));
sortCollection(netResultList);
for (ProcessResult processResult : netResultList) {
if (processResult instanceof DefiniteResult) {
TestResult testResult = getTestResult(processResult, true, false);
testResultList.add(testResult);
}
}
Map<Theme, List<TestResult>> testResultMap = new HashMap();
testResultMap.put(test.getCriterion().getTheme(), testResultList);
return testResultMap;
}
use of org.asqatasun.webapp.presentation.data.TestResult in project Asqatasun by Asqatasun.
the class TestResultFactory method getTestResult.
/**
*
* @param processResult
* @param hasResultDetails
* @param truncatable
* @return an instance of ProcessResult
*/
public TestResult getTestResult(ProcessResult processResult, boolean hasResultDetails, boolean truncatable) {
TestResult testResult = new TestResultImpl();
testResult.setTestUrl(processResult.getTest().getDescription());
testResult.setTestShortLabel(processResult.getTest().getLabel());
testResult.setTestCode(processResult.getTest().getCode());
testResult.setLevelCode(processResult.getTest().getLevel().getCode());
testResult.setResult(processResult.getValue().toString());
testResult.setResultCode(setResultToLowerCase(processResult, testResult));
testResult.setRuleDesignUrl(processResult.getTest().getRuleDesignUrl());
testResult.setResultCounter(ResultCounterFactory.getInstance().getResultCounter());
testResult.setTest(processResult.getTest());
testResult.setHistory(constructHistoryChanges(processResult));
if (processResult instanceof DefiniteResult && processResult.getManualValue() != null) {
testResult.setComment(((DefiniteResult) processResult).getManualAuditComment());
switch((TestSolution) processResult.getManualValue()) {
case FAILED:
testResult.setManualResult(TestResult.FAILED_LOWER);
break;
case PASSED:
testResult.setManualResult(TestResult.PASSED_LOWER);
break;
case NOT_APPLICABLE:
testResult.setManualResult(TestResult.NOT_APPLICABLE_LOWER);
break;
}
}
try {
testResult.setTestRepresentation(Integer.valueOf(representationBundle.getString(testResult.getTestCode() + TestResult.REPRESENTATION_SUFFIX_KEY)));
} catch (MissingResourceException mre) {
Logger.getLogger(this.getClass()).warn(mre);
}
try {
testResult.setTestEvidenceRepresentationOrder(representationBundle.getString(testResult.getTestCode() + TestResult.REPRESENTATION_ORDER_SUFFIX_KEY));
} catch (MissingResourceException mre) {
Logger.getLogger(this.getClass()).warn(mre);
}
try {
testResult.setColorTestContrastRatio(representationBundle.getString(testResult.getTestCode() + TestResult.CONTRAST_RATIO_SUFFIX_KEY));
} catch (MissingResourceException mre) {
Logger.getLogger(this.getClass()).warn(mre);
}
if (hasResultDetails && (testResult.getResult().equalsIgnoreCase(TestSolution.FAILED.toString()) || testResult.getResult().equalsIgnoreCase(TestSolution.NEED_MORE_INFO.toString()))) {
addRemarkInfosMapToTestResult(testResult, processResult, truncatable);
}
return testResult;
}
use of org.asqatasun.webapp.presentation.data.TestResult in project Asqatasun by Asqatasun.
the class TestResultFactory method prepareThemeResultMap.
/**
*
* @param netResultList
* @return
*/
private Map<Theme, List<TestResult>> prepareThemeResultMap(List<ProcessResult> netResultList) {
// Map that associates a list of results with a theme
Map<Theme, List<TestResult>> testResultMap = new LinkedHashMap();
sortCollection(netResultList);
for (ProcessResult processResult : netResultList) {
if (processResult instanceof DefiniteResult) {
TestResult testResult = getTestResult(processResult, true, true);
Theme theme = processResult.getTest().getCriterion().getTheme();
if (testResultMap.containsKey(theme)) {
testResultMap.get(theme).add(testResult);
} else {
List<TestResult> testResultList = new ArrayList();
testResultList.add(testResult);
testResultMap.put(theme, testResultList);
}
}
}
return testResultMap;
}
use of org.asqatasun.webapp.presentation.data.TestResult in project Asqatasun by Asqatasun.
the class TestResultFactory method getTestResultList.
/**
*
* @param webresource
* @param scope
* @param locale
* @return the test result list without user filter (used for the export
* function)
*/
public List<TestResult> getTestResultList(WebResource webresource, Scope scope, Locale locale) {
// Map that associates a list of results with a theme
List<TestResult> testResultList = new LinkedList();
List<ProcessResult> netResultList = (List<ProcessResult>) processResultDataService.getProcessResultListByWebResourceAndScope(webresource, scope);
netResultList.addAll(addNotTestedProcessResult(getTestListFromWebResource(webresource), selectAllThemeKey, netResultList));
sortCollection(netResultList);
for (ProcessResult processResult : netResultList) {
if (processResult instanceof DefiniteResult) {
TestResult testResult = getTestResult(processResult, true, false);
testResultList.add(testResult);
}
}
return testResultList;
}
use of org.asqatasun.webapp.presentation.data.TestResult in project Asqatasun by Asqatasun.
the class AuditExportResultController method prepareSuccessfullAuditDataToExport.
/**
*
* @param page
* @param model
* @param locale
* @param exportFormat
* @param request
* @param response
* @return
* @throws IOException
*/
private void prepareSuccessfullAuditDataToExport(WebResource webResource, Model model, Locale locale, String exportFormat, HttpServletRequest request, HttpServletResponse response) throws NotSupportedExportFormatException {
model.addAttribute(TgolKeyStore.LOCALE_KEY, locale);
Scope scope = getSiteScope();
if (webResource instanceof Page) {
scope = getPageScope();
}
List<TestResult> testResultList = TestResultFactory.getInstance().getTestResultList(webResource, scope, getLocaleResolver().resolveLocale(request));
AuditStatistics auditStatistics = getAuditStatistics(webResource, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE, //TODO a revoir dans le cas manuel
false);
model.addAttribute(TgolKeyStore.STATISTICS_KEY, auditStatistics);
try {
exportService.export(response, webResource.getId(), auditStatistics, testResultList, locale, exportFormat);
} catch (ColumnBuilderException | ClassNotFoundException | JRException ex) {
LOGGER.error(ex);
}
}
Aggregations