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;
}
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);
}
}
Aggregations