use of org.asqatasun.webapp.presentation.data.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 AuditStatisticsImpl();
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;
}
use of org.asqatasun.webapp.presentation.data.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.getInstance().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;
}
use of org.asqatasun.webapp.presentation.data.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.getInstance().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<String>());
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;
}
use of org.asqatasun.webapp.presentation.data.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) {
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;
}
Aggregations