Search in sources :

Example 11 with Theme

use of org.asqatasun.entity.reference.Theme 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) {
    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.presentation.data.ResultCounter)

Example 12 with Theme

use of org.asqatasun.entity.reference.Theme in project Asqatasun by Asqatasun.

the class AuditStatisticsFactory method setThemeDataService.

@Autowired
public final void setThemeDataService(ThemeDataService themeDataService) {
    Collection<Theme> themeList = themeDataService.findAll();
    if (fullThemeMapByRef == null) {
        fullThemeMapByRef = new HashMap();
    }
    // to be associated with a criterion
    for (Theme theme : themeList) {
        if (!theme.getCriterionList().isEmpty()) {
            String referenceCode = theme.getCriterionList().iterator().next().getReference().getCode();
            if (!fullThemeMapByRef.containsKey(referenceCode)) {
                Collection<Theme> themeListByRef = new ArrayList();
                themeListByRef.add(theme);
                fullThemeMapByRef.put(referenceCode, themeListByRef);
            } else {
                fullThemeMapByRef.get(referenceCode).add(theme);
            }
        }
    }
    for (Collection<Theme> entry : fullThemeMapByRef.values()) {
        sortThemeList(entry);
    }
}
Also used : Theme(org.asqatasun.entity.reference.Theme) Autowired(org.springframework.beans.factory.annotation.Autowired)

Aggregations

Theme (org.asqatasun.entity.reference.Theme)12 Criterion (org.asqatasun.entity.reference.Criterion)3 TestResult (org.asqatasun.webapp.presentation.data.TestResult)3 Test (org.asqatasun.entity.reference.Test)2 CriterionStatistics (org.asqatasun.entity.statistics.CriterionStatistics)2 ThemeStatistics (org.asqatasun.entity.statistics.ThemeStatistics)2 ResultCounter (org.asqatasun.webapp.presentation.data.ResultCounter)2 HashMap (java.util.HashMap)1 ProcessResult (org.asqatasun.entity.audit.ProcessResult)1 TestSolution (org.asqatasun.entity.audit.TestSolution)1 WebResourceStatisticsDAO (org.asqatasun.entity.dao.statistics.WebResourceStatisticsDAO)1 Reference (org.asqatasun.entity.reference.Reference)1 ThemeDataService (org.asqatasun.entity.service.reference.ThemeDataService)1 WebResourceStatistics (org.asqatasun.entity.statistics.WebResourceStatistics)1 Site (org.asqatasun.entity.subject.Site)1 WebResource (org.asqatasun.entity.subject.WebResource)1 CriterionResult (org.asqatasun.webapp.presentation.data.CriterionResult)1 FailedThemeInfo (org.asqatasun.webapp.presentation.data.FailedThemeInfo)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1