Search in sources :

Example 1 with ResultCounter

use of org.asqatasun.webapp.dto.ResultCounter in project Asqatasun by Asqatasun.

the class AuditSynthesisController method prepareSynthesisSiteData.

/**
 * This method prepares data for the synthesis page. Only multi pages audit
 * are considered here
 *
 * @param audit
 * @param model
 * @return
 * @throws IOException
 */
private String prepareSynthesisSiteData(Audit audit, Model model) {
    // Add this step, we are sure that the audit subject
    // is a site, we can trustly cast it
    Site site = (Site) audit.getSubject();
    // TODO cas manual
    addAuditStatisticsToModel(site, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE);
    Map<Theme, ResultCounter> top5SortedThemeMap = new LinkedHashMap<>();
    @SuppressWarnings("unchecked") Collection<FailedThemeInfo> tfiCollection = (Collection<FailedThemeInfo>) statisticsDataService.getResultCountByResultTypeAndTheme(site, audit, TestSolution.FAILED, nbOfDisplayedFailedTest);
    for (FailedThemeInfo tfi : tfiCollection) {
        ResultCounter failedCounter = resultCounterFactory.getResultCounter();
        failedCounter.setFailedCount(tfi.getResultCounter().intValue());
        top5SortedThemeMap.put(auditStatisticsFactory.getTheme(tfi.getThemeId()), failedCounter);
    }
    model.addAttribute(TgolKeyStore.AUDITED_PAGES_COUNT_KEY, statisticsDataService.getWebResourceCountByAuditAndHttpStatusCode(audit.getId(), HttpStatusCodeFamily.f2xx, null, null).intValue());
    model.addAttribute(TgolKeyStore.TOP5_SORTED_THEME_MAP, top5SortedThemeMap);
    model.addAttribute(TgolKeyStore.FAILED_PAGE_INFO_BY_TEST_SET_KEY, statisticsDataService.getFailedWebResourceSortedByTest(site, audit, nbOfDisplayedFailedPages));
    model.addAttribute(TgolKeyStore.FAILED_PAGE_INFO_BY_OCCURRENCE_SET_KEY, statisticsDataService.getFailedWebResourceSortedByOccurrence(site, audit, nbOfDisplayedFailedPages));
    model.addAttribute(TgolKeyStore.FAILED_TEST_INFO_BY_OCCURRENCE_SET_KEY, statisticsDataService.getFailedTestByOccurrence(site, audit, nbOfDisplayedFailedTest));
    model.addAttribute(TgolKeyStore.HAS_SITE_SCOPE_TEST_KEY, processResultDataService.hasAuditSiteScopeResult(site, siteScope));
    model.addAttribute(TgolKeyStore.STATUS_KEY, computeAuditStatus(site.getAudit()));
    return TgolKeyStore.SYNTHESIS_SITE_VIEW_NAME;
}
Also used : Site(org.asqatasun.entity.subject.Site) FailedThemeInfo(org.asqatasun.webapp.dto.FailedThemeInfo) Theme(org.asqatasun.entity.reference.Theme) Collection(java.util.Collection) ResultCounter(org.asqatasun.webapp.dto.ResultCounter) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with ResultCounter

use of org.asqatasun.webapp.dto.ResultCounter in project Asqatasun by Asqatasun.

the class AuditStatisticsFactory method getAuditStatistics.

/**
 * This methods creates an instance of auditStatistics (audit meta-data)
 * with the URL, the date, the number of components (in case of site audit )
 * and the mark of the audit
 *
 * @param webResource
 * @param parametersToDisplay
 * @param displayScope
 * @param isAuditManual
 * @return
 */
public AuditStatistics getAuditStatistics(WebResource webResource, Map<String, String> parametersToDisplay, String displayScope, boolean isAuditManual) {
    AuditStatistics auditStats = new AuditStatistics();
    auditStats.setUrl(webResource.getURL());
    auditStats.setSnapshotUrl(webResource.getURL());
    auditStats.setRawMark(markFormatter(webResource, true, isAuditManual));
    auditStats.setWeightedMark(markFormatter(webResource, false, isAuditManual));
    Audit audit;
    if (webResource instanceof Site) {
        auditStats.setPageCounter(webResourceDataService.getChildWebResourceCount(webResource).intValue());
        audit = webResource.getAudit();
        auditStats.setAuditedPageCounter(statisticsDataService.getWebResourceCountByAuditAndHttpStatusCode(audit.getId(), HttpStatusCodeFamily.f2xx, null, null).intValue());
    } else if (webResource.getParent() != null) {
        audit = webResource.getParent().getAudit();
    } else {
        audit = webResource.getAudit();
    }
    auditStats.setDate(audit.getDateOfCreation());
    auditStats.setAuditScope(actDataService.getActFromAudit(audit).getScope().getCode());
    ResultCounter resultCounter = auditStats.getResultCounter();
    resultCounter.setPassedCount(0);
    resultCounter.setFailedCount(0);
    resultCounter.setNmiCount(0);
    resultCounter.setNaCount(0);
    resultCounter.setNtCount(0);
    auditStats.setCounterByThemeMap(addCounterByThemeMap(audit, webResource, resultCounter, displayScope, isAuditManual));
    auditStats.setParametersMap(getAuditParameters(audit, parametersToDisplay));
    return auditStats;
}
Also used : AuditStatistics(org.asqatasun.webapp.dto.AuditStatistics) Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) ResultCounter(org.asqatasun.webapp.dto.ResultCounter)

Example 3 with ResultCounter

use of org.asqatasun.webapp.dto.ResultCounter in project Asqatasun by Asqatasun.

the class AuditStatisticsFactory method addCounterByThemeMap.

/**
 * Retrieve the number of results by type for each themes of the audit and
 * populate a map with the Theme as key and a ResultCounter instance as
 * value.
 *
 * @param audit
 * @param webResource
 * @param globalResultCounter
 * @param displayScope
 * @param isAuditManual
 * @return
 */
private Map<Theme, ResultCounter> addCounterByThemeMap(Audit audit, WebResource webResource, ResultCounter globalResultCounter, String displayScope, boolean isAuditManual) {
    if (fullThemeMapByRef.isEmpty()) {
        init();
    }
    Map<Theme, ResultCounter> counterByThemeMap = new LinkedHashMap();
    for (Theme theme : getThemeListFromAudit(audit)) {
        ResultCounter themeResultCounter = null;
        if (StringUtils.equalsIgnoreCase(displayScope, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE)) {
            themeResultCounter = getResultCounterByThemeForTest(webResource, audit, theme, isAuditManual);
        } else if (StringUtils.equalsIgnoreCase(displayScope, TgolKeyStore.CRITERION_DISPLAY_SCOPE_VALUE)) {
            themeResultCounter = getResultCounterByThemeForCriterion(webResource, theme);
        }
        if (themeResultCounter != null) {
            globalResultCounter.setPassedCount(themeResultCounter.getPassedCount() + globalResultCounter.getPassedCount());
            globalResultCounter.setFailedCount(themeResultCounter.getFailedCount() + globalResultCounter.getFailedCount());
            globalResultCounter.setNmiCount(themeResultCounter.getNmiCount() + globalResultCounter.getNmiCount());
            globalResultCounter.setNaCount(themeResultCounter.getNaCount() + globalResultCounter.getNaCount());
            globalResultCounter.setNtCount(themeResultCounter.getNtCount() + globalResultCounter.getNtCount());
            counterByThemeMap.put(theme, themeResultCounter);
        }
    }
    // the manual statistics input when creating the audit.
    if (isAuditManual && globalResultCounter.getPassedCount() == 0 && globalResultCounter.getNaCount() == 0 && globalResultCounter.getNmiCount() == 0 && globalResultCounter.getFailedCount() == 0) {
        Collection<Test> testList = auditDataService.getAuditWithTest(audit.getId()).getTestList();
        globalResultCounter.setNtCount(testList.size());
        Theme theme;
        for (Test test : testList) {
            theme = test.getCriterion().getTheme();
            if (counterByThemeMap.containsKey(theme)) {
                counterByThemeMap.get(theme).setNtCount(counterByThemeMap.get(theme).getNtCount() + 1);
            }
        }
    }
    return counterByThemeMap;
}
Also used : Test(org.asqatasun.entity.reference.Test) Theme(org.asqatasun.entity.reference.Theme) ResultCounter(org.asqatasun.webapp.dto.ResultCounter)

Example 4 with ResultCounter

use of org.asqatasun.webapp.dto.ResultCounter in project Asqatasun by Asqatasun.

the class AuditStatisticsFactory method getResultCounterByThemeForCriterion.

/**
 * @param webResource
 * @param theme
 * @return
 */
private ResultCounter getResultCounterByThemeForCriterion(WebResource webResource, Theme theme) {
    ResultCounter resultCounter = resultCounterFactory.getResultCounter();
    int passedCount = 0;
    int failedCount = 0;
    int nmiCount = 0;
    int naCount = 0;
    int ntCount = 0;
    Collection<CriterionStatistics> csc = criterionStatisticsDataService.getCriterionStatisticsByWebResource(webResource, theme.getCode(), new ArrayList<>());
    for (CriterionStatistics cs : csc) {
        switch(cs.getCriterionResult()) {
            case FAILED:
                failedCount++;
                break;
            case PASSED:
                passedCount++;
                break;
            case NEED_MORE_INFO:
                nmiCount++;
                break;
            case NOT_APPLICABLE:
                naCount++;
                break;
            case NOT_TESTED:
                ntCount++;
                break;
        }
    }
    resultCounter.setPassedCount(passedCount);
    resultCounter.setFailedCount(failedCount);
    resultCounter.setNmiCount(nmiCount);
    resultCounter.setNaCount(naCount);
    resultCounter.setNtCount(ntCount);
    return resultCounter;
}
Also used : CriterionStatistics(org.asqatasun.entity.statistics.CriterionStatistics) ResultCounter(org.asqatasun.webapp.dto.ResultCounter)

Example 5 with ResultCounter

use of org.asqatasun.webapp.dto.ResultCounter in project Asqatasun by Asqatasun.

the class AuditStatisticsFactory method getResultCounterByThemeForTest.

/**
 * @param webResource
 * @param audit
 * @param theme
 * @return
 */
private ResultCounter getResultCounterByThemeForTest(WebResource webResource, Audit audit, Theme theme, boolean manualAudit) {
    ResultCounter resultCounter = resultCounterFactory.getResultCounter();
    resultCounter.setPassedCount(statisticsDataService.getResultCountByResultTypeAndTheme(webResource, audit, TestSolution.PASSED, theme, manualAudit).intValue());
    resultCounter.setFailedCount(statisticsDataService.getResultCountByResultTypeAndTheme(webResource, audit, TestSolution.FAILED, theme, manualAudit).intValue());
    resultCounter.setNmiCount(statisticsDataService.getResultCountByResultTypeAndTheme(webResource, audit, TestSolution.NEED_MORE_INFO, theme, manualAudit).intValue());
    resultCounter.setNaCount(statisticsDataService.getResultCountByResultTypeAndTheme(webResource, audit, TestSolution.NOT_APPLICABLE, theme, manualAudit).intValue());
    resultCounter.setNtCount(statisticsDataService.getResultCountByResultTypeAndTheme(webResource, audit, TestSolution.NOT_TESTED, theme, manualAudit).intValue());
    return resultCounter;
}
Also used : ResultCounter(org.asqatasun.webapp.dto.ResultCounter)

Aggregations

ResultCounter (org.asqatasun.webapp.dto.ResultCounter)5 Theme (org.asqatasun.entity.reference.Theme)2 Site (org.asqatasun.entity.subject.Site)2 Collection (java.util.Collection)1 LinkedHashMap (java.util.LinkedHashMap)1 Audit (org.asqatasun.entity.audit.Audit)1 Test (org.asqatasun.entity.reference.Test)1 CriterionStatistics (org.asqatasun.entity.statistics.CriterionStatistics)1 AuditStatistics (org.asqatasun.webapp.dto.AuditStatistics)1 FailedThemeInfo (org.asqatasun.webapp.dto.FailedThemeInfo)1