use of org.asqatasun.entity.statistics.CriterionStatistics in project Asqatasun by Asqatasun.
the class WebResourceStatisticsDataServiceImpl method createWebResourceStatisticsForManualAudit.
@Override
public WebResourceStatistics createWebResourceStatisticsForManualAudit(Audit audit, WebResource webResource, List<ProcessResult> netResultList) {
boolean isNewWebRs = false;
WebResourceStatistics wrStats = ((WebResourceStatisticsDAO) entityDao).findWebResourceStatisticsByWebResource(webResource, true);
if (wrStats == null) {
wrStats = this.create();
isNewWebRs = true;
}
Map<Criterion, CriterionStatistics> csMap = new HashMap<>();
Map<Theme, ThemeStatistics> tsMap = new HashMap<>();
// Map<Theme, List<ProcessResult>> mapProcessResultBytheme = new HashMap<Theme, List<ProcessResult>>();
int nbOfPassed = 0;
int nbOfFailed = 0;
int nbOfNmi = 0;
int nbOfNa = 0;
int nbOfDetected = 0;
int nbOfSuspected = 0;
int nbOfNt = 0;
for (ProcessResult pr : netResultList) {
// l'audit est manual
if (pr.getManualValue() != null) {
TestSolution prResult = (TestSolution) pr.getManualValue();
switch(prResult) {
case PASSED:
nbOfPassed++;
break;
case FAILED:
nbOfFailed++;
break;
case NOT_APPLICABLE:
nbOfNa++;
break;
case NEED_MORE_INFO:
case DETECTED:
case SUSPECTED_FAILED:
case SUSPECTED_PASSED:
nbOfNmi++;
break;
case NOT_TESTED:
nbOfNt++;
break;
}
addResultToCriterionCounterMap(prResult, pr.getTest().getCriterion(), wrStats, csMap);
addResultToThemeCounterMap(prResult, pr.getTest().getCriterion().getTheme(), wrStats, tsMap);
} else {
addResultToCriterionCounterMap(TestSolution.NOT_TESTED, pr.getTest().getCriterion(), wrStats, csMap);
addResultToThemeCounterMap(TestSolution.NOT_TESTED, pr.getTest().getCriterion().getTheme(), wrStats, tsMap);
nbOfNt++;
}
}
wrStats.setNbOfFailed(wrStats.getNbOfFailed() + nbOfFailed);
wrStats.setNbOfInvalidTest(wrStats.getNbOfInvalidTest() + nbOfFailed);
wrStats.setNbOfPassed(wrStats.getNbOfPassed() + nbOfPassed);
wrStats.setNbOfNmi(wrStats.getNbOfNmi() + nbOfNmi);
wrStats.setNbOfNa(wrStats.getNbOfNa() + nbOfNa);
wrStats.setNbOfDetected(wrStats.getNbOfDetected() + nbOfDetected);
wrStats.setNbOfSuspected(wrStats.getNbOfSuspected() + nbOfSuspected);
wrStats.setNbOfNotTested(wrStats.getNbOfNotTested() + nbOfNt);
setWeightedResult(wrStats, webResource);
wrStats.setHttpStatusCode(getHttpStatusCodeByWebResource(webResource.getId()));
wrStats = computeMark(wrStats);
wrStats = computeRawMark(wrStats);
wrStats = computeNumberOfFailedOccurrences(wrStats, webResource, true);
wrStats.setAudit(audit);
wrStats.setWebResource(webResource);
wrStats.setIsManualAuditStatistics(1);
// criterionStatistics to the current webResourceStatistics
if (isNewWebRs) {
for (CriterionStatistics cs : csMap.values()) {
computeCriterionResult(cs);
wrStats.addCriterionStatistics(cs);
}
// Link each themeStatistics to the current webResourceStatistics
for (ThemeStatistics ts : tsMap.values()) {
wrStats.addThemeStatistics(ts);
}
} else {
//recuperer les Crtiterion à partir de wrstat et id_criterion pour MAJ
for (CriterionStatistics css : csMap.values()) {
CriterionStatistics criterionStatisticsFromMap = csMap.get(css.getCriterion());
CriterionStatistics criterionStatisticsDb = criterionStatisticsDAO.findCriterionStatisticsByWebResource(css.getCriterion(), wrStats);
if (criterionStatisticsDb == null) {
criterionStatisticsDb = criterionStatisticsDataService.create();
criterionStatisticsDb.setWebResourceStatistics(wrStats);
criterionStatisticsDb.setCriterion(css.getCriterion());
}
populateCriterionStatistics(criterionStatisticsDb, criterionStatisticsFromMap);
computeCriterionResult(criterionStatisticsDb);
criterionStatisticsDAO.saveOrUpdate(criterionStatisticsDb);
}
for (ThemeStatistics ts : tsMap.values()) {
ThemeStatistics themeStatisticsFromMap = tsMap.get(ts.getTheme());
ThemeStatistics themeStatisticsDb = themeStatisticsDAO.findThemeStatisticsByWebResource(ts.getTheme(), wrStats);
if (themeStatisticsDb == null) {
themeStatisticsDb = themeStatisticsDataService.create();
themeStatisticsDb.setWebResourceStatistics(wrStats);
themeStatisticsDb.setTheme(ts.getTheme());
}
populateThemeStatistics(themeStatisticsDb, themeStatisticsFromMap);
themeStatisticsDAO.saveOrUpdate(themeStatisticsDb);
}
}
this.saveOrUpdate(wrStats);
return wrStats;
}
use of org.asqatasun.entity.statistics.CriterionStatistics in project Asqatasun by Asqatasun.
the class CriterionResultFactory method prepareThemeResultMap.
/**
*
* @param netResultList
* @return
*/
private Map<Theme, List<CriterionResult>> prepareThemeResultMap(List<CriterionStatistics> criterionStatList) {
// Map that associates a list of results with a theme
Map<Theme, List<CriterionResult>> criterionResultMap = new LinkedHashMap<Theme, List<CriterionResult>>();
sortCollection(criterionStatList);
for (CriterionStatistics crs : criterionStatList) {
CriterionResult testResult = getCriterionResult(crs);
Theme theme = crs.getCriterion().getTheme();
if (criterionResultMap.containsKey(theme)) {
criterionResultMap.get(theme).add(testResult);
} else {
List<CriterionResult> criterionResultList = new ArrayList<CriterionResult>();
criterionResultList.add(testResult);
criterionResultMap.put(theme, criterionResultList);
}
}
return criterionResultMap;
}
use of org.asqatasun.entity.statistics.CriterionStatistics 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;
}
Aggregations