Search in sources :

Example 1 with TestResult

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;
}
Also used : Theme(org.asqatasun.entity.reference.Theme) TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Example 2 with TestResult

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;
}
Also used : TestResultImpl(org.asqatasun.webapp.presentation.data.TestResultImpl) TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Example 3 with 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;
}
Also used : Theme(org.asqatasun.entity.reference.Theme) TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Example 4 with TestResult

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;
}
Also used : TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Example 5 with TestResult

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);
    }
}
Also used : AuditStatistics(org.asqatasun.webapp.presentation.data.AuditStatistics) ColumnBuilderException(ar.com.fdvs.dj.domain.builders.ColumnBuilderException) Scope(org.asqatasun.entity.reference.Scope) JRException(net.sf.jasperreports.engine.JRException) Page(org.asqatasun.entity.subject.Page) TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Aggregations

TestResult (org.asqatasun.webapp.presentation.data.TestResult)6 Theme (org.asqatasun.entity.reference.Theme)3 ColumnBuilderException (ar.com.fdvs.dj.domain.builders.ColumnBuilderException)1 JRException (net.sf.jasperreports.engine.JRException)1 Scope (org.asqatasun.entity.reference.Scope)1 Page (org.asqatasun.entity.subject.Page)1 AuditStatistics (org.asqatasun.webapp.presentation.data.AuditStatistics)1 TestResultImpl (org.asqatasun.webapp.presentation.data.TestResultImpl)1