Search in sources :

Example 1 with AuditStatistics

use of org.asqatasun.webapp.presentation.data.AuditStatistics 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;
}
Also used : AuditStatistics(org.asqatasun.webapp.presentation.data.AuditStatistics) Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) AuditStatisticsImpl(org.asqatasun.webapp.presentation.data.AuditStatisticsImpl) ResultCounter(org.asqatasun.webapp.presentation.data.ResultCounter)

Example 2 with AuditStatistics

use of org.asqatasun.webapp.presentation.data.AuditStatistics in project Asqatasun by Asqatasun.

the class AuditExportResultController method prepareSuccessfullAuditDataToExport.

/**
     * 
     * @param page
     * @param model
     * @param locale
     * @param exportFormat
     * @param request
     * @param response
     * @return
     * @throws IOException
     */
private void prepareSuccessfullAuditDataToExport(WebResource webResource, Model model, Locale locale, String exportFormat, HttpServletRequest request, HttpServletResponse response) throws NotSupportedExportFormatException {
    model.addAttribute(TgolKeyStore.LOCALE_KEY, locale);
    Scope scope = getSiteScope();
    if (webResource instanceof Page) {
        scope = getPageScope();
    }
    List<TestResult> testResultList = TestResultFactory.getInstance().getTestResultList(webResource, scope, getLocaleResolver().resolveLocale(request));
    AuditStatistics auditStatistics = getAuditStatistics(webResource, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE, //TODO a revoir dans le cas manuel 
    false);
    model.addAttribute(TgolKeyStore.STATISTICS_KEY, auditStatistics);
    try {
        exportService.export(response, webResource.getId(), auditStatistics, testResultList, locale, exportFormat);
    } catch (ColumnBuilderException | ClassNotFoundException | JRException ex) {
        LOGGER.error(ex);
    }
}
Also used : AuditStatistics(org.asqatasun.webapp.presentation.data.AuditStatistics) ColumnBuilderException(ar.com.fdvs.dj.domain.builders.ColumnBuilderException) Scope(org.asqatasun.entity.reference.Scope) JRException(net.sf.jasperreports.engine.JRException) Page(org.asqatasun.entity.subject.Page) TestResult(org.asqatasun.webapp.presentation.data.TestResult)

Aggregations

AuditStatistics (org.asqatasun.webapp.presentation.data.AuditStatistics)2 ColumnBuilderException (ar.com.fdvs.dj.domain.builders.ColumnBuilderException)1 JRException (net.sf.jasperreports.engine.JRException)1 Audit (org.asqatasun.entity.audit.Audit)1 Scope (org.asqatasun.entity.reference.Scope)1 Page (org.asqatasun.entity.subject.Page)1 Site (org.asqatasun.entity.subject.Site)1 AuditStatisticsImpl (org.asqatasun.webapp.presentation.data.AuditStatisticsImpl)1 ResultCounter (org.asqatasun.webapp.presentation.data.ResultCounter)1 TestResult (org.asqatasun.webapp.presentation.data.TestResult)1